2023-09-08 08:15:33 +03:00
|
|
|
import { randomUUID } from 'node:crypto';
|
|
|
|
|
2023-08-30 00:30:59 +03:00
|
|
|
import type { INestApplication } from '@nestjs/common';
|
2023-09-08 08:15:33 +03:00
|
|
|
import { hashSync } from '@node-rs/argon2';
|
2023-09-29 06:02:26 +03:00
|
|
|
import { PrismaClient, type User } from '@prisma/client';
|
2023-08-29 13:07:05 +03:00
|
|
|
import request from 'supertest';
|
|
|
|
|
2023-09-15 10:34:14 +03:00
|
|
|
import type { TokenType } from '../src/modules/auth';
|
|
|
|
import type { UserType } from '../src/modules/users';
|
|
|
|
import type { InvitationType, WorkspaceType } from '../src/modules/workspaces';
|
2023-08-29 13:07:05 +03:00
|
|
|
|
|
|
|
const gql = '/graphql';
|
|
|
|
|
|
|
|
async function signUp(
|
|
|
|
app: INestApplication,
|
|
|
|
name: string,
|
|
|
|
email: string,
|
|
|
|
password: string
|
|
|
|
): Promise<UserType & { token: TokenType }> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
signUp(name: "${name}", email: "${email}", password: "${password}") {
|
|
|
|
id, name, email, token { token }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.signUp;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function currentUser(app: INestApplication, token: string) {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
currentUser {
|
2023-08-31 15:29:25 +03:00
|
|
|
id, name, email, emailVerified, avatarUrl, createdAt, hasPassword,
|
|
|
|
token { token }
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
2023-08-31 15:29:25 +03:00
|
|
|
return res.body.data.currentUser;
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function createWorkspace(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string
|
|
|
|
): Promise<WorkspaceType> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.field(
|
|
|
|
'operations',
|
|
|
|
JSON.stringify({
|
|
|
|
name: 'createWorkspace',
|
|
|
|
query: `mutation createWorkspace($init: Upload!) {
|
|
|
|
createWorkspace(init: $init) {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
variables: { init: null },
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.field('map', JSON.stringify({ '0': ['variables.init'] }))
|
|
|
|
.attach('0', Buffer.from([0, 0]), 'init.data')
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.createWorkspace;
|
|
|
|
}
|
|
|
|
|
2023-11-06 06:49:39 +03:00
|
|
|
export async function getWorkspacePublicPages(
|
2023-08-29 13:07:05 +03:00
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string
|
2023-11-06 06:49:39 +03:00
|
|
|
) {
|
2023-08-29 13:07:05 +03:00
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
workspace(id: "${workspaceId}") {
|
2023-11-06 06:49:39 +03:00
|
|
|
publicPages {
|
|
|
|
id
|
|
|
|
mode
|
|
|
|
}
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
2023-11-06 06:49:39 +03:00
|
|
|
return res.body.data.workspace.publicPages;
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function getWorkspace(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
2023-09-12 06:37:59 +03:00
|
|
|
workspaceId: string,
|
|
|
|
skip = 0,
|
|
|
|
take = 8
|
2023-08-29 13:07:05 +03:00
|
|
|
): Promise<WorkspaceType> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
workspace(id: "${workspaceId}") {
|
2023-09-12 06:37:59 +03:00
|
|
|
id, members(skip: ${skip}, take: ${take}) { id, name, email, permission, inviteId }
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.workspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getPublicWorkspace(
|
|
|
|
app: INestApplication,
|
|
|
|
workspaceId: string
|
|
|
|
): Promise<WorkspaceType> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
publicWorkspace(id: "${workspaceId}") {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.publicWorkspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function updateWorkspace(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
isPublic: boolean
|
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
updateWorkspace(input: { id: "${workspaceId}", public: ${isPublic} }) {
|
|
|
|
public
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.updateWorkspace.public;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function inviteUser(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
email: string,
|
|
|
|
permission: string,
|
|
|
|
sendInviteMail = false
|
|
|
|
): Promise<string> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
invite(workspaceId: "${workspaceId}", email: "${email}", permission: ${permission}, sendInviteMail: ${sendInviteMail})
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.invite;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function acceptInviteById(
|
|
|
|
app: INestApplication,
|
|
|
|
workspaceId: string,
|
2023-09-07 08:08:23 +03:00
|
|
|
inviteId: string,
|
|
|
|
sendAcceptMail = false
|
2023-08-29 13:07:05 +03:00
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
2023-09-07 08:08:23 +03:00
|
|
|
acceptInviteById(workspaceId: "${workspaceId}", inviteId: "${inviteId}", sendAcceptMail: ${sendAcceptMail})
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.acceptInviteById;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function leaveWorkspace(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
2023-09-07 08:08:23 +03:00
|
|
|
workspaceId: string,
|
|
|
|
sendLeaveMail = false
|
2023-08-29 13:07:05 +03:00
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
2023-09-07 08:08:23 +03:00
|
|
|
leaveWorkspace(workspaceId: "${workspaceId}", workspaceName: "test workspace", sendLeaveMail: ${sendLeaveMail})
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.leaveWorkspace;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function revokeUser(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
userId: string
|
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
revoke(workspaceId: "${workspaceId}", userId: "${userId}")
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.revoke;
|
|
|
|
}
|
|
|
|
|
2023-11-06 06:49:39 +03:00
|
|
|
async function publishPage(
|
2023-08-29 13:07:05 +03:00
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
pageId: string
|
2023-11-06 06:49:39 +03:00
|
|
|
) {
|
2023-08-29 13:07:05 +03:00
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
2023-11-06 06:49:39 +03:00
|
|
|
publishPage(workspaceId: "${workspaceId}", pageId: "${pageId}") {
|
|
|
|
id
|
|
|
|
mode
|
|
|
|
}
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
2023-11-06 06:49:39 +03:00
|
|
|
return res.body.errors?.[0]?.message || res.body.data?.publishPage;
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
|
2023-11-06 06:49:39 +03:00
|
|
|
async function revokePublicPage(
|
2023-08-29 13:07:05 +03:00
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
pageId: string
|
2023-11-06 06:49:39 +03:00
|
|
|
) {
|
2023-08-29 13:07:05 +03:00
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
2023-11-06 06:49:39 +03:00
|
|
|
revokePublicPage(workspaceId: "${workspaceId}", pageId: "${pageId}") {
|
|
|
|
id
|
|
|
|
mode
|
|
|
|
public
|
|
|
|
}
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
2023-11-06 06:49:39 +03:00
|
|
|
return res.body.errors?.[0]?.message || res.body.data?.revokePublicPage;
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
async function listBlobs(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string
|
|
|
|
): Promise<string[]> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
listBlobs(workspaceId: "${workspaceId}")
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.listBlobs;
|
|
|
|
}
|
|
|
|
|
2023-08-31 11:39:19 +03:00
|
|
|
async function collectBlobSizes(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string
|
|
|
|
): Promise<number> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
collectBlobSizes(workspaceId: "${workspaceId}") {
|
|
|
|
size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.collectBlobSizes.size;
|
|
|
|
}
|
|
|
|
|
2023-09-01 15:56:27 +03:00
|
|
|
async function collectAllBlobSizes(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string
|
|
|
|
): Promise<number> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
collectAllBlobSizes {
|
|
|
|
size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.collectAllBlobSizes.size;
|
|
|
|
}
|
|
|
|
|
2023-09-08 00:32:41 +03:00
|
|
|
async function checkBlobSize(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
size: number
|
|
|
|
): Promise<number> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.send({
|
|
|
|
query: `query checkBlobSize($workspaceId: String!, $size: Float!) {
|
|
|
|
checkBlobSize(workspaceId: $workspaceId, size: $size) {
|
|
|
|
size
|
|
|
|
}
|
|
|
|
}`,
|
|
|
|
variables: { workspaceId, size },
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.checkBlobSize.size;
|
|
|
|
}
|
|
|
|
|
2023-08-29 13:07:05 +03:00
|
|
|
async function setBlob(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
workspaceId: string,
|
|
|
|
buffer: Buffer
|
|
|
|
): Promise<string> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.field(
|
|
|
|
'operations',
|
|
|
|
JSON.stringify({
|
|
|
|
name: 'setBlob',
|
|
|
|
query: `mutation setBlob($blob: Upload!) {
|
|
|
|
setBlob(workspaceId: "${workspaceId}", blob: $blob)
|
|
|
|
}`,
|
|
|
|
variables: { blob: null },
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.field('map', JSON.stringify({ '0': ['variables.blob'] }))
|
|
|
|
.attach('0', buffer, 'blob.data')
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.setBlob;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function flushDB() {
|
|
|
|
const client = new PrismaClient();
|
|
|
|
await client.$connect();
|
|
|
|
const result: { tablename: string }[] =
|
|
|
|
await client.$queryRaw`SELECT tablename
|
|
|
|
FROM pg_catalog.pg_tables
|
2023-09-13 08:11:19 +03:00
|
|
|
WHERE schemaname != 'pg_catalog'
|
|
|
|
AND schemaname != 'information_schema'`;
|
2023-08-29 13:07:05 +03:00
|
|
|
|
|
|
|
// remove all table data
|
|
|
|
await client.$executeRawUnsafe(
|
|
|
|
`TRUNCATE TABLE ${result
|
|
|
|
.map(({ tablename }) => tablename)
|
|
|
|
.filter(name => !name.includes('migrations'))
|
|
|
|
.join(', ')}`
|
|
|
|
);
|
|
|
|
|
|
|
|
await client.$disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
async function getInviteInfo(
|
|
|
|
app: INestApplication,
|
|
|
|
token: string,
|
|
|
|
inviteId: string
|
|
|
|
): Promise<InvitationType> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(token, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
query {
|
|
|
|
getInviteInfo(inviteId: "${inviteId}") {
|
|
|
|
workspace {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
avatar
|
|
|
|
}
|
|
|
|
user {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
avatarUrl
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
2023-08-31 15:29:25 +03:00
|
|
|
return res.body.data.getInviteInfo;
|
2023-08-29 13:07:05 +03:00
|
|
|
}
|
|
|
|
|
2023-09-13 19:54:02 +03:00
|
|
|
async function sendChangeEmail(
|
|
|
|
app: INestApplication,
|
|
|
|
userToken: string,
|
|
|
|
email: string,
|
|
|
|
callbackUrl: string
|
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(userToken, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
sendChangeEmail(email: "${email}", callbackUrl: "${callbackUrl}")
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
|
|
|
|
return res.body.data.sendChangeEmail;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function sendVerifyChangeEmail(
|
|
|
|
app: INestApplication,
|
|
|
|
userToken: string,
|
|
|
|
token: string,
|
|
|
|
email: string,
|
|
|
|
callbackUrl: string
|
|
|
|
): Promise<boolean> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(userToken, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
sendVerifyChangeEmail(token:"${token}", email: "${email}", callbackUrl: "${callbackUrl}")
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
|
|
|
|
return res.body.data.sendVerifyChangeEmail;
|
|
|
|
}
|
|
|
|
|
|
|
|
async function changeEmail(
|
|
|
|
app: INestApplication,
|
|
|
|
userToken: string,
|
|
|
|
token: string
|
|
|
|
): Promise<UserType & { token: TokenType }> {
|
|
|
|
const res = await request(app.getHttpServer())
|
|
|
|
.post(gql)
|
|
|
|
.auth(userToken, { type: 'bearer' })
|
|
|
|
.set({ 'x-request-id': 'test', 'x-operation-name': 'test' })
|
|
|
|
.send({
|
|
|
|
query: `
|
|
|
|
mutation {
|
|
|
|
changeEmail(token: "${token}") {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
avatarUrl
|
|
|
|
email
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
})
|
|
|
|
.expect(200);
|
|
|
|
return res.body.data.changeEmail;
|
|
|
|
}
|
|
|
|
|
2023-09-08 08:15:33 +03:00
|
|
|
export class FakePrisma {
|
|
|
|
fakeUser: User = {
|
|
|
|
id: randomUUID(),
|
|
|
|
name: 'Alex Yang',
|
|
|
|
avatarUrl: '',
|
|
|
|
email: 'alex.yang@example.org',
|
|
|
|
password: hashSync('123456'),
|
|
|
|
emailVerified: new Date(),
|
|
|
|
createdAt: new Date(),
|
|
|
|
};
|
2023-09-13 08:11:19 +03:00
|
|
|
|
2023-09-08 08:15:33 +03:00
|
|
|
get user() {
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
|
|
const prisma = this;
|
|
|
|
return {
|
|
|
|
async findFirst() {
|
|
|
|
return prisma.fakeUser;
|
|
|
|
},
|
|
|
|
async findUnique() {
|
|
|
|
return this.findFirst();
|
|
|
|
},
|
|
|
|
async update() {
|
|
|
|
return this.findFirst();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-29 13:07:05 +03:00
|
|
|
export {
|
|
|
|
acceptInviteById,
|
2023-09-13 19:54:02 +03:00
|
|
|
changeEmail,
|
2023-09-08 00:32:41 +03:00
|
|
|
checkBlobSize,
|
2023-09-01 15:56:27 +03:00
|
|
|
collectAllBlobSizes,
|
2023-08-31 11:39:19 +03:00
|
|
|
collectBlobSizes,
|
2023-08-29 13:07:05 +03:00
|
|
|
createWorkspace,
|
|
|
|
currentUser,
|
|
|
|
flushDB,
|
|
|
|
getInviteInfo,
|
|
|
|
getPublicWorkspace,
|
|
|
|
getWorkspace,
|
|
|
|
inviteUser,
|
|
|
|
leaveWorkspace,
|
|
|
|
listBlobs,
|
2023-11-06 06:49:39 +03:00
|
|
|
publishPage,
|
|
|
|
revokePublicPage,
|
2023-08-29 13:07:05 +03:00
|
|
|
revokeUser,
|
2023-09-13 19:54:02 +03:00
|
|
|
sendChangeEmail,
|
|
|
|
sendVerifyChangeEmail,
|
2023-08-29 13:07:05 +03:00
|
|
|
setBlob,
|
|
|
|
signUp,
|
|
|
|
updateWorkspace,
|
|
|
|
};
|