@iyio/protogen-runtime 0.0.1
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/README.md +7 -0
- package/esm/package.json +3 -0
- package/esm/src/index.d.ts +12 -0
- package/esm/src/index.js +13 -0
- package/esm/src/index.js.map +1 -0
- package/esm/src/lib/default-plugins.d.ts +2 -0
- package/esm/src/lib/default-plugins.js +74 -0
- package/esm/src/lib/default-plugins.js.map +1 -0
- package/esm/src/lib/plugins/examplePlugin.d.ts +26 -0
- package/esm/src/lib/plugins/examplePlugin.js +65 -0
- package/esm/src/lib/plugins/examplePlugin.js.map +1 -0
- package/esm/src/lib/plugins/fileReader.d.ts +2 -0
- package/esm/src/lib/plugins/fileReader.js +22 -0
- package/esm/src/lib/plugins/fileReader.js.map +1 -0
- package/esm/src/lib/plugins/fileWriter.d.ts +2 -0
- package/esm/src/lib/plugins/fileWriter.js +57 -0
- package/esm/src/lib/plugins/fileWriter.js.map +1 -0
- package/esm/src/lib/plugins/functionPlugin.d.ts +26 -0
- package/esm/src/lib/plugins/functionPlugin.js +79 -0
- package/esm/src/lib/plugins/functionPlugin.js.map +1 -0
- package/esm/src/lib/plugins/markdownParser.d.ts +2 -0
- package/esm/src/lib/plugins/markdownParser.js +15 -0
- package/esm/src/lib/plugins/markdownParser.js.map +1 -0
- package/esm/src/lib/plugins/reactCompPlugin.d.ts +32 -0
- package/esm/src/lib/plugins/reactCompPlugin.js +167 -0
- package/esm/src/lib/plugins/reactCompPlugin.js.map +1 -0
- package/esm/src/lib/plugins/serverFnPlugin.d.ts +68 -0
- package/esm/src/lib/plugins/serverFnPlugin.js +158 -0
- package/esm/src/lib/plugins/serverFnPlugin.js.map +1 -0
- package/esm/src/lib/plugins/tablePlugin.d.ts +38 -0
- package/esm/src/lib/plugins/tablePlugin.js +176 -0
- package/esm/src/lib/plugins/tablePlugin.js.map +1 -0
- package/esm/src/lib/plugins/tsConfigPathsPlugin.d.ts +14 -0
- package/esm/src/lib/plugins/tsConfigPathsPlugin.js +49 -0
- package/esm/src/lib/plugins/tsConfigPathsPlugin.js.map +1 -0
- package/esm/src/lib/plugins/tsExternalExecutor.d.ts +2 -0
- package/esm/src/lib/plugins/tsExternalExecutor.js +55 -0
- package/esm/src/lib/plugins/tsExternalExecutor.js.map +1 -0
- package/esm/src/lib/plugins/zodPlugin.d.ts +26 -0
- package/esm/src/lib/plugins/zodPlugin.js +330 -0
- package/esm/src/lib/plugins/zodPlugin.js.map +1 -0
- package/esm/src/lib/protogen-cli-entry.d.ts +1 -0
- package/esm/src/lib/protogen-cli-entry.js +6 -0
- package/esm/src/lib/protogen-cli-entry.js.map +1 -0
- package/esm/src/lib/protogen-runtime.d.ts +5 -0
- package/esm/src/lib/protogen-runtime.js +63 -0
- package/esm/src/lib/protogen-runtime.js.map +1 -0
- package/esm/src/lib/runProtogenCliAsync.d.ts +12 -0
- package/esm/src/lib/runProtogenCliAsync.js +99 -0
- package/esm/src/lib/runProtogenCliAsync.js.map +1 -0
- package/esm/src/lib/sharedTsConfig.d.ts +18 -0
- package/esm/src/lib/sharedTsConfig.js +12 -0
- package/esm/src/lib/sharedTsConfig.js.map +1 -0
- package/esm/src/lib/test-plugins/echo-generator.d.ts +1 -0
- package/esm/src/lib/test-plugins/echo-generator.js +12 -0
- package/esm/src/lib/test-plugins/echo-generator.js.map +1 -0
- package/package.json +20 -0
- package/src/index.d.ts +12 -0
- package/src/index.js +16 -0
- package/src/index.js.map +1 -0
- package/src/lib/default-plugins.d.ts +2 -0
- package/src/lib/default-plugins.js +78 -0
- package/src/lib/default-plugins.js.map +1 -0
- package/src/lib/plugins/examplePlugin.d.ts +26 -0
- package/src/lib/plugins/examplePlugin.js +68 -0
- package/src/lib/plugins/examplePlugin.js.map +1 -0
- package/src/lib/plugins/fileReader.d.ts +2 -0
- package/src/lib/plugins/fileReader.js +26 -0
- package/src/lib/plugins/fileReader.js.map +1 -0
- package/src/lib/plugins/fileWriter.d.ts +2 -0
- package/src/lib/plugins/fileWriter.js +61 -0
- package/src/lib/plugins/fileWriter.js.map +1 -0
- package/src/lib/plugins/functionPlugin.d.ts +26 -0
- package/src/lib/plugins/functionPlugin.js +82 -0
- package/src/lib/plugins/functionPlugin.js.map +1 -0
- package/src/lib/plugins/markdownParser.d.ts +2 -0
- package/src/lib/plugins/markdownParser.js +19 -0
- package/src/lib/plugins/markdownParser.js.map +1 -0
- package/src/lib/plugins/reactCompPlugin.d.ts +32 -0
- package/src/lib/plugins/reactCompPlugin.js +170 -0
- package/src/lib/plugins/reactCompPlugin.js.map +1 -0
- package/src/lib/plugins/serverFnPlugin.d.ts +68 -0
- package/src/lib/plugins/serverFnPlugin.js +161 -0
- package/src/lib/plugins/serverFnPlugin.js.map +1 -0
- package/src/lib/plugins/tablePlugin.d.ts +38 -0
- package/src/lib/plugins/tablePlugin.js +179 -0
- package/src/lib/plugins/tablePlugin.js.map +1 -0
- package/src/lib/plugins/tsConfigPathsPlugin.d.ts +14 -0
- package/src/lib/plugins/tsConfigPathsPlugin.js +52 -0
- package/src/lib/plugins/tsConfigPathsPlugin.js.map +1 -0
- package/src/lib/plugins/tsExternalExecutor.d.ts +2 -0
- package/src/lib/plugins/tsExternalExecutor.js +58 -0
- package/src/lib/plugins/tsExternalExecutor.js.map +1 -0
- package/src/lib/plugins/zodPlugin.d.ts +26 -0
- package/src/lib/plugins/zodPlugin.js +333 -0
- package/src/lib/plugins/zodPlugin.js.map +1 -0
- package/src/lib/protogen-cli-entry.d.ts +1 -0
- package/src/lib/protogen-cli-entry.js +8 -0
- package/src/lib/protogen-cli-entry.js.map +1 -0
- package/src/lib/protogen-runtime.d.ts +5 -0
- package/src/lib/protogen-runtime.js +69 -0
- package/src/lib/protogen-runtime.js.map +1 -0
- package/src/lib/runProtogenCliAsync.d.ts +12 -0
- package/src/lib/runProtogenCliAsync.js +103 -0
- package/src/lib/runProtogenCliAsync.js.map +1 -0
- package/src/lib/sharedTsConfig.d.ts +18 -0
- package/src/lib/sharedTsConfig.js +16 -0
- package/src/lib/sharedTsConfig.js.map +1 -0
- package/src/lib/test-plugins/echo-generator.d.ts +1 -0
- package/src/lib/test-plugins/echo-generator.js +14 -0
- package/src/lib/test-plugins/echo-generator.js.map +1 -0
- package/src/package.json +4 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.markdownParser = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const protogen_1 = require("@iyio/protogen");
|
|
6
|
+
const markdownParser = ({ sources, log, nodes }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
7
|
+
const supported = sources.filter(s => s.ext === 'md' || s.contentType === 'text/markdown');
|
|
8
|
+
log(`${supported.length} supported source(s)`);
|
|
9
|
+
for (const source of supported) {
|
|
10
|
+
log(`parse - ${source.input}`);
|
|
11
|
+
const mNodes = (0, protogen_1.protoMarkdownParseNodes)(source.content).rootNodes;
|
|
12
|
+
log(`${mNodes.length} node(s) parsed`);
|
|
13
|
+
for (const node of mNodes) {
|
|
14
|
+
nodes.push(node);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
exports.markdownParser = markdownParser;
|
|
19
|
+
//# sourceMappingURL=markdownParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownParser.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/markdownParser.ts"],"names":[],"mappings":";;;;AAAA,6CAAuE;AAEhE,MAAM,cAAc,GAAC,CAAO,EAC/B,OAAO,EACP,GAAG,EACH,KAAK,EACK,EAAC,EAAE;IAEb,MAAM,SAAS,GAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,GAAG,KAAG,IAAI,IAAG,CAAC,CAAC,WAAW,KAAG,eAAe,CAAC,CAAC;IAElF,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,sBAAsB,CAAC,CAAC;IAG/C,KAAI,MAAM,MAAM,IAAI,SAAS,EAAC;QAE1B,GAAG,CAAC,WAAW,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;QAE/B,MAAM,MAAM,GAAC,IAAA,kCAAuB,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC;QAE/D,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,iBAAiB,CAAC,CAAC;QAEvC,KAAI,MAAM,IAAI,IAAI,MAAM,EAAC;YACrB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SACpB;KACJ;AACL,CAAC,CAAA,CAAA;AAvBY,QAAA,cAAc,kBAuB1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const ReactCompPluginConfig: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* @default .reactPackage
|
|
6
|
+
*/
|
|
7
|
+
reactCompPath: z.ZodOptional<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* @default "react-comp-index.ts"
|
|
10
|
+
*/
|
|
11
|
+
reactCompIndexFilename: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
reactCompUseStyledJsx: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
/**
|
|
17
|
+
* @default "components"
|
|
18
|
+
*/
|
|
19
|
+
reactCompPackage: z.ZodOptional<z.ZodString>;
|
|
20
|
+
}, "strip", z.ZodTypeAny, {
|
|
21
|
+
reactCompPath?: string | undefined;
|
|
22
|
+
reactCompIndexFilename?: string | undefined;
|
|
23
|
+
reactCompUseStyledJsx?: boolean | undefined;
|
|
24
|
+
reactCompPackage?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
reactCompPath?: string | undefined;
|
|
27
|
+
reactCompIndexFilename?: string | undefined;
|
|
28
|
+
reactCompUseStyledJsx?: boolean | undefined;
|
|
29
|
+
reactCompPackage?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const reactCompPlugin: ProtoPipelineConfigurablePlugin<typeof ReactCompPluginConfig>;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reactCompPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@iyio/common");
|
|
6
|
+
const protogen_1 = require("@iyio/protogen");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const supportedTypes = ['comp', 'view', 'screen'];
|
|
9
|
+
const ReactCompPluginConfig = zod_1.z.object({
|
|
10
|
+
/**
|
|
11
|
+
* @default .reactPackage
|
|
12
|
+
*/
|
|
13
|
+
reactCompPath: zod_1.z.string().optional(),
|
|
14
|
+
/**
|
|
15
|
+
* @default "react-comp-index.ts"
|
|
16
|
+
*/
|
|
17
|
+
reactCompIndexFilename: zod_1.z.string().optional(),
|
|
18
|
+
/**
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
reactCompUseStyledJsx: zod_1.z.boolean().optional(),
|
|
22
|
+
/**
|
|
23
|
+
* @default "components"
|
|
24
|
+
*/
|
|
25
|
+
reactCompPackage: zod_1.z.string().optional(),
|
|
26
|
+
});
|
|
27
|
+
exports.reactCompPlugin = {
|
|
28
|
+
configScheme: ReactCompPluginConfig,
|
|
29
|
+
generate: (ctx, config) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
const { log, nodes, outputs, packagePaths, namespace, } = ctx;
|
|
31
|
+
const { reactCompPackage = 'components', reactCompPath, reactCompIndexFilename = 'react-comp-index.ts' } = config;
|
|
32
|
+
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath, { packagePaths, indexFilename: reactCompIndexFilename });
|
|
33
|
+
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
34
|
+
log(`reactPlugin. ${supported.length} supported node(s)`);
|
|
35
|
+
for (const node of supported) {
|
|
36
|
+
log(`component - ${node.name}`);
|
|
37
|
+
yield generateComponentAsync(node, ctx, config);
|
|
38
|
+
}
|
|
39
|
+
if (supported.length) {
|
|
40
|
+
outputs.push({
|
|
41
|
+
path: (0, common_1.joinPaths)(path, reactCompIndexFilename),
|
|
42
|
+
content: '',
|
|
43
|
+
generator: {
|
|
44
|
+
root: path,
|
|
45
|
+
recursive: true,
|
|
46
|
+
generator: protogen_1.protoGenerateTsIndex
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
const generateComponentAsync = (node, { tab, importMap, outputs, namespace, }, { reactCompPackage = 'components', reactCompPath, reactCompUseStyledJsx = false, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
54
|
+
const { path, packageName } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath);
|
|
55
|
+
const imports = [];
|
|
56
|
+
const addImport = (im, pkg) => {
|
|
57
|
+
(0, protogen_1.addTsImport)(im, pkg, imports, importMap);
|
|
58
|
+
};
|
|
59
|
+
const name = node.name;
|
|
60
|
+
const filename = (0, common_1.requireUnrootPath)((_d = (_c = (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a['$filename']) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.trim()) !== null && _d !== void 0 ? _d : name + '.tsx');
|
|
61
|
+
importMap[name] = packageName;
|
|
62
|
+
importMap[name + 'Props'] = packageName;
|
|
63
|
+
const baseLayout = (_e = node.children) === null || _e === void 0 ? void 0 : _e['baseLayout'];
|
|
64
|
+
const baseLayoutType = baseLayout ? getBaseLayoutName(baseLayout.value || 'outer') : null;
|
|
65
|
+
if (baseLayoutType) {
|
|
66
|
+
addImport(baseLayoutType, '@iyio/common');
|
|
67
|
+
addImport('bcn', '@iyio/common');
|
|
68
|
+
}
|
|
69
|
+
let startI;
|
|
70
|
+
const out = [];
|
|
71
|
+
const propsNode = (_f = node.children) === null || _f === void 0 ? void 0 : _f['props'];
|
|
72
|
+
const props = propsNode === null || propsNode === void 0 ? void 0 : propsNode.children;
|
|
73
|
+
if (props) {
|
|
74
|
+
out.push('');
|
|
75
|
+
if (propsNode.comment) {
|
|
76
|
+
out.push(...(0, protogen_1.protoFormatTsComment)(propsNode.comment, '').split('\n'));
|
|
77
|
+
}
|
|
78
|
+
startI = out.length;
|
|
79
|
+
out.push(`export interface ${name}Props`);
|
|
80
|
+
out.push('{');
|
|
81
|
+
for (const name in props) {
|
|
82
|
+
const p = props[name];
|
|
83
|
+
if (p.special || p.isContent) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const type = (0, protogen_1.protoGetTsType)(p.type);
|
|
87
|
+
if (!(0, protogen_1.protoIsTsBuiltType)(type)) {
|
|
88
|
+
addImport(type);
|
|
89
|
+
}
|
|
90
|
+
if (p.comment) {
|
|
91
|
+
out.push(...(0, protogen_1.protoFormatTsComment)(p.comment, tab).split('\n'));
|
|
92
|
+
}
|
|
93
|
+
out.push(`${tab}${name}:${type};`);
|
|
94
|
+
}
|
|
95
|
+
(0, protogen_1.protoLabelOutputLines)(out, 'props', startI);
|
|
96
|
+
out.push('}');
|
|
97
|
+
out.push('');
|
|
98
|
+
}
|
|
99
|
+
if (node.comment) {
|
|
100
|
+
out.push(...(0, protogen_1.protoFormatTsComment)(node.comment, '').split('\n'));
|
|
101
|
+
}
|
|
102
|
+
startI = out.length;
|
|
103
|
+
out.push(`export function ${name}(${props ? '{' : ')'}`);
|
|
104
|
+
(0, protogen_1.protoLabelOutputLines)(out, 'comp', startI);
|
|
105
|
+
if (props) {
|
|
106
|
+
for (const name in props) {
|
|
107
|
+
const p = props[name];
|
|
108
|
+
if (p.special || p.isContent) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const defaultValue = (_h = (_g = p.children) === null || _g === void 0 ? void 0 : _g['default']) === null || _h === void 0 ? void 0 : _h.value;
|
|
112
|
+
out.push(`${tab}${name}${defaultValue ? '=' + defaultValue : ''},`);
|
|
113
|
+
}
|
|
114
|
+
if (baseLayoutType) {
|
|
115
|
+
out.push(`${tab}...props`);
|
|
116
|
+
out.push(`}:${name}Props & ${baseLayoutType}){`);
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
out.push(`}:${name}Props){`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
out.push('{');
|
|
124
|
+
}
|
|
125
|
+
out.push('');
|
|
126
|
+
out.push(`${tab}return (`);
|
|
127
|
+
if (baseLayoutType) {
|
|
128
|
+
out.push(`${tab}${tab}<div className={bcn(props,'${name}')}>`);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
out.push(`${tab}${tab}<div className="${name}">`);
|
|
132
|
+
}
|
|
133
|
+
const bodyTab = `${tab}${tab}${tab}`;
|
|
134
|
+
out.push('');
|
|
135
|
+
out.push(`${bodyTab}${name}`);
|
|
136
|
+
out.push('');
|
|
137
|
+
if (reactCompUseStyledJsx || ((_j = node.children) === null || _j === void 0 ? void 0 : _j['styled-jsx'])) {
|
|
138
|
+
out.push(`${bodyTab}<style global jsx>{\``);
|
|
139
|
+
out.push(`${bodyTab}${tab}.${name}{`);
|
|
140
|
+
out.push(`${bodyTab}${tab}${tab}display:flex;`);
|
|
141
|
+
out.push(`${bodyTab}${tab}${tab}flex-direction:column;`);
|
|
142
|
+
out.push(`${bodyTab}${tab}}`);
|
|
143
|
+
out.push(`${bodyTab}\`}</style>`);
|
|
144
|
+
}
|
|
145
|
+
out.push(`${tab}${tab}</div>`);
|
|
146
|
+
out.push(`${tab})`);
|
|
147
|
+
out.push('}');
|
|
148
|
+
if (imports.length) {
|
|
149
|
+
(0, protogen_1.protoPrependTsImports)(imports, importMap, out);
|
|
150
|
+
}
|
|
151
|
+
outputs.push({
|
|
152
|
+
path: (0, common_1.joinPaths)(path, filename),
|
|
153
|
+
content: out.join('\n'),
|
|
154
|
+
autoMerge: true,
|
|
155
|
+
mergeHandler: protogen_1.protoMergeTsImports
|
|
156
|
+
});
|
|
157
|
+
return name;
|
|
158
|
+
});
|
|
159
|
+
const getBaseLayoutName = (type) => {
|
|
160
|
+
switch (type) {
|
|
161
|
+
case "inner": return 'BaseLayoutInnerProps';
|
|
162
|
+
case "outer-no-flex": return 'BaseLayoutOuterNoFlexProps';
|
|
163
|
+
case "base": return 'BaseLayoutProps';
|
|
164
|
+
case "all": return 'AllBaseLayoutProps';
|
|
165
|
+
case "outer":
|
|
166
|
+
default:
|
|
167
|
+
return 'BaseLayoutOuterProps';
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=reactCompPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactCompPlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/reactCompPlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAA4D;AAC5D,6CAAqR;AACrR,6BAAwB;AAExB,MAAM,cAAc,GAAC,CAAC,MAAM,EAAC,MAAM,EAAC,QAAQ,CAAC,CAAC;AAE9C,MAAM,qBAAqB,GAAC,OAAC,CAAC,MAAM,CACpC;IACI;;OAEG;IACH,aAAa,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAEnC;;OAEG;IACH,sBAAsB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE5C;;OAEG;IACH,qBAAqB,EAAC,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAG5C;;OAEG;IACH,gBAAgB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACz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EAAC;QACd,IAAA,gCAAqB,EAAC,OAAO,EAAC,SAAS,EAAC,GAAG,CAAC,CAAC;KAChD;IAED,OAAO,CAAC,IAAI,CAAC;QACT,IAAI,EAAC,IAAA,kBAAS,EAAC,IAAI,EAAC,QAAQ,CAAC;QAC7B,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,SAAS,EAAC,IAAI;QACd,YAAY,EAAC,8BAAmB;KACnC,CAAC,CAAA;IAEF,OAAO,IAAI,CAAC;AAEhB,CAAC,CAAA,CAAA;AAGD,MAAM,iBAAiB,GAAC,CAAC,IAAW,EAAC,EAAE;IAEnC,QAAO,IAAI,EAAC;QACR,KAAK,OAAO,CAAC,CAAC,OAAO,sBAAsB,CAAC;QAC5C,KAAK,eAAe,CAAC,CAAC,OAAO,4BAA4B,CAAC;QAC1D,KAAK,MAAM,CAAC,CAAC,OAAO,iBAAiB,CAAC;QACtC,KAAK,KAAK,CAAC,CAAC,OAAO,oBAAoB,CAAC;QACxC,KAAK,OAAO,CAAC;QACb;YACI,OAAO,sBAAsB,CAAC;KACrC;AACL,CAAC,CAAA"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const ServerFnPluginConfig: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* @default .serverFnPackage
|
|
6
|
+
*/
|
|
7
|
+
serverFnPath: z.ZodOptional<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* @default "serverFns"
|
|
10
|
+
*/
|
|
11
|
+
serverFnPackage: z.ZodOptional<z.ZodString>;
|
|
12
|
+
/**
|
|
13
|
+
* @default .serverFnClientPackage
|
|
14
|
+
*/
|
|
15
|
+
serverFnClientPath: z.ZodOptional<z.ZodString>;
|
|
16
|
+
/**
|
|
17
|
+
* @default "serverFnsClient"
|
|
18
|
+
*/
|
|
19
|
+
serverFnClientPackage: z.ZodOptional<z.ZodString>;
|
|
20
|
+
/**
|
|
21
|
+
* @default "serverFn-params.ts"
|
|
22
|
+
*/
|
|
23
|
+
serverFnParamsFilename: z.ZodOptional<z.ZodString>;
|
|
24
|
+
/**
|
|
25
|
+
* @default "serverFn-client-index.ts"
|
|
26
|
+
*/
|
|
27
|
+
serverFnClientIndexFilename: z.ZodOptional<z.ZodString>;
|
|
28
|
+
/**
|
|
29
|
+
* @default "serverFnClients.ts"
|
|
30
|
+
*/
|
|
31
|
+
serverFnClientFilename: z.ZodOptional<z.ZodString>;
|
|
32
|
+
/**
|
|
33
|
+
* @default "handler"
|
|
34
|
+
*/
|
|
35
|
+
serverFnHandlerName: z.ZodOptional<z.ZodString>;
|
|
36
|
+
/**
|
|
37
|
+
* @default "@iyio/common"
|
|
38
|
+
*/
|
|
39
|
+
serverFnLibPackage: z.ZodOptional<z.ZodString>;
|
|
40
|
+
/**
|
|
41
|
+
* @default "@iyio/aws-lambda"
|
|
42
|
+
*/
|
|
43
|
+
serverFnLambdaPackage: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, "strip", z.ZodTypeAny, {
|
|
45
|
+
serverFnPath?: string | undefined;
|
|
46
|
+
serverFnPackage?: string | undefined;
|
|
47
|
+
serverFnClientPath?: string | undefined;
|
|
48
|
+
serverFnClientPackage?: string | undefined;
|
|
49
|
+
serverFnParamsFilename?: string | undefined;
|
|
50
|
+
serverFnClientIndexFilename?: string | undefined;
|
|
51
|
+
serverFnClientFilename?: string | undefined;
|
|
52
|
+
serverFnHandlerName?: string | undefined;
|
|
53
|
+
serverFnLibPackage?: string | undefined;
|
|
54
|
+
serverFnLambdaPackage?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
serverFnPath?: string | undefined;
|
|
57
|
+
serverFnPackage?: string | undefined;
|
|
58
|
+
serverFnClientPath?: string | undefined;
|
|
59
|
+
serverFnClientPackage?: string | undefined;
|
|
60
|
+
serverFnParamsFilename?: string | undefined;
|
|
61
|
+
serverFnClientIndexFilename?: string | undefined;
|
|
62
|
+
serverFnClientFilename?: string | undefined;
|
|
63
|
+
serverFnHandlerName?: string | undefined;
|
|
64
|
+
serverFnLibPackage?: string | undefined;
|
|
65
|
+
serverFnLambdaPackage?: string | undefined;
|
|
66
|
+
}>;
|
|
67
|
+
export declare const serverFnPlugin: ProtoPipelineConfigurablePlugin<typeof ServerFnPluginConfig>;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serverFnPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const common_1 = require("@iyio/common");
|
|
6
|
+
const protogen_1 = require("@iyio/protogen");
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const supportedTypes = ['serverFn'];
|
|
9
|
+
const ServerFnPluginConfig = zod_1.z.object({
|
|
10
|
+
/**
|
|
11
|
+
* @default .serverFnPackage
|
|
12
|
+
*/
|
|
13
|
+
serverFnPath: zod_1.z.string().optional(),
|
|
14
|
+
/**
|
|
15
|
+
* @default "serverFns"
|
|
16
|
+
*/
|
|
17
|
+
serverFnPackage: zod_1.z.string().optional(),
|
|
18
|
+
/**
|
|
19
|
+
* @default .serverFnClientPackage
|
|
20
|
+
*/
|
|
21
|
+
serverFnClientPath: zod_1.z.string().optional(),
|
|
22
|
+
/**
|
|
23
|
+
* @default "serverFnsClient"
|
|
24
|
+
*/
|
|
25
|
+
serverFnClientPackage: zod_1.z.string().optional(),
|
|
26
|
+
/**
|
|
27
|
+
* @default "serverFn-params.ts"
|
|
28
|
+
*/
|
|
29
|
+
serverFnParamsFilename: zod_1.z.string().optional(),
|
|
30
|
+
/**
|
|
31
|
+
* @default "serverFn-client-index.ts"
|
|
32
|
+
*/
|
|
33
|
+
serverFnClientIndexFilename: zod_1.z.string().optional(),
|
|
34
|
+
/**
|
|
35
|
+
* @default "serverFnClients.ts"
|
|
36
|
+
*/
|
|
37
|
+
serverFnClientFilename: zod_1.z.string().optional(),
|
|
38
|
+
/**
|
|
39
|
+
* @default "handler"
|
|
40
|
+
*/
|
|
41
|
+
serverFnHandlerName: zod_1.z.string().optional(),
|
|
42
|
+
/**
|
|
43
|
+
* @default "@iyio/common"
|
|
44
|
+
*/
|
|
45
|
+
serverFnLibPackage: zod_1.z.string().optional(),
|
|
46
|
+
/**
|
|
47
|
+
* @default "@iyio/aws-lambda"
|
|
48
|
+
*/
|
|
49
|
+
serverFnLambdaPackage: zod_1.z.string().optional(),
|
|
50
|
+
});
|
|
51
|
+
exports.serverFnPlugin = {
|
|
52
|
+
configScheme: ServerFnPluginConfig,
|
|
53
|
+
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, }, { serverFnPackage = 'serverFns', serverFnPath = serverFnPackage, serverFnClientPackage = 'serverFnsClient', serverFnClientPath = serverFnClientPackage, serverFnParamsFilename = 'serverFn-params.ts', serverFnHandlerName = 'handler', serverFnLibPackage = '@iyio/common', serverFnClientFilename = 'serverFnClients.ts', serverFnLambdaPackage = '@iyio/aws-lambda', serverFnClientIndexFilename = 'serverFn-client-index.ts', }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
55
|
+
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnPackage, serverFnPath);
|
|
56
|
+
const { path: clientPath } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnClientPackage, serverFnClientPath, { packagePaths, indexFilename: serverFnClientIndexFilename });
|
|
57
|
+
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
58
|
+
log(`${supported.length} supported node(s)`);
|
|
59
|
+
if (!supported.length) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const paramsOut = [];
|
|
63
|
+
paramsOut.push('import { defineStringParam } from "@iyio/common";');
|
|
64
|
+
paramsOut.push('');
|
|
65
|
+
const clientOut = [];
|
|
66
|
+
const clientInputs = [];
|
|
67
|
+
const clientParamImports = [];
|
|
68
|
+
clientOut.push(`import { lambdaClient } from '${serverFnLambdaPackage}';`);
|
|
69
|
+
clientOut.push('');
|
|
70
|
+
for (const node of supported) {
|
|
71
|
+
const out = [];
|
|
72
|
+
const imports = [];
|
|
73
|
+
const name = node.name;
|
|
74
|
+
const inputType = (_c = (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a['input']) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : 'void';
|
|
75
|
+
const outputType = (_f = (_e = (_d = node.children) === null || _d === void 0 ? void 0 : _d['output']) === null || _e === void 0 ? void 0 : _e.type) !== null && _f !== void 0 ? _f : 'void';
|
|
76
|
+
const inputPackage = importMap[inputType + 'Scheme'];
|
|
77
|
+
const outputPackage = importMap[outputType + 'Scheme'];
|
|
78
|
+
const paramName = (0, common_1.strFirstToLower)(name) + 'ArnParam';
|
|
79
|
+
importMap[paramName] = serverFnClientPackage;
|
|
80
|
+
clientParamImports.push(paramName);
|
|
81
|
+
paramsOut.push(`export const ${paramName}=defineStringParam('${(0, common_1.strFirstToLower)(name)}Arn');`);
|
|
82
|
+
const clientName = name.endsWith('Fn') ? name.substring(0, name.length - 2) : name;
|
|
83
|
+
importMap[clientName] = serverFnClientPackage;
|
|
84
|
+
clientOut.push(`export const ${clientName}=(input:${inputType}):Promise<${outputType}>=>(`);
|
|
85
|
+
clientOut.push(`${tab}lambdaClient().invokeAsync<${inputType},${outputType}>({`);
|
|
86
|
+
clientOut.push(`${tab}${tab}fn:${paramName}(),`);
|
|
87
|
+
clientOut.push(`${tab}${tab}input,`);
|
|
88
|
+
if (inputPackage) {
|
|
89
|
+
clientInputs.push(inputType + 'Scheme');
|
|
90
|
+
clientOut.push(`${tab}${tab}inputScheme:${inputType}Scheme,`);
|
|
91
|
+
}
|
|
92
|
+
if (outputPackage) {
|
|
93
|
+
clientInputs.push(outputType + 'Scheme');
|
|
94
|
+
clientOut.push(`${tab}${tab}outputScheme:${outputType}Scheme,`);
|
|
95
|
+
}
|
|
96
|
+
clientOut.push(`${tab}})`);
|
|
97
|
+
clientOut.push(')');
|
|
98
|
+
clientOut.push('');
|
|
99
|
+
const handlerName = (_j = (_h = (_g = node.children) === null || _g === void 0 ? void 0 : _g['handlerName']) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : serverFnHandlerName;
|
|
100
|
+
const isDefault = handlerName === 'default';
|
|
101
|
+
if (!(0, protogen_1.protoIsTsBuiltType)(inputType)) {
|
|
102
|
+
imports.push(inputType);
|
|
103
|
+
clientInputs.push(inputType);
|
|
104
|
+
}
|
|
105
|
+
if (!(0, protogen_1.protoIsTsBuiltType)(outputType)) {
|
|
106
|
+
imports.push(outputType);
|
|
107
|
+
clientInputs.push(outputType);
|
|
108
|
+
}
|
|
109
|
+
out.push(`import { createFnHandler, FnEvent } from '${serverFnLibPackage}';`);
|
|
110
|
+
out.push('');
|
|
111
|
+
if (node.comment) {
|
|
112
|
+
out.push(...(0, protogen_1.protoFormatTsComment)(node.comment, '').split('\n'));
|
|
113
|
+
}
|
|
114
|
+
const startI = out.length;
|
|
115
|
+
out.push(`const ${name}=async (`);
|
|
116
|
+
out.push(`${tab}fnEvt:FnEvent${inputType === 'void' ? '' : ','}`);
|
|
117
|
+
out.push(`${inputType === 'void' ? '' : `${tab}input:${inputType}`}`);
|
|
118
|
+
out.push(`):Promise<${outputType}>=>{`);
|
|
119
|
+
(0, protogen_1.protoLabelOutputLines)(out, 'head', startI);
|
|
120
|
+
out.push(`${tab}// do cool stuff`);
|
|
121
|
+
out.push('}');
|
|
122
|
+
out.push('');
|
|
123
|
+
out.push(isDefault ? `export default ${name};` : `export const ${handlerName}=createFnHandler(${name},{`);
|
|
124
|
+
if (inputPackage) {
|
|
125
|
+
imports.push(inputType + 'Scheme');
|
|
126
|
+
out.push(`${tab}inputScheme:${inputType}Scheme,`);
|
|
127
|
+
}
|
|
128
|
+
if (outputPackage) {
|
|
129
|
+
imports.push(outputType + 'Scheme');
|
|
130
|
+
out.push(`${tab}outputScheme:${outputType}Scheme,`);
|
|
131
|
+
}
|
|
132
|
+
out.push('});');
|
|
133
|
+
(0, protogen_1.protoPrependTsImports)(imports, importMap, out);
|
|
134
|
+
outputs.push({
|
|
135
|
+
path: (0, common_1.joinPaths)(path, name + '.ts'),
|
|
136
|
+
content: out.join('\n'),
|
|
137
|
+
autoMerge: true,
|
|
138
|
+
mergeHandler: protogen_1.protoMergeTsImports
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
clientOut.unshift(`import { ${clientParamImports.join(', ')} } from './${(0, common_1.getFileNameNoExt)(serverFnParamsFilename)}';`);
|
|
142
|
+
(0, protogen_1.protoPrependTsImports)(clientInputs, importMap, clientOut);
|
|
143
|
+
outputs.push({
|
|
144
|
+
path: (0, common_1.joinPaths)(clientPath, serverFnClientFilename),
|
|
145
|
+
content: clientOut.join('\n'),
|
|
146
|
+
});
|
|
147
|
+
outputs.push({
|
|
148
|
+
path: (0, common_1.joinPaths)(clientPath, serverFnParamsFilename),
|
|
149
|
+
content: paramsOut.join('\n'),
|
|
150
|
+
});
|
|
151
|
+
outputs.push({
|
|
152
|
+
path: (0, common_1.joinPaths)(clientPath, serverFnClientIndexFilename),
|
|
153
|
+
content: '',
|
|
154
|
+
generator: {
|
|
155
|
+
root: clientPath,
|
|
156
|
+
generator: protogen_1.protoGenerateTsIndex
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
})
|
|
160
|
+
};
|
|
161
|
+
//# sourceMappingURL=serverFnPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFnPlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/serverFnPlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAA4E;AAC5E,6CAA+N;AAC/N,6BAAwB;AAExB,MAAM,cAAc,GAAC,CAAC,UAAU,CAAC,CAAC;AAElC,M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AC,IAAI,EAAC,IAAI,GAAC,KAAK,CAAC;gBAC/B,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACtB,SAAS,EAAC,IAAI;gBACd,YAAY,EAAC,8BAAmB;aACnC,CAAC,CAAA;SAEL;QAED,SAAS,CAAC,OAAO,CAAC,YAAY,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,IAAA,yBAAgB,EAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;QACtH,IAAA,gCAAqB,EAAC,YAAY,EAAC,SAAS,EAAC,SAAS,CAAC,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,IAAA,kBAAS,EAAC,UAAU,EAAC,sBAAsB,CAAC;YACjD,OAAO,EAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,IAAA,kBAAS,EAAC,UAAU,EAAC,sBAAsB,CAAC;YACjD,OAAO,EAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;SAC/B,CAAC,CAAA;QACF,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,IAAA,kBAAS,EAAC,UAAU,EAAC,2BAA2B,CAAC;YACtD,OAAO,EAAC,EAAE;YACV,SAAS,EAAC;gBACN,IAAI,EAAC,UAAU;gBACf,SAAS,EAAC,+BAAoB;aACjC;SACJ,CAAC,CAAA;IAEN,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const TablePluginConfig: z.ZodObject<{
|
|
4
|
+
tablePath: z.ZodOptional<z.ZodString>;
|
|
5
|
+
tableFilename: z.ZodOptional<z.ZodString>;
|
|
6
|
+
tableIndexFilename: z.ZodOptional<z.ZodString>;
|
|
7
|
+
tableParamsFilename: z.ZodOptional<z.ZodString>;
|
|
8
|
+
tablePackage: z.ZodOptional<z.ZodString>;
|
|
9
|
+
tableUseParamIds: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
dataTableDescriptionPackage: z.ZodOptional<z.ZodString>;
|
|
11
|
+
allTableArrayName: z.ZodOptional<z.ZodString>;
|
|
12
|
+
tsSchemePrefix: z.ZodOptional<z.ZodString>;
|
|
13
|
+
tsSchemeSuffix: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
tablePath?: string | undefined;
|
|
16
|
+
tableFilename?: string | undefined;
|
|
17
|
+
tableIndexFilename?: string | undefined;
|
|
18
|
+
tableParamsFilename?: string | undefined;
|
|
19
|
+
tablePackage?: string | undefined;
|
|
20
|
+
tableUseParamIds?: boolean | undefined;
|
|
21
|
+
dataTableDescriptionPackage?: string | undefined;
|
|
22
|
+
allTableArrayName?: string | undefined;
|
|
23
|
+
tsSchemePrefix?: string | undefined;
|
|
24
|
+
tsSchemeSuffix?: string | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
tablePath?: string | undefined;
|
|
27
|
+
tableFilename?: string | undefined;
|
|
28
|
+
tableIndexFilename?: string | undefined;
|
|
29
|
+
tableParamsFilename?: string | undefined;
|
|
30
|
+
tablePackage?: string | undefined;
|
|
31
|
+
tableUseParamIds?: boolean | undefined;
|
|
32
|
+
dataTableDescriptionPackage?: string | undefined;
|
|
33
|
+
allTableArrayName?: string | undefined;
|
|
34
|
+
tsSchemePrefix?: string | undefined;
|
|
35
|
+
tsSchemeSuffix?: string | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const tablePlugin: ProtoPipelineConfigurablePlugin<typeof TablePluginConfig>;
|
|
38
|
+
export {};
|