@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.
Files changed (56) hide show
  1. package/dist/authenticator.d.ts +62 -0
  2. package/dist/constants.d.ts +1 -0
  3. package/dist/core.cjs.development.js +5011 -0
  4. package/dist/core.cjs.development.js.map +1 -0
  5. package/dist/core.cjs.production.min.js +2 -0
  6. package/dist/core.cjs.production.min.js.map +1 -0
  7. package/dist/core.esm.js +4947 -0
  8. package/dist/core.esm.js.map +1 -0
  9. package/dist/data-access/index.d.ts +350 -0
  10. package/dist/framework.d.ts +116 -0
  11. package/dist/generated-types/index.d.ts +4 -0
  12. package/dist/index.d.ts +16 -0
  13. package/dist/index.js +8 -0
  14. package/dist/integration.d.ts +100 -0
  15. package/dist/lib/index.d.ts +5 -0
  16. package/dist/lib/query-builder/constants.d.ts +16 -0
  17. package/dist/lib/query-builder/filters/sql.d.ts +8 -0
  18. package/dist/lib/query-builder/schema.d.ts +36 -0
  19. package/dist/lib/query-builder/sorts/sql.d.ts +7 -0
  20. package/dist/lib/query-builder/types.d.ts +30 -0
  21. package/dist/lib/query-builder/utils.d.ts +26 -0
  22. package/dist/lib/utils/object.d.ts +50 -0
  23. package/dist/next/callback.d.ts +3 -0
  24. package/dist/next/connect.d.ts +3 -0
  25. package/dist/next/index.d.ts +15 -0
  26. package/dist/next/inngest.d.ts +3 -0
  27. package/dist/next/utils.d.ts +9 -0
  28. package/dist/next/webhook.d.ts +9 -0
  29. package/dist/prisma/client.d.ts +2 -0
  30. package/dist/prisma/client.ts +31 -0
  31. package/dist/prisma/gen.js +139 -0
  32. package/dist/prisma/migrations/20240828034109_initial_migration/migration.sql +111 -0
  33. package/dist/prisma/migrations/20240829210901_initial_migration/migration.sql +1 -0
  34. package/dist/prisma/migrations/20240905143158_initial_migration/migration.sql +1 -0
  35. package/dist/prisma/migrations/20240911212856_initial_migration/migration.sql +1 -0
  36. package/dist/prisma/migrations/20240915044235_initial_migration/migration.sql +1 -0
  37. package/dist/prisma/migrations/migration_lock.toml +3 -0
  38. package/dist/prisma/schema.prisma +129 -0
  39. package/dist/schemas.d.ts +84 -0
  40. package/dist/service/service.property.d.ts +24 -0
  41. package/dist/service/service.record.d.ts +24 -0
  42. package/dist/sync-factory.d.ts +13 -0
  43. package/dist/sync-fixtures/github.d.ts +949 -0
  44. package/dist/sync-fixtures/stripe.d.ts +92 -0
  45. package/dist/types.d.ts +367 -0
  46. package/dist/utils/errors.d.ts +3 -0
  47. package/dist/utils/index.d.ts +12 -0
  48. package/dist/utils/inngest.d.ts +4 -0
  49. package/dist/workflows/conditions/constants.d.ts +16 -0
  50. package/dist/workflows/conditions/types.d.ts +2 -0
  51. package/dist/workflows/handler.d.ts +38 -0
  52. package/dist/workflows/runner.d.ts +43 -0
  53. package/dist/workflows/schemas.d.ts +1043 -0
  54. package/dist/workflows/types.d.ts +96 -0
  55. package/dist/workflows/utils.d.ts +111 -0
  56. package/package.json +2 -2
@@ -0,0 +1,350 @@
1
+ import { Prisma, PrismaClient, Credential } from '@prisma-app/client';
2
+ import { FilterObject } from '../lib/query-builder/types';
3
+ import { prisma } from '../prisma/client';
4
+ import { RecordService } from '../service/service.record';
5
+ import { CredentialValue } from '../types';
6
+ export declare class DataLayer {
7
+ db: PrismaClient;
8
+ recordService: RecordService<typeof prisma>;
9
+ constructor({ url }: {
10
+ url: string;
11
+ provider: string;
12
+ });
13
+ createConnection({ connection, credential, }: {
14
+ connection: Prisma.ConnectionUncheckedCreateInput;
15
+ credential: Omit<Prisma.CredentialUncheckedCreateInput, 'k_id'>;
16
+ }): Promise<{
17
+ id: string;
18
+ name: string;
19
+ issues: string[];
20
+ syncConfig: Prisma.JsonValue | null;
21
+ connectionId: string;
22
+ createdAt: Date;
23
+ updatedAt: Date | null;
24
+ lastSyncAt: Date | null;
25
+ subscriptionId: string | null;
26
+ } & {
27
+ credential: Credential;
28
+ }>;
29
+ deleteConnection({ connectionId }: {
30
+ connectionId: string;
31
+ }): Promise<{
32
+ id: string;
33
+ name: string;
34
+ issues: string[];
35
+ syncConfig: Prisma.JsonValue | null;
36
+ connectionId: string;
37
+ createdAt: Date;
38
+ updatedAt: Date | null;
39
+ lastSyncAt: Date | null;
40
+ subscriptionId: string | null;
41
+ }>;
42
+ getConnection({ connectionId, name, }: {
43
+ name: string;
44
+ connectionId: string;
45
+ }): Promise<{
46
+ id: string;
47
+ name: string;
48
+ issues: string[];
49
+ syncConfig: Prisma.JsonValue | null;
50
+ connectionId: string;
51
+ createdAt: Date;
52
+ updatedAt: Date | null;
53
+ lastSyncAt: Date | null;
54
+ subscriptionId: string | null;
55
+ } | null>;
56
+ getConnectionsByIntegrationName({ name }: {
57
+ name: string;
58
+ }): Promise<{
59
+ id: string;
60
+ name: string;
61
+ issues: string[];
62
+ syncConfig: Prisma.JsonValue | null;
63
+ connectionId: string;
64
+ createdAt: Date;
65
+ updatedAt: Date | null;
66
+ lastSyncAt: Date | null;
67
+ subscriptionId: string | null;
68
+ }[]>;
69
+ getAllConnections(): Promise<{
70
+ name: string;
71
+ connectionId: string;
72
+ }[]>;
73
+ getConnectionById({ k_id }: {
74
+ k_id: string;
75
+ }): Promise<{
76
+ id: string;
77
+ name: string;
78
+ issues: string[];
79
+ syncConfig: Prisma.JsonValue | null;
80
+ connectionId: string;
81
+ createdAt: Date;
82
+ updatedAt: Date | null;
83
+ lastSyncAt: Date | null;
84
+ subscriptionId: string | null;
85
+ } | null>;
86
+ getCredentialsByConnection(k_id: string): Promise<{
87
+ connection: {
88
+ id: string;
89
+ name: string;
90
+ issues: string[];
91
+ syncConfig: Prisma.JsonValue | null;
92
+ connectionId: string;
93
+ createdAt: Date;
94
+ updatedAt: Date | null;
95
+ lastSyncAt: Date | null;
96
+ subscriptionId: string | null;
97
+ };
98
+ } & {
99
+ id: string;
100
+ type: string;
101
+ value: Prisma.JsonValue;
102
+ scope: string[];
103
+ k_id: string;
104
+ }>;
105
+ updateConnectionCredential({ k_id, token, }: {
106
+ k_id: string;
107
+ token: CredentialValue;
108
+ }): Promise<{
109
+ id: string;
110
+ type: string;
111
+ value: Prisma.JsonValue;
112
+ scope: string[];
113
+ k_id: string;
114
+ }>;
115
+ createEntity({ connectionId, type, k_id, }: {
116
+ k_id: string;
117
+ type: string;
118
+ connectionId: string;
119
+ }): Promise<{
120
+ id: string;
121
+ type: string;
122
+ createdAt: Date;
123
+ updatedAt: Date | null;
124
+ createdBy: string;
125
+ k_id: string;
126
+ lastSyncId: string | null;
127
+ }>;
128
+ getEntityById(entityId: string): Promise<{
129
+ id: string;
130
+ type: string;
131
+ createdAt: Date;
132
+ updatedAt: Date | null;
133
+ createdBy: string;
134
+ k_id: string;
135
+ lastSyncId: string | null;
136
+ }>;
137
+ addPropertiesToEntity({ entityId, properties, }: {
138
+ entityId: string;
139
+ properties: Prisma.PropertyCreateInput[];
140
+ }): Promise<{
141
+ id: string;
142
+ type: string;
143
+ createdAt: Date;
144
+ updatedAt: Date | null;
145
+ createdBy: string;
146
+ k_id: string;
147
+ lastSyncId: string | null;
148
+ }>;
149
+ getEntityRecordsByConnectionAndType({ k_id, type, }: {
150
+ k_id: string;
151
+ type: string;
152
+ }): Promise<({
153
+ properties: {
154
+ id: string;
155
+ name: string;
156
+ displayName: string;
157
+ visible: boolean;
158
+ config: Prisma.JsonValue | null;
159
+ description: string | null;
160
+ type: import("@prisma-app/client").$Enums.PropertyType;
161
+ order: number;
162
+ modifiable: boolean;
163
+ parentId: string | null;
164
+ entityId: string | null;
165
+ }[];
166
+ records: {
167
+ id: string;
168
+ externalId: string | null;
169
+ data: Prisma.JsonValue;
170
+ source: string;
171
+ entityType: string;
172
+ entityId: string | null;
173
+ status: import("@prisma-app/client").$Enums.RecordStatus;
174
+ enrichmentStatus: import("@prisma-app/client").$Enums.RecordEnrichmentStatus;
175
+ deletedAt: Date | null;
176
+ createdAt: Date;
177
+ updatedAt: Date | null;
178
+ }[];
179
+ } & {
180
+ id: string;
181
+ type: string;
182
+ createdAt: Date;
183
+ updatedAt: Date | null;
184
+ createdBy: string;
185
+ k_id: string;
186
+ lastSyncId: string | null;
187
+ }) | null>;
188
+ getEntityByConnectionAndType({ k_id, type, }: {
189
+ k_id: string;
190
+ type: string;
191
+ }): Promise<{
192
+ id: string;
193
+ type: string;
194
+ createdAt: Date;
195
+ updatedAt: Date | null;
196
+ createdBy: string;
197
+ k_id: string;
198
+ lastSyncId: string | null;
199
+ } | null>;
200
+ updateEntityLastSyncId({ entityId, syncId, }: {
201
+ entityId: string;
202
+ syncId: string;
203
+ }): Promise<{
204
+ id: string;
205
+ type: string;
206
+ createdAt: Date;
207
+ updatedAt: Date | null;
208
+ createdBy: string;
209
+ k_id: string;
210
+ lastSyncId: string | null;
211
+ }>;
212
+ deleteEntityById(entityId: string): Promise<{
213
+ id: string;
214
+ type: string;
215
+ createdAt: Date;
216
+ updatedAt: Date | null;
217
+ createdBy: string;
218
+ k_id: string;
219
+ lastSyncId: string | null;
220
+ }>;
221
+ /**
222
+ * Creates new records for a entity, or updates existing record 'data' if it already exists
223
+ * @param entityId
224
+ * @param records
225
+ */
226
+ mergeExternalRecordsForEntity({ entityId, records, }: {
227
+ entityId: string;
228
+ records: {
229
+ externalId: string;
230
+ data: Record<string, any>;
231
+ entityType?: string;
232
+ }[];
233
+ }): Promise<[Prisma.BatchPayload | undefined, number | undefined] | undefined>;
234
+ updateConnectionCredentials({ k_id, ...update }: Prisma.CredentialUpdateInput & {
235
+ k_id: string;
236
+ }): Promise<{
237
+ id: string;
238
+ type: string;
239
+ value: Prisma.JsonValue;
240
+ scope: string[];
241
+ k_id: string;
242
+ }>;
243
+ getRecords<T extends string | number | symbol>({ entityType, k_id, filters, sort, }: {
244
+ entityType: string;
245
+ k_id: string;
246
+ filters?: FilterObject<T>;
247
+ sort?: string[];
248
+ }): Promise<any>;
249
+ getRecordByPropertyNameAndValues({ propertyName, propertValues, type, connectionId, }: {
250
+ propertyName: string;
251
+ propertValues: string[];
252
+ type?: string;
253
+ connectionId: string;
254
+ }): Promise<{
255
+ id: string;
256
+ externalId: string | null;
257
+ data: Prisma.JsonValue;
258
+ source: string;
259
+ entityType: string;
260
+ entityId: string | null;
261
+ status: import("@prisma-app/client").$Enums.RecordStatus;
262
+ enrichmentStatus: import("@prisma-app/client").$Enums.RecordEnrichmentStatus;
263
+ deletedAt: Date | null;
264
+ createdAt: Date;
265
+ updatedAt: Date | null;
266
+ }[]>;
267
+ getRecordByPropertyNameAndValue({ propertyName, propertyValue, type, connectionId, }: {
268
+ propertyName: string;
269
+ propertyValue: string;
270
+ type: string;
271
+ connectionId: string;
272
+ }): Promise<{
273
+ id: string;
274
+ externalId: string | null;
275
+ data: Prisma.JsonValue;
276
+ source: string;
277
+ entityType: string;
278
+ entityId: string | null;
279
+ status: import("@prisma-app/client").$Enums.RecordStatus;
280
+ enrichmentStatus: import("@prisma-app/client").$Enums.RecordEnrichmentStatus;
281
+ deletedAt: Date | null;
282
+ createdAt: Date;
283
+ updatedAt: Date | null;
284
+ } | null>;
285
+ getRecordsByPropertyName({ propertyName, connectionId, }: {
286
+ propertyName: string;
287
+ connectionId: string;
288
+ }): Promise<{
289
+ id: string;
290
+ externalId: string | null;
291
+ data: Prisma.JsonValue;
292
+ source: string;
293
+ entityType: string;
294
+ entityId: string | null;
295
+ status: import("@prisma-app/client").$Enums.RecordStatus;
296
+ enrichmentStatus: import("@prisma-app/client").$Enums.RecordEnrichmentStatus;
297
+ deletedAt: Date | null;
298
+ createdAt: Date;
299
+ updatedAt: Date | null;
300
+ }[]>;
301
+ setConnectionError({ k_id, error }: {
302
+ k_id: string;
303
+ error: string;
304
+ }): Promise<{
305
+ id: string;
306
+ name: string;
307
+ issues: string[];
308
+ syncConfig: Prisma.JsonValue | null;
309
+ connectionId: string;
310
+ createdAt: Date;
311
+ updatedAt: Date | null;
312
+ lastSyncAt: Date | null;
313
+ subscriptionId: string | null;
314
+ }>;
315
+ setConnectionSubscriptionId({ k_id, subscriptionId, }: {
316
+ k_id: string;
317
+ subscriptionId: string;
318
+ }): Promise<{
319
+ id: string;
320
+ name: string;
321
+ issues: string[];
322
+ syncConfig: Prisma.JsonValue | null;
323
+ connectionId: string;
324
+ createdAt: Date;
325
+ updatedAt: Date | null;
326
+ lastSyncAt: Date | null;
327
+ subscriptionId: string | null;
328
+ }>;
329
+ syncData({ connectionId, name, data, type, properties, lastSyncId, }: {
330
+ name: string;
331
+ properties: Prisma.PropertyCreateInput[];
332
+ connectionId: string;
333
+ data: any;
334
+ type: string;
335
+ lastSyncId?: string;
336
+ }): Promise<void>;
337
+ getConnectionsBySubscriptionId({ subscriptionId, }: {
338
+ subscriptionId: string;
339
+ }): Promise<{
340
+ id: string;
341
+ name: string;
342
+ issues: string[];
343
+ syncConfig: Prisma.JsonValue | null;
344
+ connectionId: string;
345
+ createdAt: Date;
346
+ updatedAt: Date | null;
347
+ lastSyncAt: Date | null;
348
+ subscriptionId: string | null;
349
+ }[]>;
350
+ }
@@ -0,0 +1,116 @@
1
+ import { DataLayer } from './data-access';
2
+ import { Integration } from './integration';
3
+ import { Config, IntegrationApi, IntegrationApiExcutorParams, IntegrationContext, IntegrationEvent, Routes, ZodeSchemaGenerator } from './types';
4
+ import { Blueprint } from './workflows/types';
5
+ import { NextRequest, NextResponse } from 'next/server';
6
+ import { IntegrationMap } from './generated-types';
7
+ import { Prisma } from '@prisma-app/client';
8
+ import { z, ZodSchema } from 'zod';
9
+ export declare class Framework<C extends Config = Config> {
10
+ globalEvents: Map<string, Record<string, IntegrationEvent<any>>>;
11
+ globalEventHandlers: any[];
12
+ globalApis: Map<string, Record<string, IntegrationApi<any>>>;
13
+ integrations: Map<string, Integration>;
14
+ dataLayer: DataLayer;
15
+ config: C;
16
+ static init<C extends Config = Config>(config: C): Framework<C>;
17
+ constructor({ dataLayer, config }: {
18
+ dataLayer: DataLayer;
19
+ config: C;
20
+ });
21
+ connectedIntegrations({ context, }: {
22
+ context: {
23
+ connectionId: string;
24
+ };
25
+ }): Promise<Integration<unknown>[]>;
26
+ get routes(): Record<Routes, string>;
27
+ __registerIntgeration(definition: Integration): void;
28
+ __registerEvents({ events, integrationName, }: {
29
+ events: Record<string, IntegrationEvent<any>>;
30
+ integrationName?: string;
31
+ }): void;
32
+ __registerApis({ apis, integrationName, }: {
33
+ apis: IntegrationApi[];
34
+ integrationName?: string;
35
+ }): void;
36
+ availableIntegrations(): {
37
+ name: string;
38
+ integration: Integration<unknown>;
39
+ }[];
40
+ getIntegration<T extends keyof IntegrationMap>(name: T): IntegrationMap[T];
41
+ getGlobalEvents(): Map<string, Record<string, IntegrationEvent<any>>>;
42
+ getSystemEvents(): Record<string, IntegrationEvent<any>>;
43
+ getEventsByIntegration(name: string): Record<string, IntegrationEvent<any>> | undefined;
44
+ getGlobalEventHandlers(): any[];
45
+ getApis(): Map<string, Record<string, IntegrationApi<any>>>;
46
+ getSystemApis(): Record<string, IntegrationApi<any>> | undefined;
47
+ getApisByIntegration(name: string, includeHidden?: boolean): Record<string, IntegrationApi<any>> | undefined;
48
+ authenticatableIntegrations(): {
49
+ name: string;
50
+ integration: Integration<unknown>;
51
+ }[];
52
+ authenticator(name: string): import("./authenticator").IntegrationAuth;
53
+ connectIntegrationByCredential({ name, connectionId, credential, }: {
54
+ name: string;
55
+ connectionId: string;
56
+ credential: Omit<Prisma.CredentialUncheckedCreateInput, 'k_id'>;
57
+ }): Promise<void>;
58
+ disconnectIntegration({ name, connectionId, }: {
59
+ name: string;
60
+ connectionId: string;
61
+ }): Promise<void>;
62
+ callApi({ integrationName, api, payload, }: {
63
+ integrationName?: string;
64
+ api: string;
65
+ payload: IntegrationApiExcutorParams;
66
+ }): Promise<Record<string, any>>;
67
+ subscribeEvent({ id, interval, timeout, }: {
68
+ id: string;
69
+ interval?: number;
70
+ timeout?: number;
71
+ }): Promise<{
72
+ status: string;
73
+ startedAt: string;
74
+ endedAt: string;
75
+ } | null>;
76
+ triggerEvent<KEY extends keyof C['workflows']['systemEvents'], SYSTEM_EVENT_SCHEMA extends C['workflows']['systemEvents'][KEY]['schema']>({ key, data, user, integrationName, }: {
77
+ integrationName?: string;
78
+ key: KEY;
79
+ data: SYSTEM_EVENT_SCHEMA extends ZodSchema ? z.infer<SYSTEM_EVENT_SCHEMA> : SYSTEM_EVENT_SCHEMA extends ZodeSchemaGenerator ? z.infer<Awaited<ReturnType<SYSTEM_EVENT_SCHEMA>>> : never;
80
+ user?: {
81
+ connectionId: string;
82
+ [key: string]: any;
83
+ };
84
+ }): Promise<{
85
+ event: any;
86
+ workflowEvent?: any;
87
+ }>;
88
+ triggerSystemEvent<T = Record<string, any>>({ key, data, user, }: {
89
+ key: string;
90
+ data: T;
91
+ user?: {
92
+ connectionId: string;
93
+ [key: string]: any;
94
+ };
95
+ }): Promise<import("inngest/types").SendEventOutput<{
96
+ id: string;
97
+ }>>;
98
+ createRouter(): {
99
+ makeWebhookUrl: ({ event, name, }: {
100
+ name: string;
101
+ event: string;
102
+ }) => string;
103
+ makeRedirectURI: () => string;
104
+ makeConnectURI: (props: {
105
+ name: string;
106
+ connectionId: string;
107
+ clientRedirectPath: string;
108
+ }) => string;
109
+ registerRoutes: () => (req: NextRequest) => NextResponse<unknown> | Promise<Response>;
110
+ };
111
+ runBlueprint: ({ blueprint, dataCtx, ctx, }: {
112
+ blueprint: Blueprint;
113
+ dataCtx?: any;
114
+ ctx: IntegrationContext;
115
+ }) => Promise<void>;
116
+ }
@@ -0,0 +1,4 @@
1
+ import type { Integration } from '../integration';
2
+ export interface IntegrationMap {
3
+ [s: string]: Integration;
4
+ }
@@ -0,0 +1,16 @@
1
+ export * from './workflows/types';
2
+ export { IntegrationError } from './utils/errors';
3
+ export { DataLayer } from './data-access';
4
+ export { registerRoutes } from './next';
5
+ export * from './types';
6
+ export * from './lib';
7
+ export { Integration } from './integration';
8
+ export { IntegrationCredentialType } from './types';
9
+ export { PropertyType, Connection, Credential, Entity, Property, Record, } from '@prisma-app/client';
10
+ export { IntegrationAuth } from './authenticator';
11
+ export * from './utils';
12
+ export * from './next/utils';
13
+ export * from './schemas';
14
+ export * from './sync-factory';
15
+ export { Framework } from './framework';
16
+ export * from './generated-types';
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./core.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./core.cjs.development.js')
8
+ }
@@ -0,0 +1,100 @@
1
+ import { EventHandlerReturnType, IntegrationApi, IntegrationCredentialType, IntegrationEvent, MakeWebhookURL } from './types';
2
+ import { ZodSchema } from 'zod';
3
+ import { DataLayer } from './data-access';
4
+ import { IntegrationAuth } from './authenticator';
5
+ import { Connection } from '@prisma-app/client';
6
+ import { FilterObject } from './lib';
7
+ export type IntegrationConfig = {
8
+ name: string;
9
+ logoUrl: string;
10
+ scopes?: string[];
11
+ authType?: IntegrationCredentialType;
12
+ authConnectionOptions?: ZodSchema;
13
+ [key: string]: any;
14
+ };
15
+ export type CoreIntegrationPresets = {
16
+ redirectURI: string;
17
+ };
18
+ /**
19
+ * @params T - The type of the client that the integration provides
20
+ */
21
+ export declare class Integration<T = unknown> {
22
+ name: string;
23
+ logoUrl: string;
24
+ categories: string[];
25
+ description: string;
26
+ dataLayer?: DataLayer;
27
+ config: Omit<IntegrationConfig, 'name' | 'logoUrl'> & {
28
+ [key: string]: any;
29
+ };
30
+ availableScopes?: {
31
+ key: string;
32
+ description: string;
33
+ }[];
34
+ events: Record<string, IntegrationEvent<any>>;
35
+ apis: Record<string, IntegrationApi<any>>;
36
+ entityTypes: Record<string, string>;
37
+ corePresets: CoreIntegrationPresets;
38
+ constructor(config: IntegrationConfig);
39
+ getConfig(): Omit<IntegrationConfig, "name" | "logoUrl"> & {
40
+ [key: string]: any;
41
+ };
42
+ getClientZodSchema(): any;
43
+ getCommentsForClientApis(): Record<string, {
44
+ comment: string;
45
+ doc?: string;
46
+ }>;
47
+ getBaseClient(): any;
48
+ getApiClient(params: {
49
+ connectionId: string;
50
+ }): Promise<any>;
51
+ getApi({ connectionId }: {
52
+ connectionId: string;
53
+ }): Promise<any>;
54
+ _convertApiClientToSystemApis: () => Promise<void>;
55
+ getAuthenticator(): IntegrationAuth;
56
+ makeClient: (params: {
57
+ connectionId: string;
58
+ }) => Promise<T>;
59
+ attachDataLayer({ dataLayer }: {
60
+ dataLayer: DataLayer;
61
+ }): void;
62
+ getEventHandlers: ({ makeWebhookUrl, }: {
63
+ makeWebhookUrl: MakeWebhookURL;
64
+ }) => EventHandlerReturnType[];
65
+ registerApis(): {};
66
+ getApis(): Record<string, IntegrationApi<any>>;
67
+ registerEvents<T extends Integration>(): Record<string, IntegrationEvent<T>>;
68
+ getEvents<T extends Integration>(): Record<string, IntegrationEvent<T>>;
69
+ query<T extends string | number | symbol>(props: {
70
+ connectionId: string;
71
+ entityType: any;
72
+ filters?: FilterObject<T>;
73
+ sort?: string[];
74
+ }): Promise<any>;
75
+ getEvent(name: string): IntegrationEvent<any>;
76
+ processWebhookRequest(params: {
77
+ reqBody: any;
78
+ event: string;
79
+ connectionsBySubscriptionId: (subscriptionId: string) => Promise<Connection[]>;
80
+ }): Promise<void>;
81
+ triggerEvent<T = Record<string, any>>({ key, data, user, }: {
82
+ key: string;
83
+ data: T;
84
+ user?: {
85
+ connectionId: string;
86
+ [key: string]: any;
87
+ };
88
+ }): Promise<import("inngest/types").SendEventOutput<{
89
+ id: string;
90
+ }>>;
91
+ test({ connectionId, }: {
92
+ connectionId: string;
93
+ }): Promise<string | null>;
94
+ onConnectionCreated({ connection, }: {
95
+ connection: Connection;
96
+ }): Promise<any>;
97
+ onDisconnect({ connectionId, }: {
98
+ connectionId: string;
99
+ }): Promise<any>;
100
+ }
@@ -0,0 +1,5 @@
1
+ export * from './query-builder/types';
2
+ export * from './query-builder/schema';
3
+ export * from './query-builder/constants';
4
+ export * from './query-builder/utils';
5
+ export * from './utils/object';
@@ -0,0 +1,16 @@
1
+ import { PropertyType } from '@prisma-app/client';
2
+ import { FilterOperators } from './types';
3
+ export interface SortField {
4
+ type: string;
5
+ name: string;
6
+ displayName: string;
7
+ config?: Record<string, any>;
8
+ }
9
+ export interface SortLogic {
10
+ field: SortField;
11
+ mode: 'ascending' | 'descending';
12
+ }
13
+ export declare const fieldsWithCommaSeparatedValues: PropertyType[];
14
+ export declare const FieldTypePrimitiveMap: Record<PropertyType, string>;
15
+ export declare const SORT_MODE_TO_ABBR: Record<SortLogic['mode'], string>;
16
+ export declare const FilterOperatorToSQL: Record<FilterOperators, string>;
@@ -0,0 +1,8 @@
1
+ import { FilterClauseArgs } from '../types';
2
+ /**
3
+ * Get the SQL filter clause for the given filters.
4
+ * @param filters - Filters to apply.
5
+ * @param fields - Optional. JSON fields with associated types to apply filters on.
6
+ * @param parentTableRef - Parent table reference to apply filters on.
7
+ */
8
+ export declare const getFilterClauseSQL: ({ filters, fields, parentTableRef, }: FilterClauseArgs<string>) => string;
@@ -0,0 +1,36 @@
1
+ import { z } from 'zod';
2
+ import { FilterOperators } from './types';
3
+ type ValueOf<T> = Required<T>[keyof T];
4
+ export declare const filterQuerySchema: z.ZodObject<Record<ValueOf<typeof FilterOperators>, any>, "strip", z.ZodTypeAny, {
5
+ is?: any;
6
+ eq?: any;
7
+ not_eq?: any;
8
+ contains?: any;
9
+ in?: any;
10
+ not_in?: any;
11
+ gt?: any;
12
+ lt?: any;
13
+ not_contains?: any;
14
+ gte?: any;
15
+ lte?: any;
16
+ op?: any;
17
+ set?: any;
18
+ not_set?: any;
19
+ }, {
20
+ is?: any;
21
+ eq?: any;
22
+ not_eq?: any;
23
+ contains?: any;
24
+ in?: any;
25
+ not_in?: any;
26
+ gt?: any;
27
+ lt?: any;
28
+ not_contains?: any;
29
+ gte?: any;
30
+ lte?: any;
31
+ op?: any;
32
+ set?: any;
33
+ not_set?: any;
34
+ }>;
35
+ export declare const sortQuerySchema: z.ZodEffects<z.ZodString, string[] | undefined, string>;
36
+ export {};
@@ -0,0 +1,7 @@
1
+ import { SortClauseArgs } from '../types';
2
+ /**
3
+ * Get the SQL sort clause for the given sort fields.
4
+ * A sort clause is an array of strings where each string is a field to sort by.
5
+ * e.g. ["field1 ASC", "field2 DESC"] will sort by field1 in ascending order and field2 in descending order.
6
+ */
7
+ export declare const getSortClauseSQL: ({ sort, parentTableRef, fields, }: SortClauseArgs) => string[];