Skip to content

Commit d0cf49a

Browse files
committed
feat: prototype structures for profile builder
1 parent 391304f commit d0cf49a

File tree

4 files changed

+56
-11
lines changed

4 files changed

+56
-11
lines changed

types/protocols/profile.d.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { FunctionContext } from "./functions";
2+
import { AnalyticsServerEvent } from "./analytics";
3+
4+
export type ProfileResult = {
5+
properties: Record<string, any>
6+
}
7+
8+
export type ProfileFunction = (params: {
9+
context: FunctionContext;
10+
events: Iterable<AnalyticsServerEvent>;
11+
user:{
12+
id?: string;
13+
anonymousId?: string;
14+
traits: Record<string, any>;
15+
}
16+
}) => Promise<ProfileResult>

types/protocols/tsconfig.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
}

webapps/console/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"tool:hash": "ts-node scripts/password-hash.ts",
2121
"db:code-gen": "prisma generate",
2222
"db:update-schema": "dotenv -e ../../.env.local -- prisma db push",
23+
"db:format-schema": "dotenv -e ../../.env.local -- prisma format",
2324
"db:update-schema-force": "dotenv -e ../../.env.local -- prisma db push --accept-data-loss"
2425
},
2526
"dependencies": {

webapps/console/prisma/schema.prisma

+36-11
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,20 @@ model UserProfile {
5959
workspaceAccess WorkspaceAccess[]
6060
userPreferences UserPreferences[]
6161
workspaceUserProperties WorkspaceUserProperties[]
62-
password UserPassword?
62+
password UserPassword?
6363
64-
@@index(externalId)
6564
@@unique([loginProvider, externalId])
65+
@@index(externalId)
6666
}
6767

6868
model UserPassword {
69-
id String @id @default(cuid())
70-
createdAt DateTime @default(now()) /// @zod.custom(z.coerce.date())
71-
updatedAt DateTime @default(now()) @updatedAt /// @zod.custom(z.coerce.date())
72-
userId String @unique
73-
user UserProfile @relation(fields: [userId], references: [id])
74-
hash String
75-
changeAtNextLogin Boolean @default(false)
69+
id String @id @default(cuid())
70+
createdAt DateTime @default(now()) /// @zod.custom(z.coerce.date())
71+
updatedAt DateTime @default(now()) @updatedAt /// @zod.custom(z.coerce.date())
72+
userId String @unique
73+
user UserProfile @relation(fields: [userId], references: [id])
74+
hash String
75+
changeAtNextLogin Boolean @default(false)
7676
}
7777

7878
model Workspace {
@@ -90,6 +90,7 @@ model Workspace {
9090
preferences UserPreferences[]
9191
workspaceUserProperties WorkspaceUserProperties[]
9292
featuresEnabled String[] @default([])
93+
profileBuilderSettings ProfileBuilderSettings[]
9394
9495
@@unique(slug)
9596
@@index(slug)
@@ -162,8 +163,10 @@ model ConfigurationObject {
162163
workspace Workspace @relation(fields: [workspaceId], references: [id])
163164
config Json?
164165
165-
fromLinks ConfigurationObjectLink[] @relation("from")
166-
toLinks ConfigurationObjectLink[] @relation("to")
166+
fromLinks ConfigurationObjectLink[] @relation("from")
167+
toLinks ConfigurationObjectLink[] @relation("to")
168+
ProfileBuilderSettings ProfileBuilderSettings[]
169+
ProfileBuilderFunctions ProfileBuilderFunctions[]
167170
168171
@@index(updatedAt(sort: Desc))
169172
}
@@ -288,6 +291,28 @@ model task_log {
288291
@@index(timestamp)
289292
}
290293

294+
model ProfileBuilderSettings {
295+
id String @id @default(cuid())
296+
createdAt DateTime @default(now()) /// @zod.custom(z.coerce.date())
297+
updatedAt DateTime @default(now()) @updatedAt /// @zod.custom(z.coerce.date())
298+
workspaceId String
299+
workspace Workspace @relation(fields: [workspaceId], references: [id])
300+
intermediateStorageCredentials Json
301+
destinationId String
302+
destination ConfigurationObject @relation(fields: [destinationId], references: [id])
303+
ProfileBuilderFunctions ProfileBuilderFunctions[]
304+
}
305+
306+
model ProfileBuilderFunctions {
307+
id String @id @default(cuid())
308+
createdAt DateTime @default(now()) /// @zod.custom(z.coerce.date())
309+
updatedAt DateTime @default(now()) @updatedAt /// @zod.custom(z.coerce.date())
310+
profileBuilderSettingsId String
311+
profileBuilderSettings ProfileBuilderSettings @relation(fields: [profileBuilderSettingsId], references: [id])
312+
functionId String
313+
function ConfigurationObject @relation(fields: [functionId], references: [id])
314+
}
315+
291316
//
292317

293318
//model OauthSecrets {

0 commit comments

Comments
 (0)