@iyio/protogen-runtime 0.0.11 → 0.0.13
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/esm/src/lib/default-plugins.js +42 -0
- package/esm/src/lib/default-plugins.js.map +1 -1
- package/esm/src/lib/plugins/actionPlugin.d.ts +40 -0
- package/esm/src/lib/plugins/actionPlugin.js +97 -0
- package/esm/src/lib/plugins/actionPlugin.js.map +1 -0
- package/esm/src/lib/plugins/assignPlugin.d.ts +20 -0
- package/esm/src/lib/plugins/assignPlugin.js +52 -0
- package/esm/src/lib/plugins/assignPlugin.js.map +1 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js +10 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -1
- package/esm/src/lib/plugins/bucketCdkTemplate.js +4 -2
- package/esm/src/lib/plugins/bucketCdkTemplate.js.map +1 -1
- package/esm/src/lib/plugins/bucketPlugin.js +16 -4
- package/esm/src/lib/plugins/bucketPlugin.js.map +1 -1
- package/esm/src/lib/plugins/callablePlugin.d.ts +40 -0
- package/esm/src/lib/plugins/callablePlugin.js +86 -0
- package/esm/src/lib/plugins/callablePlugin.js.map +1 -0
- package/esm/src/lib/plugins/examplePlugin.js +1 -2
- package/esm/src/lib/plugins/examplePlugin.js.map +1 -1
- package/esm/src/lib/plugins/fileWriter.js +3 -2
- package/esm/src/lib/plugins/fileWriter.js.map +1 -1
- package/esm/src/lib/plugins/functionPlugin.js +37 -8
- package/esm/src/lib/plugins/functionPlugin.js.map +1 -1
- package/esm/src/lib/plugins/nextJsAppPlugin.js +14 -5
- package/esm/src/lib/plugins/nextJsAppPlugin.js.map +1 -1
- package/esm/src/lib/plugins/nextJsAppTemplate.js +18 -0
- package/esm/src/lib/plugins/nextJsAppTemplate.js.map +1 -1
- package/esm/src/lib/plugins/nextJsPagePlugin.d.ts +15 -0
- package/esm/src/lib/plugins/nextJsPagePlugin.js +65 -0
- package/esm/src/lib/plugins/nextJsPagePlugin.js.map +1 -0
- package/esm/src/lib/plugins/reactCompPlugin.js +1 -1
- package/esm/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/esm/src/lib/plugins/serverFnCdkTemplate.d.ts +2 -1
- package/esm/src/lib/plugins/serverFnCdkTemplate.js +10 -3
- package/esm/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- package/esm/src/lib/plugins/serverFnPlugin.d.ts +6 -0
- package/esm/src/lib/plugins/serverFnPlugin.js +87 -23
- package/esm/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.d.ts +5 -0
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.js +40 -0
- package/esm/src/lib/plugins/sqlMigrationCdkTemplate.js.map +1 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.d.ts +39 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.js +114 -0
- package/esm/src/lib/plugins/sqlMigrationsPlugin.js.map +1 -0
- package/esm/src/lib/plugins/sqlTablePlugin.d.ts +64 -0
- package/esm/src/lib/plugins/sqlTablePlugin.js +162 -0
- package/esm/src/lib/plugins/sqlTablePlugin.js.map +1 -0
- package/esm/src/lib/plugins/tablePlugin.js +16 -134
- package/esm/src/lib/plugins/tablePlugin.js.map +1 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.js +1 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/esm/src/lib/plugins/userPoolPlugin.js +16 -1
- package/esm/src/lib/plugins/userPoolPlugin.js.map +1 -1
- package/esm/src/lib/plugins/zodPlugin.d.ts +3 -0
- package/esm/src/lib/plugins/zodPlugin.js +151 -33
- package/esm/src/lib/plugins/zodPlugin.js.map +1 -1
- package/esm/src/lib/protogen-table-generator.d.ts +39 -0
- package/esm/src/lib/protogen-table-generator.js +181 -0
- package/esm/src/lib/protogen-table-generator.js.map +1 -0
- package/esm/src/lib/runProtogenCliAsync.js +5 -0
- package/esm/src/lib/runProtogenCliAsync.js.map +1 -1
- package/package.json +18 -10
- package/src/lib/default-plugins.js +42 -0
- package/src/lib/default-plugins.js.map +1 -1
- package/src/lib/plugins/actionPlugin.d.ts +40 -0
- package/src/lib/plugins/actionPlugin.js +100 -0
- package/src/lib/plugins/actionPlugin.js.map +1 -0
- package/src/lib/plugins/assignPlugin.d.ts +20 -0
- package/src/lib/plugins/assignPlugin.js +55 -0
- package/src/lib/plugins/assignPlugin.js.map +1 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js +10 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -1
- package/src/lib/plugins/bucketCdkTemplate.js +4 -2
- package/src/lib/plugins/bucketCdkTemplate.js.map +1 -1
- package/src/lib/plugins/bucketPlugin.js +15 -3
- package/src/lib/plugins/bucketPlugin.js.map +1 -1
- package/src/lib/plugins/callablePlugin.d.ts +40 -0
- package/src/lib/plugins/callablePlugin.js +89 -0
- package/src/lib/plugins/callablePlugin.js.map +1 -0
- package/src/lib/plugins/examplePlugin.js +1 -2
- package/src/lib/plugins/examplePlugin.js.map +1 -1
- package/src/lib/plugins/fileWriter.js +3 -2
- package/src/lib/plugins/fileWriter.js.map +1 -1
- package/src/lib/plugins/functionPlugin.js +36 -7
- package/src/lib/plugins/functionPlugin.js.map +1 -1
- package/src/lib/plugins/nextJsAppPlugin.js +13 -4
- package/src/lib/plugins/nextJsAppPlugin.js.map +1 -1
- package/src/lib/plugins/nextJsAppTemplate.js +18 -0
- package/src/lib/plugins/nextJsAppTemplate.js.map +1 -1
- package/src/lib/plugins/nextJsPagePlugin.d.ts +15 -0
- package/src/lib/plugins/nextJsPagePlugin.js +68 -0
- package/src/lib/plugins/nextJsPagePlugin.js.map +1 -0
- package/src/lib/plugins/reactCompPlugin.js +1 -1
- package/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/src/lib/plugins/serverFnCdkTemplate.d.ts +2 -1
- package/src/lib/plugins/serverFnCdkTemplate.js +10 -3
- package/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- package/src/lib/plugins/serverFnPlugin.d.ts +6 -0
- package/src/lib/plugins/serverFnPlugin.js +85 -21
- package/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/src/lib/plugins/sqlMigrationCdkTemplate.d.ts +5 -0
- package/src/lib/plugins/sqlMigrationCdkTemplate.js +44 -0
- package/src/lib/plugins/sqlMigrationCdkTemplate.js.map +1 -0
- package/src/lib/plugins/sqlMigrationsPlugin.d.ts +39 -0
- package/src/lib/plugins/sqlMigrationsPlugin.js +117 -0
- package/src/lib/plugins/sqlMigrationsPlugin.js.map +1 -0
- package/src/lib/plugins/sqlTablePlugin.d.ts +64 -0
- package/src/lib/plugins/sqlTablePlugin.js +165 -0
- package/src/lib/plugins/sqlTablePlugin.js.map +1 -0
- package/src/lib/plugins/tablePlugin.js +15 -133
- package/src/lib/plugins/tablePlugin.js.map +1 -1
- package/src/lib/plugins/tsProtoNodePlugin.js +1 -1
- package/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/src/lib/plugins/userPoolPlugin.js +16 -1
- package/src/lib/plugins/userPoolPlugin.js.map +1 -1
- package/src/lib/plugins/zodPlugin.d.ts +3 -0
- package/src/lib/plugins/zodPlugin.js +149 -31
- package/src/lib/plugins/zodPlugin.js.map +1 -1
- package/src/lib/protogen-table-generator.d.ts +39 -0
- package/src/lib/protogen-table-generator.js +185 -0
- package/src/lib/protogen-table-generator.js.map +1 -0
- package/src/lib/runProtogenCliAsync.js +5 -0
- package/src/lib/runProtogenCliAsync.js.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { joinPaths } from "@iyio/common";
|
|
3
|
-
import { getProtoPluginPackAndPath, protoFormatTsComment, protoGenerateTsIndex, protoGetChildren, protoIsTsBuiltType, protoLabelOutputLines, protoPrependTsImports } from "@iyio/protogen";
|
|
3
|
+
import { addPackageInfoToProtoType, getProtoPluginPackAndPath, protoFormatTsComment, protoGenerateTsIndex, protoGetChildren, protoIsTsBuiltType, protoLabelOutputLines, protoPrependTsImports } from "@iyio/protogen";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
const supportedTypes = ['function'];
|
|
6
6
|
const FunctionPluginConfig = z.object({
|
|
@@ -19,8 +19,8 @@ const FunctionPluginConfig = z.object({
|
|
|
19
19
|
});
|
|
20
20
|
export const functionPlugin = {
|
|
21
21
|
configScheme: FunctionPluginConfig,
|
|
22
|
-
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, libStyle, }, { functionPackage = 'domain-functions', functionPath = functionPackage, functionIndexFilename = 'domain-functions-index.ts', }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
-
var _a, _b, _c, _d;
|
|
22
|
+
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, libStyle, callables, }, { functionPackage = 'domain-functions', functionPath = functionPackage, functionIndexFilename = 'domain-functions-index.ts', }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
24
24
|
const { path, packageName } = getProtoPluginPackAndPath(namespace, functionPackage, functionPath, libStyle, { packagePaths, indexFilename: functionIndexFilename });
|
|
25
25
|
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
26
26
|
log(`${supported.length} supported node(s)`);
|
|
@@ -36,13 +36,35 @@ export const functionPlugin = {
|
|
|
36
36
|
importMap[name] = packageName;
|
|
37
37
|
const isAsync = name.toLowerCase().endsWith('async') || ((_a = node.children) === null || _a === void 0 ? void 0 : _a['async']) !== undefined;
|
|
38
38
|
const args = protoGetChildren((_b = node.children) === null || _b === void 0 ? void 0 : _b['args'], false);
|
|
39
|
-
const
|
|
40
|
-
const
|
|
39
|
+
const returnNode = (_c = node.children) === null || _c === void 0 ? void 0 : _c['return'];
|
|
40
|
+
const returnTypeBase = (returnNode === null || returnNode === void 0 ? void 0 : returnNode.type) || 'void';
|
|
41
|
+
const returnOptional = (returnNode === null || returnNode === void 0 ? void 0 : returnNode.optional) ? true : false;
|
|
42
|
+
const returnArray = ((_e = (_d = returnNode === null || returnNode === void 0 ? void 0 : returnNode.types) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.isArray) ? true : false;
|
|
43
|
+
let rb = returnTypeBase + (returnOptional ? '|undefined' : '');
|
|
44
|
+
if (returnArray && returnOptional) {
|
|
45
|
+
rb = `(${rb})`;
|
|
46
|
+
}
|
|
47
|
+
if (returnArray) {
|
|
48
|
+
rb = rb + '[]';
|
|
49
|
+
}
|
|
50
|
+
const returnType = isAsync ? `Promise<${rb}>` : rb;
|
|
51
|
+
const argsExportName = name + 'FunctionArgsScheme';
|
|
52
|
+
const argsPackage = importMap[argsExportName];
|
|
53
|
+
callables.push({
|
|
54
|
+
name,
|
|
55
|
+
exportName: name,
|
|
56
|
+
package: packageName,
|
|
57
|
+
args: args.map(a => addPackageInfoToProtoType(a.types[0], importMap, a.name)),
|
|
58
|
+
argsExportName: argsPackage ? argsExportName : undefined,
|
|
59
|
+
argsPackage,
|
|
60
|
+
returnType: (returnNode === null || returnNode === void 0 ? void 0 : returnNode.types[0]) ? addPackageInfoToProtoType(returnNode.types[0], importMap) : undefined,
|
|
61
|
+
isAsync: isAsync ? true : undefined,
|
|
62
|
+
});
|
|
41
63
|
if (!protoIsTsBuiltType(returnTypeBase)) {
|
|
42
64
|
imports.push(returnTypeBase);
|
|
43
65
|
}
|
|
44
66
|
const startI = out.length;
|
|
45
|
-
const oneLiner = `export const ${name}=${isAsync ? 'async ' : ''}(${args.map(a => `${a.name}:${a.type}
|
|
67
|
+
const oneLiner = `export const ${name}=${isAsync ? 'async ' : ''}(${args.map(a => { var _a, _b; return `${a.name}${a.optional ? '?' : ''}:${a.type}${((_b = (_a = a.types) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.isArray) ? '[]' : ''}`; }).join(', ')}):${returnType}=>`;
|
|
46
68
|
if (oneLiner.length <= 90 || args.length === 0) {
|
|
47
69
|
out.push(oneLiner);
|
|
48
70
|
out.push('{');
|
|
@@ -51,12 +73,19 @@ export const functionPlugin = {
|
|
|
51
73
|
out.push(`export const ${name}=${isAsync ? 'async ' : ''}(`);
|
|
52
74
|
for (let a = 0; a < args.length; a++) {
|
|
53
75
|
const arg = args[a];
|
|
54
|
-
out.push(`${tab}${arg.name}:${arg.type}${a === args.length - 1 ? '' : ','}`);
|
|
76
|
+
out.push(`${tab}${arg.name}${arg.optional ? '?' : ''}:${arg.type}${((_g = (_f = arg.types) === null || _f === void 0 ? void 0 : _f[0]) === null || _g === void 0 ? void 0 : _g.isArray) ? '[]' : ''}${a === args.length - 1 ? '' : ','}`);
|
|
55
77
|
}
|
|
56
78
|
out.push(`):${returnType}=>{`);
|
|
57
79
|
}
|
|
80
|
+
for (const a of args) {
|
|
81
|
+
if (!protoIsTsBuiltType(a.type)) {
|
|
82
|
+
imports.push(a.type);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
58
85
|
protoLabelOutputLines(out, 'function', startI);
|
|
59
|
-
out.push(
|
|
86
|
+
out.push('');
|
|
87
|
+
out.push(`${tab}throw new Error('${name} not implemented')`);
|
|
88
|
+
out.push('');
|
|
60
89
|
out.push('}');
|
|
61
90
|
if (imports.length) {
|
|
62
91
|
protoPrependTsImports(imports, importMap, out);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"functionPlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/functionPlugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,qBAAqB,EAAmC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"functionPlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/functionPlugin.ts"],"names":[],"mappings":";AAAA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1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { joinPaths, strFirstToUpper } from "@iyio/common";
|
|
3
|
-
import { protoMergeJson } from "@iyio/protogen";
|
|
3
|
+
import { protoGetChildrenByName, protoMergeJson } from "@iyio/protogen";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { nextJsAppTemplate } from "./nextJsAppTemplate";
|
|
6
6
|
import { siteCdkTemplate } from "./siteCdkTemplate";
|
|
@@ -21,8 +21,8 @@ const NextJsPluginConfig = z.object({
|
|
|
21
21
|
});
|
|
22
22
|
export const nextJsAppPlugin = {
|
|
23
23
|
configScheme: NextJsPluginConfig,
|
|
24
|
-
generate: ({ outputs, log, nodes, namespace, libStyle, cdkProjectDir }, { nextJsAppOverrideTemplateFiles = false, nextJsAppCdkConstructClassName = 'Apps', nextJsAppCdkConstructFile = libStyle === 'nx' ? `packages/cdk/src/${nextJsAppCdkConstructClassName}.ts` : undefined, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
|
|
24
|
+
generate: ({ outputs, log, nodes, namespace, libStyle, cdkProjectDir, metadata }, { nextJsAppOverrideTemplateFiles = false, nextJsAppCdkConstructClassName = 'Apps', nextJsAppCdkConstructFile = libStyle === 'nx' ? `packages/cdk/src/${nextJsAppCdkConstructClassName}.ts` : undefined, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13;
|
|
26
26
|
const supported = nodes.filter(n => { var _a, _b, _c; return supportedTypes.some(t => n.types.some(nt => nt.type === t)) && ((_c = (_b = (_a = n.children) === null || _a === void 0 ? void 0 : _a['name']) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.trim()); });
|
|
27
27
|
log(`${supported.length} supported node(s)`);
|
|
28
28
|
if (!supported.length) {
|
|
@@ -34,6 +34,7 @@ export const nextJsAppPlugin = {
|
|
|
34
34
|
if (!name) {
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
|
+
metadata['screens-path-' + name] = `packages/${name}/pages`;
|
|
37
38
|
outputs.push(...nextJsAppTemplate({
|
|
38
39
|
mapOptions: {
|
|
39
40
|
targetDir: `packages/${name}`,
|
|
@@ -62,17 +63,25 @@ export const nextJsAppPlugin = {
|
|
|
62
63
|
const deploymentType = (_9 = (_8 = (_7 = node.children) === null || _7 === void 0 ? void 0 : _7['deploy']) === null || _8 === void 0 ? void 0 : _8.value) === null || _9 === void 0 ? void 0 : _9.trim();
|
|
63
64
|
if (deploymentType) {
|
|
64
65
|
switch (deploymentType) {
|
|
65
|
-
case 'static':
|
|
66
|
+
case 'static': {
|
|
67
|
+
const redirectHandler = (_11 = (_10 = node.children) === null || _10 === void 0 ? void 0 : _10['redirectHandler']) === null || _11 === void 0 ? void 0 : _11.type;
|
|
68
|
+
if (redirectHandler && !nodes.find(n => n.name === redirectHandler)) {
|
|
69
|
+
throw new Error(`redirectHandler type not found. type:${redirectHandler}, appName:${node.name}`);
|
|
70
|
+
}
|
|
71
|
+
const domains = protoGetChildrenByName(node, 'domain', false);
|
|
66
72
|
sites.push({
|
|
67
73
|
name: strFirstToUpper(name.replace(/-(\w)/g, (_, c) => c.toUpperCase())),
|
|
74
|
+
redirectHandler,
|
|
68
75
|
staticSite: {
|
|
69
76
|
nxExportedPackage: name,
|
|
70
77
|
cdn: true,
|
|
71
|
-
domainName: (
|
|
78
|
+
domainName: (_13 = (_12 = domains[0]) === null || _12 === void 0 ? void 0 : _12.value) === null || _13 === void 0 ? void 0 : _13.trim(),
|
|
79
|
+
additionalDomainNames: domains.length > 1 ? domains.map(d => { var _a; return (_a = d.value) === null || _a === void 0 ? void 0 : _a.trim(); }).filter((d, i) => d && i > 0) : undefined,
|
|
72
80
|
createOutputs: true,
|
|
73
81
|
}
|
|
74
82
|
});
|
|
75
83
|
break;
|
|
84
|
+
}
|
|
76
85
|
default:
|
|
77
86
|
throw new Error(`deployment type ${deploymentType} is not supported by nextJsAppPlugin`);
|
|
78
87
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextJsAppPlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/nextJsAppPlugin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAmC,cAAc,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"nextJsAppPlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/nextJsAppPlugin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAmC,sBAAsB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACzG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,cAAc,GAAC,CAAC,SAAS,CAAC,CAAC;AAEjC,MAAM,kBAAkB,GAAC,CAAC,CAAC,MAAM,CACjC;IAEI;;OAEG;IACH,8BAA8B,EAAC,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAErD;;OAEG;IACH,yBAAyB,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAE/C;;OAEG;IACH,8BAA8B,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAA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,MAAM,CAAC,CAAC,CAAC,EAAC,CAAC,EAAC,EAAE,CAAA,CAAC,IAAI,CAAC,GAAC,CAAC,CAAa,CAAA,CAAC,CAAA,SAAS;gCACpH,aAAa,EAAC,IAAI;6BACrB;yBACJ,CAAC,CAAA;wBAEF,MAAM;qBACT;oBAED;wBACI,MAAM,IAAI,KAAK,CAAC,mBAAmB,cAAc,sCAAsC,CAAC,CAAC;iBAEhG;aACJ;SAEJ;QAGD,IAAG,yBAAyB,EAAC;YACzB,OAAO,CAAC,IAAI,CAAC;gBACT,IAAI,EAAC,yBAAyB;gBAC9B,OAAO,EAAC,eAAe,CAAC,8BAA8B,EAAC,KAAK,CAAC;aAChE,CAAC,CAAA;SACL;IAEL,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -42,6 +42,24 @@ export const nextJsAppTemplate = ({ mapOptions: __transformerParam__, namespace,
|
|
|
42
42
|
"jest": true
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
+
`,
|
|
46
|
+
"components/Page.tsx":
|
|
47
|
+
/*tsx*/ `export interface PageProps
|
|
48
|
+
{
|
|
49
|
+
children?:any;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function Page({
|
|
53
|
+
children
|
|
54
|
+
}:PageProps){
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div className="Page">
|
|
58
|
+
{children}
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
}
|
|
45
63
|
`,
|
|
46
64
|
"index.d.ts":
|
|
47
65
|
/*ts*/ `/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nextJsAppTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/nextJsAppTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAczE,MAAM,CAAC,MAAM,iBAA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;;;;;;;;;;;;;;;;;;CAqBP;KACI,CAAA;IACD,OAAO,eAAe,CAAC,KAAK,EAAC,oBAAoB,CAAC,CAAC;AACvD,CAAC,CAAA"}
|
|
1
|
+
{"version":3,"file":"nextJsAppTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/nextJsAppTemplate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAczE,MAAM,CAAC,MAAM,iBAAiB,GAAC,CAAC,EAC5B,UAAU,EAAC,oBAAoB,EAC/B,SAAS,EACT,OAAO,EACP,cAAc,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,WAAW,EACX,OAAO,GACe,EAAC,EAAE;IACzB,MAAM,KAAK,GAAC;QAChB,UAAU;QACV,WAAW,CAAA;;;;CAIV;QACD,gBAAgB;QAChB,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCP;QACD,qBAAqB;QACrB,OAAO,CAAA;;;;;;;;;;;;;;;;CAgBN;QACD,YAAY;QACZ,MAAM,CAAA;;;;;;CAML;QACD,gBAAgB;QAChB,MAAM,CAAA;;;;;;;;;;;CAWL;QACD,eAAe;QACf,MAAM,CAAA;;;;;CAKL;QACD,gBAAgB;QAChB,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;CAoBL;QACD,gBAAgB;QAChB,OAAO,CAAA,iEAAiE,SAAS,IAAI,OAAO;WACjF,cAAc,mDAAmD,SAAS,IAAI,WAAW;;;;;;;;;;;;yBAY3E,cAAc;;;;;;;;;yBASd,SAAS;;;;qDAImB,SAAS;2DACH,eAAe;;;;;;;;;CASzE;QACD,qBAAqB;QACrB,OAAO,CAAA,sCAAsC,SAAS,IAAI,OAAO;;;;;;;;;;;;;;;;CAgBhE;QACD,iBAAiB;QACjB,OAAO,CAAA;;;;;;;;CAQN;QACD,cAAc;QACd,QAAQ,CAAA;eACO,WAAW;;8BAEI,WAAW;;;;;;;;;;oCAUL,WAAW;+CACA,WAAW;;;;8CAIZ,WAAW;;;;;;;;;kCASvB,WAAW;;0BAEnB,OAAO;;;;sCAIK,WAAW;;;;sCAIX,WAAW;;;;;;;;kCAQf,WAAW;;;;;;;;;;;;mCAYV,WAAW;;;;;;;;;;0CAUJ,WAAW;;;;;;;;;;;gCAWrB,WAAW;;;;;;;CAO1C;QACD,iBAAiB;QACjB,WAAW,CAAA,EAAE;QACb,eAAe;QACf,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;CAyBP;QACD,oBAAoB;QACpB,QAAQ,CAAA;;;;;;;;;;;;;;;;;;;;;CAqBP;KACI,CAAA;IACD,OAAO,eAAe,CAAC,KAAK,EAAC,oBAAoB,CAAC,CAAC;AACvD,CAAC,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const NextJsPagePluginConfig: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* Fallback path to pages dir
|
|
6
|
+
* @default "pages"
|
|
7
|
+
*/
|
|
8
|
+
nextJsPageFallbackDir: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
nextJsPageFallbackDir?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
nextJsPageFallbackDir?: string | undefined;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const nextJsPagePlugin: ProtoPipelineConfigurablePlugin<typeof NextJsPagePluginConfig>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { aryRemoveItem, getSubstringCount, joinPaths } from "@iyio/common";
|
|
3
|
+
import { protoFormatTsComment } from "@iyio/protogen";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const supportedTypes = ['screen'];
|
|
6
|
+
const NextJsPagePluginConfig = z.object({
|
|
7
|
+
/**
|
|
8
|
+
* Fallback path to pages dir
|
|
9
|
+
* @default "pages"
|
|
10
|
+
*/
|
|
11
|
+
nextJsPageFallbackDir: z.string().optional()
|
|
12
|
+
});
|
|
13
|
+
export const nextJsPagePlugin = {
|
|
14
|
+
configScheme: NextJsPagePluginConfig,
|
|
15
|
+
generate: ({ outputs, log, nodes, metadata }, { nextJsPageFallbackDir = "pages" }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
17
|
+
const supported = nodes.filter(n => supportedTypes.some(t => n.types.some(nt => nt.type === t)));
|
|
18
|
+
log(`${supported.length} supported node(s)`);
|
|
19
|
+
if (!supported.length) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
for (const node of supported) {
|
|
23
|
+
const appNode = (_a = node.children) === null || _a === void 0 ? void 0 : _a['app'];
|
|
24
|
+
const appName = (_e = (_d = (_c = (_b = nodes.find(n => n.name === (appNode === null || appNode === void 0 ? void 0 : appNode.type))) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c['name']) === null || _d === void 0 ? void 0 : _d.value) !== null && _e !== void 0 ? _e : appNode === null || appNode === void 0 ? void 0 : appNode.type;
|
|
25
|
+
const pagesDir = appName ? metadata['screens-path-' + appName] : nextJsPageFallbackDir;
|
|
26
|
+
if (!pagesDir) {
|
|
27
|
+
throw new Error('Unable to determine pages dir for screen. Try setting the app prop');
|
|
28
|
+
}
|
|
29
|
+
const name = node.name.endsWith('Screen') ? node.name.substring(0, node.name.length - ("Screen".length)) : node.name;
|
|
30
|
+
const route = '/' + (((_h = (_g = (_f = node.children) === null || _f === void 0 ? void 0 : _f['route']) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : name)
|
|
31
|
+
.replace(/\\/g, '/')
|
|
32
|
+
.replace(/\.{2,}/g, '')
|
|
33
|
+
.replace(/\/{2,}/g, '/')
|
|
34
|
+
.replace(/^\/*/g, '')
|
|
35
|
+
.replace(/\/*$/g, '')
|
|
36
|
+
|| 'index');
|
|
37
|
+
const out = [];
|
|
38
|
+
out.push(`import { Page } from "${new Array(getSubstringCount(route, '/')).fill('..').join('/')}/components/Page"`);
|
|
39
|
+
if (node.comment) {
|
|
40
|
+
out.push(...protoFormatTsComment(node.comment, '').split('\n'));
|
|
41
|
+
}
|
|
42
|
+
out.push(`export default function ${name}()
|
|
43
|
+
{
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Page>
|
|
47
|
+
${name} _🚧
|
|
48
|
+
</Page>
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
}`);
|
|
52
|
+
const filePath = joinPaths(pagesDir, route + '.tsx');
|
|
53
|
+
const existing = outputs.filter(o => o.path === filePath);
|
|
54
|
+
for (const e of existing) {
|
|
55
|
+
aryRemoveItem(outputs, e);
|
|
56
|
+
}
|
|
57
|
+
outputs.push({
|
|
58
|
+
path: filePath,
|
|
59
|
+
content: out.join('\n'),
|
|
60
|
+
autoMerge: true,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=nextJsPagePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nextJsPagePlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/nextJsPagePlugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAmC,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACvF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAC,CAAC,QAAQ,CAAC,CAAC;AAEhC,MAAM,sBAAsB,GAAC,CAAC,CAAC,MAAM,CACrC;IACI;;;OAGG;IACH,qBAAqB,EAAC,CAAC,CAAC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CAAA,CAAC,CAAC,IAAI,KAAG,QAAQ,CAAC,CAAC;YACpD,KAAI,MAAM,CAAC,IAAI,QAAQ,EAAC;gBACpB,aAAa,CAAC,OAAO,EAAC,CAAC,CAAC,CAAC;aAC5B;YAED,OAAO,CAAC,IAAI,CAAC;gBACT,IAAI,EAAC,QAAQ;gBACb,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBACtB,SAAS,EAAC,IAAI;aACjB,CAAC,CAAA;SAEL;IAGL,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { __awaiter } from "tslib";
|
|
|
2
2
|
import { joinPaths, requireUnrootPath } from "@iyio/common";
|
|
3
3
|
import { addTsImport, getProtoPluginPackAndPath, protoFormatTsComment, protoGenerateTsIndex, protoGetTsType, protoIsTsBuiltType, protoLabelOutputLines, protoPrependTsImports } from "@iyio/protogen";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
const supportedTypes = ['comp', 'view'
|
|
5
|
+
const supportedTypes = ['comp', 'view'];
|
|
6
6
|
const ReactCompPluginConfig = z.object({
|
|
7
7
|
/**
|
|
8
8
|
* @default .reactPackage
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactCompPlugin.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/reactCompPlugin.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAA4D,WAAW,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAChQ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,cAAc,GAAC,CAAC,MAAM,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"reactCompPlugin.js","sourceRoot":"","sources":["../../../../../../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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"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { FnInfo } from "@iyio/cdk-common";
|
|
2
|
-
export type FnInfoTemplate = Omit<FnInfo, 'arnParam'> & {
|
|
2
|
+
export type FnInfoTemplate = Omit<FnInfo, 'arnParam' | 'urlParam'> & {
|
|
3
3
|
arnParam: string;
|
|
4
|
+
urlParam?: string;
|
|
4
5
|
};
|
|
5
6
|
export declare const serverFnCdkTemplate: (constructName: string, infos: FnInfoTemplate[], importMap: Record<string, string>) => string;
|
|
@@ -3,6 +3,9 @@ export const serverFnCdkTemplate = (constructName, infos, importMap) => {
|
|
|
3
3
|
for (let i = 0; i < infos.length; i++) {
|
|
4
4
|
const t = infos[i];
|
|
5
5
|
imports.push(`import { ${t.arnParam} as _fnParam${i}} from '${importMap[t.arnParam]}';`);
|
|
6
|
+
if (t.urlParam) {
|
|
7
|
+
imports.push(`import { ${t.urlParam} as _fnUrlParam${i}} from '${importMap[t.urlParam]}';`);
|
|
8
|
+
}
|
|
6
9
|
}
|
|
7
10
|
return `import { Construct } from "constructs";
|
|
8
11
|
import { FnsBuilder, FnInfo, ManagedProps } from "@iyio/cdk-common";
|
|
@@ -33,10 +36,14 @@ ${infos.map((info, i) => {
|
|
|
33
36
|
var _a;
|
|
34
37
|
return ` {
|
|
35
38
|
name:${JSON.stringify(info.name)},
|
|
36
|
-
arnParam:_fnParam${i}
|
|
39
|
+
arnParam:_fnParam${i},${info.urlParam ? `
|
|
40
|
+
urlParam:_fnUrlParam${i},` : ''}
|
|
37
41
|
grantAccess:true,
|
|
38
|
-
accessRequests:${JSON.stringify((_a = info.accessRequests) !== null && _a !== void 0 ? _a : [])}
|
|
39
|
-
|
|
42
|
+
accessRequests:${JSON.stringify((_a = info.accessRequests) !== null && _a !== void 0 ? _a : [])},${info.grantAccessRequests ? `
|
|
43
|
+
grantAccessRequests:${JSON.stringify(info.grantAccessRequests)},` : ''}${info.noPassiveAccess ? `
|
|
44
|
+
noPassiveAccess:true,` : ''}
|
|
45
|
+
createProps:${JSON.stringify(info.createProps)},${info.siteSources ? `
|
|
46
|
+
siteSources:${JSON.stringify(info.siteSources)},` : ''}
|
|
40
47
|
}`;
|
|
41
48
|
})
|
|
42
49
|
.join(',\n')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverFnCdkTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/serverFnCdkTemplate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverFnCdkTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/serverFnCdkTemplate.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,mBAAmB,GAAC,CAAC,aAAoB,EAAC,KAAsB,EAAC,SAA+B,EAAC,EAAE;IAE5G,MAAM,OAAO,GAAU,EAAE,CAAC;IAC1B,KAAI,IAAI,CAAC,GAAC,CAAC,EAAC,CAAC,GAAC,KAAK,CAAC,MAAM,EAAC,CAAC,EAAE,EAAC;QAC3B,MAAM,CAAC,GAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,eAAe,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzF,IAAG,CAAC,CAAC,QAAQ,EAAC;YACV,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,QAAQ,kBAAkB,CAAC,WAAW,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;SAC/F;KACJ;IAGD,OAAO;;EAET,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;;mBAED,aAAa;;;;;;eAMjB,aAAa;;;;;;QAMpB,aAAa;;;;;;;;;EAUjB,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAC,CAAC,EAAC,EAAE;;QAAA,OAAA;eACT,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;2BACb,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAA,CAAC,CAAA;8BAChB,CAAC,GAAG,CAAA,CAAC,CAAA,EAAE;;yBAEZ,IAAI,CAAC,SAAS,CAAC,MAAA,IAAI,CAAC,cAAc,mCAAE,EAAE,CAAC,IAAI,IAAI,CAAC,mBAAmB,CAAA,CAAC,CAAA;8BAC/D,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAA,CAAC,CAAA,EAAE,GAAG,IAAI,CAAC,eAAe,CAAA,CAAC,CAAA;8BACtE,CAAA,CAAC,CAAA,EAAE;sBACX,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC,WAAW,CAAA,CAAC,CAAA;sBACrD,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAA,CAAC,CAAA,EAAE;MACtD,CAAA;KAAA,CAAC;SACF,IAAI,CAAC,KAAK,CACf;;;CAGC,CAAA;AACD,CAAC,CAAA"}
|
|
@@ -58,6 +58,10 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
58
58
|
serverFnInit: z.ZodOptional<z.ZodBoolean>;
|
|
59
59
|
serverFnInitFunction: z.ZodOptional<z.ZodString>;
|
|
60
60
|
serverFnInitFunctionPackage: z.ZodOptional<z.ZodString>;
|
|
61
|
+
/**
|
|
62
|
+
* The default timeout for generated functions in milliseconds
|
|
63
|
+
*/
|
|
64
|
+
serverFnDefaultTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
61
65
|
}, "strip", z.ZodTypeAny, {
|
|
62
66
|
serverFnPath?: string | undefined;
|
|
63
67
|
serverFnPackage?: string | undefined;
|
|
@@ -75,6 +79,7 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
75
79
|
serverFnInit?: boolean | undefined;
|
|
76
80
|
serverFnInitFunction?: string | undefined;
|
|
77
81
|
serverFnInitFunctionPackage?: string | undefined;
|
|
82
|
+
serverFnDefaultTimeoutMs?: number | undefined;
|
|
78
83
|
}, {
|
|
79
84
|
serverFnPath?: string | undefined;
|
|
80
85
|
serverFnPackage?: string | undefined;
|
|
@@ -92,6 +97,7 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
92
97
|
serverFnInit?: boolean | undefined;
|
|
93
98
|
serverFnInitFunction?: string | undefined;
|
|
94
99
|
serverFnInitFunctionPackage?: string | undefined;
|
|
100
|
+
serverFnDefaultTimeoutMs?: number | undefined;
|
|
95
101
|
}>;
|
|
96
102
|
export declare const serverFnPlugin: ProtoPipelineConfigurablePlugin<typeof ServerFnPluginConfig>;
|
|
97
103
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import { getSubstringCount, joinPaths } from "@iyio/common";
|
|
3
|
-
import { getProtoPluginPackAndPath, protoAddContextParam, protoFormatTsComment, protoGenerateTsIndex, protoIsTsBuiltType, protoLabelOutputLines, protoNodeChildrenToAccessRequests, protoPrependTsImports } from "@iyio/protogen";
|
|
2
|
+
import { getSubstringCount, joinPaths, safeParseNumberOrUndefined } from "@iyio/common";
|
|
3
|
+
import { addPackageInfoToProtoType, getProtoPluginPackAndPath, protoAddContextParam, protoFormatTsComment, protoGenerateTsIndex, protoGetChildrenByName, protoIsTsBuiltType, protoLabelOutputLines, protoNodeChildrenToAccessRequests, protoNodeChildrenToGrantAccessRequests, protoPrependTsImports } from "@iyio/protogen";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { serverFnCdkTemplate } from "./serverFnCdkTemplate";
|
|
6
6
|
const supportedTypes = ['serverFn'];
|
|
@@ -62,11 +62,15 @@ const ServerFnPluginConfig = z.object({
|
|
|
62
62
|
serverFnInit: z.boolean().optional(),
|
|
63
63
|
serverFnInitFunction: z.string().optional(),
|
|
64
64
|
serverFnInitFunctionPackage: z.string().optional(),
|
|
65
|
+
/**
|
|
66
|
+
* The default timeout for generated functions in milliseconds
|
|
67
|
+
*/
|
|
68
|
+
serverFnDefaultTimeoutMs: z.number().optional(),
|
|
65
69
|
});
|
|
66
70
|
export const serverFnPlugin = {
|
|
67
71
|
configScheme: ServerFnPluginConfig,
|
|
68
|
-
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, libStyle, paramMap, paramPackage, }, { serverFnPackage = 'fns', serverFnPath = serverFnPackage, serverFnClientPackage = 'fn-clients', serverFnIndexFilename = 'fn-index.ts', serverFnClientPath = serverFnClientPackage, serverFnHandlerName = 'handler', serverFnLibPackage = '@iyio/common', serverFnClientFilename = 'fn-clients.ts', serverFnLambdaPackage = '@iyio/aws-lambda', serverFnClientIndexFilename = 'fn-clients-index.ts', serverFnCdkConstructClassName = 'Fns', serverFnCdkConstructFile = libStyle === 'nx' ? `packages/cdk/src/${serverFnCdkConstructClassName}.ts` : undefined, serverFnInit = true, serverFnInitFunction = 'initBackend', serverFnInitFunctionPackage = `backend
|
|
69
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
72
|
+
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, libStyle, paramMap, paramPackage, callables, }, { serverFnPackage = 'fns', serverFnPath = serverFnPackage, serverFnClientPackage = 'fn-clients', serverFnIndexFilename = 'fn-index.ts', serverFnClientPath = serverFnClientPackage, serverFnHandlerName = 'handler', serverFnLibPackage = '@iyio/common', serverFnClientFilename = 'fn-clients.ts', serverFnLambdaPackage = '@iyio/aws-lambda', serverFnClientIndexFilename = 'fn-clients-index.ts', serverFnCdkConstructClassName = 'Fns', serverFnCdkConstructFile = libStyle === 'nx' ? `packages/cdk/src/${serverFnCdkConstructClassName}.ts` : undefined, serverFnInit = true, serverFnInitFunction = 'initBackend', serverFnInitFunctionPackage = `backend`, serverFnDefaultTimeoutMs, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
70
74
|
const { path } = getProtoPluginPackAndPath(namespace, serverFnPackage, serverFnPath, libStyle, { packagePaths, indexFilename: serverFnIndexFilename });
|
|
71
75
|
const cdkRelPath = ('../'
|
|
72
76
|
.repeat(getSubstringCount(path, '/') - 1));
|
|
@@ -89,39 +93,97 @@ export const serverFnPlugin = {
|
|
|
89
93
|
const filepath = joinPaths(path, name + '.ts');
|
|
90
94
|
const inputNode = (_a = node.children) === null || _a === void 0 ? void 0 : _a['input'];
|
|
91
95
|
const outputNode = (_b = node.children) === null || _b === void 0 ? void 0 : _b['output'];
|
|
92
|
-
const
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
+
const inputTypeInfo = inputNode === null || inputNode === void 0 ? void 0 : inputNode.types[0];
|
|
97
|
+
const outputTypeInfo = outputNode === null || outputNode === void 0 ? void 0 : outputNode.types[0];
|
|
98
|
+
const inputIsArray = (_c = inputTypeInfo === null || inputTypeInfo === void 0 ? void 0 : inputTypeInfo.isArray) !== null && _c !== void 0 ? _c : false;
|
|
99
|
+
const outputIsArray = (_d = outputTypeInfo === null || outputTypeInfo === void 0 ? void 0 : outputTypeInfo.isArray) !== null && _d !== void 0 ? _d : false;
|
|
100
|
+
const outputIsOptional = (_e = outputNode === null || outputNode === void 0 ? void 0 : outputNode.optional) !== null && _e !== void 0 ? _e : false;
|
|
101
|
+
const inputType = (_f = inputNode === null || inputNode === void 0 ? void 0 : inputNode.type) !== null && _f !== void 0 ? _f : 'void';
|
|
102
|
+
const outputType = (_g = outputNode === null || outputNode === void 0 ? void 0 : outputNode.type) !== null && _g !== void 0 ? _g : 'void';
|
|
96
103
|
const tsInputType = inputType + (inputIsArray ? '[]' : '');
|
|
97
|
-
const tsOutputType = outputType + (outputIsArray ? '[]' : '');
|
|
104
|
+
const tsOutputType = outputType + (outputIsArray ? '[]' : '') + (outputIsOptional ? '|undefined' : '');
|
|
98
105
|
const inputScheme = inputType + 'Scheme' + (inputIsArray ? '.array()' : '');
|
|
99
|
-
const outputScheme = outputType + 'Scheme' + (outputIsArray ? '.array()' : '');
|
|
106
|
+
const outputScheme = outputType + 'Scheme' + (outputIsArray ? '.array()' : '') + (outputIsOptional ? '.optional()' : '');
|
|
100
107
|
const inputPackage = importMap[inputType + 'Scheme'];
|
|
101
108
|
const outputPackage = importMap[outputType + 'Scheme'];
|
|
102
109
|
const paramName = protoAddContextParam(name + 'Arn', paramPackage, paramMap, importMap);
|
|
103
110
|
clientParamImports.push(paramName);
|
|
111
|
+
const sourcePath = (_j = (_h = node.children) === null || _h === void 0 ? void 0 : _h['sourcePath']) === null || _j === void 0 ? void 0 : _j.value;
|
|
112
|
+
const timeoutValue = safeParseNumberOrUndefined((_l = (_k = node.children) === null || _k === void 0 ? void 0 : _k['timeout']) === null || _l === void 0 ? void 0 : _l.value);
|
|
104
113
|
const fnInfo = {
|
|
105
114
|
name,
|
|
106
115
|
createProps: {
|
|
107
|
-
createPublicUrl: ((
|
|
108
|
-
handlerFileName: joinPaths(cdkRelPath, filepath),
|
|
109
|
-
handler: 'handler'
|
|
116
|
+
createPublicUrl: ((_o = (_m = node.children) === null || _m === void 0 ? void 0 : _m['publicUrl']) === null || _o === void 0 ? void 0 : _o.value) === 'true',
|
|
117
|
+
handlerFileName: sourcePath ? (libStyle === 'nx' ? joinPaths('../..', sourcePath) : sourcePath) : joinPaths(cdkRelPath, filepath),
|
|
118
|
+
handler: 'handler',
|
|
119
|
+
timeoutMs: timeoutValue === undefined ? serverFnDefaultTimeoutMs : timeoutValue * 1000,
|
|
110
120
|
},
|
|
111
121
|
arnParam: paramName
|
|
112
122
|
};
|
|
113
123
|
infos.push(fnInfo);
|
|
114
|
-
|
|
124
|
+
if (fnInfo.createProps.createPublicUrl) {
|
|
125
|
+
const urlParamName = protoAddContextParam(name + 'Url', paramPackage, paramMap, importMap);
|
|
126
|
+
fnInfo.urlParam = urlParamName;
|
|
127
|
+
}
|
|
128
|
+
const siteSources = protoGetChildrenByName(node, 'siteSource', false);
|
|
129
|
+
if (siteSources.length) {
|
|
130
|
+
const sources = [];
|
|
131
|
+
fnInfo.siteSources = sources;
|
|
132
|
+
for (const ss of siteSources) {
|
|
133
|
+
const target = nodes.find(n => n.name === ss.type);
|
|
134
|
+
if (!target) {
|
|
135
|
+
throw new Error(`No matching site source found for ${ss.type}. Fn=${node.name}`);
|
|
136
|
+
}
|
|
137
|
+
let prefix = (_q = (_p = ss.children) === null || _p === void 0 ? void 0 : _p['prefix']) === null || _q === void 0 ? void 0 : _q.value;
|
|
138
|
+
if (prefix) {
|
|
139
|
+
if (!prefix.startsWith('/')) {
|
|
140
|
+
prefix = '/' + prefix;
|
|
141
|
+
}
|
|
142
|
+
if (!prefix.endsWith('/')) {
|
|
143
|
+
prefix += '/';
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
sources.push({
|
|
147
|
+
targetSiteName: ss.type,
|
|
148
|
+
prefix,
|
|
149
|
+
accessSiteOrigin: ((_r = ss.children) === null || _r === void 0 ? void 0 : _r['accessSiteOrigin']) ? true : false,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const accessProp = (_s = node.children) === null || _s === void 0 ? void 0 : _s['$access'];
|
|
115
154
|
if (accessProp === null || accessProp === void 0 ? void 0 : accessProp.children) {
|
|
116
155
|
fnInfo.accessRequests = protoNodeChildrenToAccessRequests(accessProp);
|
|
117
156
|
}
|
|
118
|
-
const
|
|
157
|
+
const grantAccessProp = (_t = node.children) === null || _t === void 0 ? void 0 : _t['$grant-access'];
|
|
158
|
+
if (grantAccessProp === null || grantAccessProp === void 0 ? void 0 : grantAccessProp.children) {
|
|
159
|
+
fnInfo.grantAccessRequests = protoNodeChildrenToGrantAccessRequests(node.name, grantAccessProp);
|
|
160
|
+
}
|
|
161
|
+
if ((_u = node.children) === null || _u === void 0 ? void 0 : _u['$no-passive-access']) {
|
|
162
|
+
fnInfo.noPassiveAccess = true;
|
|
163
|
+
}
|
|
164
|
+
const clientName = 'invoke' + name;
|
|
119
165
|
importMap[clientName] = clientPackageName;
|
|
166
|
+
const argsExportName = 'invoke' + name + 'FunctionArgsScheme';
|
|
167
|
+
const argsPackage = importMap[argsExportName];
|
|
168
|
+
callables.push({
|
|
169
|
+
name,
|
|
170
|
+
exportName: clientName,
|
|
171
|
+
package: clientPackageName,
|
|
172
|
+
args: inputType === 'void' || !inputTypeInfo ? [] : [
|
|
173
|
+
addPackageInfoToProtoType(inputTypeInfo, importMap, 'input')
|
|
174
|
+
],
|
|
175
|
+
argsExportName: argsPackage ? argsExportName : undefined,
|
|
176
|
+
argsPackage,
|
|
177
|
+
returnType: outputType === 'void' || !outputTypeInfo ?
|
|
178
|
+
undefined : addPackageInfoToProtoType(outputTypeInfo, importMap, 'output'),
|
|
179
|
+
isAsync: true,
|
|
180
|
+
});
|
|
120
181
|
if (node.comment) {
|
|
121
182
|
clientOut.push(...protoFormatTsComment(node.comment, '').split('\n'));
|
|
122
183
|
}
|
|
123
184
|
clientOut.push(`export const ${clientName}=(input:${tsInputType}):Promise<${tsOutputType}>=>(`);
|
|
124
185
|
clientOut.push(`${tab}lambdaClient().invokeAsync<${tsInputType},${tsOutputType}>({`);
|
|
186
|
+
clientOut.push(`${tab}${tab}label:${JSON.stringify(name)},`);
|
|
125
187
|
clientOut.push(`${tab}${tab}fn:${paramName}(),`);
|
|
126
188
|
clientOut.push(`${tab}${tab}input,`);
|
|
127
189
|
if (inputPackage) {
|
|
@@ -135,7 +197,7 @@ export const serverFnPlugin = {
|
|
|
135
197
|
clientOut.push(`${tab}})`);
|
|
136
198
|
clientOut.push(')');
|
|
137
199
|
clientOut.push('');
|
|
138
|
-
const handlerName = (
|
|
200
|
+
const handlerName = (_x = (_w = (_v = node.children) === null || _v === void 0 ? void 0 : _v['handlerName']) === null || _w === void 0 ? void 0 : _w.value) !== null && _x !== void 0 ? _x : serverFnHandlerName;
|
|
139
201
|
const isDefault = handlerName === 'default';
|
|
140
202
|
if (!protoIsTsBuiltType(inputType)) {
|
|
141
203
|
imports.push(inputType);
|
|
@@ -180,13 +242,15 @@ export const serverFnPlugin = {
|
|
|
180
242
|
out.push('});');
|
|
181
243
|
protoLabelOutputLines(out, 'handlerExport', startI);
|
|
182
244
|
protoPrependTsImports(imports, importMap, out);
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
245
|
+
if (!sourcePath) {
|
|
246
|
+
outputs.push({
|
|
247
|
+
path: filepath,
|
|
248
|
+
content: out.join('\n'),
|
|
249
|
+
mainExport: isDefault ? undefined : handlerName,
|
|
250
|
+
mainExportAs: name,
|
|
251
|
+
autoMerge: true
|
|
252
|
+
});
|
|
253
|
+
}
|
|
190
254
|
}
|
|
191
255
|
outputs.push({
|
|
192
256
|
path: joinPaths(path, serverFnIndexFilename),
|