@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,96 @@
1
+ import { z } from 'zod';
2
+ import { actionPayloadSchema, actionPayloadValueSchema, actionVariableSchema, actionSchema, blueprintSchema, conditionSchema, logicConditionSchema, triggerSchema, createBlueprintSchema, createRunSchema, PayloadFieldTypeEnum, updatActionSchema, updateBlueprintSchema, updateRunSchema, updateTriggerSchema } from './schemas';
3
+ export declare const WorkflowStatusEnum: {
4
+ readonly DRAFT: "DRAFT";
5
+ readonly UNPUBLISHED: "UNPUBLISHED";
6
+ readonly PUBLISHED: "PUBLISHED";
7
+ };
8
+ export type WorkflowStatus = (typeof WorkflowStatusEnum)[keyof typeof WorkflowStatusEnum];
9
+ export declare const RunStatus: {
10
+ readonly PENDING: "PENDING";
11
+ readonly RUNNING: "RUNNING";
12
+ readonly COMPLETED: "COMPLETED";
13
+ readonly FAILED: "FAILED";
14
+ };
15
+ export type RunStatus = (typeof RunStatus)[keyof typeof RunStatus];
16
+ export type Run = {
17
+ id: string;
18
+ status: RunStatus;
19
+ completedAt: Date | null;
20
+ failedAt: Date | null;
21
+ blueprintId: string;
22
+ createdAt: Date;
23
+ updatedAt: Date | null;
24
+ };
25
+ export type CreateBlueprintDto = z.infer<typeof createBlueprintSchema>;
26
+ export type CreateRunDto = z.infer<typeof createRunSchema>;
27
+ export type UpdateBlueprintDto = z.infer<typeof updateBlueprintSchema>;
28
+ export type UpdateRunDto = z.infer<typeof updateRunSchema>;
29
+ export type WorkflowTrigger = z.infer<typeof triggerSchema>;
30
+ export type UpdateTrigger = z.infer<typeof updateTriggerSchema>;
31
+ export type WorkflowAction = z.infer<typeof actionSchema>;
32
+ export type WorkflowParentBlock = {
33
+ blockType: 'action' | 'trigger';
34
+ } & (WorkflowAction | WorkflowTrigger);
35
+ export type WorkflowParentBlocks = WorkflowParentBlock[];
36
+ export type ActionWithParentCondition = WorkflowAction & {
37
+ parentCondition?: WorkflowLogicConditionGroup;
38
+ };
39
+ export type Blueprint = z.infer<typeof blueprintSchema>;
40
+ export type BlueprintWithRelations = Blueprint & {
41
+ runs?: Run[];
42
+ isLoading?: boolean;
43
+ };
44
+ export type UpdateAction = z.infer<typeof updatActionSchema>;
45
+ export type WorkflowConditionGroup = z.infer<typeof conditionSchema> & {
46
+ actionId?: string;
47
+ blockId?: string;
48
+ isDefault?: boolean;
49
+ };
50
+ export type WorkflowLogicConditionGroup = z.infer<typeof logicConditionSchema>;
51
+ export type ConditionConj = 'and' | 'or';
52
+ export type WorkflowCondition = Pick<WorkflowConditionGroup, 'field' | 'operator' | 'value' | 'id'> & {
53
+ conj?: ConditionConj;
54
+ actionId?: string;
55
+ blockId?: string;
56
+ isDefault?: boolean;
57
+ };
58
+ export type ActionPayload = z.infer<typeof actionPayloadSchema>;
59
+ export type ActionVariables = z.infer<typeof actionVariableSchema>;
60
+ export type ActionVariable = z.infer<typeof actionVariableSchema.valueSchema>;
61
+ export type PayloadField = (typeof PayloadFieldTypeEnum)[keyof typeof PayloadFieldTypeEnum];
62
+ export type ActionPayloadValue = z.infer<typeof actionPayloadValueSchema>;
63
+ export type WorkflowContextBlueprintInfo = Omit<BlueprintWithRelations, 'actions' | 'trigger' | 'isLoading' | 'runs'>;
64
+ export type WorkflowContextAction = UpdateAction & {
65
+ id: string;
66
+ parentActionId?: string;
67
+ };
68
+ export type WorkflowContextWorkflowActionsShape = {
69
+ [key: string]: WorkflowContextAction;
70
+ };
71
+ export type WorkflowContextSelectedBlock = {
72
+ type: 'action';
73
+ block: WorkflowAction;
74
+ } | {
75
+ type: 'trigger';
76
+ block: WorkflowTrigger;
77
+ } | {
78
+ type: 'path';
79
+ block: WorkflowLogicConditionGroup;
80
+ };
81
+ export type NewActionInMiddleProps = {
82
+ newAction: WorkflowContextAction;
83
+ isParentATrigger?: boolean;
84
+ } & ({
85
+ isParentACondition?: never;
86
+ conditionId?: never;
87
+ } | {
88
+ isParentACondition: boolean;
89
+ conditionId: string;
90
+ });
91
+ export interface UpdateLogicCondtion {
92
+ actionId: string;
93
+ condition: WorkflowLogicConditionGroup;
94
+ isNewCondition?: boolean;
95
+ isPathFromGraph?: boolean;
96
+ }
@@ -0,0 +1,111 @@
1
+ import { IntegrationContext, RefinedIntegrationApi, RefinedIntegrationEvent } from '../types';
2
+ import { BlueprintWithRelations, WorkflowCondition, WorkflowConditionGroup, WorkflowParentBlock, WorkflowStatus, WorkflowTrigger, WorkflowContextWorkflowActionsShape } from './types';
3
+ import { FilterOperator } from './conditions/types';
4
+ export declare const workflowStatusColorMap: Record<WorkflowStatus, string>;
5
+ export declare const workflowStatusTextMap: Record<WorkflowStatus, string>;
6
+ export declare function extractConditions(group?: WorkflowConditionGroup): WorkflowCondition[];
7
+ export declare const getAllParentBlocks: ({ actions, actionId, trigger, }: {
8
+ actions: WorkflowContextWorkflowActionsShape;
9
+ actionId: string;
10
+ trigger: WorkflowTrigger;
11
+ }) => WorkflowParentBlock[];
12
+ export declare const getOutputSchema: ({ block, payload, blockType, }: {
13
+ block: RefinedIntegrationApi | RefinedIntegrationEvent;
14
+ payload: {
15
+ value?: unknown;
16
+ } | Record<string, any>;
17
+ blockType: "action" | "trigger";
18
+ }) => any;
19
+ export declare const getOutputSchemaServer: ({ ctx, block, payload, blockType, }: {
20
+ ctx: IntegrationContext;
21
+ block: RefinedIntegrationApi | RefinedIntegrationEvent;
22
+ payload: {
23
+ value?: unknown;
24
+ } | Record<string, any>;
25
+ blockType: "action" | "trigger";
26
+ }) => Promise<any>;
27
+ export declare const getSchemaServer: ({ ctx, block, payload, blockType, }: {
28
+ ctx: IntegrationContext;
29
+ block: RefinedIntegrationApi | RefinedIntegrationEvent;
30
+ payload: {
31
+ value?: unknown;
32
+ } | Record<string, any>;
33
+ blockType: "action" | "trigger";
34
+ }) => Promise<any>;
35
+ export declare const getSchemaClient: ({ block, payload, blockType, }: {
36
+ block: RefinedIntegrationApi | RefinedIntegrationEvent;
37
+ payload: {
38
+ value?: unknown;
39
+ } | Record<string, any>;
40
+ blockType: "action" | "trigger";
41
+ }) => any;
42
+ export declare const filterChecks: {
43
+ stringCheck: ({ filterField, operator, comparator, }: {
44
+ filterField: string;
45
+ operator: FilterOperator;
46
+ comparator: string;
47
+ }) => boolean;
48
+ numberCheck: ({ filterField, operator, comparator, }: {
49
+ filterField: number;
50
+ operator: FilterOperator;
51
+ comparator: number;
52
+ }) => boolean;
53
+ dateCheck: ({ filterField, operator, comparator, }: {
54
+ filterField: string;
55
+ operator: FilterOperator;
56
+ comparator: string;
57
+ }) => boolean;
58
+ booleanCheck: ({ filterField, operator, comparator, }: {
59
+ filterField: boolean;
60
+ operator: FilterOperator;
61
+ comparator: unknown;
62
+ }) => boolean;
63
+ };
64
+ export declare const constructWorkflowContextBluePrint: (blueprint: BlueprintWithRelations) => {
65
+ trigger: {
66
+ id: string;
67
+ type: string;
68
+ description?: string | undefined;
69
+ payload?: {
70
+ value?: unknown;
71
+ } | undefined;
72
+ condition?: ({
73
+ id?: string | undefined;
74
+ field?: string | undefined;
75
+ operator?: "" | "EQUAL" | "NOT_EQUAL" | "CONTAINS" | "IS" | "IS_NOT" | "NOT_CONTAINS" | "IS_ANY_OF" | "GREATER_THAN" | "LESS_THAN" | "DOES_NOT_CONTAIN" | "GREATER_THAN_OR_EQUAL" | "LESS_THAN_OR_EQUAL" | "SET" | "NOT_SET" | undefined;
76
+ value?: unknown;
77
+ blockId?: string | undefined;
78
+ actionId?: string | undefined;
79
+ } & {
80
+ and?: ({
81
+ id?: string | undefined;
82
+ field?: string | undefined;
83
+ operator?: "" | "EQUAL" | "NOT_EQUAL" | "CONTAINS" | "IS" | "IS_NOT" | "NOT_CONTAINS" | "IS_ANY_OF" | "GREATER_THAN" | "LESS_THAN" | "DOES_NOT_CONTAIN" | "GREATER_THAN_OR_EQUAL" | "LESS_THAN_OR_EQUAL" | "SET" | "NOT_SET" | undefined;
84
+ value?: unknown;
85
+ blockId?: string | undefined;
86
+ actionId?: string | undefined;
87
+ } & any)[];
88
+ or?: ({
89
+ id?: string | undefined;
90
+ field?: string | undefined;
91
+ operator?: "" | "EQUAL" | "NOT_EQUAL" | "CONTAINS" | "IS" | "IS_NOT" | "NOT_CONTAINS" | "IS_ANY_OF" | "GREATER_THAN" | "LESS_THAN" | "DOES_NOT_CONTAIN" | "GREATER_THAN_OR_EQUAL" | "LESS_THAN_OR_EQUAL" | "SET" | "NOT_SET" | undefined;
92
+ value?: unknown;
93
+ blockId?: string | undefined;
94
+ actionId?: string | undefined;
95
+ } & any)[];
96
+ }) | undefined;
97
+ } | null;
98
+ blueprintInfo: {
99
+ id: string;
100
+ status: "DRAFT" | "UNPUBLISHED" | "PUBLISHED";
101
+ title: string;
102
+ ownerId: string;
103
+ workspaceId: string;
104
+ createdAt: Date;
105
+ description?: string | null | undefined;
106
+ updatedAt?: Date | undefined;
107
+ runs?: import("./types").Run[];
108
+ isLoading?: boolean;
109
+ };
110
+ actions: WorkflowContextWorkflowActionsShape;
111
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/mylib.esm.js",
@@ -66,7 +66,7 @@
66
66
  "scripts": {
67
67
  "check": "tsc --noEmit",
68
68
  "analyze": "size-limit --why",
69
- "build": "dts build && cp ./src/prisma/* ./dist/prisma",
69
+ "build": "dts build && cp -r ./src/prisma/* ./dist/prisma",
70
70
  "build:dev": "dts watch",
71
71
  "lint": "dts lint",
72
72
  "size": "size-limit",