@mastra/core 0.1.0 → 0.1.2
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/authenticator.d.ts +62 -0
- package/dist/constants.d.ts +1 -0
- package/dist/core.cjs.development.js +5011 -0
- package/dist/core.cjs.development.js.map +1 -0
- package/dist/core.cjs.production.min.js +2 -0
- package/dist/core.cjs.production.min.js.map +1 -0
- package/dist/core.esm.js +4947 -0
- package/dist/core.esm.js.map +1 -0
- package/dist/data-access/index.d.ts +350 -0
- package/dist/framework.d.ts +116 -0
- package/dist/generated-types/index.d.ts +4 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +8 -0
- package/dist/integration.d.ts +100 -0
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/query-builder/constants.d.ts +16 -0
- package/dist/lib/query-builder/filters/sql.d.ts +8 -0
- package/dist/lib/query-builder/schema.d.ts +36 -0
- package/dist/lib/query-builder/sorts/sql.d.ts +7 -0
- package/dist/lib/query-builder/types.d.ts +30 -0
- package/dist/lib/query-builder/utils.d.ts +26 -0
- package/dist/lib/utils/object.d.ts +50 -0
- package/dist/next/callback.d.ts +3 -0
- package/dist/next/connect.d.ts +3 -0
- package/dist/next/index.d.ts +15 -0
- package/dist/next/inngest.d.ts +3 -0
- package/dist/next/utils.d.ts +9 -0
- package/dist/next/webhook.d.ts +9 -0
- package/dist/prisma/client.d.ts +2 -0
- package/dist/prisma/client.ts +31 -0
- package/dist/prisma/gen.js +139 -0
- package/dist/prisma/migrations/20240828034109_initial_migration/migration.sql +111 -0
- package/dist/prisma/migrations/20240829210901_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240905143158_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240911212856_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/20240915044235_initial_migration/migration.sql +1 -0
- package/dist/prisma/migrations/migration_lock.toml +3 -0
- package/dist/prisma/schema.prisma +129 -0
- package/dist/schemas.d.ts +84 -0
- package/dist/service/service.property.d.ts +24 -0
- package/dist/service/service.record.d.ts +24 -0
- package/dist/sync-factory.d.ts +13 -0
- package/dist/sync-fixtures/github.d.ts +949 -0
- package/dist/sync-fixtures/stripe.d.ts +92 -0
- package/dist/types.d.ts +367 -0
- package/dist/utils/errors.d.ts +3 -0
- package/dist/utils/index.d.ts +12 -0
- package/dist/utils/inngest.d.ts +4 -0
- package/dist/workflows/conditions/constants.d.ts +16 -0
- package/dist/workflows/conditions/types.d.ts +2 -0
- package/dist/workflows/handler.d.ts +38 -0
- package/dist/workflows/runner.d.ts +43 -0
- package/dist/workflows/schemas.d.ts +1043 -0
- package/dist/workflows/types.d.ts +96 -0
- package/dist/workflows/utils.d.ts +111 -0
- package/package.json +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Property } from '@prisma-app/client';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { filterQuerySchema } from './schema';
|
|
4
|
+
export type FilterObject<T extends string | number | symbol> = Record<T, z.infer<typeof filterQuerySchema>>;
|
|
5
|
+
export interface FilterClauseArgs<T extends string | number | symbol> {
|
|
6
|
+
parentTableRef?: string;
|
|
7
|
+
filters: FilterObject<T>;
|
|
8
|
+
fields?: Pick<Property, 'name' | 'type'>[];
|
|
9
|
+
}
|
|
10
|
+
export interface SortClauseArgs {
|
|
11
|
+
parentTableRef?: string;
|
|
12
|
+
sort: string[];
|
|
13
|
+
fields?: Pick<Property, 'name' | 'type'>[];
|
|
14
|
+
}
|
|
15
|
+
export declare enum FilterOperators {
|
|
16
|
+
IS = "is",
|
|
17
|
+
EQUAL = "eq",
|
|
18
|
+
NOT_EQUAL = "not_eq",
|
|
19
|
+
CONTAINS = "contains",
|
|
20
|
+
IN = "in",
|
|
21
|
+
NOT_IN = "not_in",
|
|
22
|
+
GREATER_THAN = "gt",
|
|
23
|
+
LESS_THAN = "lt",
|
|
24
|
+
NOT_CONTAINS = "not_contains",
|
|
25
|
+
GREATER_THAN_OR_EQUAL = "gte",
|
|
26
|
+
LESS_THAN_OR_EQUAL = "lte",
|
|
27
|
+
OP = "op",
|
|
28
|
+
SET = "set",
|
|
29
|
+
NOT_SET = "not_set"
|
|
30
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { PropertyType } from '@prisma-app/client';
|
|
2
|
+
/**
|
|
3
|
+
* Split a string on commas and strip quotes from each part
|
|
4
|
+
* @param str input string
|
|
5
|
+
* @returns array of strings
|
|
6
|
+
*/
|
|
7
|
+
export declare const splitAndStripQuotes: (str: string) => string[];
|
|
8
|
+
export declare const transformFilterValueArray: (value: string | undefined) => string[] | undefined;
|
|
9
|
+
export declare const transformFilterValueBoolean: (value: string | undefined) => boolean | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* This returns the SQL field for a JSON field with appropriate casting.
|
|
12
|
+
* @param column - JSON field to cast.
|
|
13
|
+
* @param type - Type of the JSON field.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getJSONField: (column: string, type: PropertyType) => string;
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* Builds a query string from filter and sort query strings
|
|
19
|
+
* @param filterQueryString Filter query string
|
|
20
|
+
* @param sortQueryString Sort query string
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildQueryString({ filterQueryString, sortQueryString, }: {
|
|
24
|
+
filterQueryString?: string;
|
|
25
|
+
sortQueryString?: string;
|
|
26
|
+
}): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if object is empty
|
|
3
|
+
* @param objectName
|
|
4
|
+
* @returns boolean
|
|
5
|
+
*/
|
|
6
|
+
export declare const isObjectEmpty: (objectName: Object) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Get a value from an object by a given path. This function emulates the behavior of lodash's _.get method.
|
|
9
|
+
*
|
|
10
|
+
* @param {Record<string, any>} object - The object from which to get the value.
|
|
11
|
+
* @param {string | string[]} path - The path to the value in the object. This can be a string (e.g., 'a.b.c') or an array of keys (e.g., ['a', 'b', 'c']).
|
|
12
|
+
* @returns {unknown} The value at the given path in the object, or undefined if the path does not exist.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getPath: (object: Record<string, any>, path: string | string[]) => unknown;
|
|
15
|
+
export declare function recordHasData(record: Record<any, any>): boolean;
|
|
16
|
+
export declare function isLiteralObject(a: unknown): boolean;
|
|
17
|
+
export declare const constructObjFromStringPath: (path: string, value: any) => Record<string, any>;
|
|
18
|
+
/**
|
|
19
|
+
* Flatten a nested object, flatten from flat package works - https://www.npmjs.com/package/flat
|
|
20
|
+
* but this allows you to define where you want it to stop by passing the keys that'll exist in the object you want it to stop at
|
|
21
|
+
*
|
|
22
|
+
* @param {Record<string, any>} object - The object to flatten.
|
|
23
|
+
* @param {string[]} endKeys - The keys you want each value (which will be an object in this case) in the flattened object to possible have (e.g., ['a', 'b', 'c']).
|
|
24
|
+
* @param {boolean} flattenArrayValue - This flag indicates that any array value should be flattened to object too.
|
|
25
|
+
* @returns {Record<string, any>} Your flattened object
|
|
26
|
+
*/
|
|
27
|
+
export declare const flattenObject: (object: Record<string, any>, endKeys?: string[], flattenArrayValue?: boolean) => Record<string, unknown>;
|
|
28
|
+
type AnyObject = {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Merges two objects, ensuring that only defined properties from the second object
|
|
33
|
+
* override those in the first object.
|
|
34
|
+
*
|
|
35
|
+
* @template T - The type of the base object.
|
|
36
|
+
* @template U - The type of the overrides object.
|
|
37
|
+
* @param {T} base - The base object whose properties will be overridden.
|
|
38
|
+
* @param {U} overrides - The object containing properties to override in the base object.
|
|
39
|
+
* Only properties that are defined (not `undefined`) will override.
|
|
40
|
+
* @returns {T & U} - A new object that combines properties from both `base` and `overrides`.
|
|
41
|
+
* Properties in `base` will be overridden by defined properties in `overrides`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const worksheetData = { a: 1, b: 2, c: 3 };
|
|
45
|
+
* const payload = { b: undefined, c: 4 };
|
|
46
|
+
* const extendedData = mergeWithDefinedOnly(worksheetData, payload);
|
|
47
|
+
* // extendedData = { a: 1, b: 2, c: 4 }
|
|
48
|
+
*/
|
|
49
|
+
export declare function mergeWithDefinedOnly<T extends AnyObject, U extends AnyObject>(base: T, overrides: U): T & U;
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { Framework } from '../framework';
|
|
3
|
+
import { makeConnect } from './connect';
|
|
4
|
+
import { makeCallback } from './callback';
|
|
5
|
+
import { makeInngest } from './inngest';
|
|
6
|
+
import { makeWebhook } from './webhook';
|
|
7
|
+
type PathParams = {
|
|
8
|
+
[key: string]: string[];
|
|
9
|
+
};
|
|
10
|
+
export declare const registerRoutes: ({ framework }: {
|
|
11
|
+
framework: Framework;
|
|
12
|
+
}) => (req: NextRequest, { params }: {
|
|
13
|
+
params: PathParams;
|
|
14
|
+
}) => NextResponse<unknown> | Promise<Response>;
|
|
15
|
+
export { makeConnect, makeCallback, makeInngest, makeWebhook };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { headers } from 'next/headers';
|
|
2
|
+
import { NextRequest } from 'next/server';
|
|
3
|
+
import { z, ZodSchema } from 'zod';
|
|
4
|
+
export declare const parseQueryParams: <T>(req: NextRequest, schema: ZodSchema) => {
|
|
5
|
+
success: boolean;
|
|
6
|
+
data: T;
|
|
7
|
+
error: z.ZodError<any> | undefined;
|
|
8
|
+
};
|
|
9
|
+
export declare const nextHeaders: typeof headers;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
import { Framework } from '../framework';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
export declare const makeWebhook: (framework: Framework) => (req: NextRequest) => NextResponse<{
|
|
5
|
+
error: z.ZodError<any>;
|
|
6
|
+
status: number;
|
|
7
|
+
}> | NextResponse<{
|
|
8
|
+
message: string;
|
|
9
|
+
}>;
|
|
@@ -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 "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');
|
|
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 "properties" (
|
|
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" "PropertyType" NOT NULL,
|
|
19
|
+
"order" INTEGER NOT NULL,
|
|
20
|
+
"modifiable" BOOLEAN NOT NULL DEFAULT true,
|
|
21
|
+
"parentId" TEXT,
|
|
22
|
+
"entityId" TEXT,
|
|
23
|
+
|
|
24
|
+
CONSTRAINT "properties_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
|
+
"entityType" TEXT NOT NULL,
|
|
34
|
+
"entityId" 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 "credentials" (
|
|
46
|
+
"id" TEXT NOT NULL,
|
|
47
|
+
"type" TEXT NOT NULL,
|
|
48
|
+
"value" JSONB NOT NULL,
|
|
49
|
+
"scope" TEXT[],
|
|
50
|
+
"connectionId" TEXT NOT NULL,
|
|
51
|
+
|
|
52
|
+
CONSTRAINT "credentials_pkey" PRIMARY KEY ("id")
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
-- CreateTable
|
|
56
|
+
CREATE TABLE "connections" (
|
|
57
|
+
"id" TEXT NOT NULL,
|
|
58
|
+
"name" TEXT NOT NULL,
|
|
59
|
+
"issues" TEXT[] DEFAULT ARRAY[]::TEXT[],
|
|
60
|
+
"syncConfig" JSONB,
|
|
61
|
+
"referenceId" 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 "connections_pkey" PRIMARY KEY ("id")
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
-- CreateTable
|
|
71
|
+
CREATE TABLE "entity" (
|
|
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
|
+
"connectionId" TEXT NOT NULL,
|
|
78
|
+
"lastSyncId" TEXT,
|
|
79
|
+
|
|
80
|
+
CONSTRAINT "entity_pkey" PRIMARY KEY ("id")
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
-- CreateIndex
|
|
84
|
+
CREATE INDEX "records_externalId_idx" ON "records"("externalId");
|
|
85
|
+
|
|
86
|
+
-- CreateIndex
|
|
87
|
+
CREATE UNIQUE INDEX "credentials_connectionId_key" ON "credentials"("connectionId");
|
|
88
|
+
|
|
89
|
+
-- CreateIndex
|
|
90
|
+
CREATE INDEX "connections_subscriptionId_idx" ON "connections"("subscriptionId");
|
|
91
|
+
|
|
92
|
+
-- CreateIndex
|
|
93
|
+
CREATE UNIQUE INDEX "connections_referenceId_name_key" ON "connections"("referenceId", "name");
|
|
94
|
+
|
|
95
|
+
-- CreateIndex
|
|
96
|
+
CREATE UNIQUE INDEX "entity_connectionId_type_key" ON "entity"("connectionId", "type");
|
|
97
|
+
|
|
98
|
+
-- AddForeignKey
|
|
99
|
+
ALTER TABLE "properties" ADD CONSTRAINT "properties_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "properties"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
100
|
+
|
|
101
|
+
-- AddForeignKey
|
|
102
|
+
ALTER TABLE "properties" ADD CONSTRAINT "properties_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "entity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
103
|
+
|
|
104
|
+
-- AddForeignKey
|
|
105
|
+
ALTER TABLE "records" ADD CONSTRAINT "records_entityId_fkey" FOREIGN KEY ("entityId") REFERENCES "entity"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
|
106
|
+
|
|
107
|
+
-- AddForeignKey
|
|
108
|
+
ALTER TABLE "credentials" ADD CONSTRAINT "credentials_connectionId_fkey" FOREIGN KEY ("connectionId") REFERENCES "connections"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
|
109
|
+
|
|
110
|
+
-- AddForeignKey
|
|
111
|
+
ALTER TABLE "entity" ADD CONSTRAINT "entity_connectionId_fkey" FOREIGN KEY ("connectionId") REFERENCES "connections"("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,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
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const connectParams: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
connectionId: z.ZodString;
|
|
5
|
+
clientRedirectPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
name: string;
|
|
8
|
+
connectionId: string;
|
|
9
|
+
clientRedirectPath: string;
|
|
10
|
+
}, {
|
|
11
|
+
name: string;
|
|
12
|
+
connectionId: string;
|
|
13
|
+
clientRedirectPath?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export declare const oauthState: z.ZodObject<z.objectUtil.extendShape<{
|
|
16
|
+
name: z.ZodString;
|
|
17
|
+
connectionId: z.ZodString;
|
|
18
|
+
clientRedirectPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
19
|
+
}, {
|
|
20
|
+
previewRedirect: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}>, "strip", z.ZodTypeAny, {
|
|
22
|
+
name: string;
|
|
23
|
+
connectionId: string;
|
|
24
|
+
clientRedirectPath: string;
|
|
25
|
+
previewRedirect?: string | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
name: string;
|
|
28
|
+
connectionId: string;
|
|
29
|
+
clientRedirectPath?: string | undefined;
|
|
30
|
+
previewRedirect?: string | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const callbackParams: z.ZodObject<{
|
|
33
|
+
state: z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
34
|
+
name: z.ZodString;
|
|
35
|
+
connectionId: z.ZodString;
|
|
36
|
+
clientRedirectPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
37
|
+
}, {
|
|
38
|
+
previewRedirect: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}>, "strip", z.ZodTypeAny, {
|
|
40
|
+
name: string;
|
|
41
|
+
connectionId: string;
|
|
42
|
+
clientRedirectPath: string;
|
|
43
|
+
previewRedirect?: string | undefined;
|
|
44
|
+
}, {
|
|
45
|
+
name: string;
|
|
46
|
+
connectionId: string;
|
|
47
|
+
clientRedirectPath?: string | undefined;
|
|
48
|
+
previewRedirect?: string | undefined;
|
|
49
|
+
}>, {
|
|
50
|
+
name: string;
|
|
51
|
+
connectionId: string;
|
|
52
|
+
clientRedirectPath: string;
|
|
53
|
+
previewRedirect?: string | undefined;
|
|
54
|
+
}, unknown>;
|
|
55
|
+
error: z.ZodOptional<z.ZodString>;
|
|
56
|
+
}, "strip", z.ZodTypeAny, {
|
|
57
|
+
state: {
|
|
58
|
+
name: string;
|
|
59
|
+
connectionId: string;
|
|
60
|
+
clientRedirectPath: string;
|
|
61
|
+
previewRedirect?: string | undefined;
|
|
62
|
+
};
|
|
63
|
+
error?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
state?: unknown;
|
|
66
|
+
error?: string | undefined;
|
|
67
|
+
}>;
|
|
68
|
+
export declare const webhookQueryParams: z.ZodObject<{
|
|
69
|
+
event: z.ZodString;
|
|
70
|
+
name: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
name: string;
|
|
73
|
+
event: string;
|
|
74
|
+
}, {
|
|
75
|
+
name: string;
|
|
76
|
+
event: string;
|
|
77
|
+
}>;
|
|
78
|
+
export declare const apiKeyConnectionOptions: z.ZodObject<{
|
|
79
|
+
apiKey: z.ZodString;
|
|
80
|
+
}, "strip", z.ZodTypeAny, {
|
|
81
|
+
apiKey: string;
|
|
82
|
+
}, {
|
|
83
|
+
apiKey: string;
|
|
84
|
+
}>;
|