remove next-pwa for now

This commit is contained in:
m5r 2021-08-08 10:58:28 +08:00
parent d20eeb0617
commit cc36a34149
16 changed files with 1869 additions and 479 deletions

View File

@ -1,11 +1,14 @@
import { BlitzConfig, sessionMiddleware, simpleRolesIsAuthorized } from "blitz";
/// <reference path='./next-pwa.d.ts' />
import type { BlitzConfig } from "blitz";
import { sessionMiddleware, simpleRolesIsAuthorized } from "blitz";
// import withPWA from "next-pwa";
const withPWA = require("next-pwa");
type Module = Omit<NodeModule, "exports"> & { exports: BlitzConfig };
const config: BlitzConfig = {
(module as Module).exports = {
middleware: [
sessionMiddleware({
cookiePrefix: "shellphone",
cookiePrefix: "virtual-phone",
isAuthorized: simpleRolesIsAuthorized,
}),
],
@ -49,15 +52,8 @@ const config: BlitzConfig = {
return config
},
*/
/*pwa: {
dest: "public",
disable: process.env.NODE_ENV !== "production",
},*/
};
module.exports =
process.env.NODE_ENV === "test"
? config
: withPWA({
...config,
pwa: {
dest: "public",
disable: process.env.NODE_ENV !== "production",
},
});

View File

@ -1,57 +0,0 @@
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT,
"role" TEXT NOT NULL DEFAULT E'USER',
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Session" (
"id" SERIAL NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"expiresAt" TIMESTAMP(3),
"handle" TEXT NOT NULL,
"hashedSessionToken" TEXT,
"antiCSRFToken" TEXT,
"publicData" TEXT,
"privateData" TEXT,
"userId" INTEGER,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Token" (
"id" SERIAL NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"hashedToken" TEXT NOT NULL,
"type" TEXT NOT NULL,
"expiresAt" TIMESTAMP(3) NOT NULL,
"sentTo" TEXT NOT NULL,
"userId" INTEGER NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Session.handle_unique" ON "Session"("handle");
-- CreateIndex
CREATE UNIQUE INDEX "Token.hashedToken_type_unique" ON "Token"("hashedToken", "type");
-- AddForeignKey
ALTER TABLE "Session" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Token" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,137 +0,0 @@
/*
Warnings:
- The primary key for the `Session` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `Token` table will be changed. If it partially fails, the table could be left without primary key constraint.
- The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.
- A unique constraint covering the columns `[hashedToken,type]` on the table `Token` will be added. If there are existing duplicate values, this will fail.
- Changed the type of `type` on the `Token` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.
*/
-- CreateEnum
CREATE TYPE "TokenType" AS ENUM ('RESET_PASSWORD');
-- CreateEnum
CREATE TYPE "Direction" AS ENUM ('Inbound', 'Outbound');
-- CreateEnum
CREATE TYPE "MessageStatus" AS ENUM ('Queued', 'Sending', 'Sent', 'Failed', 'Delivered', 'Undelivered', 'Receiving', 'Received', 'Accepted', 'Scheduled', 'Read', 'PartiallyDelivered', 'Canceled');
-- CreateEnum
CREATE TYPE "CallStatus" AS ENUM ('Queued', 'Ringing', 'InProgress', 'Completed', 'Busy', 'Failed', 'NoAnswer', 'Canceled');
-- DropForeignKey
ALTER TABLE "Session" DROP CONSTRAINT "Session_userId_fkey";
-- DropForeignKey
ALTER TABLE "Token" DROP CONSTRAINT "Token_userId_fkey";
-- AlterTable
ALTER TABLE "Session" DROP CONSTRAINT "Session_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "expiresAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "userId" SET DATA TYPE TEXT,
ADD PRIMARY KEY ("id");
DROP SEQUENCE "Session_id_seq";
-- AlterTable
ALTER TABLE "Token" DROP CONSTRAINT "Token_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ,
DROP COLUMN "type",
ADD COLUMN "type" "TokenType" NOT NULL,
ALTER COLUMN "expiresAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "userId" SET DATA TYPE TEXT,
ADD PRIMARY KEY ("id");
DROP SEQUENCE "Token_id_seq";
-- AlterTable
ALTER TABLE "User" DROP CONSTRAINT "User_pkey",
ALTER COLUMN "id" DROP DEFAULT,
ALTER COLUMN "id" SET DATA TYPE TEXT,
ALTER COLUMN "createdAt" SET DATA TYPE TIMESTAMPTZ,
ALTER COLUMN "updatedAt" SET DATA TYPE TIMESTAMPTZ,
ADD PRIMARY KEY ("id");
DROP SEQUENCE "User_id_seq";
-- CreateTable
CREATE TABLE "Customer" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"encryptionKey" TEXT NOT NULL,
"accountSid" TEXT,
"authToken" TEXT,
"twimlAppSid" TEXT,
"paddleCustomerId" TEXT,
"paddleSubscriptionId" TEXT,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Message" (
"id" TEXT NOT NULL,
"sentAt" TIMESTAMPTZ NOT NULL,
"content" TEXT NOT NULL,
"from" TEXT NOT NULL,
"to" TEXT NOT NULL,
"direction" "Direction" NOT NULL,
"status" "MessageStatus" NOT NULL,
"twilioSid" TEXT,
"customerId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PhoneCall" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL,
"twilioSid" TEXT NOT NULL,
"from" TEXT NOT NULL,
"to" TEXT NOT NULL,
"status" "CallStatus" NOT NULL,
"direction" "Direction" NOT NULL,
"duration" TEXT NOT NULL,
"customerId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PhoneNumber" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL,
"phoneNumberSid" TEXT NOT NULL,
"phoneNumber" TEXT NOT NULL,
"customerId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Token.hashedToken_type_unique" ON "Token"("hashedToken", "type");
-- AddForeignKey
ALTER TABLE "Session" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Token" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Customer" ADD FOREIGN KEY ("id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Message" ADD FOREIGN KEY ("customerId") REFERENCES "Customer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneCall" ADD FOREIGN KEY ("customerId") REFERENCES "Customer"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneNumber" ADD FOREIGN KEY ("customerId") REFERENCES "Customer"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,12 +0,0 @@
/*
Warnings:
- The `role` column on the `User` table would be dropped and recreated. This will lead to data loss if there is data in the column.
*/
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN');
-- AlterTable
ALTER TABLE "User" DROP COLUMN "role",
ADD COLUMN "role" "Role" NOT NULL DEFAULT E'USER';

View File

@ -1,5 +0,0 @@
-- AlterTable
ALTER TABLE "PhoneCall" ALTER COLUMN "createdAt" SET DEFAULT CURRENT_TIMESTAMP;
-- AlterTable
ALTER TABLE "PhoneNumber" ALTER COLUMN "createdAt" SET DEFAULT CURRENT_TIMESTAMP;

View File

@ -1,16 +0,0 @@
-- CreateTable
CREATE TABLE "NotificationSubscription" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"endpoint" TEXT NOT NULL,
"expirationTime" INTEGER,
"keys_p256dh" TEXT NOT NULL,
"keys_auth" TEXT NOT NULL,
"customerId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "NotificationSubscription" ADD FOREIGN KEY ("customerId") REFERENCES "Customer"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,8 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[endpoint]` on the table `NotificationSubscription` will be added. If there are existing duplicate values, this will fail.
*/
-- CreateIndex
CREATE UNIQUE INDEX "NotificationSubscription.endpoint_unique" ON "NotificationSubscription"("endpoint");

View File

@ -1,148 +0,0 @@
/*
Warnings:
- You are about to drop the column `customerId` on the `Message` table. All the data in the column will be lost.
- You are about to drop the column `twilioSid` on the `Message` table. All the data in the column will be lost.
- You are about to drop the column `customerId` on the `NotificationSubscription` table. All the data in the column will be lost.
- You are about to drop the column `customerId` on the `PhoneCall` table. All the data in the column will be lost.
- You are about to drop the column `twilioSid` on the `PhoneCall` table. All the data in the column will be lost.
- You are about to drop the column `customerId` on the `PhoneNumber` table. All the data in the column will be lost.
- You are about to drop the column `phoneNumber` on the `PhoneNumber` table. All the data in the column will be lost.
- You are about to drop the column `phoneNumberSid` on the `PhoneNumber` table. All the data in the column will be lost.
- The `role` column on the `User` table would be dropped and recreated. This will lead to data loss if there is data in the column.
- You are about to drop the `Customer` table. If the table is not empty, all the data it contains will be lost.
- A unique constraint covering the columns `[phoneNumberId,id]` on the table `Message` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[phoneNumberId,id]` on the table `PhoneCall` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[organizationId,id]` on the table `PhoneNumber` will be added. If there are existing duplicate values, this will fail.
- Added the required column `phoneNumberId` to the `Message` table without a default value. This is not possible if the table is not empty.
- Added the required column `organizationId` to the `NotificationSubscription` table without a default value. This is not possible if the table is not empty.
- Added the required column `phoneNumberId` to the `NotificationSubscription` table without a default value. This is not possible if the table is not empty.
- Added the required column `phoneNumberId` to the `PhoneCall` table without a default value. This is not possible if the table is not empty.
- Added the required column `number` to the `PhoneNumber` table without a default value. This is not possible if the table is not empty.
- Added the required column `organizationId` to the `PhoneNumber` table without a default value. This is not possible if the table is not empty.
*/
-- CreateEnum
CREATE TYPE "MembershipRole" AS ENUM ('OWNER', 'ADMIN', 'USER');
-- CreateEnum
CREATE TYPE "GlobalRole" AS ENUM ('SUPERADMIN', 'CUSTOMER');
-- AlterEnum
ALTER TYPE "MessageStatus" ADD VALUE 'Error';
-- DropForeignKey
ALTER TABLE "Customer" DROP CONSTRAINT "Customer_id_fkey";
-- DropForeignKey
ALTER TABLE "Message" DROP CONSTRAINT "Message_customerId_fkey";
-- DropForeignKey
ALTER TABLE "NotificationSubscription" DROP CONSTRAINT "NotificationSubscription_customerId_fkey";
-- DropForeignKey
ALTER TABLE "PhoneCall" DROP CONSTRAINT "PhoneCall_customerId_fkey";
-- DropForeignKey
ALTER TABLE "PhoneNumber" DROP CONSTRAINT "PhoneNumber_customerId_fkey";
-- AlterTable
ALTER TABLE "Message" DROP COLUMN "customerId",
DROP COLUMN "twilioSid",
ADD COLUMN "phoneNumberId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "NotificationSubscription" DROP COLUMN "customerId",
ADD COLUMN "organizationId" TEXT NOT NULL,
ADD COLUMN "phoneNumberId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "PhoneCall" DROP COLUMN "customerId",
DROP COLUMN "twilioSid",
ADD COLUMN "phoneNumberId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "PhoneNumber" DROP COLUMN "customerId",
DROP COLUMN "phoneNumber",
DROP COLUMN "phoneNumberSid",
ADD COLUMN "number" TEXT NOT NULL,
ADD COLUMN "organizationId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "User" DROP COLUMN "role",
ADD COLUMN "role" "GlobalRole" NOT NULL DEFAULT E'CUSTOMER';
-- DropTable
DROP TABLE "Customer";
-- CreateTable
CREATE TABLE "TwilioCredentials" (
"accountSid" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"authToken" TEXT NOT NULL,
"twimlAppSid" TEXT,
"organizationId" TEXT NOT NULL,
PRIMARY KEY ("accountSid")
);
-- CreateTable
CREATE TABLE "Organization" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"encryptionKey" TEXT NOT NULL,
"paddleCustomerId" TEXT,
"paddleSubscriptionId" TEXT,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Membership" (
"id" TEXT NOT NULL,
"role" "MembershipRole" NOT NULL,
"organizationId" TEXT NOT NULL,
"userId" TEXT,
"invitedName" TEXT,
"invitedEmail" TEXT,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Membership.organizationId_invitedEmail_unique" ON "Membership"("organizationId", "invitedEmail");
-- CreateIndex
CREATE UNIQUE INDEX "Message.phoneNumberId_id_unique" ON "Message"("phoneNumberId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "PhoneCall.phoneNumberId_id_unique" ON "PhoneCall"("phoneNumberId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "PhoneNumber.organizationId_id_unique" ON "PhoneNumber"("organizationId", "id");
-- AddForeignKey
ALTER TABLE "TwilioCredentials" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Membership" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Membership" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Message" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneCall" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneNumber" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "NotificationSubscription" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "NotificationSubscription" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -1,16 +0,0 @@
/*
Warnings:
- You are about to drop the `TwilioCredentials` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropForeignKey
ALTER TABLE "TwilioCredentials" DROP CONSTRAINT "TwilioCredentials_organizationId_fkey";
-- AlterTable
ALTER TABLE "Organization" ADD COLUMN "twilioAccountSid" TEXT,
ADD COLUMN "twilioAuthToken" TEXT,
ADD COLUMN "twimlAppSid" TEXT;
-- DropTable
DROP TABLE "TwilioCredentials";

View File

@ -1,36 +0,0 @@
/*
Warnings:
- A unique constraint covering the columns `[organizationId,phoneNumberId,id]` on the table `Message` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[id,twilioAccountSid]` on the table `Organization` will be added. If there are existing duplicate values, this will fail.
- A unique constraint covering the columns `[organizationId,phoneNumberId,id]` on the table `PhoneCall` will be added. If there are existing duplicate values, this will fail.
- Added the required column `organizationId` to the `Message` table without a default value. This is not possible if the table is not empty.
- Added the required column `organizationId` to the `PhoneCall` table without a default value. This is not possible if the table is not empty.
*/
-- DropIndex
DROP INDEX "Message.phoneNumberId_id_unique";
-- DropIndex
DROP INDEX "PhoneCall.phoneNumberId_id_unique";
-- AlterTable
ALTER TABLE "Message" ADD COLUMN "organizationId" TEXT NOT NULL;
-- AlterTable
ALTER TABLE "PhoneCall" ADD COLUMN "organizationId" TEXT NOT NULL;
-- CreateIndex
CREATE UNIQUE INDEX "Message.organizationId_phoneNumberId_id_unique" ON "Message"("organizationId", "phoneNumberId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "Organization.id_twilioAccountSid_unique" ON "Organization"("id", "twilioAccountSid");
-- CreateIndex
CREATE UNIQUE INDEX "PhoneCall.organizationId_phoneNumberId_id_unique" ON "PhoneCall"("organizationId", "phoneNumberId", "id");
-- AddForeignKey
ALTER TABLE "Message" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneCall" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -0,0 +1,205 @@
-- CreateEnum
CREATE TYPE "MembershipRole" AS ENUM ('OWNER', 'ADMIN', 'USER');
-- CreateEnum
CREATE TYPE "GlobalRole" AS ENUM ('SUPERADMIN', 'CUSTOMER');
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('USER', 'ADMIN');
-- CreateEnum
CREATE TYPE "TokenType" AS ENUM ('RESET_PASSWORD');
-- CreateEnum
CREATE TYPE "Direction" AS ENUM ('Inbound', 'Outbound');
-- CreateEnum
CREATE TYPE "MessageStatus" AS ENUM ('Queued', 'Sending', 'Sent', 'Failed', 'Delivered', 'Undelivered', 'Receiving', 'Received', 'Accepted', 'Scheduled', 'Read', 'PartiallyDelivered', 'Canceled', 'Error');
-- CreateEnum
CREATE TYPE "CallStatus" AS ENUM ('Queued', 'Ringing', 'InProgress', 'Completed', 'Busy', 'Failed', 'NoAnswer', 'Canceled');
-- CreateTable
CREATE TABLE "Organization" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"encryptionKey" TEXT NOT NULL,
"paddleCustomerId" TEXT,
"paddleSubscriptionId" TEXT,
"twilioAccountSid" TEXT,
"twilioAuthToken" TEXT,
"twimlAppSid" TEXT,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Membership" (
"id" TEXT NOT NULL,
"role" "MembershipRole" NOT NULL,
"organizationId" TEXT NOT NULL,
"userId" TEXT,
"invitedName" TEXT,
"invitedEmail" TEXT,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"name" TEXT,
"email" TEXT NOT NULL,
"hashedPassword" TEXT,
"role" "GlobalRole" NOT NULL DEFAULT E'CUSTOMER',
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Session" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"expiresAt" TIMESTAMPTZ,
"handle" TEXT NOT NULL,
"hashedSessionToken" TEXT,
"antiCSRFToken" TEXT,
"publicData" TEXT,
"privateData" TEXT,
"userId" TEXT,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Token" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"hashedToken" TEXT NOT NULL,
"type" "TokenType" NOT NULL,
"expiresAt" TIMESTAMPTZ NOT NULL,
"sentTo" TEXT NOT NULL,
"userId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "Message" (
"id" TEXT NOT NULL,
"sentAt" TIMESTAMPTZ NOT NULL,
"content" TEXT NOT NULL,
"from" TEXT NOT NULL,
"to" TEXT NOT NULL,
"direction" "Direction" NOT NULL,
"status" "MessageStatus" NOT NULL,
"organizationId" TEXT NOT NULL,
"phoneNumberId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PhoneCall" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"from" TEXT NOT NULL,
"to" TEXT NOT NULL,
"status" "CallStatus" NOT NULL,
"direction" "Direction" NOT NULL,
"duration" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"phoneNumberId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "PhoneNumber" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"number" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "NotificationSubscription" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ NOT NULL,
"endpoint" TEXT NOT NULL,
"expirationTime" INTEGER,
"keys_p256dh" TEXT NOT NULL,
"keys_auth" TEXT NOT NULL,
"organizationId" TEXT NOT NULL,
"phoneNumberId" TEXT NOT NULL,
PRIMARY KEY ("id")
);
-- CreateIndex
CREATE UNIQUE INDEX "Organization.id_twilioAccountSid_unique" ON "Organization"("id", "twilioAccountSid");
-- CreateIndex
CREATE UNIQUE INDEX "Membership.organizationId_invitedEmail_unique" ON "Membership"("organizationId", "invitedEmail");
-- CreateIndex
CREATE UNIQUE INDEX "User.email_unique" ON "User"("email");
-- CreateIndex
CREATE UNIQUE INDEX "Session.handle_unique" ON "Session"("handle");
-- CreateIndex
CREATE UNIQUE INDEX "Token.hashedToken_type_unique" ON "Token"("hashedToken", "type");
-- CreateIndex
CREATE UNIQUE INDEX "Message.organizationId_phoneNumberId_id_unique" ON "Message"("organizationId", "phoneNumberId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "PhoneCall.organizationId_phoneNumberId_id_unique" ON "PhoneCall"("organizationId", "phoneNumberId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "PhoneNumber.organizationId_id_unique" ON "PhoneNumber"("organizationId", "id");
-- CreateIndex
CREATE UNIQUE INDEX "NotificationSubscription.endpoint_unique" ON "NotificationSubscription"("endpoint");
-- AddForeignKey
ALTER TABLE "Membership" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Membership" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Session" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Token" ADD FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Message" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "Message" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneCall" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneCall" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "PhoneNumber" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "NotificationSubscription" ADD FOREIGN KEY ("organizationId") REFERENCES "Organization"("id") ON DELETE CASCADE ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE "NotificationSubscription" ADD FOREIGN KEY ("phoneNumberId") REFERENCES "PhoneNumber"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@ -6,7 +6,7 @@ services:
restart: unless-stopped
volumes:
- data:/var/lib/postgresql/data
env_file: ./.env.local #Here we are using the already existing .env.local file
env_file: ./.env #Here we are using the already existing .env file
ports:
- "5432:5432"
admin:

7
next-pwa.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import type { BlitzConfig } from "blitz";
declare module "next-pwa" {
function withPWA(config: BlitzConfig): BlitzConfig;
export default withPWA;
}

1662
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -50,17 +50,15 @@
"@react-aria/interactions": "3.5.0",
"@tailwindcss/forms": "0.3.3",
"@tailwindcss/typography": "0.4.1",
"autoprefixer": "10.3.1",
"@twilio/voice-sdk": "2.0.1",
"blitz": "0.38.6",
"clsx": "1.1.1",
"concurrently": "6.2.0",
"got": "11.8.2",
"jotai": "1.2.2",
"next-pwa": "5.2.24",
"pino": "6.13.0",
"pino-pretty": "5.1.2",
"postcss": "8.3.6",
"quirrel": "1.7.0",
"quirrel": "1.6.3",
"react": "18.0.0-alpha-6f3fcbd6f-20210730",
"react-dom": "18.0.0-alpha-6f3fcbd6f-20210730",
"react-hook-form": "7.12.2",
@ -79,10 +77,13 @@
"@types/preview-email": "2.0.1",
"@types/react": "17.0.15",
"@types/web-push": "3.3.2",
"autoprefixer": "10.3.1",
"concurrently": "6.2.0",
"eslint": "7.32.0",
"husky": "6.0.0",
"lint-staged": "10.5.4",
"next-test-api-route-handler": "2.0.2",
"postcss": "8.3.6",
"prettier": "2.3.2",
"prettier-plugin-prisma": "2.28.0",
"pretty-quick": "3.1.1",

View File

@ -1,3 +1,5 @@
jest.mock("next-pwa", () => ({ __esModule: true, default: jest.fn().mockImplementation((config) => config) }));
import { setConfig } from "blitz";
// see https://github.com/vercel/next.js/issues/4024