790d97383c
* feat(workspaces): drop createdByUserId from the dataschema * feat(workspaces): repositories WIP * merge * protect against removing last admin in workspace * quick impl and stub tests * add tests * services * unit tests for role services * feat(workspaces): authorize project creation if workspace specified * feat(workspaces): emit project created event * fix(workspaces): protect against adding a project to a workspace if module not enabled * fix(workspaces): oops broke tests during merge --------- Co-authored-by: Gergő Jedlicska <gergo@jedlicska.com>
20 lines
596 B
TypeScript
20 lines
596 B
TypeScript
import { StreamRecord } from '@/modules/core/helpers/types'
|
|
import { initializeModuleEventEmitter } from '@/modules/shared/services/moduleEventEmitterSetup'
|
|
|
|
export const ProjectEvents = {
|
|
Created: 'created'
|
|
} as const
|
|
|
|
export type ProjectEvents = (typeof ProjectEvents)[keyof typeof ProjectEvents]
|
|
|
|
export type ProjectEventsPayloads = {
|
|
[ProjectEvents.Created]: { project: StreamRecord }
|
|
}
|
|
|
|
const { emit, listen } = initializeModuleEventEmitter<ProjectEventsPayloads>({
|
|
moduleName: 'core',
|
|
namespace: 'projects'
|
|
})
|
|
|
|
export const ProjectsEmitter = { emit, listen, events: ProjectEvents }
|