Skip to content

Commit 1f56c96

Browse files
chore: wip
1 parent b380812 commit 1f56c96

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

storage/framework/core/events/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// thanks to mitt for the base of this wonderful functional event emitter
22

3+
import type { ModelEvents } from '@stacksjs/types'
34
import type { UserModel } from '../../../orm/src/models/User'
45

56
export type EventType = string | symbol
@@ -143,13 +144,10 @@ export default function mitt<Events extends Record<EventType, unknown>>(
143144
*/
144145

145146
// TODO: need to create an action that auto generates this Events type from the ./app/Events
146-
interface StacksEvents {
147+
interface StacksEvents extends ModelEvents {
147148
'user:registered': UserModel
148149
'user:logged-in': UserModel
149150
'user:logged-out': UserModel
150-
'user:updated': Partial<UserModel>
151-
'user:created': Partial<UserModel>
152-
'user:deleted': Partial<UserModel>
153151
'user:password-reset': UserModel
154152
'user:password-changed': UserModel
155153
}

storage/framework/core/orm/src/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {
22
Attributes,
3+
AttributesElements,
34
BaseRelation,
45
FieldArrayElement,
56
Model,
@@ -235,7 +236,7 @@ export async function fetchOtherModelRelations(modelName?: string): Promise<Rela
235236
return modelRelations
236237
}
237238

238-
export function getHiddenAttributes(attributes: Attributes | undefined): string[] {
239+
export function getHiddenAttributes(attributes: AttributesElements | undefined): string[] {
239240
if (attributes === undefined)
240241
return []
241242

@@ -426,7 +427,7 @@ export async function writeModelEvents(): Promise<void> {
426427

427428
eventString += `
428429
${observerImports} \n\n
429-
430+
430431
export interface ModelEvents {\n
431432
${observerString}
432433
}`

storage/framework/core/types/src/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@
2828
export interface Events {
2929
[key: string]: string[]
3030
}
31+
32+
export * from '../../../types/events'

0 commit comments

Comments
 (0)