Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/disabling notification sms whatsapp #182

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**
18 changes: 10 additions & 8 deletions apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "yarn db:deploy && dotenv -e ../../.env next build",
"dev": "dotenv -e ../../.env next dev",
"postinstall": "cd ../../ && npx prisma generate",
"postinstall": "npm run db:generate",
"lint": "dotenv -e ../../.env next lint",
"start": "dotenv -e ../../.env next start",
"heroku-start": "next start -p $PORT",
Expand All @@ -17,15 +17,17 @@
"db:pull": "dotenv -e ../../.env npx prisma db pull",
"db:deploy": "dotenv -e ../../.env npx prisma migrate deploy",
"db:reset": "dotenv -e ../../.env npx prisma migrate reset",
"db:generate": "dotenv -e ../../.env npx prisma generate"
"db:generate": "dotenv -e ../../.env npx prisma generate",
"db:studio": "dotenv -e ../../.env npx prisma studio"
},
"dependencies": {
"@google/earthengine": "^0.1.396",
"@google/earthengine": "^1.4.3",
"@logtail/node": "^0.4.0",
"@planet-sdk/common": "^0.1.11",
"@prisma/client": "^5.0.0",
"@sentry/nextjs": "^7.77.0",
"@sentry/profiling-node": "^0.3.0",
"@prisma/client": "^6.1.0",
"@sentry/nextjs": "^8.47.0",
"@sentry/node": "^8.47.0",
"@sentry/profiling-node": "^8.47.0",
"@tanstack/react-query": "^4.20.2",
"@trpc/client": "^10.9.0",
"@trpc/next": "^10.40.0",
Expand All @@ -44,7 +46,7 @@
"nodemailer": "^6.9.1",
"pg-promise": "^11.4.3",
"phone": "^3.1.37",
"prisma": "^5.10.2",
"prisma": "^6.1.0",
"react": "^18.2.0",
"react-cookie": "^4.1.1",
"react-dom": "^18.2.0",
Expand All @@ -66,7 +68,7 @@
"@typescript-eslint/parser": "^5.53.0",
"eslint": "^8.34.0",
"eslint-config-next": "^13.5.4",
"prisma": "^5.10.2",
"prisma": "^6.1.0",
"tsconfig": "*",
"typescript": "^5.0.3"
},
Expand Down
267 changes: 133 additions & 134 deletions apps/server/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,178 +1,177 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
}

datasource db {
provider = "postgresql"
url = env("DATABASE_PRISMA_URL")
directUrl = env("DATABASE_URL_NON_POOLING")
shadowDatabaseUrl = env("DATABASE_URL_NON_POOLING")
provider = "postgresql"
url = env("DATABASE_PRISMA_URL")
directUrl = env("DATABASE_URL_NON_POOLING")
shadowDatabaseUrl = env("DATABASE_URL_NON_POOLING_SHADOW")
}

model User {
id String @id @default(cuid())
sub String? @unique
name String?
email String @unique
emailVerified Boolean @default(false)
detectionMethods Json // ["MODIS","VIIRS","LANDSAT","GEOSTATIONARY"]
isPlanetRO Boolean?
plan String @default("basic") //"basic" or "custom"
image String?
deletedAt DateTime?
isVerified Boolean?
lastLogin DateTime?
signupDate DateTime @default(now())
roles Role @default(ROLE_CLIENT)
alertMethods AlertMethod[]
projects Project[]
sites Site[]
remoteId String?
id String @id @default(cuid())
sub String? @unique
name String?
email String @unique
emailVerified Boolean @default(false)
detectionMethods Json // ["MODIS","VIIRS","LANDSAT","GEOSTATIONARY"]
isPlanetRO Boolean?
plan String @default("basic") //"basic" or "custom"
image String?
deletedAt DateTime?
isVerified Boolean?
lastLogin DateTime?
signupDate DateTime @default(now())
roles Role @default(ROLE_CLIENT)
alertMethods AlertMethod[]
projects Project[]
sites Site[]
remoteId String?
}

model VerificationRequest {
id String @id @default(cuid())
token String @unique
expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
alertMethodId String @unique
alertMethod AlertMethod @relation(fields: [alertMethodId], references: [id], onDelete: Cascade)

@@unique([id, token])
id String @id @default(cuid())
token String @unique
expires DateTime
createdAt DateTime @default(now())
updatedAt DateTime? @updatedAt
alertMethodId String @unique
alertMethod AlertMethod @relation(fields: [alertMethodId], references: [id], onDelete: Cascade)

@@unique([id, token])
}

model AlertMethod {
id String @id @default(cuid())
method String
destination String
isVerified Boolean @default(false)
isEnabled Boolean @default(false)
deletedAt DateTime?
deviceName String?
deviceId String?
tokenSentCount Int @default(0)
lastTokenSentDate DateTime?
userId String
failCount Int @default(0)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
verificationRequest VerificationRequest?

@@unique([destination, userId, method])
id String @id @default(cuid())
method String
destination String
isVerified Boolean @default(false)
isEnabled Boolean @default(false)
deletedAt DateTime?
deviceName String?
deviceId String?
tokenSentCount Int @default(0)
lastTokenSentDate DateTime?
userId String
failCount Int @default(0)
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
verificationRequest VerificationRequest?

@@unique([destination, userId, method])
}

model Site {
id String @id @default(cuid())
remoteId String?
name String?
origin String @default("firealert")
type SiteType
geometry Json
radius Int @default(0)
isMonitored Boolean @default(true)
deletedAt DateTime?
projectId String?
lastUpdated DateTime?
stopAlertUntil DateTime?
lastMessageCreated DateTime?
userId String
slices Json? // Will be something like ["1","2"] or ["3"] or ["1"] or ["7","8"]
detectionGeometry Unsupported("geometry")?
originalGeometry Unsupported("geometry")?
detectionArea Float?
alerts SiteAlert[]
project Project? @relation(fields: [projectId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
id String @id @default(cuid())
remoteId String?
name String?
origin String @default("firealert")
type SiteType
geometry Json
radius Int @default(0)
isMonitored Boolean @default(true)
deletedAt DateTime?
projectId String?
lastUpdated DateTime?
stopAlertUntil DateTime?
lastMessageCreated DateTime?
userId String
slices Json? // Will be something like ["1","2"] or ["3"] or ["1"] or ["7","8"]
detectionGeometry Unsupported("geometry")?
originalGeometry Unsupported("geometry")?
detectionArea Float?
alerts SiteAlert[]
project Project? @relation(fields: [projectId], references: [id])
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
}

model Project {
id String @id
name String
slug String?
lastUpdated DateTime?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
sites Site[]
id String @id
name String
slug String?
lastUpdated DateTime?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
sites Site[]
}

model GeoEventProvider {
id String @id @default(cuid())
name String?
description String?
type String // Fire
clientApiKey String @unique
clientId String // LANDSAT_NRT
fetchFrequency Int?
isActive Boolean
lastRun DateTime?
config Json
id String @id @default(cuid())
name String?
description String?
type String // Fire
clientApiKey String @unique
clientId String // LANDSAT_NRT
fetchFrequency Int?
isActive Boolean
lastRun DateTime?
config Json
}

model GeoEvent {
id String @id @default(cuid())
type String // Fire
latitude Float
longitude Float
eventDate DateTime
geometry Unsupported("geometry")?
confidence AlertConfidence
isProcessed Boolean @default(false)
geoEventProviderClientId String // LANDSAT_NRT
geoEventProviderId String
radius Int?
slice String // "1" or "2" or "8"
data Json?
id String @id @default(cuid())
type String // Fire
latitude Float
longitude Float
eventDate DateTime
geometry Unsupported("geometry")?
confidence AlertConfidence
isProcessed Boolean @default(false)
geoEventProviderClientId String // LANDSAT_NRT
geoEventProviderId String
radius Int?
slice String // "1" or "2" or "8"
data Json?
}

model SiteAlert {
id String @id @default(cuid())
siteId String
site Site @relation(fields: [siteId], references: [id], onDelete: Cascade)
notifications Notification[]
type String //Fire
latitude Float
longitude Float
eventDate DateTime
detectedBy String //GeoEventProviderClientId
confidence AlertConfidence
isProcessed Boolean @default(false)
deletedAt DateTime?
distance Int
data Json?
id String @id @default(cuid())
siteId String
site Site @relation(fields: [siteId], references: [id], onDelete: Cascade)
notifications Notification[]
type String //Fire
latitude Float
longitude Float
eventDate DateTime
detectedBy String //GeoEventProviderClientId
confidence AlertConfidence
isProcessed Boolean @default(false)
deletedAt DateTime?
distance Int
data Json?
}

model Notification {
id String @id @default(cuid())
siteAlertId String
siteAlert SiteAlert @relation(fields: [siteAlertId], references: [id], onDelete: Cascade)
alertMethod String
destination String
sentAt DateTime?
isDelivered Boolean @default(false)
id String @id @default(cuid())
siteAlertId String
siteAlert SiteAlert @relation(fields: [siteAlertId], references: [id], onDelete: Cascade)
alertMethod String
destination String
sentAt DateTime?
isDelivered Boolean @default(false)
}

model Stats {
id String @id @default(cuid())
metric String @unique
count Int
lastUpdated DateTime
id String @id @default(cuid())
metric String @unique
count Int
lastUpdated DateTime
}


enum Role {
ROLE_CLIENT
ROLE_ADMIN
ROLE_SUPPORT
ROLE_CLIENT
ROLE_ADMIN
ROLE_SUPPORT
}

enum SiteType {
Point
Polygon
MultiPolygon
Point
Polygon
MultiPolygon
}

enum AlertConfidence {
high
medium
low
high
medium
low
}
4 changes: 2 additions & 2 deletions apps/server/sentry.edge.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as Sentry from '@sentry/nextjs';
import {env} from './src/env.mjs';
import {ProfilingIntegration} from '@sentry/profiling-node';
import {nodeProfilingIntegration} from '@sentry/profiling-node';

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
Expand All @@ -19,6 +19,6 @@ Sentry.init({
profilesSampleRate: 1,
integrations: [
// Add profiling integration to list of integrations
new ProfilingIntegration(),
nodeProfilingIntegration(),
],
});
4 changes: 2 additions & 2 deletions apps/server/sentry.server.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as Sentry from '@sentry/nextjs';
import {env} from './src/env.mjs';
import {ProfilingIntegration} from '@sentry/profiling-node';
import {nodeProfilingIntegration} from '@sentry/profiling-node';

Sentry.init({
dsn: env.NEXT_PUBLIC_SENTRY_DSN,
Expand All @@ -18,6 +18,6 @@ Sentry.init({
profilesSampleRate: 1,
integrations: [
// Add profiling integration to list of integrations
new ProfilingIntegration(),
nodeProfilingIntegration(),
],
});
Loading
Loading