@mettlecast/domain-cli 0.2.17 → 0.2.19
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.
|
@@ -27,13 +27,14 @@ function makeEvalScript(absoluteFilePath) {
|
|
|
27
27
|
const fileUrl = pathToFileURL(absoluteFilePath).href;
|
|
28
28
|
return `
|
|
29
29
|
import { z } from 'zod';
|
|
30
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
30
31
|
import * as mod from ${JSON.stringify(fileUrl)};
|
|
31
32
|
const KINDS = new Set(['api','webhook','subscriber','schedule','job','action','integration','event','domain']);
|
|
32
33
|
function isZod(v) {
|
|
33
34
|
return v && typeof v === 'object' && typeof v.parse === 'function' && typeof v.safeParse === 'function' && v._def !== undefined;
|
|
34
35
|
}
|
|
35
36
|
function toJsonSchema(v) {
|
|
36
|
-
try { return z.toJSONSchema(v); } catch { return { type: 'null' }; }
|
|
37
|
+
try { return z.toJSONSchema ? z.toJSONSchema(v) : zodToJsonSchema(v); } catch { return { type: 'null' }; }
|
|
37
38
|
}
|
|
38
39
|
function strip(obj) {
|
|
39
40
|
const out = {};
|
|
@@ -24,6 +24,7 @@ import { defineApi } from '@mettlecast/domain-runtime';
|
|
|
24
24
|
export const ${camelCase(apiId)} = defineApi({
|
|
25
25
|
id: '${apiId}',
|
|
26
26
|
path: '${tenantPath}/${domainId}/${apiId}',
|
|
27
|
+
method: 'POST',
|
|
27
28
|
tenancy: '${tenancy}',
|
|
28
29
|
versions: {
|
|
29
30
|
v1: {
|
|
@@ -35,6 +36,10 @@ export const ${camelCase(apiId)} = defineApi({
|
|
|
35
36
|
},
|
|
36
37
|
},
|
|
37
38
|
},
|
|
39
|
+
examples: {
|
|
40
|
+
request: {},
|
|
41
|
+
response: { ok: true },
|
|
42
|
+
},
|
|
38
43
|
});
|
|
39
44
|
`;
|
|
40
45
|
}
|
package/package.json
CHANGED
|
@@ -44,13 +44,14 @@ function makeEvalScript(absoluteFilePath: string): string {
|
|
|
44
44
|
const fileUrl = pathToFileURL(absoluteFilePath).href;
|
|
45
45
|
return `
|
|
46
46
|
import { z } from 'zod';
|
|
47
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
47
48
|
import * as mod from ${JSON.stringify(fileUrl)};
|
|
48
49
|
const KINDS = new Set(['api','webhook','subscriber','schedule','job','action','integration','event','domain']);
|
|
49
50
|
function isZod(v) {
|
|
50
51
|
return v && typeof v === 'object' && typeof v.parse === 'function' && typeof v.safeParse === 'function' && v._def !== undefined;
|
|
51
52
|
}
|
|
52
53
|
function toJsonSchema(v) {
|
|
53
|
-
try { return z.toJSONSchema(v); } catch { return { type: 'null' }; }
|
|
54
|
+
try { return z.toJSONSchema ? z.toJSONSchema(v) : zodToJsonSchema(v); } catch { return { type: 'null' }; }
|
|
54
55
|
}
|
|
55
56
|
function strip(obj) {
|
|
56
57
|
const out = {};
|
|
@@ -26,6 +26,7 @@ import { defineApi } from '@mettlecast/domain-runtime';
|
|
|
26
26
|
export const ${camelCase(apiId)} = defineApi({
|
|
27
27
|
id: '${apiId}',
|
|
28
28
|
path: '${tenantPath}/${domainId}/${apiId}',
|
|
29
|
+
method: 'POST',
|
|
29
30
|
tenancy: '${tenancy}',
|
|
30
31
|
versions: {
|
|
31
32
|
v1: {
|
|
@@ -37,6 +38,10 @@ export const ${camelCase(apiId)} = defineApi({
|
|
|
37
38
|
},
|
|
38
39
|
},
|
|
39
40
|
},
|
|
41
|
+
examples: {
|
|
42
|
+
request: {},
|
|
43
|
+
response: { ok: true },
|
|
44
|
+
},
|
|
40
45
|
});
|
|
41
46
|
`;
|
|
42
47
|
}
|