Files
medusa-store/packages/medusa/src/models/invite.ts
Shahed Nasser 91615f9c45 chore: improve JS Client TSDoc comments (#5582)
* add oas schema to tsdoc parser

* add tsdoc (part 1)

* Finished tsdoc in js client

* general fixes

* added tsdoc in core medusa package

* parse schema tags in model files

* added maxlevel option

* added more tsdoc

* added tsdoc in core

* added TSDoc in core package

* generated client types

* support featureFlag and expandable tags

* added support for resource feature flag note

* fix api ignore plugin

* added eslint plugin

* support feature flag and expandable badges

* adjusted overview page + generated reference

* revert generated files

* added changeset

* add details about new typedoc options

* fix broken link
2023-11-09 12:51:17 +02:00

110 lines
2.9 KiB
TypeScript

import { BeforeInsert, Column, CreateDateColumn, Entity, Index } from "typeorm"
import { DbAwareColumn, resolveDbType } from "../utils/db-aware-column"
import { SoftDeletableEntity } from "../interfaces/models/soft-deletable-entity"
import { UserRoles } from "./user"
import { generateEntityId } from "../utils/generate-entity-id"
@Entity()
export class Invite extends SoftDeletableEntity {
@Index({ unique: true, where: "deleted_at IS NULL" })
@Column()
user_email: string
@DbAwareColumn({
type: "enum",
enum: UserRoles,
nullable: true,
default: UserRoles.MEMBER,
})
role: UserRoles
@Column({ default: false })
accepted: boolean
@Column()
token: string
@CreateDateColumn({ type: resolveDbType("timestamptz") })
expires_at: Date
@DbAwareColumn({ type: "jsonb", nullable: true })
metadata: Record<string, unknown>
/**
* @apiIgnore
*/
@BeforeInsert()
private beforeInsert(): void {
this.id = generateEntityId(this.id, "invite")
}
}
/**
* @schema Invite
* title: "Invite"
* description: "An invite is created when an admin user invites a new user to join the store's team. Once the invite is accepted, it's deleted."
* type: object
* required:
* - accepted
* - created_at
* - deleted_at
* - expires_at
* - id
* - metadata
* - role
* - token
* - updated_at
* - user_email
* properties:
* id:
* type: string
* description: The invite's ID
* example: invite_01G8TKE4XYCTHSCK2GDEP47RE1
* user_email:
* description: The email of the user being invited.
* type: string
* format: email
* role:
* description: The user's role. These roles don't change the privileges of the user.
* nullable: true
* type: string
* enum:
* - admin
* - member
* - developer
* default: member
* accepted:
* description: Whether the invite was accepted or not.
* type: boolean
* default: false
* token:
* description: The token used to accept the invite.
* type: string
* expires_at:
* description: The date the invite expires at.
* type: string
* format: date-time
* created_at:
* description: The date with timezone at which the resource was created.
* type: string
* format: date-time
* updated_at:
* description: The date with timezone at which the resource was updated.
* type: string
* format: date-time
* deleted_at:
* description: The date with timezone at which the resource was deleted.
* nullable: true
* type: string
* format: date-time
* metadata:
* description: An optional key-value map with additional details
* nullable: true
* type: object
* example: {car: "white"}
* externalDocs:
* description: "Learn about the metadata attribute, and how to delete and update it."
* url: "https://docs.medusajs.com/development/entities/overview#metadata-attribute"
*/