30
packages/application/src/ports/action-events.repository.ts
Normal file
30
packages/application/src/ports/action-events.repository.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
export type ActionEventRecord = {
|
||||
id: string;
|
||||
userId: string;
|
||||
actionType: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
summary: string;
|
||||
beforeState: Record<string, unknown>;
|
||||
afterState: Record<string, unknown>;
|
||||
metadata: Record<string, unknown> | null;
|
||||
createdAt: Date;
|
||||
undoneAt: Date | null;
|
||||
};
|
||||
|
||||
export type RecordActionInput = {
|
||||
userId: string;
|
||||
actionType: string;
|
||||
entityType: string;
|
||||
entityId: string;
|
||||
summary: string;
|
||||
beforeState: Record<string, unknown>;
|
||||
afterState: Record<string, unknown>;
|
||||
metadata?: Record<string, unknown>;
|
||||
};
|
||||
|
||||
export interface ActionEventsRepository {
|
||||
recordAction(input: RecordActionInput): Promise<ActionEventRecord>;
|
||||
getActionEvent(id: string, userId: string): Promise<ActionEventRecord | null>;
|
||||
markUndone(id: string): Promise<void>;
|
||||
}
|
||||
86
packages/application/src/ports/adventure.repository.ts
Normal file
86
packages/application/src/ports/adventure.repository.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import type { AdventureItemState } from "@adventureos/domain";
|
||||
|
||||
export type DailyAdventureItemRecord = {
|
||||
id: string;
|
||||
dailyAdventureId: string;
|
||||
type: string;
|
||||
label: string;
|
||||
config: Record<string, unknown> | null;
|
||||
value: Record<string, unknown> | null;
|
||||
state: AdventureItemState;
|
||||
completedAt: Date | null;
|
||||
enabled: boolean;
|
||||
isCustom: boolean;
|
||||
sortOrder: number;
|
||||
sourceItemId: string | null;
|
||||
};
|
||||
|
||||
export type DailyAdventureRecord = {
|
||||
id: string;
|
||||
userId: string;
|
||||
date: string;
|
||||
templateId: string | null;
|
||||
isRestDay: boolean;
|
||||
isCustomized: boolean;
|
||||
workHoursTarget: string | null;
|
||||
dayMode: string | null;
|
||||
};
|
||||
|
||||
export type DailyTodoRecord = {
|
||||
id: string;
|
||||
dailyAdventureId: string;
|
||||
label: string;
|
||||
done: boolean;
|
||||
sortOrder: number;
|
||||
};
|
||||
|
||||
export type AdventureTemplateRecord = {
|
||||
id: string;
|
||||
userId: string;
|
||||
daysOfWeek: number[];
|
||||
sortPriority: number;
|
||||
isDefault: boolean;
|
||||
deletedAt: Date | null;
|
||||
};
|
||||
|
||||
export type AdventureTemplateItemRecord = {
|
||||
id: string;
|
||||
templateId: string;
|
||||
type: string;
|
||||
label: string;
|
||||
config: Record<string, unknown> | null;
|
||||
sortOrder: number;
|
||||
enabled: boolean;
|
||||
deletedAt: Date | null;
|
||||
};
|
||||
|
||||
export interface AdventureRepository {
|
||||
findDailyAdventure(userId: string, date: string): Promise<DailyAdventureRecord | null>;
|
||||
createDailyAdventure(
|
||||
userId: string,
|
||||
date: string,
|
||||
templateId?: string | null
|
||||
): Promise<DailyAdventureRecord>;
|
||||
listDailyAdventureItems(adventureId: string): Promise<DailyAdventureItemRecord[]>;
|
||||
listDailyTodos(adventureId: string): Promise<DailyTodoRecord[]>;
|
||||
updateDailyAdventureItem(
|
||||
itemId: string,
|
||||
updates: {
|
||||
value?: Record<string, unknown>;
|
||||
state?: AdventureItemState;
|
||||
completedAt?: Date | null;
|
||||
}
|
||||
): Promise<void>;
|
||||
softDeleteDailyAdventureItems(adventureId: string): Promise<void>;
|
||||
insertDailyAdventureItem(
|
||||
adventureId: string,
|
||||
item: Omit<DailyAdventureItemRecord, "id" | "dailyAdventureId">
|
||||
): Promise<DailyAdventureItemRecord>;
|
||||
updateDailyAdventure(
|
||||
adventureId: string,
|
||||
updates: Record<string, unknown>
|
||||
): Promise<void>;
|
||||
listTemplates(userId: string): Promise<AdventureTemplateRecord[]>;
|
||||
listTemplateItems(templateId: string): Promise<AdventureTemplateItemRecord[]>;
|
||||
findTemplate(userId: string, templateId: string): Promise<AdventureTemplateRecord | null>;
|
||||
}
|
||||
6
packages/application/src/ports/scoring.service.ts
Normal file
6
packages/application/src/ports/scoring.service.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { DaySnapshot } from "@adventureos/domain";
|
||||
|
||||
export interface ScoringService {
|
||||
refreshScores(userId: string): Promise<void>;
|
||||
buildDaySnapshot(userId: string, date: string): Promise<DaySnapshot>;
|
||||
}
|
||||
9
packages/application/src/ports/user.repository.ts
Normal file
9
packages/application/src/ports/user.repository.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export type UserRecord = {
|
||||
id: string;
|
||||
displayName: string;
|
||||
};
|
||||
|
||||
export interface UserRepository {
|
||||
getUser(userId: string): Promise<UserRecord | null>;
|
||||
getSingleUser(): Promise<UserRecord | null>;
|
||||
}
|
||||
39
packages/application/src/ports/xp.repository.ts
Normal file
39
packages/application/src/ports/xp.repository.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { XpSource } from "@adventureos/domain";
|
||||
|
||||
export type UserProgressRecord = {
|
||||
userId: string;
|
||||
totalXp: number;
|
||||
level: number;
|
||||
currentChapter: string;
|
||||
consistencyScore: number;
|
||||
disciplineScore: number;
|
||||
learningScore: number;
|
||||
spiritualScore: number;
|
||||
healthScore: number;
|
||||
readingScore: number;
|
||||
};
|
||||
|
||||
export type XpEventRecord = {
|
||||
id: string;
|
||||
userId: string;
|
||||
date: string;
|
||||
source: XpSource;
|
||||
amount: number;
|
||||
metadata: Record<string, unknown> | null;
|
||||
};
|
||||
|
||||
export interface XpRepository {
|
||||
getDailyXpEarned(userId: string, date: string, source?: XpSource): Promise<number>;
|
||||
insertXpEvent(event: Omit<XpEventRecord, "id">): Promise<XpEventRecord>;
|
||||
getUserProgress(userId: string): Promise<UserProgressRecord | null>;
|
||||
updateUserProgress(
|
||||
userId: string,
|
||||
updates: Partial<UserProgressRecord>
|
||||
): Promise<void>;
|
||||
listXpEventsByDateAndSource(
|
||||
userId: string,
|
||||
date: string,
|
||||
source: XpSource
|
||||
): Promise<XpEventRecord[]>;
|
||||
listAllXpEvents(userId: string): Promise<XpEventRecord[]>;
|
||||
}
|
||||
Reference in New Issue
Block a user