@motiadev/core 0.9.4-beta.151-160668 → 0.9.4-beta.151-307192
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/src/infrastructure-validator/schemas.d.ts +119 -17
- package/dist/src/infrastructure-validator/schemas.d.ts.map +1 -1
- package/dist/src/infrastructure-validator/validations.js +2 -2
- package/dist/src/node/get-config.js +14 -19
- package/dist/src/step-validator.js +3 -3
- package/dist/src/steps/emit.step.js +1 -1
- package/dist/src/steps/emit.step.ts +1 -1
- package/dist/src/types/generate-type-from-schema.d.ts +2 -2
- package/dist/src/types/generate-type-from-schema.d.ts.map +1 -1
- package/dist/src/types/generate-types.d.ts.map +1 -1
- package/dist/src/types/generate-types.js +1 -4
- package/dist/src/types/merge-schemas.d.ts +1 -2
- package/dist/src/types/merge-schemas.d.ts.map +1 -1
- package/dist/src/types/merge-schemas.js +22 -130
- package/dist/src/types/schema.types.d.ts +27 -5
- package/dist/src/types/schema.types.d.ts.map +1 -1
- package/dist/src/types-stream.d.ts +2 -2
- package/dist/src/types-stream.d.ts.map +1 -1
- package/dist/src/types.d.ts +5 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/validate-event-input.d.ts.map +1 -1
- package/dist/src/validate-event-input.js +5 -3
- package/package.json +3 -2
- package/dist/src/schema-utils.d.ts +0 -9
- package/dist/src/schema-utils.d.ts.map +0 -1
- package/dist/src/schema-utils.js +0 -80
|
@@ -11,35 +11,137 @@ export declare const handlerBaseSchema: z.ZodObject<{
|
|
|
11
11
|
ram: z.ZodNumber;
|
|
12
12
|
timeout: z.ZodNumber;
|
|
13
13
|
cpu: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
}, z.
|
|
15
|
-
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
ram: number;
|
|
16
|
+
timeout: number;
|
|
17
|
+
cpu?: number | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
ram: number;
|
|
20
|
+
timeout: number;
|
|
21
|
+
cpu?: number | undefined;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const handlerSchema: z.ZodEffects<z.ZodObject<{
|
|
16
24
|
ram: z.ZodOptional<z.ZodNumber>;
|
|
17
25
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
18
26
|
cpu: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
19
|
-
}, z.
|
|
27
|
+
}, "strip", z.ZodTypeAny, {
|
|
28
|
+
ram?: number | undefined;
|
|
29
|
+
timeout?: number | undefined;
|
|
30
|
+
cpu?: number | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
ram?: number | undefined;
|
|
33
|
+
timeout?: number | undefined;
|
|
34
|
+
cpu?: number | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
ram?: number | undefined;
|
|
37
|
+
timeout?: number | undefined;
|
|
38
|
+
cpu?: number | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
ram?: number | undefined;
|
|
41
|
+
timeout?: number | undefined;
|
|
42
|
+
cpu?: number | undefined;
|
|
43
|
+
}>;
|
|
20
44
|
export declare const queueSchema: z.ZodObject<{
|
|
21
|
-
type: z.ZodEnum<
|
|
22
|
-
standard: "standard";
|
|
23
|
-
fifo: "fifo";
|
|
24
|
-
}>;
|
|
45
|
+
type: z.ZodEnum<["standard", "fifo"]>;
|
|
25
46
|
visibilityTimeout: z.ZodNumber;
|
|
26
47
|
maxRetries: z.ZodNumber;
|
|
27
48
|
delaySeconds: z.ZodOptional<z.ZodNumber>;
|
|
28
|
-
}, z.
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
type: "standard" | "fifo";
|
|
51
|
+
visibilityTimeout: number;
|
|
52
|
+
maxRetries: number;
|
|
53
|
+
delaySeconds?: number | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
type: "standard" | "fifo";
|
|
56
|
+
visibilityTimeout: number;
|
|
57
|
+
maxRetries: number;
|
|
58
|
+
delaySeconds?: number | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const infrastructureSchema: z.ZodEffects<z.ZodObject<{
|
|
61
|
+
handler: z.ZodOptional<z.ZodEffects<z.ZodObject<{
|
|
31
62
|
ram: z.ZodOptional<z.ZodNumber>;
|
|
32
63
|
timeout: z.ZodOptional<z.ZodNumber>;
|
|
33
64
|
cpu: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
34
|
-
}, z.
|
|
65
|
+
}, "strip", z.ZodTypeAny, {
|
|
66
|
+
ram?: number | undefined;
|
|
67
|
+
timeout?: number | undefined;
|
|
68
|
+
cpu?: number | undefined;
|
|
69
|
+
}, {
|
|
70
|
+
ram?: number | undefined;
|
|
71
|
+
timeout?: number | undefined;
|
|
72
|
+
cpu?: number | undefined;
|
|
73
|
+
}>, {
|
|
74
|
+
ram?: number | undefined;
|
|
75
|
+
timeout?: number | undefined;
|
|
76
|
+
cpu?: number | undefined;
|
|
77
|
+
}, {
|
|
78
|
+
ram?: number | undefined;
|
|
79
|
+
timeout?: number | undefined;
|
|
80
|
+
cpu?: number | undefined;
|
|
81
|
+
}>>;
|
|
35
82
|
queue: z.ZodOptional<z.ZodObject<{
|
|
36
|
-
type: z.ZodOptional<z.ZodEnum<
|
|
37
|
-
standard: "standard";
|
|
38
|
-
fifo: "fifo";
|
|
39
|
-
}>>;
|
|
83
|
+
type: z.ZodOptional<z.ZodEnum<["standard", "fifo"]>>;
|
|
40
84
|
visibilityTimeout: z.ZodOptional<z.ZodNumber>;
|
|
41
85
|
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
42
86
|
delaySeconds: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
|
|
43
|
-
}, z.
|
|
44
|
-
|
|
87
|
+
}, "strip", z.ZodTypeAny, {
|
|
88
|
+
type?: "standard" | "fifo" | undefined;
|
|
89
|
+
visibilityTimeout?: number | undefined;
|
|
90
|
+
maxRetries?: number | undefined;
|
|
91
|
+
delaySeconds?: number | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
type?: "standard" | "fifo" | undefined;
|
|
94
|
+
visibilityTimeout?: number | undefined;
|
|
95
|
+
maxRetries?: number | undefined;
|
|
96
|
+
delaySeconds?: number | undefined;
|
|
97
|
+
}>>;
|
|
98
|
+
}, "strip", z.ZodTypeAny, {
|
|
99
|
+
handler?: {
|
|
100
|
+
ram?: number | undefined;
|
|
101
|
+
timeout?: number | undefined;
|
|
102
|
+
cpu?: number | undefined;
|
|
103
|
+
} | undefined;
|
|
104
|
+
queue?: {
|
|
105
|
+
type?: "standard" | "fifo" | undefined;
|
|
106
|
+
visibilityTimeout?: number | undefined;
|
|
107
|
+
maxRetries?: number | undefined;
|
|
108
|
+
delaySeconds?: number | undefined;
|
|
109
|
+
} | undefined;
|
|
110
|
+
}, {
|
|
111
|
+
handler?: {
|
|
112
|
+
ram?: number | undefined;
|
|
113
|
+
timeout?: number | undefined;
|
|
114
|
+
cpu?: number | undefined;
|
|
115
|
+
} | undefined;
|
|
116
|
+
queue?: {
|
|
117
|
+
type?: "standard" | "fifo" | undefined;
|
|
118
|
+
visibilityTimeout?: number | undefined;
|
|
119
|
+
maxRetries?: number | undefined;
|
|
120
|
+
delaySeconds?: number | undefined;
|
|
121
|
+
} | undefined;
|
|
122
|
+
}>, {
|
|
123
|
+
handler?: {
|
|
124
|
+
ram?: number | undefined;
|
|
125
|
+
timeout?: number | undefined;
|
|
126
|
+
cpu?: number | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
queue?: {
|
|
129
|
+
type?: "standard" | "fifo" | undefined;
|
|
130
|
+
visibilityTimeout?: number | undefined;
|
|
131
|
+
maxRetries?: number | undefined;
|
|
132
|
+
delaySeconds?: number | undefined;
|
|
133
|
+
} | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
handler?: {
|
|
136
|
+
ram?: number | undefined;
|
|
137
|
+
timeout?: number | undefined;
|
|
138
|
+
cpu?: number | undefined;
|
|
139
|
+
} | undefined;
|
|
140
|
+
queue?: {
|
|
141
|
+
type?: "standard" | "fifo" | undefined;
|
|
142
|
+
visibilityTimeout?: number | undefined;
|
|
143
|
+
maxRetries?: number | undefined;
|
|
144
|
+
delaySeconds?: number | undefined;
|
|
145
|
+
} | undefined;
|
|
146
|
+
}>;
|
|
45
147
|
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/infrastructure-validator/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAA;AAEV,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAevD,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBxD;AAED,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/infrastructure-validator/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAA;AAEV,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAevD,CAAA;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBxD;AAED,eAAO,MAAM,iBAAiB;;;;;;;;;;;;EAU5B,CAAA;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;EAexB,CAAA;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;EAStB,CAAA;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAe7B,CAAA"}
|
|
@@ -11,7 +11,7 @@ const validateQueueConfig = (queueConfig) => {
|
|
|
11
11
|
}
|
|
12
12
|
catch (error) {
|
|
13
13
|
if (error instanceof zod_1.z.ZodError) {
|
|
14
|
-
const errors = error.
|
|
14
|
+
const errors = error.errors.map((err) => ({
|
|
15
15
|
path: err.path.length > 0 ? err.path.join('.') : 'queue',
|
|
16
16
|
message: err.message,
|
|
17
17
|
}));
|
|
@@ -39,7 +39,7 @@ const validateInfrastructureConfig = (infrastructureConfig) => {
|
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
41
41
|
if (error instanceof zod_1.z.ZodError) {
|
|
42
|
-
const errors = error.
|
|
42
|
+
const errors = error.errors.map((err) => ({
|
|
43
43
|
path: err.path.length > 0 ? err.path.join('.') : 'infrastructure',
|
|
44
44
|
message: err.message,
|
|
45
45
|
}));
|
|
@@ -4,42 +4,37 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const node_path_1 = __importDefault(require("node:path"));
|
|
7
|
-
const
|
|
7
|
+
const zod_to_json_schema_1 = __importDefault(require("zod-to-json-schema"));
|
|
8
|
+
// Add ts-node registration before dynamic imports
|
|
8
9
|
require('ts-node').register({
|
|
9
10
|
transpileOnly: true,
|
|
10
11
|
compilerOptions: { module: 'commonjs' },
|
|
11
12
|
});
|
|
13
|
+
function isZodSchema(value) {
|
|
14
|
+
return Boolean(value && typeof value.safeParse === 'function' && value._def);
|
|
15
|
+
}
|
|
12
16
|
async function getConfig(filePath) {
|
|
13
17
|
try {
|
|
14
18
|
const module = require(node_path_1.default.resolve(filePath));
|
|
19
|
+
// Check if the specified function exists in the module
|
|
15
20
|
if (!module.config) {
|
|
16
21
|
throw new Error(`Config not found in module ${filePath}`);
|
|
17
22
|
}
|
|
18
|
-
if (module.config.input) {
|
|
19
|
-
|
|
20
|
-
if (converted) {
|
|
21
|
-
module.config.input = converted;
|
|
22
|
-
}
|
|
23
|
+
if (isZodSchema(module.config.input)) {
|
|
24
|
+
module.config.input = (0, zod_to_json_schema_1.default)(module.config.input, { $refStrategy: 'none' });
|
|
23
25
|
}
|
|
24
|
-
if (module.config.bodySchema) {
|
|
25
|
-
|
|
26
|
-
if (converted) {
|
|
27
|
-
module.config.bodySchema = converted;
|
|
28
|
-
}
|
|
26
|
+
else if (isZodSchema(module.config.bodySchema)) {
|
|
27
|
+
module.config.bodySchema = (0, zod_to_json_schema_1.default)(module.config.bodySchema, { $refStrategy: 'none' });
|
|
29
28
|
}
|
|
30
29
|
if (module.config.responseSchema) {
|
|
31
30
|
for (const [status, schema] of Object.entries(module.config.responseSchema)) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
module.config.responseSchema[status] = converted;
|
|
31
|
+
if (isZodSchema(schema)) {
|
|
32
|
+
module.config.responseSchema[status] = (0, zod_to_json_schema_1.default)(schema, { $refStrategy: 'none' });
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
|
-
if (module.config.schema) {
|
|
39
|
-
|
|
40
|
-
if (converted) {
|
|
41
|
-
module.config.schema = converted;
|
|
42
|
-
}
|
|
36
|
+
if (isZodSchema(module.config.schema)) {
|
|
37
|
+
module.config.schema = (0, zod_to_json_schema_1.default)(module.config.schema, { $refStrategy: 'none' });
|
|
43
38
|
}
|
|
44
39
|
process.send?.(module.config);
|
|
45
40
|
process.exit(0);
|
|
@@ -5,7 +5,7 @@ const zod_1 = require("zod");
|
|
|
5
5
|
const schemas_1 = require("./infrastructure-validator/schemas");
|
|
6
6
|
const objectSchema = zod_1.z.object({
|
|
7
7
|
type: zod_1.z.literal('object'),
|
|
8
|
-
properties: zod_1.z.record(zod_1.z.
|
|
8
|
+
properties: zod_1.z.record(zod_1.z.any()),
|
|
9
9
|
required: zod_1.z.array(zod_1.z.string()).optional(),
|
|
10
10
|
additionalProperties: zod_1.z.boolean().optional(),
|
|
11
11
|
description: zod_1.z.string().optional(),
|
|
@@ -121,8 +121,8 @@ const validateStep = (step) => {
|
|
|
121
121
|
if (error instanceof zod_1.z.ZodError) {
|
|
122
122
|
return {
|
|
123
123
|
success: false,
|
|
124
|
-
error: error.
|
|
125
|
-
errors: error.
|
|
124
|
+
error: error.errors.map((err) => err.message).join(', '),
|
|
125
|
+
errors: error.errors.map((err) => ({ path: err.path.join('.'), message: err.message })),
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
// Handle unexpected errors
|
|
@@ -12,7 +12,7 @@ exports.config = {
|
|
|
12
12
|
flows: ['_system'],
|
|
13
13
|
bodySchema: zod_1.z.object({
|
|
14
14
|
topic: zod_1.z.string(),
|
|
15
|
-
data: zod_1.z.record(zod_1.z.
|
|
15
|
+
data: zod_1.z.record(zod_1.z.unknown()),
|
|
16
16
|
}),
|
|
17
17
|
};
|
|
18
18
|
const handler = async (req, { emit, logger }) => {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type
|
|
2
|
-
export declare const generateTypeFromSchema: (schema:
|
|
1
|
+
import { type JsonSchema } from './schema.types';
|
|
2
|
+
export declare const generateTypeFromSchema: (schema: JsonSchema) => string;
|
|
3
3
|
//# sourceMappingURL=generate-type-from-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-type-from-schema.d.ts","sourceRoot":"","sources":["../../../src/types/generate-type-from-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"generate-type-from-schema.d.ts","sourceRoot":"","sources":["../../../src/types/generate-type-from-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEzD,eAAO,MAAM,sBAAsB,GAAI,QAAQ,UAAU,KAAG,MA6C3D,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../../src/types/generate-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"generate-types.d.ts","sourceRoot":"","sources":["../../../src/types/generate-types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,KAAK,EAAQ,IAAI,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAM7C,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAAA;AACvE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAExC,eAAO,MAAM,mBAAmB,GAAI,UAAU,WAAW,EAAE,SAAS,UAAU,KAAG,MAwBhF,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAI,OAAO,IAAI,EAAE,EAAE,SAAS,OAAO,KAAG,WAsFxE,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAG,UAO1E,CAAA"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateTypesFromStreams = exports.generateTypesFromSteps = exports.generateTypesString = void 0;
|
|
4
4
|
const guards_1 = require("../guards");
|
|
5
|
-
const schema_utils_1 = require("../schema-utils");
|
|
6
5
|
const generate_type_from_schema_1 = require("./generate-type-from-schema");
|
|
7
6
|
const generate_types_from_response_1 = require("./generate-types-from-response");
|
|
8
7
|
const merge_schemas_1 = require("./merge-schemas");
|
|
@@ -58,9 +57,7 @@ const generateTypesFromSteps = (steps, printer) => {
|
|
|
58
57
|
}
|
|
59
58
|
try {
|
|
60
59
|
const input = step.config.input;
|
|
61
|
-
const schema = existingSchema
|
|
62
|
-
? (0, merge_schemas_1.mergeSchemas)(existingSchema, input)
|
|
63
|
-
: ((0, schema_utils_1.schemaToJsonSchema)(input) ?? input);
|
|
60
|
+
const schema = existingSchema ? (0, merge_schemas_1.mergeSchemas)(existingSchema, input) : input;
|
|
64
61
|
topics[topic] = (0, generate_type_from_schema_1.generateTypeFromSchema)(schema);
|
|
65
62
|
topicsSchemas[topic] = schema;
|
|
66
63
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type SchemaInput } from '../schema-utils';
|
|
2
1
|
import { type JsonSchema } from './schema.types';
|
|
3
2
|
export declare const isCompatible: (schema: JsonSchema, otherSchema: JsonSchema) => boolean;
|
|
4
|
-
export declare const mergeSchemas: (schema:
|
|
3
|
+
export declare const mergeSchemas: (schema: JsonSchema, otherSchema: JsonSchema) => JsonSchema;
|
|
5
4
|
//# sourceMappingURL=merge-schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-schemas.d.ts","sourceRoot":"","sources":["../../../src/types/merge-schemas.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"merge-schemas.d.ts","sourceRoot":"","sources":["../../../src/types/merge-schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,UAAU,EAAwC,MAAM,gBAAgB,CAAA;AAE/F,eAAO,MAAM,YAAY,GAAI,QAAQ,UAAU,EAAE,aAAa,UAAU,KAAG,OAgC1E,CAAA;AAED,eAAO,MAAM,YAAY,GAAI,QAAQ,UAAU,EAAE,aAAa,UAAU,KAAG,UAgD1E,CAAA"}
|
|
@@ -1,45 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.mergeSchemas = exports.isCompatible = void 0;
|
|
37
|
-
const z = __importStar(require("zod"));
|
|
38
|
-
const schema_utils_1 = require("../schema-utils");
|
|
39
4
|
const schema_types_1 = require("./schema.types");
|
|
40
|
-
const isJsonSchema = (value) => {
|
|
41
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value) && typeof value !== 'boolean';
|
|
42
|
-
};
|
|
43
5
|
const isCompatible = (schema, otherSchema) => {
|
|
44
6
|
if ((0, schema_types_1.isAnyOf)(schema)) {
|
|
45
7
|
return schema.anyOf.every((item) => (0, exports.isCompatible)(item, otherSchema));
|
|
@@ -48,136 +10,66 @@ const isCompatible = (schema, otherSchema) => {
|
|
|
48
10
|
return otherSchema.anyOf.every((item) => (0, exports.isCompatible)(schema, item));
|
|
49
11
|
}
|
|
50
12
|
if (schema.type !== otherSchema.type) {
|
|
51
|
-
return false;
|
|
13
|
+
return false; // different types
|
|
52
14
|
}
|
|
53
15
|
if (schema.type === 'array' && otherSchema.type === 'array') {
|
|
54
|
-
|
|
55
|
-
return schema.items === otherSchema.items;
|
|
56
|
-
}
|
|
57
|
-
if (Array.isArray(schema.items) || Array.isArray(otherSchema.items)) {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
if (isJsonSchema(schema.items) && isJsonSchema(otherSchema.items)) {
|
|
61
|
-
return (0, exports.isCompatible)(schema.items, otherSchema.items);
|
|
62
|
-
}
|
|
63
|
-
return schema.items === otherSchema.items;
|
|
16
|
+
return (0, exports.isCompatible)(schema.items, otherSchema.items);
|
|
64
17
|
}
|
|
65
18
|
if (schema.type === 'object' && otherSchema.type === 'object') {
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
if (!schemaProps || !otherSchemaProps) {
|
|
69
|
-
return schemaProps === otherSchemaProps;
|
|
70
|
-
}
|
|
71
|
-
const keysFromSchema = Object.keys(schemaProps);
|
|
72
|
-
const keysFromOtherSchema = Object.keys(otherSchemaProps);
|
|
19
|
+
const keysFromSchema = Object.keys(schema.properties);
|
|
20
|
+
const keysFromOtherSchema = Object.keys(otherSchema.properties);
|
|
73
21
|
const commonKeys = keysFromSchema.filter((key) => keysFromOtherSchema.includes(key));
|
|
74
22
|
if (schema.required?.some((key) => !keysFromOtherSchema.includes(key))) {
|
|
75
|
-
return false;
|
|
23
|
+
return false; // some required keys are not present in the other schema
|
|
76
24
|
}
|
|
77
25
|
else if (otherSchema.required?.some((key) => !keysFromSchema.includes(key))) {
|
|
78
|
-
return false;
|
|
26
|
+
return false; // some required keys are not present in the schema
|
|
79
27
|
}
|
|
80
28
|
if (commonKeys.length > 0) {
|
|
81
|
-
return commonKeys.every((key) =>
|
|
82
|
-
const prop1 = schemaProps[key];
|
|
83
|
-
const prop2 = otherSchemaProps[key];
|
|
84
|
-
if (isJsonSchema(prop1) && isJsonSchema(prop2)) {
|
|
85
|
-
return (0, exports.isCompatible)(prop1, prop2);
|
|
86
|
-
}
|
|
87
|
-
return prop1 === prop2;
|
|
88
|
-
});
|
|
29
|
+
return commonKeys.every((key) => (0, exports.isCompatible)(schema.properties[key], otherSchema.properties[key]));
|
|
89
30
|
}
|
|
90
31
|
}
|
|
91
32
|
return true;
|
|
92
33
|
};
|
|
93
34
|
exports.isCompatible = isCompatible;
|
|
94
|
-
const mergeZodSchemas = (schema, otherSchema) => {
|
|
95
|
-
try {
|
|
96
|
-
return z.intersection(schema, otherSchema);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
throw new schema_types_1.JsonSchemaError(`Cannot merge Zod schemas: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
35
|
const mergeSchemas = (schema, otherSchema) => {
|
|
103
|
-
if ((0,
|
|
104
|
-
const mergedZodSchema = mergeZodSchemas(schema, otherSchema);
|
|
105
|
-
const jsonSchema = (0, schema_utils_1.schemaToJsonSchema)(mergedZodSchema);
|
|
106
|
-
if (!jsonSchema) {
|
|
107
|
-
throw new schema_types_1.JsonSchemaError('Failed to convert merged Zod schema to JSON Schema');
|
|
108
|
-
}
|
|
109
|
-
return jsonSchema;
|
|
110
|
-
}
|
|
111
|
-
const schemaJsonResult = (0, schema_utils_1.schemaToJsonSchema)(schema);
|
|
112
|
-
const otherSchemaJsonResult = (0, schema_utils_1.schemaToJsonSchema)(otherSchema);
|
|
113
|
-
if (!schemaJsonResult || !otherSchemaJsonResult) {
|
|
114
|
-
throw new schema_types_1.JsonSchemaError('Cannot merge schemas: failed to convert to JSON Schema');
|
|
115
|
-
}
|
|
116
|
-
const schemaJson = schemaJsonResult;
|
|
117
|
-
const otherSchemaJson = otherSchemaJsonResult;
|
|
118
|
-
if (!(0, exports.isCompatible)(schemaJson, otherSchemaJson)) {
|
|
36
|
+
if (!(0, exports.isCompatible)(schema, otherSchema)) {
|
|
119
37
|
throw new schema_types_1.JsonSchemaError('Cannot merge schemas of different types');
|
|
120
38
|
}
|
|
121
|
-
if ((0, schema_types_1.isAnyOf)(
|
|
39
|
+
if ((0, schema_types_1.isAnyOf)(schema)) {
|
|
122
40
|
return {
|
|
123
|
-
anyOf:
|
|
41
|
+
anyOf: schema.anyOf.map((item) => (0, exports.mergeSchemas)(item, otherSchema)),
|
|
124
42
|
};
|
|
125
43
|
}
|
|
126
|
-
else if ((0, schema_types_1.isAnyOf)(
|
|
44
|
+
else if ((0, schema_types_1.isAnyOf)(otherSchema)) {
|
|
127
45
|
return {
|
|
128
|
-
anyOf:
|
|
46
|
+
anyOf: otherSchema.anyOf.map((item) => (0, exports.mergeSchemas)(schema, item)),
|
|
129
47
|
};
|
|
130
48
|
}
|
|
131
|
-
if (
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
throw new schema_types_1.JsonSchemaError('Cannot merge object schemas without properties');
|
|
136
|
-
}
|
|
137
|
-
const mergedProperties = { ...schemaProps, ...otherSchemaProps };
|
|
138
|
-
const otherSchemaKeys = Object.keys(otherSchemaProps).reduce((acc, key) => {
|
|
139
|
-
acc[key] = true;
|
|
140
|
-
return acc;
|
|
141
|
-
}, {});
|
|
142
|
-
for (const key in schemaProps) {
|
|
49
|
+
if (schema.type === 'object' && otherSchema.type === 'object') {
|
|
50
|
+
const mergedProperties = { ...schema.properties, ...otherSchema.properties };
|
|
51
|
+
const otherSchemaKeys = Object.keys(otherSchema.properties).reduce((acc, key) => ({ ...acc, [key]: true }), {});
|
|
52
|
+
for (const key in schema.properties) {
|
|
143
53
|
if (otherSchemaKeys[key]) {
|
|
144
|
-
|
|
145
|
-
const prop2 = otherSchemaProps[key];
|
|
146
|
-
if (isJsonSchema(prop1) && isJsonSchema(prop2)) {
|
|
147
|
-
mergedProperties[key] = (0, exports.mergeSchemas)(prop1, prop2);
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
mergedProperties[key] = prop2;
|
|
151
|
-
}
|
|
54
|
+
mergedProperties[key] = (0, exports.mergeSchemas)(schema.properties[key], otherSchema.properties[key]);
|
|
152
55
|
}
|
|
153
56
|
}
|
|
154
|
-
const
|
|
155
|
-
const otherSchemaRequired = otherSchemaJson.required;
|
|
156
|
-
const mergedRequired = new Set([...(schemaRequired ?? []), ...(otherSchemaRequired ?? [])]);
|
|
57
|
+
const mergedRequired = new Set([...(schema.required ?? []), ...(otherSchema.required ?? [])]);
|
|
157
58
|
return {
|
|
158
59
|
type: 'object',
|
|
159
60
|
properties: mergedProperties,
|
|
160
61
|
required: Array.from(mergedRequired),
|
|
161
62
|
};
|
|
162
63
|
}
|
|
163
|
-
if (
|
|
164
|
-
if (!schemaJson.items || !otherSchemaJson.items) {
|
|
165
|
-
throw new schema_types_1.JsonSchemaError('Cannot merge array schemas without items');
|
|
166
|
-
}
|
|
167
|
-
if (Array.isArray(schemaJson.items) || Array.isArray(otherSchemaJson.items)) {
|
|
168
|
-
throw new schema_types_1.JsonSchemaError('Cannot merge array schemas with array items');
|
|
169
|
-
}
|
|
170
|
-
if (!isJsonSchema(schemaJson.items) || !isJsonSchema(otherSchemaJson.items)) {
|
|
171
|
-
throw new schema_types_1.JsonSchemaError('Cannot merge array schemas with non-object items');
|
|
172
|
-
}
|
|
64
|
+
if (schema.type === 'array' && otherSchema.type === 'array') {
|
|
173
65
|
return {
|
|
174
66
|
type: 'array',
|
|
175
|
-
items: (0, exports.mergeSchemas)(
|
|
67
|
+
items: (0, exports.mergeSchemas)(schema.items, otherSchema.items),
|
|
176
68
|
};
|
|
177
69
|
}
|
|
178
70
|
return {
|
|
179
|
-
type:
|
|
180
|
-
description:
|
|
71
|
+
type: schema.type,
|
|
72
|
+
description: schema.description ?? otherSchema.description,
|
|
181
73
|
};
|
|
182
74
|
};
|
|
183
75
|
exports.mergeSchemas = mergeSchemas;
|
|
@@ -1,9 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
export type
|
|
1
|
+
export type JsonSchemaType = 'number' | 'boolean';
|
|
2
|
+
export type JsonArray = {
|
|
3
|
+
type: 'array';
|
|
4
|
+
description?: string;
|
|
5
|
+
items: JsonSchema;
|
|
6
|
+
};
|
|
7
|
+
export type JsonObject = {
|
|
8
|
+
type: 'object';
|
|
9
|
+
description?: string;
|
|
10
|
+
properties: Record<string, JsonSchema>;
|
|
11
|
+
required?: string[];
|
|
12
|
+
additionalProperties?: JsonSchema;
|
|
13
|
+
};
|
|
14
|
+
export type JsonString = {
|
|
15
|
+
type: 'string';
|
|
16
|
+
description?: string;
|
|
17
|
+
enum?: string[];
|
|
18
|
+
};
|
|
19
|
+
export type JsonAnyOf = {
|
|
20
|
+
anyOf: JsonSchema[];
|
|
21
|
+
};
|
|
22
|
+
export type JsonProperty = {
|
|
23
|
+
type: JsonSchemaType;
|
|
24
|
+
description?: string;
|
|
25
|
+
};
|
|
26
|
+
export type JsonSchema = JsonArray | JsonObject | JsonString | JsonProperty | JsonAnyOf;
|
|
3
27
|
export declare class JsonSchemaError extends Error {
|
|
4
28
|
constructor(message: string);
|
|
5
29
|
}
|
|
6
|
-
export declare const isAnyOf: (schema: JsonSchema) => schema is
|
|
7
|
-
anyOf: JSONSchema.BaseSchema[];
|
|
8
|
-
};
|
|
30
|
+
export declare const isAnyOf: (schema: JsonSchema) => schema is JsonAnyOf;
|
|
9
31
|
//# sourceMappingURL=schema.types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.types.d.ts","sourceRoot":"","sources":["../../../src/types/schema.types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"schema.types.d.ts","sourceRoot":"","sources":["../../../src/types/schema.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEjD,MAAM,MAAM,SAAS,GAAG;IACtB,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,UAAU,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IACtC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,oBAAoB,CAAC,EAAE,UAAU,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,QAAQ,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,cAAc,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAAA;AAEvF,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,eAAO,MAAM,OAAO,GAAI,QAAQ,UAAU,KAAG,MAAM,IAAI,SAEtD,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import type { ZodObject } from 'zod';
|
|
1
2
|
import type { StreamFactory } from './streams/stream-factory';
|
|
2
|
-
import type { StepSchemaInput } from './types';
|
|
3
3
|
export interface StreamConfig {
|
|
4
4
|
name: string;
|
|
5
|
-
schema:
|
|
5
|
+
schema: ZodObject<any>;
|
|
6
6
|
baseConfig: {
|
|
7
7
|
storageType: 'default';
|
|
8
8
|
} | {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types-stream.d.ts","sourceRoot":"","sources":["../../src/types-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types-stream.d.ts","sourceRoot":"","sources":["../../src/types-stream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAE7D,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,CAAA;IACtB,UAAU,EAAE;QAAE,WAAW,EAAE,SAAS,CAAA;KAAE,GAAG;QAAE,WAAW,EAAE,QAAQ,CAAC;QAAC,OAAO,EAAE,MAAM,WAAW,CAAC,GAAG,CAAC,CAAA;KAAE,CAAA;CACpG;AAED,MAAM,MAAM,uBAAuB,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AACtE,MAAM,MAAM,gBAAgB,CAAC,KAAK,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAA;AAEnE,MAAM,MAAM,cAAc,CAAC,KAAK,GAAG,OAAO,IAAI,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAA;AAEpE,MAAM,MAAM,MAAM,CAAC,OAAO,SAAS,YAAY,GAAG,YAAY,IAAI;IAChE,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;CAChC,CAAA;AAED,MAAM,WAAW,WAAW,CAAC,KAAK;IAChC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;IACvE,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAA;IAC7E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;IAC1E,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;IAE3D,IAAI,CAAC,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACrF"}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { ZodArray, ZodObject } from 'zod';
|
|
2
|
-
import type { StandardSchemaV1 } from 'zod/v4/core/standard-schema.cjs';
|
|
1
|
+
import type { ZodAny, ZodArray, ZodObject, z } from 'zod';
|
|
3
2
|
import type { Logger } from './logger';
|
|
4
3
|
import type { Tracer } from './observability';
|
|
5
|
-
import type { JsonSchema } from './types/schema.types';
|
|
6
4
|
export * from './types/app-config-types';
|
|
7
5
|
export type ZodInput = ZodObject<any> | ZodArray<any>;
|
|
8
|
-
export type StepSchemaInput = StandardSchemaV1 | ZodInput | JsonSchema;
|
|
9
6
|
export type InternalStateManager = {
|
|
10
7
|
get<T>(groupId: string, key: string): Promise<T | null>;
|
|
11
8
|
set<T>(groupId: string, key: string, value: T): Promise<T>;
|
|
@@ -57,7 +54,7 @@ export type EventConfig = {
|
|
|
57
54
|
emits: Emit[];
|
|
58
55
|
virtualEmits?: Emit[];
|
|
59
56
|
virtualSubscribes?: string[];
|
|
60
|
-
input
|
|
57
|
+
input: ZodInput;
|
|
61
58
|
flows?: string[];
|
|
62
59
|
/**
|
|
63
60
|
* Files to include in the step bundle.
|
|
@@ -91,8 +88,8 @@ export interface ApiRouteConfig {
|
|
|
91
88
|
virtualSubscribes?: string[];
|
|
92
89
|
flows?: string[];
|
|
93
90
|
middleware?: ApiMiddleware<any, any, any>[];
|
|
94
|
-
bodySchema?:
|
|
95
|
-
responseSchema?: Record<number,
|
|
91
|
+
bodySchema?: ZodInput;
|
|
92
|
+
responseSchema?: Record<number, ZodInput | ZodAny>;
|
|
96
93
|
queryParams?: QueryParam[];
|
|
97
94
|
/**
|
|
98
95
|
* Files to include in the step bundle.
|
|
@@ -131,7 +128,7 @@ export type CronHandler<TEmitData = never> = (ctx: FlowContext<TEmitData>) => Pr
|
|
|
131
128
|
/**
|
|
132
129
|
* @deprecated Use `Handlers` instead.
|
|
133
130
|
*/
|
|
134
|
-
export type StepHandler<T> = T extends EventConfig ? EventHandler<
|
|
131
|
+
export type StepHandler<T> = T extends EventConfig ? EventHandler<z.infer<T['input']>, {
|
|
135
132
|
topic: string;
|
|
136
133
|
data: any;
|
|
137
134
|
}> : T extends ApiRouteConfig ? ApiRouteHandler<any, ApiResponse<number, any>, {
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAi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AI,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"validate-event-input.d.ts","sourceRoot":"","sources":["../../src/validate-event-input.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAIvD,eAAO,MAAM,kBAAkB,GAAI,MAAM,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,KAAK,EAAE,OAAO,GAAG,SAyEnF,CAAA"}
|
|
@@ -5,9 +5,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateEventInput = void 0;
|
|
7
7
|
const ajv_1 = __importDefault(require("ajv"));
|
|
8
|
+
const zod_to_json_schema_1 = require("zod-to-json-schema");
|
|
8
9
|
const logger_1 = require("./logger");
|
|
9
10
|
const printer_1 = require("./printer");
|
|
10
|
-
const schema_utils_1 = require("./schema-utils");
|
|
11
11
|
const ajv = new ajv_1.default({ allErrors: true, strict: false });
|
|
12
12
|
const validateEventInput = (step, event, motia) => {
|
|
13
13
|
const { data } = event;
|
|
@@ -22,8 +22,10 @@ const validateEventInput = (step, event, motia) => {
|
|
|
22
22
|
let compiledSchema;
|
|
23
23
|
const inputSchema = step.config.input;
|
|
24
24
|
try {
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
if (inputSchema && typeof inputSchema === 'object' && 'safeParse' in inputSchema) {
|
|
26
|
+
compiledSchema = (0, zod_to_json_schema_1.zodToJsonSchema)(inputSchema, { target: 'jsonSchema7' });
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
27
29
|
compiledSchema = inputSchema;
|
|
28
30
|
}
|
|
29
31
|
}
|
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.9.4-beta.151-
|
|
5
|
+
"version": "0.9.4-beta.151-307192",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@amplitude/analytics-node": "^1.3.8",
|
|
8
8
|
"ajv": "^8.17.1",
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
"tsconfig-paths": "^4.2.0",
|
|
16
16
|
"uuid": "^11.1.0",
|
|
17
17
|
"ws": "^8.18.2",
|
|
18
|
-
"zod": "^
|
|
18
|
+
"zod": "^3.24.1",
|
|
19
|
+
"zod-to-json-schema": "^3.24.5"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
22
|
"@types/body-parser": "^1.19.5",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as z from 'zod';
|
|
2
|
-
import type { StandardSchemaV1 } from 'zod/v4/core/standard-schema.cjs';
|
|
3
|
-
import type { JsonSchema } from './types/schema.types';
|
|
4
|
-
export type SchemaInput = StandardSchemaV1 | z.ZodType | JsonSchema | null | undefined;
|
|
5
|
-
export declare function isStandardSchema(value: unknown): value is StandardSchemaV1;
|
|
6
|
-
export declare function isZodSchema(value: unknown): value is z.ZodType;
|
|
7
|
-
export declare function isJsonSchema(value: unknown): value is JsonSchema;
|
|
8
|
-
export declare function schemaToJsonSchema(schema: SchemaInput): JsonSchema | null;
|
|
9
|
-
//# sourceMappingURL=schema-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-utils.d.ts","sourceRoot":"","sources":["../../src/schema-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AACvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AAStD,MAAM,MAAM,WAAW,GAAG,gBAAgB,GAAG,CAAC,CAAC,OAAO,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAA;AAEtF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAQ1E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,OAAO,CAS9D;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAMhE;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,GAAG,IAAI,CAqBzE"}
|
package/dist/src/schema-utils.js
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.isStandardSchema = isStandardSchema;
|
|
37
|
-
exports.isZodSchema = isZodSchema;
|
|
38
|
-
exports.isJsonSchema = isJsonSchema;
|
|
39
|
-
exports.schemaToJsonSchema = schemaToJsonSchema;
|
|
40
|
-
const z = __importStar(require("zod"));
|
|
41
|
-
function isStandardSchema(value) {
|
|
42
|
-
if (!value || typeof value !== 'object') {
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
const schema = value;
|
|
46
|
-
return '~standard' in schema && schema['~standard'] !== null && typeof schema['~standard'] === 'object';
|
|
47
|
-
}
|
|
48
|
-
function isZodSchema(value) {
|
|
49
|
-
return Boolean(value &&
|
|
50
|
-
typeof value === 'object' &&
|
|
51
|
-
typeof value.safeParse === 'function' &&
|
|
52
|
-
'_zod' in value &&
|
|
53
|
-
typeof value._zod === 'object' &&
|
|
54
|
-
'def' in value._zod);
|
|
55
|
-
}
|
|
56
|
-
function isJsonSchema(value) {
|
|
57
|
-
if (!value || typeof value !== 'object') {
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
const schema = value;
|
|
61
|
-
return typeof schema.type === 'string' || Array.isArray(schema.type) || 'properties' in schema;
|
|
62
|
-
}
|
|
63
|
-
function schemaToJsonSchema(schema) {
|
|
64
|
-
if (!schema) {
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
67
|
-
if (isZodSchema(schema)) {
|
|
68
|
-
return z.toJSONSchema(schema, { target: 'draft-7' });
|
|
69
|
-
}
|
|
70
|
-
if (isStandardSchema(schema)) {
|
|
71
|
-
if ('toJSON' in schema && typeof schema.toJSON === 'function') {
|
|
72
|
-
return schema.toJSON();
|
|
73
|
-
}
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
if (isJsonSchema(schema)) {
|
|
77
|
-
return schema;
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|