feat(user, types): add invite and user properties + migration (#6327)

**What**
- Add invite model 
- Populate user model
This commit is contained in:
Philip Korsholm
2024-02-14 13:58:14 +00:00
committed by GitHub
parent 16927469eb
commit 4d51f095b3
45 changed files with 1751 additions and 100 deletions
+38 -2
View File
@@ -1,5 +1,41 @@
export type UserDTO = {
import { DateComparisonOperator } from "../common"
import { BaseFilterable } from "../dal"
export interface UserDTO {
id: string
email: string
first_name: string | null
last_name: string | null
avatar_url: string | null
metadata: Record<string, unknown> | null
created_at: Date
updated_at: Date
deleted_at: Date | null
}
export type FilterableUserProps = {}
export interface FilterableUserProps
extends BaseFilterable<FilterableUserProps> {
id?: string | string[]
email?: string | string[]
first_name?: string | string[]
last_name?: string | string[]
}
export interface InviteDTO {
id: string
email: string
accepted: boolean
token: string
expires_at: Date
metadata: Record<string, unknown> | null
created_at: Date
updated_at: Date
deleted_at: Date | null
}
export interface FilterableInviteProps
extends BaseFilterable<FilterableInviteProps> {
id?: string | string[]
email?: string | string[]
expires_at?: DateComparisonOperator
}
+18 -2
View File
@@ -1,6 +1,22 @@
export interface CreateUserDTO {
id?: string
email: string
first_name?: string | null
last_name?: string | null
avatar_url?: string | null
metadata?: Record<string, unknown> | null
}
export interface UpdateUserDTO {
export interface UpdateUserDTO extends Partial<Omit<CreateUserDTO, "email">> {
id: string
}
export interface CreateInviteDTO {
email: string
accepted?: boolean
token: string
expires_at: Date
metadata?: Record<string, unknown> | null
}
export interface UpdateInviteDTO extends Partial<CreateInviteDTO> {
id: string
}
+72 -2
View File
@@ -1,9 +1,15 @@
import { CreateUserDTO, UpdateUserDTO } from "./mutations"
import { FilterableUserProps, UserDTO } from "./common"
import {
CreateInviteDTO,
CreateUserDTO,
UpdateInviteDTO,
UpdateUserDTO,
} from "./mutations"
import { FilterableUserProps, InviteDTO, UserDTO } from "./common"
import { Context } from "../shared-context"
import { FindConfig } from "../common"
import { IModuleService } from "../modules-sdk"
import { RestoreReturn, SoftDeleteReturn } from "../dal"
export interface IUserModuleService extends IModuleService {
retrieve(
@@ -33,4 +39,68 @@ export interface IUserModuleService extends IModuleService {
update(data: UpdateUserDTO, sharedContext?: Context): Promise<UserDTO>
delete(ids: string[], sharedContext?: Context): Promise<void>
softDelete<TReturnableLinkableKeys extends string = string>(
userIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
restore<TReturnableLinkableKeys extends string = string>(
userIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
retrieveInvite(
id: string,
config?: FindConfig<InviteDTO>,
sharedContext?: Context
): Promise<InviteDTO>
listInvites(
filters?: FilterableUserProps,
config?: FindConfig<InviteDTO>,
sharedContext?: Context
): Promise<InviteDTO[]>
listAndCountInvites(
filters?: FilterableUserProps,
config?: FindConfig<InviteDTO>,
sharedContext?: Context
): Promise<[InviteDTO[], number]>
createInvites(
data: CreateInviteDTO[],
sharedContext?: Context
): Promise<InviteDTO[]>
createInvites(
data: CreateInviteDTO,
sharedContext?: Context
): Promise<InviteDTO>
updateInvites(
data: UpdateInviteDTO[],
sharedContext?: Context
): Promise<InviteDTO[]>
updateInvites(
data: UpdateInviteDTO,
sharedContext?: Context
): Promise<InviteDTO>
deleteInvites(ids: string[], sharedContext?: Context): Promise<void>
softDeleteInvites<TReturnableLinkableKeys extends string = string>(
inviteIds: string[],
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
restoreInvites<TReturnableLinkableKeys extends string = string>(
inviteIds: string[],
config?: RestoreReturn<TReturnableLinkableKeys>,
sharedContext?: Context
): Promise<Record<TReturnableLinkableKeys, string[]> | void>
}
+1
View File
@@ -3,3 +3,4 @@ export * as CommonWorkflow from "./common"
export * as ProductWorkflow from "./product"
export * as InventoryWorkflow from "./inventory"
export * as PriceListWorkflow from "./price-list"
export * as UserWorkflow from "./user"
@@ -0,0 +1,5 @@
import { CreateUserDTO } from "../../user"
export interface CreateUsersWorkflowInputDTO {
users: CreateUserDTO[]
}
@@ -0,0 +1,3 @@
export interface DeleteUserWorkflowInput {
ids: string[]
}
@@ -0,0 +1,3 @@
export * from "./create-user"
export * from "./update-user"
export * from "./delete-user"
@@ -0,0 +1,5 @@
import { UpdateUserDTO } from "../../user"
export interface UpdateUsersWorkflowInputDTO {
updates: UpdateUserDTO[]
}