@motiadev/core 0.7.1-beta.132 → 0.7.1-beta.133-796499
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.
|
@@ -12,7 +12,11 @@ const uuid_1 = require("uuid");
|
|
|
12
12
|
const getNodeComponentPath = (filePath) => {
|
|
13
13
|
const filePathWithoutExtension = filePath.replace(/\.[^/.]+$/, '');
|
|
14
14
|
const tsxPath = filePathWithoutExtension + '.tsx';
|
|
15
|
-
|
|
15
|
+
const jsxPath = filePathWithoutExtension + '.jsx';
|
|
16
|
+
if (fs_1.default.existsSync(tsxPath))
|
|
17
|
+
return tsxPath;
|
|
18
|
+
if (fs_1.default.existsSync(jsxPath))
|
|
19
|
+
return jsxPath;
|
|
16
20
|
};
|
|
17
21
|
const getRelativePath = (filePath) => {
|
|
18
22
|
const baseDir = process.cwd();
|
package/dist/src/server.d.ts
CHANGED
|
@@ -19,8 +19,6 @@ export type MotiaServer = {
|
|
|
19
19
|
type MotiaServerConfig = {
|
|
20
20
|
isVerbose: boolean;
|
|
21
21
|
printer?: Printer;
|
|
22
|
-
isDev: boolean;
|
|
23
|
-
version: string;
|
|
24
22
|
};
|
|
25
23
|
export declare const createServer: (lockedData: LockedData, eventManager: EventManager, state: InternalStateManager, config: MotiaServerConfig) => MotiaServer;
|
|
26
24
|
export {};
|
package/dist/src/server.js
CHANGED
|
@@ -155,13 +155,6 @@ const createServer = (lockedData, eventManager, state, config) => {
|
|
|
155
155
|
};
|
|
156
156
|
app.use(body_parser_1.default.json({ limit: '1gb' }));
|
|
157
157
|
app.use(body_parser_1.default.urlencoded({ extended: true, limit: '1gb' }));
|
|
158
|
-
app.get('/__motia', (_, res) => {
|
|
159
|
-
const { version, isDev } = config;
|
|
160
|
-
res //
|
|
161
|
-
.header('Access-Control-Allow-Origin', '*')
|
|
162
|
-
.status(200)
|
|
163
|
-
.json({ version, isDev });
|
|
164
|
-
});
|
|
165
158
|
const router = express_1.default.Router();
|
|
166
159
|
const addRoute = (step) => {
|
|
167
160
|
const { method, path } = step.config;
|
|
@@ -20,7 +20,7 @@ const getFeatures = async (filePath) => {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
const stepEndpoint = (app, lockedData) => {
|
|
23
|
-
app.get('/step/:stepId', async (req, res) => {
|
|
23
|
+
app.get('/__motia/step/:stepId', async (req, res) => {
|
|
24
24
|
const id = req.params.stepId;
|
|
25
25
|
const allSteps = [...lockedData.activeSteps, ...lockedData.devSteps];
|
|
26
26
|
const step = allSteps.find((step) => (0, flows_helper_1.generateStepId)(step.filePath) === id);
|
|
@@ -2,38 +2,31 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.validateStep = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
6
|
-
type: zod_1.z.
|
|
5
|
+
const objectSchema = zod_1.z.object({
|
|
6
|
+
type: zod_1.z.literal('object'),
|
|
7
7
|
properties: zod_1.z.record(zod_1.z.any()),
|
|
8
8
|
required: zod_1.z.array(zod_1.z.string()).optional(),
|
|
9
9
|
additionalProperties: zod_1.z.boolean().optional(),
|
|
10
10
|
description: zod_1.z.string().optional(),
|
|
11
11
|
title: zod_1.z.string().optional(),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
pattern: zod_1.z.string().optional(),
|
|
31
|
-
maxItems: zod_1.z.number().optional(),
|
|
32
|
-
minItems: zod_1.z.number().optional(),
|
|
33
|
-
uniqueItems: zod_1.z.boolean().optional(),
|
|
34
|
-
maxProperties: zod_1.z.number().optional(),
|
|
35
|
-
minProperties: zod_1.z.number().optional(),
|
|
36
|
-
const: zod_1.z.any().optional(),
|
|
12
|
+
});
|
|
13
|
+
const arraySchema = zod_1.z.object({
|
|
14
|
+
type: zod_1.z.literal('array'),
|
|
15
|
+
items: objectSchema,
|
|
16
|
+
description: zod_1.z.string().optional(),
|
|
17
|
+
title: zod_1.z.string().optional(),
|
|
18
|
+
});
|
|
19
|
+
const jsonSchema = zod_1.z.any().refine((data) => {
|
|
20
|
+
if (!data) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
else if (data.type === 'object') {
|
|
24
|
+
return objectSchema.parse(data);
|
|
25
|
+
}
|
|
26
|
+
else if (data.type === 'array') {
|
|
27
|
+
return arraySchema.parse(data);
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
37
30
|
});
|
|
38
31
|
const emits = zod_1.z.array(zod_1.z.union([
|
|
39
32
|
zod_1.z.string(),
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { z, ZodObject } from 'zod';
|
|
1
|
+
import { z, ZodArray, ZodObject } from 'zod';
|
|
2
2
|
import { Logger } from './logger';
|
|
3
3
|
import { Tracer } from './observability';
|
|
4
|
+
export type ZodInput = ZodObject<any> | ZodArray<any>;
|
|
4
5
|
export type InternalStateManager = {
|
|
5
6
|
get<T>(groupId: string, key: string): Promise<T | null>;
|
|
6
7
|
set<T>(groupId: string, key: string, value: T): Promise<T>;
|
|
@@ -35,7 +36,7 @@ export type EventConfig = {
|
|
|
35
36
|
subscribes: string[];
|
|
36
37
|
emits: Emit[];
|
|
37
38
|
virtualEmits?: Emit[];
|
|
38
|
-
input:
|
|
39
|
+
input: ZodInput;
|
|
39
40
|
flows?: string[];
|
|
40
41
|
/**
|
|
41
42
|
* Files to include in the step bundle.
|
|
@@ -53,11 +54,11 @@ export type NoopConfig = {
|
|
|
53
54
|
};
|
|
54
55
|
export type ApiRouteMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'OPTIONS' | 'HEAD';
|
|
55
56
|
export type ApiMiddleware<TBody = unknown, TEmitData = never, TResult = unknown> = (req: ApiRequest<TBody>, ctx: FlowContext<TEmitData>, next: () => Promise<ApiResponse<number, TResult>>) => Promise<ApiResponse<number, TResult>>;
|
|
56
|
-
export
|
|
57
|
+
export interface QueryParam {
|
|
57
58
|
name: string;
|
|
58
59
|
description: string;
|
|
59
|
-
}
|
|
60
|
-
export
|
|
60
|
+
}
|
|
61
|
+
export interface ApiRouteConfig {
|
|
61
62
|
type: 'api';
|
|
62
63
|
name: string;
|
|
63
64
|
description?: string;
|
|
@@ -68,15 +69,15 @@ export type ApiRouteConfig = {
|
|
|
68
69
|
virtualSubscribes?: string[];
|
|
69
70
|
flows?: string[];
|
|
70
71
|
middleware?: ApiMiddleware<any, any, any>[];
|
|
71
|
-
bodySchema?:
|
|
72
|
-
responseSchema?: Record<number,
|
|
72
|
+
bodySchema?: ZodInput;
|
|
73
|
+
responseSchema?: Record<number, ZodInput>;
|
|
73
74
|
queryParams?: QueryParam[];
|
|
74
75
|
/**
|
|
75
76
|
* Files to include in the step bundle.
|
|
76
77
|
* Needs to be relative to the step file.
|
|
77
78
|
*/
|
|
78
79
|
includeFiles?: string[];
|
|
79
|
-
}
|
|
80
|
+
}
|
|
80
81
|
export interface ApiRequest<TBody = unknown> {
|
|
81
82
|
pathParams: Record<string, string>;
|
|
82
83
|
queryParams: Record<string, string | string[]>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@motiadev/core",
|
|
3
3
|
"description": "Core functionality for the Motia framework, providing the foundation for building event-driven workflows.",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
|
-
"version": "0.7.1-beta.
|
|
5
|
+
"version": "0.7.1-beta.133-796499",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"body-parser": "^1.20.3",
|