@mastra/core 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/prisma/client.ts +31 -0
- package/dist/prisma/gen.js +139 -0
- package/dist/prisma/migrations/20240814224445_init_whatever/migration.sql +111 -0
- package/dist/prisma/migrations/20240814225622_/migration.sql +1 -0
- package/dist/prisma/migrations/20240814225630_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240814225753_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240814225840_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240814225903_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240814230029_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240815062142_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240815062201_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240815062218_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240815064200_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240815064621_best_migration_ever/migration.sql +1 -0
- package/dist/prisma/migrations/20240820191237_initial_migration/migration.sql +129 -0
- package/dist/prisma/migrations/20240822185855_initial_migration/migration.sql +10 -0
- package/dist/prisma/migrations/20240822185857_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240822185900_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240822185902_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240822185905_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240823001241_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240823002023_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240823004537_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240823221851_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240826044931_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240826050355_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240826064156_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240826184832_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240827055655_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240827055923_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240828080451_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240828080638_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240828081251_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240828153839_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829184351_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829185428_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829190304_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829190630_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829190932_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240829192057_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240904212452_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240904213122_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240904213429_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240904221049_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240912224612_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240912233310_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240917221719_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/migration_lock.toml +3 -0
- package/dist/prisma/schema.prisma +129 -0
- package/package.json +3 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { PrismaClient, Prisma } from '@prisma-app/client';
|
|
2
|
+
|
|
3
|
+
const globalForPrisma = globalThis as unknown as {
|
|
4
|
+
standardPrisma: PrismaClient;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const logLevels = ['error', 'warn', 'info'] as Prisma.LogLevel[];
|
|
8
|
+
|
|
9
|
+
if (process.env.SHOW_SQL_QUERY === 'true') {
|
|
10
|
+
logLevels.push('query');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const prisma = (url: string): PrismaClient => {
|
|
14
|
+
let prismaInstance;
|
|
15
|
+
|
|
16
|
+
if (globalForPrisma.standardPrisma) {
|
|
17
|
+
console.log('Reusing Global Prisma Client...');
|
|
18
|
+
prismaInstance = globalForPrisma.standardPrisma;
|
|
19
|
+
} else {
|
|
20
|
+
prismaInstance = new PrismaClient({
|
|
21
|
+
datasourceUrl: url,
|
|
22
|
+
log: logLevels,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
27
|
+
globalForPrisma.standardPrisma = prismaInstance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return prismaInstance;
|
|
31
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
const { writeFileSync } = require('fs');
|
|
2
|
+
|
|
3
|
+
const tmpl = `
|
|
4
|
+
enum PropertyType {
|
|
5
|
+
LONG_TEXT
|
|
6
|
+
SINGLE_LINE_TEXT
|
|
7
|
+
SINGLE_SELECT
|
|
8
|
+
MULTI_SELECT
|
|
9
|
+
CHECKBOX
|
|
10
|
+
DATE
|
|
11
|
+
USER
|
|
12
|
+
BADGE_LIST
|
|
13
|
+
CURRENCY
|
|
14
|
+
URL
|
|
15
|
+
PHONE
|
|
16
|
+
CONTACT
|
|
17
|
+
COMPANY
|
|
18
|
+
PERSON
|
|
19
|
+
ENRICHMENT
|
|
20
|
+
COMPOSITE
|
|
21
|
+
BOOLEAN
|
|
22
|
+
NUMBER
|
|
23
|
+
FLOAT
|
|
24
|
+
JSON_OBJECT
|
|
25
|
+
JSON_ARRAY
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
model Property {
|
|
29
|
+
id String @id @default(cuid())
|
|
30
|
+
name String
|
|
31
|
+
displayName String
|
|
32
|
+
visible Boolean @default(true)
|
|
33
|
+
config Json?
|
|
34
|
+
description String?
|
|
35
|
+
type PropertyType
|
|
36
|
+
order Int
|
|
37
|
+
modifiable Boolean @default(true)
|
|
38
|
+
parentId String? @map("parentId")
|
|
39
|
+
parent Property? @relation("PropertyToProperty", fields: [parentId], references: [id])
|
|
40
|
+
compositeProperty Property[] @relation("PropertyToProperty")
|
|
41
|
+
entity Entity? @relation(fields: [entityId], references: [id])
|
|
42
|
+
entityId String?
|
|
43
|
+
@@map("properties")
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
enum RecordStatus {
|
|
47
|
+
ACTIVE
|
|
48
|
+
ARCHIVED
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
enum RecordEnrichmentStatus {
|
|
52
|
+
PENDING
|
|
53
|
+
APPLIED
|
|
54
|
+
UNAPPLIED
|
|
55
|
+
FAILED
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
model Record {
|
|
59
|
+
id String @id @default(cuid())
|
|
60
|
+
externalId String?
|
|
61
|
+
data Json @default("{}")
|
|
62
|
+
source String @default("MANUAL")
|
|
63
|
+
entityType String
|
|
64
|
+
entity Entity? @relation(fields: [entityId], references: [id])
|
|
65
|
+
entityId String?
|
|
66
|
+
status RecordStatus @default(ACTIVE)
|
|
67
|
+
enrichmentStatus RecordEnrichmentStatus @default(UNAPPLIED)
|
|
68
|
+
deletedAt DateTime?
|
|
69
|
+
createdAt DateTime @default(now())
|
|
70
|
+
updatedAt DateTime? @default(now())
|
|
71
|
+
|
|
72
|
+
@@index([externalId])
|
|
73
|
+
@@map("records")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
model Credential {
|
|
77
|
+
id String @id @default(cuid())
|
|
78
|
+
type String
|
|
79
|
+
value Json
|
|
80
|
+
scope String[]
|
|
81
|
+
connection Connection @relation(fields: [k_id], references: [id], onDelete: Cascade)
|
|
82
|
+
k_id String @unique
|
|
83
|
+
@@map("credentials")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
model Connection {
|
|
87
|
+
id String @id @default(cuid())
|
|
88
|
+
name String
|
|
89
|
+
issues String[] @default([])
|
|
90
|
+
syncConfig Json?
|
|
91
|
+
connectionId String
|
|
92
|
+
createdAt DateTime @default(now())
|
|
93
|
+
updatedAt DateTime? @updatedAt
|
|
94
|
+
|
|
95
|
+
lastSyncAt DateTime?
|
|
96
|
+
credential Credential?
|
|
97
|
+
subscriptionId String?
|
|
98
|
+
entities Entity[]
|
|
99
|
+
@@unique([connectionId, name])
|
|
100
|
+
@@index([subscriptionId])
|
|
101
|
+
@@map("connections")
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
model Entity {
|
|
105
|
+
id String @id @default(cuid())
|
|
106
|
+
type String
|
|
107
|
+
properties Property[]
|
|
108
|
+
records Record[]
|
|
109
|
+
|
|
110
|
+
createdAt DateTime @default(now())
|
|
111
|
+
updatedAt DateTime? @default(now())
|
|
112
|
+
createdBy String
|
|
113
|
+
|
|
114
|
+
connection Connection @relation(fields: [k_id], references: [id])
|
|
115
|
+
k_id String
|
|
116
|
+
|
|
117
|
+
lastSyncId String?
|
|
118
|
+
@@unique([k_id, type])
|
|
119
|
+
@@map("entity")
|
|
120
|
+
}
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
function main() {
|
|
124
|
+
const schema = `
|
|
125
|
+
datasource db {
|
|
126
|
+
provider = "postgresql"
|
|
127
|
+
url = env("DB_URL")
|
|
128
|
+
}
|
|
129
|
+
generator client {
|
|
130
|
+
provider = "prisma-client-js"
|
|
131
|
+
output = "../../node_modules/@prisma-app/client"
|
|
132
|
+
}
|
|
133
|
+
${tmpl}
|
|
134
|
+
`;
|
|
135
|
+
|
|
136
|
+
writeFileSync(__dirname + '/schema.prisma', schema);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
main();
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
-- CreateEnum
|
|
2
|
+
CREATE TYPE "FieldTypes" AS ENUM ('LONG_TEXT', 'SINGLE_LINE_TEXT', 'SINGLE_SELECT', 'MULTI_SELECT', 'CHECKBOX', 'DATE', 'USER', 'BADGE_LIST', 'CURRENCY', 'URL', 'PHONE', 'CONTACT', 'COMPANY', 'PERSON', 'ENRICHMENT', 'COMPOSITE');
|
|
3
|
+
|
|
4
|
+
-- CreateEnum
|
|
5
|
+
CREATE TYPE "RecordStatus" AS ENUM ('ACTIVE', 'ARCHIVED');
|
|
6
|
+
|
|
7
|
+
-- CreateEnum
|
|
8
|
+
CREATE TYPE "RecordEnrichmentStatus" AS ENUM ('PENDING', 'APPLIED', 'UNAPPLIED', 'FAILED');
|
|
9
|
+
|
|
10
|
+
-- CreateTable
|
|
11
|
+
CREATE TABLE "fields" (
|
|
12
|
+
"id" TEXT NOT NULL,
|
|
13
|
+
"name" TEXT NOT NULL,
|
|
14
|
+
"displayName" TEXT NOT NULL,
|
|
15
|
+
"visible" BOOLEAN NOT NULL DEFAULT true,
|
|
16
|
+
"config" JSONB,
|
|
17
|
+
"description" TEXT,
|
|
18
|
+
"type" "FieldTypes" NOT NULL,
|
|
19
|
+
"order" INTEGER NOT NULL,
|
|
20
|
+
"modifiable" BOOLEAN NOT NULL DEFAULT true,
|
|
21
|
+
"parentId" TEXT,
|
|
22
|
+
"syncTableId" TEXT,
|
|
23
|
+
|
|
24
|
+
CONSTRAINT "fields_pkey" PRIMARY KEY ("id")
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
-- CreateTable
|
|
28
|
+
CREATE TABLE "records" (
|
|
29
|
+
"id" TEXT NOT NULL,
|
|
30
|
+
"externalId" TEXT,
|
|
31
|
+
"data" JSONB NOT NULL DEFAULT '{}',
|
|
32
|
+
"source" TEXT NOT NULL DEFAULT 'MANUAL',
|
|
33
|
+
"recordType" TEXT NOT NULL,
|
|
34
|
+
"syncTableId" TEXT,
|
|
35
|
+
"status" "RecordStatus" NOT NULL DEFAULT 'ACTIVE',
|
|
36
|
+
"enrichmentStatus" "RecordEnrichmentStatus" NOT NULL DEFAULT 'UNAPPLIED',
|
|
37
|
+
"deletedAt" TIMESTAMP(3),
|
|
38
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
39
|
+
"updatedAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
|
|
40
|
+
|
|
41
|
+
CONSTRAINT "records_pkey" PRIMARY KEY ("id")
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
-- CreateTable
|
|
45
|
+
CREATE TABLE "data_integration_credentials" (
|
|
46
|
+
"id" TEXT NOT NULL,
|
|
47
|
+
"type" TEXT NOT NULL,
|
|
48
|
+
"value" JSONB NOT NULL,
|
|
49
|
+
"scope" TEXT[],
|
|
50
|
+
"dataIntegrationId" TEXT NOT NULL,
|
|
51
|
+
|
|
52
|
+
CONSTRAINT "data_integration_credentials_pkey" PRIMARY KEY ("id")
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
-- CreateTable
|
|
56
|
+
CREATE TABLE "data_integrations" (
|
|
57
|
+
"id" TEXT NOT NULL,
|
|
58
|
+
"name" TEXT NOT NULL,
|
|
59
|
+
"issues" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
|
60
|
+
"syncConfig" JSONB,
|
|
61
|
+
"connectionId" TEXT NOT NULL,
|
|
62
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
63
|
+
"updatedAt" TIMESTAMP(3),
|
|
64
|
+
"lastSyncAt" TIMESTAMP(3),
|
|
65
|
+
"subscriptionId" TEXT,
|
|
66
|
+
|
|
67
|
+
CONSTRAINT "data_integrations_pkey" PRIMARY KEY ("id")
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- CreateTable
|
|
71
|
+
CREATE TABLE "syncTable" (
|
|
72
|
+
"id" TEXT NOT NULL,
|
|
73
|
+
"type" TEXT NOT NULL,
|
|
74
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
75
|
+
"updatedAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
|
|
76
|
+
"createdBy" TEXT NOT NULL,
|
|
77
|
+
"dataIntegrationId" TEXT NOT NULL,
|
|
78
|
+
"lastSyncId" TEXT,
|
|
79
|
+
|
|
80
|
+
CONSTRAINT "syncTable_pkey" PRIMARY KEY ("id")
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
-- CreateIndex
|
|
84
|
+
CREATE INDEX "records_externalId_idx" ON "records"("externalId");
|
|
85
|
+
|
|
86
|
+
-- CreateIndex
|
|
87
|
+
CREATE UNIQUE INDEX "data_integration_credentials_dataIntegrationId_key" ON "data_integration_credentials"("dataIntegrationId");
|
|
88
|
+
|
|
89
|
+
-- CreateIndex
|
|
90
|
+
CREATE INDEX "data_integrations_subscriptionId_idx" ON "data_integrations"("subscriptionId");
|
|
91
|
+
|
|
92
|
+
-- CreateIndex
|
|
93
|
+
CREATE UNIQUE INDEX "data_integrations_connectionId_name_key" ON "data_integrations"("connectionId", "name");
|
|
94
|
+
|
|
95
|
+
-- CreateIndex
|
|
96
|
+
CREATE UNIQUE INDEX "syncTable_dataIntegrationId_type_key" ON "syncTable"("dataIntegrationId", "type");
|
|
97
|
+
|
|
98
|
+
-- AddForeignKey
|
|
99
|
+
ALTER TABLE "fields" ADD CONSTRAINT "fields_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "fields"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
100
|
+
|
|
101
|
+
-- AddForeignKey
|
|
102
|
+
ALTER TABLE "fields" ADD CONSTRAINT "fields_syncTableId_fkey" FOREIGN KEY ("syncTableId") REFERENCES "syncTable"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
103
|
+
|
|
104
|
+
-- AddForeignKey
|
|
105
|
+
ALTER TABLE "records" ADD CONSTRAINT "records_syncTableId_fkey" FOREIGN KEY ("syncTableId") REFERENCES "syncTable"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
106
|
+
|
|
107
|
+
-- AddForeignKey
|
|
108
|
+
ALTER TABLE "data_integration_credentials" ADD CONSTRAINT "data_integration_credentials_dataIntegrationId_fkey" FOREIGN KEY ("dataIntegrationId") REFERENCES "data_integrations"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
109
|
+
|
|
110
|
+
-- AddForeignKey
|
|
111
|
+
ALTER TABLE "syncTable" ADD CONSTRAINT "syncTable_dataIntegrationId_fkey" FOREIGN KEY ("dataIntegrationId") REFERENCES "data_integrations"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `syncTableId` on the `records` table. All the data in the column will be lost.
|
|
5
|
+
- You are about to drop the `data_integration_credentials` table. If the table is not empty, all the data it contains will be lost.
|
|
6
|
+
- You are about to drop the `data_integrations` table. If the table is not empty, all the data it contains will be lost.
|
|
7
|
+
- You are about to drop the `fields` table. If the table is not empty, all the data it contains will be lost.
|
|
8
|
+
- You are about to drop the `syncTable` table. If the table is not empty, all the data it contains will be lost.
|
|
9
|
+
|
|
10
|
+
*/
|
|
11
|
+
-- CreateEnum
|
|
12
|
+
CREATE TYPE "PropertyType" AS ENUM ('LONG_TEXT', 'SINGLE_LINE_TEXT', 'SINGLE_SELECT', 'MULTI_SELECT', 'CHECKBOX', 'DATE', 'USER', 'BADGE_LIST', 'CURRENCY', 'URL', 'PHONE', 'CONTACT', 'COMPANY', 'PERSON', 'ENRICHMENT', 'COMPOSITE');
|
|
13
|
+
|
|
14
|
+
-- DropForeignKey
|
|
15
|
+
ALTER TABLE "data_integration_credentials" DROP CONSTRAINT "data_integration_credentials_dataIntegrationId_fkey";
|
|
16
|
+
|
|
17
|
+
-- DropForeignKey
|
|
18
|
+
ALTER TABLE "fields" DROP CONSTRAINT "fields_parentId_fkey";
|
|
19
|
+
|
|
20
|
+
-- DropForeignKey
|
|
21
|
+
ALTER TABLE "fields" DROP CONSTRAINT "fields_syncTableId_fkey";
|
|
22
|
+
|
|
23
|
+
-- DropForeignKey
|
|
24
|
+
ALTER TABLE "records" DROP CONSTRAINT "records_syncTableId_fkey";
|
|
25
|
+
|
|
26
|
+
-- DropForeignKey
|
|
27
|
+
ALTER TABLE "syncTable" DROP CONSTRAINT "syncTable_dataIntegrationId_fkey";
|
|
28
|
+
|
|
29
|
+
-- AlterTable
|
|
30
|
+
ALTER TABLE "records" DROP COLUMN "syncTableId",
|
|
31
|
+
ADD COLUMN "entityId" TEXT;
|
|
32
|
+
|
|
33
|
+
-- DropTable
|
|
34
|
+
DROP TABLE "data_integration_credentials";
|
|
35
|
+
|
|
36
|
+
-- DropTable
|
|
37
|
+
DROP TABLE "data_integrations";
|
|
38
|
+
|
|
39
|
+
-- DropTable
|
|
40
|
+
DROP TABLE "fields";
|
|
41
|
+
|
|
42
|
+
-- DropTable
|
|
43
|
+
DROP TABLE "syncTable";
|
|
44
|
+
|
|
45
|
+
-- DropEnum
|
|
46
|
+
DROP TYPE "FieldTypes";
|
|
47
|
+
|
|
48
|
+
-- CreateTable
|
|
49
|
+
CREATE TABLE "properties" (
|
|
50
|
+
"id" TEXT NOT NULL,
|
|
51
|
+
"name" TEXT NOT NULL,
|
|
52
|
+
"displayName" TEXT NOT NULL,
|
|
53
|
+
"visible" BOOLEAN NOT NULL DEFAULT true,
|
|
54
|
+
"config" JSONB,
|
|
55
|
+
"description" TEXT,
|
|
56
|
+
"type" "PropertyType" NOT NULL,
|
|
57
|
+
"order" INTEGER NOT NULL,
|
|
58
|
+
"modifiable" BOOLEAN NOT NULL DEFAULT true,
|
|
59
|
+
"parentId" TEXT,
|
|
60
|
+
"entityId" TEXT,
|
|
61
|
+
|
|
62
|
+
CONSTRAINT "properties_pkey" PRIMARY KEY ("id")
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
-- CreateTable
|
|
66
|
+
CREATE TABLE "credentials" (
|
|
67
|
+
"id" TEXT NOT NULL,
|
|
68
|
+
"type" TEXT NOT NULL,
|
|
69
|
+
"value" JSONB NOT NULL,
|
|
70
|
+
"scope" TEXT[],
|
|
71
|
+
"connectionId" TEXT NOT NULL,
|
|
72
|
+
|
|
73
|
+
CONSTRAINT "credentials_pkey" PRIMARY KEY ("id")
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
-- CreateTable
|
|
77
|
+
CREATE TABLE "connections" (
|
|
78
|
+
"id" TEXT NOT NULL,
|
|
79
|
+
"name" TEXT NOT NULL,
|
|
80
|
+
"issues" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
|
81
|
+
"syncConfig" JSONB,
|
|
82
|
+
"referenceId" TEXT NOT NULL,
|
|
83
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
84
|
+
"updatedAt" TIMESTAMP(3),
|
|
85
|
+
"lastSyncAt" TIMESTAMP(3),
|
|
86
|
+
"subscriptionId" TEXT,
|
|
87
|
+
|
|
88
|
+
CONSTRAINT "connections_pkey" PRIMARY KEY ("id")
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
-- CreateTable
|
|
92
|
+
CREATE TABLE "entity" (
|
|
93
|
+
"id" TEXT NOT NULL,
|
|
94
|
+
"type" TEXT NOT NULL,
|
|
95
|
+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
96
|
+
"updatedAt" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
|
|
97
|
+
"createdBy" TEXT NOT NULL,
|
|
98
|
+
"connectionId" TEXT NOT NULL,
|
|
99
|
+
"lastSyncId" TEXT,
|
|
100
|
+
|
|
101
|
+
CONSTRAINT "entity_pkey" PRIMARY KEY ("id")
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
-- CreateIndex
|
|
105
|
+
CREATE UNIQUE INDEX "credentials_connectionId_key" ON "credentials"("connectionId");
|
|
106
|
+
|
|
107
|
+
-- CreateIndex
|
|
108
|
+
CREATE INDEX "connections_subscriptionId_idx" ON "connections"("subscriptionId");
|
|
109
|
+
|
|
110
|
+
-- CreateIndex
|
|
111
|
+
CREATE UNIQUE INDEX "connections_referenceId_name_key" ON "connections"("referenceId", "name");
|
|
112
|
+
|
|
113
|
+
-- CreateIndex
|
|
114
|
+
CREATE UNIQUE INDEX "entity_connectionId_type_key" ON "entity"("connectionId", "type");
|
|
115
|
+
|
|
116
|
+
-- AddForeignKey
|
|
117
|
+
ALTER TABLE "properties" ADD CONSTRAINT "properties_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "properties"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
118
|
+
|
|
119
|
+
-- AddForeignKey
|
|
120
|
+
ALTER TABLE "properties" ADD CONSTRAINT "properties_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "entity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
121
|
+
|
|
122
|
+
-- AddForeignKey
|
|
123
|
+
ALTER TABLE "records" ADD CONSTRAINT "records_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "entity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
124
|
+
|
|
125
|
+
-- AddForeignKey
|
|
126
|
+
ALTER TABLE "credentials" ADD CONSTRAINT "credentials_connectionId_fkey" FOREIGN KEY ("connectionId") REFERENCES "connections"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
127
|
+
|
|
128
|
+
-- AddForeignKey
|
|
129
|
+
ALTER TABLE "entity" ADD CONSTRAINT "entity_connectionId_fkey" FOREIGN KEY ("connectionId") REFERENCES "connections"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Warnings:
|
|
3
|
+
|
|
4
|
+
- You are about to drop the column `recordType` on the `records` table. All the data in the column will be lost.
|
|
5
|
+
- Added the required column `entityType` to the `records` table without a default value. This is not possible if the table is not empty.
|
|
6
|
+
|
|
7
|
+
*/
|
|
8
|
+
-- AlterTable
|
|
9
|
+
ALTER TABLE "records" DROP COLUMN "recordType",
|
|
10
|
+
ADD COLUMN "entityType" TEXT NOT NULL;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-- This is an empty migration.
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
|
|
2
|
+
datasource db {
|
|
3
|
+
provider = "postgresql"
|
|
4
|
+
url = env("DB_URL")
|
|
5
|
+
}
|
|
6
|
+
generator client {
|
|
7
|
+
provider = "prisma-client-js"
|
|
8
|
+
output = "../../node_modules/@prisma-app/client"
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
enum PropertyType {
|
|
12
|
+
LONG_TEXT
|
|
13
|
+
SINGLE_LINE_TEXT
|
|
14
|
+
SINGLE_SELECT
|
|
15
|
+
MULTI_SELECT
|
|
16
|
+
CHECKBOX
|
|
17
|
+
DATE
|
|
18
|
+
USER
|
|
19
|
+
BADGE_LIST
|
|
20
|
+
CURRENCY
|
|
21
|
+
URL
|
|
22
|
+
PHONE
|
|
23
|
+
CONTACT
|
|
24
|
+
COMPANY
|
|
25
|
+
PERSON
|
|
26
|
+
ENRICHMENT
|
|
27
|
+
COMPOSITE
|
|
28
|
+
BOOLEAN
|
|
29
|
+
NUMBER
|
|
30
|
+
FLOAT
|
|
31
|
+
JSON_OBJECT
|
|
32
|
+
JSON_ARRAY
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
model Property {
|
|
36
|
+
id String @id @default(cuid())
|
|
37
|
+
name String
|
|
38
|
+
displayName String
|
|
39
|
+
visible Boolean @default(true)
|
|
40
|
+
config Json?
|
|
41
|
+
description String?
|
|
42
|
+
type PropertyType
|
|
43
|
+
order Int
|
|
44
|
+
modifiable Boolean @default(true)
|
|
45
|
+
parentId String? @map("parentId")
|
|
46
|
+
parent Property? @relation("PropertyToProperty", fields: [parentId], references: [id])
|
|
47
|
+
compositeProperty Property[] @relation("PropertyToProperty")
|
|
48
|
+
entity Entity? @relation(fields: [entityId], references: [id])
|
|
49
|
+
entityId String?
|
|
50
|
+
@@map("properties")
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
enum RecordStatus {
|
|
54
|
+
ACTIVE
|
|
55
|
+
ARCHIVED
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
enum RecordEnrichmentStatus {
|
|
59
|
+
PENDING
|
|
60
|
+
APPLIED
|
|
61
|
+
UNAPPLIED
|
|
62
|
+
FAILED
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
model Record {
|
|
66
|
+
id String @id @default(cuid())
|
|
67
|
+
externalId String?
|
|
68
|
+
data Json @default("{}")
|
|
69
|
+
source String @default("MANUAL")
|
|
70
|
+
entityType String
|
|
71
|
+
entity Entity? @relation(fields: [entityId], references: [id])
|
|
72
|
+
entityId String?
|
|
73
|
+
status RecordStatus @default(ACTIVE)
|
|
74
|
+
enrichmentStatus RecordEnrichmentStatus @default(UNAPPLIED)
|
|
75
|
+
deletedAt DateTime?
|
|
76
|
+
createdAt DateTime @default(now())
|
|
77
|
+
updatedAt DateTime? @default(now())
|
|
78
|
+
|
|
79
|
+
@@index([externalId])
|
|
80
|
+
@@map("records")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
model Credential {
|
|
84
|
+
id String @id @default(cuid())
|
|
85
|
+
type String
|
|
86
|
+
value Json
|
|
87
|
+
scope String[]
|
|
88
|
+
connection Connection @relation(fields: [k_id], references: [id], onDelete: Cascade)
|
|
89
|
+
k_id String @unique
|
|
90
|
+
@@map("credentials")
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
model Connection {
|
|
94
|
+
id String @id @default(cuid())
|
|
95
|
+
name String
|
|
96
|
+
issues String[] @default([])
|
|
97
|
+
syncConfig Json?
|
|
98
|
+
connectionId String
|
|
99
|
+
createdAt DateTime @default(now())
|
|
100
|
+
updatedAt DateTime? @updatedAt
|
|
101
|
+
|
|
102
|
+
lastSyncAt DateTime?
|
|
103
|
+
credential Credential?
|
|
104
|
+
subscriptionId String?
|
|
105
|
+
entities Entity[]
|
|
106
|
+
@@unique([connectionId, name])
|
|
107
|
+
@@index([subscriptionId])
|
|
108
|
+
@@map("connections")
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
model Entity {
|
|
112
|
+
id String @id @default(cuid())
|
|
113
|
+
type String
|
|
114
|
+
properties Property[]
|
|
115
|
+
records Record[]
|
|
116
|
+
|
|
117
|
+
createdAt DateTime @default(now())
|
|
118
|
+
updatedAt DateTime? @default(now())
|
|
119
|
+
createdBy String
|
|
120
|
+
|
|
121
|
+
connection Connection @relation(fields: [k_id], references: [id])
|
|
122
|
+
k_id String
|
|
123
|
+
|
|
124
|
+
lastSyncId String?
|
|
125
|
+
@@unique([k_id, type])
|
|
126
|
+
@@map("entity")
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/mylib.esm.js",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"scripts": {
|
|
73
73
|
"check": "tsc --noEmit",
|
|
74
74
|
"analyze": "size-limit --why",
|
|
75
|
-
"build": "pnpm generate:schema &&
|
|
75
|
+
"build": "pnpm generate:schema && dts build && cp -r ./src/prisma/* ./dist/prisma",
|
|
76
76
|
"build:dev": "dts watch",
|
|
77
77
|
"lint": "dts lint",
|
|
78
78
|
"size": "size-limit",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"clean": "rm -rf dist && rm -rf node_modules",
|
|
82
82
|
"generate:schema": "node ./src/prisma/gen.js",
|
|
83
83
|
"generate": "npx prisma generate --schema=./dist/prisma/schema.prisma",
|
|
84
|
-
"postinstall": "pnpm
|
|
84
|
+
"postinstall": "pnpm generate",
|
|
85
85
|
"synchronize": "npx prisma db push --schema=./src/prisma/schema.prisma --force-reset"
|
|
86
86
|
}
|
|
87
87
|
}
|