@iyio/protogen-runtime 0.0.5 → 0.0.7
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 +32 -0
- package/esm/src/lib/default-plugins.js.map +1 -1
- package/esm/src/lib/plugins/autoPackageIndexPlugin.d.ts +14 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js +45 -0
- package/esm/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -0
- package/esm/src/lib/plugins/bucketCdkTemplate.d.ts +5 -0
- package/esm/src/lib/plugins/bucketCdkTemplate.js +43 -0
- package/esm/src/lib/plugins/bucketCdkTemplate.js.map +1 -0
- package/esm/src/lib/plugins/bucketPlugin.d.ts +38 -0
- package/esm/src/lib/plugins/bucketPlugin.js +61 -0
- package/esm/src/lib/plugins/bucketPlugin.js.map +1 -0
- package/esm/src/lib/plugins/examplePlugin.js +3 -2
- package/esm/src/lib/plugins/examplePlugin.js.map +1 -1
- package/esm/src/lib/plugins/fileWriter.js +22 -6
- package/esm/src/lib/plugins/fileWriter.js.map +1 -1
- package/esm/src/lib/plugins/functionPlugin.d.ts +2 -2
- package/esm/src/lib/plugins/functionPlugin.js +5 -4
- package/esm/src/lib/plugins/functionPlugin.js.map +1 -1
- package/esm/src/lib/plugins/nxLibraryTemplate.d.ts +7 -0
- package/esm/src/lib/plugins/nxLibraryTemplate.js +170 -0
- package/esm/src/lib/plugins/nxLibraryTemplate.js.map +1 -0
- package/esm/src/lib/plugins/paramPlugin.d.ts +20 -0
- package/esm/src/lib/plugins/paramPlugin.js +64 -0
- package/esm/src/lib/plugins/paramPlugin.js.map +1 -0
- package/esm/src/lib/plugins/reactCompPlugin.js +5 -4
- package/esm/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/esm/src/lib/plugins/serverFnCdkTemplate.js +4 -4
- package/esm/src/lib/plugins/serverFnPlugin.d.ts +7 -10
- package/esm/src/lib/plugins/serverFnPlugin.js +29 -66
- package/esm/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/esm/src/lib/plugins/tableCdkTemplate.js +4 -4
- package/esm/src/lib/plugins/tableCdkTemplate.js.map +1 -1
- package/esm/src/lib/plugins/tablePlugin.d.ts +0 -3
- package/esm/src/lib/plugins/tablePlugin.js +9 -27
- package/esm/src/lib/plugins/tablePlugin.js.map +1 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.d.ts +7 -1
- package/esm/src/lib/plugins/tsProtoNodePlugin.js +17 -4
- package/esm/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/esm/src/lib/plugins/userPoolCdkTemplate.d.ts +2 -0
- package/esm/src/lib/plugins/userPoolCdkTemplate.js +24 -0
- package/esm/src/lib/plugins/userPoolCdkTemplate.js.map +1 -0
- package/esm/src/lib/plugins/userPoolPlugin.d.ts +38 -0
- package/esm/src/lib/plugins/userPoolPlugin.js +56 -0
- package/esm/src/lib/plugins/userPoolPlugin.js.map +1 -0
- package/esm/src/lib/plugins/zodPlugin.js +3 -2
- package/esm/src/lib/plugins/zodPlugin.js.map +1 -1
- package/esm/src/lib/runProtogenCliAsync.js +15 -8
- package/esm/src/lib/runProtogenCliAsync.js.map +1 -1
- package/package.json +8 -12
- package/src/lib/default-plugins.js +32 -0
- package/src/lib/default-plugins.js.map +1 -1
- package/src/lib/plugins/autoPackageIndexPlugin.d.ts +14 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js +48 -0
- package/src/lib/plugins/autoPackageIndexPlugin.js.map +1 -0
- package/src/lib/plugins/bucketCdkTemplate.d.ts +5 -0
- package/src/lib/plugins/bucketCdkTemplate.js +47 -0
- package/src/lib/plugins/bucketCdkTemplate.js.map +1 -0
- package/src/lib/plugins/bucketPlugin.d.ts +38 -0
- package/src/lib/plugins/bucketPlugin.js +64 -0
- package/src/lib/plugins/bucketPlugin.js.map +1 -0
- package/src/lib/plugins/examplePlugin.js +3 -2
- package/src/lib/plugins/examplePlugin.js.map +1 -1
- package/src/lib/plugins/fileWriter.js +22 -6
- package/src/lib/plugins/fileWriter.js.map +1 -1
- package/src/lib/plugins/functionPlugin.d.ts +2 -2
- package/src/lib/plugins/functionPlugin.js +5 -4
- package/src/lib/plugins/functionPlugin.js.map +1 -1
- package/src/lib/plugins/nxLibraryTemplate.d.ts +7 -0
- package/src/lib/plugins/nxLibraryTemplate.js +174 -0
- package/src/lib/plugins/nxLibraryTemplate.js.map +1 -0
- package/src/lib/plugins/paramPlugin.d.ts +20 -0
- package/src/lib/plugins/paramPlugin.js +67 -0
- package/src/lib/plugins/paramPlugin.js.map +1 -0
- package/src/lib/plugins/reactCompPlugin.js +5 -4
- package/src/lib/plugins/reactCompPlugin.js.map +1 -1
- package/src/lib/plugins/serverFnCdkTemplate.js +4 -4
- package/src/lib/plugins/serverFnPlugin.d.ts +7 -10
- package/src/lib/plugins/serverFnPlugin.js +27 -64
- package/src/lib/plugins/serverFnPlugin.js.map +1 -1
- package/src/lib/plugins/tableCdkTemplate.js +4 -4
- package/src/lib/plugins/tableCdkTemplate.js.map +1 -1
- package/src/lib/plugins/tablePlugin.d.ts +0 -3
- package/src/lib/plugins/tablePlugin.js +7 -25
- package/src/lib/plugins/tablePlugin.js.map +1 -1
- package/src/lib/plugins/tsProtoNodePlugin.d.ts +7 -1
- package/src/lib/plugins/tsProtoNodePlugin.js +16 -3
- package/src/lib/plugins/tsProtoNodePlugin.js.map +1 -1
- package/src/lib/plugins/userPoolCdkTemplate.d.ts +2 -0
- package/src/lib/plugins/userPoolCdkTemplate.js +28 -0
- package/src/lib/plugins/userPoolCdkTemplate.js.map +1 -0
- package/src/lib/plugins/userPoolPlugin.d.ts +38 -0
- package/src/lib/plugins/userPoolPlugin.js +59 -0
- package/src/lib/plugins/userPoolPlugin.js.map +1 -0
- package/src/lib/plugins/zodPlugin.js +3 -2
- package/src/lib/plugins/zodPlugin.js.map +1 -1
- package/src/lib/runProtogenCliAsync.js +14 -7
- package/src/lib/runProtogenCliAsync.js.map +1 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nxLibraryTemplate = void 0;
|
|
4
|
+
const common_1 = require("@iyio/common");
|
|
5
|
+
const nxLibraryTemplate = ({ path, packageName, jsxType = 'react-jsx', }) => {
|
|
6
|
+
const parts = packageName.split('/');
|
|
7
|
+
const name = parts[parts.length - 1];
|
|
8
|
+
const outputs = {
|
|
9
|
+
'.bablerc': `{
|
|
10
|
+
"presets": [
|
|
11
|
+
[
|
|
12
|
+
"@nrwl/js/babel",
|
|
13
|
+
{
|
|
14
|
+
"useBuiltIns": "usage"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
]
|
|
18
|
+
}
|
|
19
|
+
`,
|
|
20
|
+
'.eslintrc.json': `{
|
|
21
|
+
"extends": ["../../.eslintrc.json"],
|
|
22
|
+
"ignorePatterns": ["!**/*"],
|
|
23
|
+
"overrides": [
|
|
24
|
+
{
|
|
25
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
26
|
+
"rules": {}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"files": ["*.ts", "*.tsx"],
|
|
30
|
+
"rules": {}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"files": ["*.js", "*.jsx"],
|
|
34
|
+
"rules": {}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
`,
|
|
39
|
+
'jest.config.ts': `/* eslint-disable */
|
|
40
|
+
export default {
|
|
41
|
+
displayName: '${name}',
|
|
42
|
+
preset: '../../jest.preset.js',
|
|
43
|
+
testEnvironment: 'node',
|
|
44
|
+
transform: {
|
|
45
|
+
'^.+\\.[tj]s$': [
|
|
46
|
+
'ts-jest',
|
|
47
|
+
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
51
|
+
coverageDirectory: '../../coverage/${path}',
|
|
52
|
+
};
|
|
53
|
+
`,
|
|
54
|
+
'package.json': `{
|
|
55
|
+
"name": "${packageName}",
|
|
56
|
+
"version": "0.0.1",
|
|
57
|
+
"type": "commonjs"
|
|
58
|
+
}
|
|
59
|
+
`,
|
|
60
|
+
'project.json': `{
|
|
61
|
+
"name": "${name}",
|
|
62
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
63
|
+
"sourceRoot": "${path}/src",
|
|
64
|
+
"projectType": "library",
|
|
65
|
+
"targets": {
|
|
66
|
+
"build": {
|
|
67
|
+
"executor": "@iyio/nx-common:lib-builder",
|
|
68
|
+
"outputs": ["{options.outputPath}"],
|
|
69
|
+
"options": {
|
|
70
|
+
"outputPath": "dist/${path}",
|
|
71
|
+
"main": "${path}/src/index.ts",
|
|
72
|
+
"tsConfig": "${path}/tsconfig.lib.json",
|
|
73
|
+
"assets": ["${path}/*.md"]
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"publish": {
|
|
77
|
+
"executor": "nx:run-commands",
|
|
78
|
+
"options": {
|
|
79
|
+
"command": "node tools/scripts/publish.mjs ${name} {args.ver} {args.tag}"
|
|
80
|
+
},
|
|
81
|
+
"dependsOn": ["build"]
|
|
82
|
+
},
|
|
83
|
+
"lint": {
|
|
84
|
+
"executor": "@nrwl/linter:eslint",
|
|
85
|
+
"outputs": ["{options.outputFile}"],
|
|
86
|
+
"options": {
|
|
87
|
+
"lintFilePatterns": ["${path}/**/*.ts"]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"test": {
|
|
91
|
+
"executor": "@nrwl/jest:jest",
|
|
92
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
93
|
+
"options": {
|
|
94
|
+
"jestConfig": "${path}/jest.config.ts",
|
|
95
|
+
"passWithNoTests": true
|
|
96
|
+
},
|
|
97
|
+
"configurations": {
|
|
98
|
+
"ci": {
|
|
99
|
+
"ci": true,
|
|
100
|
+
"codeCoverage": true
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
"tags": []
|
|
106
|
+
}
|
|
107
|
+
`,
|
|
108
|
+
'tsconfig.json': `{
|
|
109
|
+
"extends": "../../tsconfig.base.json",
|
|
110
|
+
"compilerOptions": {
|
|
111
|
+
"module": "commonjs",
|
|
112
|
+
"jsx": "${jsxType}",
|
|
113
|
+
"forceConsistentCasingInFileNames": true,
|
|
114
|
+
"strict": true,
|
|
115
|
+
"noUncheckedIndexedAccess": true,
|
|
116
|
+
"noImplicitOverride": true,
|
|
117
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
118
|
+
"noImplicitReturns": true,
|
|
119
|
+
"noFallthroughCasesInSwitch": true
|
|
120
|
+
},
|
|
121
|
+
"files": [],
|
|
122
|
+
"include": [],
|
|
123
|
+
"references": [
|
|
124
|
+
{
|
|
125
|
+
"path": "./tsconfig.lib.json"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"path": "./tsconfig.spec.json"
|
|
129
|
+
}
|
|
130
|
+
]
|
|
131
|
+
}
|
|
132
|
+
`,
|
|
133
|
+
'tsconfig.lib-esm.json': `{
|
|
134
|
+
"extends": "./tsconfig.lib.json",
|
|
135
|
+
"compilerOptions": {
|
|
136
|
+
"module": "ES2015"
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
`,
|
|
140
|
+
'tsconfig.spec.json': `{
|
|
141
|
+
"extends": "./tsconfig.json",
|
|
142
|
+
"compilerOptions": {
|
|
143
|
+
"outDir": "../../dist/out-tsc",
|
|
144
|
+
"module": "commonjs",
|
|
145
|
+
"types": ["jest", "node"]
|
|
146
|
+
},
|
|
147
|
+
"include": [
|
|
148
|
+
"jest.config.ts",
|
|
149
|
+
"src/**/*.test.ts",
|
|
150
|
+
"src/**/*.spec.ts",
|
|
151
|
+
"src/**/*.d.ts"
|
|
152
|
+
]
|
|
153
|
+
}
|
|
154
|
+
`,
|
|
155
|
+
'tsconfig.lib.json': `{
|
|
156
|
+
"extends": "./tsconfig.json",
|
|
157
|
+
"compilerOptions": {
|
|
158
|
+
"outDir": "../../dist/out-tsc",
|
|
159
|
+
"declaration": true,
|
|
160
|
+
"types": ["node"]
|
|
161
|
+
},
|
|
162
|
+
"include": ["src/**/*.ts"],
|
|
163
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
164
|
+
}
|
|
165
|
+
`,
|
|
166
|
+
};
|
|
167
|
+
return Object.keys(outputs).map(name => ({
|
|
168
|
+
path: (0, common_1.joinPaths)(path, name),
|
|
169
|
+
content: outputs[name],
|
|
170
|
+
overwrite: false,
|
|
171
|
+
}));
|
|
172
|
+
};
|
|
173
|
+
exports.nxLibraryTemplate = nxLibraryTemplate;
|
|
174
|
+
//# sourceMappingURL=nxLibraryTemplate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nxLibraryTemplate.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/nxLibraryTemplate.ts"],"names":[],"mappings":";;;AAAA,yCAAyC;AAUlC,MAAM,iBAAiB,GAAC,CAAC,EAC5B,IAAI,EACJ,WAAW,EACX,OAAO,GAAC,WAAW,GACG,EAAe,EAAE;IAEvC,MAAM,KAAK,GAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACnC,MAAM,IAAI,GAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC;IAEjC,MAAM,OAAO,GAAuB;QAEhC,UAAU,EAClB;;;;;;;;;;CAUC;QAEO,gBAAgB,EACxB;;;;;;;;;;;;;;;;;;CAkBC;QAEO,gBAAgB,EACxB;;oBAEoB,IAAI;;;;;;;;;;yCAUiB,IAAI;;CAE5C;QAEO,cAAc,EACtB;eACe,WAAW;;;;CAIzB;QAEO,cAAc,EACtB;eACe,IAAI;;qBAEE,IAAI;;;;;;;sCAOa,IAAI;2BACf,IAAI;+BACA,IAAI;8BACL,IAAI;;;;;;6DAM2B,IAAI;;;;;;;;wCAQzB,IAAI;;;;;;;iCAOX,IAAI;;;;;;;;;;;;;CAapC;QAEO,eAAe,EACvB;;;;kBAIkB,OAAO;;;;;;;;;;;;;;;;;;;;CAoBxB;QAEO,uBAAuB,EAC/B;;;;;;CAMC;QAEO,oBAAoB,EAC5B;;;;;;;;;;;;;;CAcC;QAEO,mBAAmB,EAC3B;;;;;;;;;;CAUC;KACI,CAAA;IAGD,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAc,IAAI,CAAA,EAAE,CAAA,CAAC;QAChD,IAAI,EAAC,IAAA,kBAAS,EAAC,IAAI,EAAC,IAAI,CAAC;QACzB,OAAO,EAAC,OAAO,CAAC,IAAI,CAAC;QACrB,SAAS,EAAC,KAAK;KAClB,CAAC,CAAC,CAAC;AAER,CAAC,CAAA;AAlMY,QAAA,iBAAiB,qBAkM7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProtoPipelineConfigurablePlugin } from "@iyio/protogen";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
declare const ParamPluginConfig: z.ZodObject<{
|
|
4
|
+
/**
|
|
5
|
+
* @default "params-index.ts"
|
|
6
|
+
*/
|
|
7
|
+
paramIndexFilename: z.ZodOptional<z.ZodString>;
|
|
8
|
+
/**
|
|
9
|
+
* @default "params.ts"
|
|
10
|
+
*/
|
|
11
|
+
paramsFilename: z.ZodOptional<z.ZodString>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
paramIndexFilename?: string | undefined;
|
|
14
|
+
paramsFilename?: string | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
paramIndexFilename?: string | undefined;
|
|
17
|
+
paramsFilename?: string | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const paramPlugin: ProtoPipelineConfigurablePlugin<typeof ParamPluginConfig>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paramPlugin = 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 ParamPluginConfig = zod_1.z.object({
|
|
9
|
+
/**
|
|
10
|
+
* @default "params-index.ts"
|
|
11
|
+
*/
|
|
12
|
+
paramIndexFilename: zod_1.z.string().optional(),
|
|
13
|
+
/**
|
|
14
|
+
* @default "params.ts"
|
|
15
|
+
*/
|
|
16
|
+
paramsFilename: zod_1.z.string().optional(),
|
|
17
|
+
});
|
|
18
|
+
exports.paramPlugin = {
|
|
19
|
+
configScheme: ParamPluginConfig,
|
|
20
|
+
generate: ({ outputs, namespace, packagePaths, libStyle, paramPackageName, paramMap, }, { paramsFilename = 'params.ts', paramIndexFilename = 'params-index.ts', }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
if (!(0, common_1.objHasValues)(paramMap)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, paramPackageName, paramPackageName, libStyle, { packagePaths: packagePaths, indexFilename: paramIndexFilename });
|
|
25
|
+
const out = [''];
|
|
26
|
+
const types = [];
|
|
27
|
+
const defMap = {
|
|
28
|
+
'string': 'defineStringParam',
|
|
29
|
+
'boolean': 'defineBoolParam',
|
|
30
|
+
'number': 'defineNumberParam',
|
|
31
|
+
};
|
|
32
|
+
for (const paramName in paramMap) {
|
|
33
|
+
const paramType = paramMap[paramName];
|
|
34
|
+
if (!types.includes(paramType)) {
|
|
35
|
+
types.push(paramType);
|
|
36
|
+
}
|
|
37
|
+
const shortName = paramName.endsWith('Param') ? paramName.substring(0, paramName.length - 5) : paramName;
|
|
38
|
+
out.push(`export const ${paramName}=${defMap[paramType]}(${JSON.stringify(shortName)});`);
|
|
39
|
+
}
|
|
40
|
+
if (types.includes('string')) {
|
|
41
|
+
out.unshift('import { defineStringParam } from "@iyio/common";');
|
|
42
|
+
}
|
|
43
|
+
if (types.includes('number')) {
|
|
44
|
+
out.unshift('import { defineNumberParam } from "@iyio/common";');
|
|
45
|
+
}
|
|
46
|
+
if (types.includes('boolean')) {
|
|
47
|
+
out.unshift('import { defineBoolParam } from "@iyio/common";');
|
|
48
|
+
}
|
|
49
|
+
outputs.push({
|
|
50
|
+
path: (0, common_1.joinPaths)(path, paramsFilename),
|
|
51
|
+
content: out.join('\n'),
|
|
52
|
+
mergeHandler: protogen_1.protoMergeTsImports
|
|
53
|
+
});
|
|
54
|
+
// add index file
|
|
55
|
+
outputs.push({
|
|
56
|
+
path: (0, common_1.joinPaths)(path, paramIndexFilename),
|
|
57
|
+
content: '',
|
|
58
|
+
isPackageIndex: true,
|
|
59
|
+
generator: {
|
|
60
|
+
root: path,
|
|
61
|
+
recursive: true,
|
|
62
|
+
generator: protogen_1.protoGenerateTsIndex
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
})
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=paramPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paramPlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/paramPlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAAuD;AACvD,6CAAuJ;AACvJ,6BAAwB;AAExB,MAAM,iBAAiB,GAAC,OAAC,CAAC,MAAM,CAChC;IAEI;;OAEG;IACH,kBAAkB,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAExC;;OAEG;IACH,cAAc,EAAC,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAA;AAEW,QAAA,WAAW,GACxB;IACI,YAAY,EAAC,iBAAi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;YACxB,GAAG,CAAC,OAAO,CAAC,mDAAmD,CAAC,CAAC;SACpE;QACD,IAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC;YACxB,GAAG,CAAC,OAAO,CAAC,mDAAmD,CAAC,CAAC;SACpE;QACD,IAAG,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAC;YACzB,GAAG,CAAC,OAAO,CAAC,iDAAiD,CAAC,CAAC;SAClE;QAED,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,IAAA,kBAAS,EAAC,IAAI,EAAC,cAAc,CAAC;YACnC,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACtB,YAAY,EAAC,8BAAmB;SACnC,CAAC,CAAA;QAEF,iBAAiB;QACjB,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,IAAA,kBAAS,EAAC,IAAI,EAAC,kBAAkB,CAAC;YACvC,OAAO,EAAC,EAAE;YACV,cAAc,EAAC,IAAI;YACnB,SAAS,EAAC;gBACN,IAAI,EAAC,IAAI;gBACT,SAAS,EAAC,IAAI;gBACd,SAAS,EAAC,+BAAoB;aACjC;SACJ,CAAC,CAAA;IACN,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -27,9 +27,9 @@ const ReactCompPluginConfig = zod_1.z.object({
|
|
|
27
27
|
exports.reactCompPlugin = {
|
|
28
28
|
configScheme: ReactCompPluginConfig,
|
|
29
29
|
generate: (ctx, config) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
-
const { log, nodes, outputs, packagePaths, namespace, } = ctx;
|
|
30
|
+
const { log, nodes, outputs, packagePaths, namespace, libStyle, } = ctx;
|
|
31
31
|
const { reactCompPackage = 'components', reactCompPath, reactCompIndexFilename = 'react-comp-index.ts' } = config;
|
|
32
|
-
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath, { packagePaths, indexFilename: reactCompIndexFilename });
|
|
32
|
+
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath, libStyle, { packagePaths, indexFilename: reactCompIndexFilename });
|
|
33
33
|
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
34
34
|
log(`reactPlugin. ${supported.length} supported node(s)`);
|
|
35
35
|
for (const node of supported) {
|
|
@@ -40,6 +40,7 @@ exports.reactCompPlugin = {
|
|
|
40
40
|
outputs.push({
|
|
41
41
|
path: (0, common_1.joinPaths)(path, reactCompIndexFilename),
|
|
42
42
|
content: '',
|
|
43
|
+
isPackageIndex: true,
|
|
43
44
|
generator: {
|
|
44
45
|
root: path,
|
|
45
46
|
recursive: true,
|
|
@@ -49,9 +50,9 @@ exports.reactCompPlugin = {
|
|
|
49
50
|
}
|
|
50
51
|
})
|
|
51
52
|
};
|
|
52
|
-
const generateComponentAsync = (node, { tab, importMap, outputs, namespace, }, { reactCompPackage = 'components', reactCompPath, reactCompUseStyledJsx = false, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
const generateComponentAsync = (node, { tab, importMap, outputs, namespace, libStyle, }, { reactCompPackage = 'components', reactCompPath, reactCompUseStyledJsx = false, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
53
54
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
54
|
-
const { path, packageName } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath);
|
|
55
|
+
const { path, packageName } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, reactCompPackage, reactCompPath, libStyle);
|
|
55
56
|
const imports = [];
|
|
56
57
|
const addImport = (im, pkg) => {
|
|
57
58
|
(0, protogen_1.addTsImport)(im, pkg, imports, importMap);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactCompPlugin.js","sourceRoot":"","sources":["../../../../../../packages/protogen-runtime/src/lib/plugins/reactCompPlugin.ts"],"names":[],"mappings":";;;;AAAA,yCAA4D;AAC5D,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;IACnB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEb,IAAG,OAAO,CAAC,MAAM,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"}
|
|
@@ -8,12 +8,12 @@ const serverFnCdkTemplate = (constructName, infos, importMap) => {
|
|
|
8
8
|
imports.push(`import { ${t.arnParam} as _fnParam${i}} from '${importMap[t.arnParam]}';`);
|
|
9
9
|
}
|
|
10
10
|
return `import { Construct } from "constructs";
|
|
11
|
-
import { FnsBuilder, FnInfo,
|
|
11
|
+
import { FnsBuilder, FnInfo, ManagedProps } from "@iyio/cdk-common";
|
|
12
12
|
${imports.join('\n')}
|
|
13
13
|
|
|
14
14
|
export interface ${constructName}Props
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
managed?:ManagedProps;
|
|
17
17
|
transform?:(fnInfos:FnInfo[])=>FnInfo[];
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -25,13 +25,13 @@ export class ${constructName} extends FnsBuilder
|
|
|
25
25
|
...props
|
|
26
26
|
}:${constructName}Props={}){
|
|
27
27
|
|
|
28
|
-
super(scope,name,{...props,fnsInfo:transform?transform(
|
|
28
|
+
super(scope,name,{...props,fnsInfo:transform?transform(getFnsInfo()):getFnsInfo()});
|
|
29
29
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const
|
|
34
|
+
const getFnsInfo=():FnInfo[]=>[
|
|
35
35
|
${infos.map((info, i) => {
|
|
36
36
|
var _a;
|
|
37
37
|
return ` {
|
|
@@ -6,7 +6,7 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
6
6
|
*/
|
|
7
7
|
serverFnPath: z.ZodOptional<z.ZodString>;
|
|
8
8
|
/**
|
|
9
|
-
* @default "
|
|
9
|
+
* @default "fns"
|
|
10
10
|
*/
|
|
11
11
|
serverFnPackage: z.ZodOptional<z.ZodString>;
|
|
12
12
|
/**
|
|
@@ -14,19 +14,15 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
14
14
|
*/
|
|
15
15
|
serverFnClientPath: z.ZodOptional<z.ZodString>;
|
|
16
16
|
/**
|
|
17
|
-
* @default "
|
|
17
|
+
* @default "fn-clients"
|
|
18
18
|
*/
|
|
19
19
|
serverFnClientPackage: z.ZodOptional<z.ZodString>;
|
|
20
20
|
/**
|
|
21
|
-
* @default "
|
|
22
|
-
*/
|
|
23
|
-
serverFnParamsFilename: z.ZodOptional<z.ZodString>;
|
|
24
|
-
/**
|
|
25
|
-
* @default "serverFn-client-index.ts"
|
|
21
|
+
* @default "fn-clients-index.ts"
|
|
26
22
|
*/
|
|
27
23
|
serverFnClientIndexFilename: z.ZodOptional<z.ZodString>;
|
|
28
24
|
/**
|
|
29
|
-
* @default "
|
|
25
|
+
* @default "fn-clients.ts"
|
|
30
26
|
*/
|
|
31
27
|
serverFnClientFilename: z.ZodOptional<z.ZodString>;
|
|
32
28
|
/**
|
|
@@ -41,6 +37,7 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
41
37
|
* @default "@iyio/aws-lambda"
|
|
42
38
|
*/
|
|
43
39
|
serverFnLambdaPackage: z.ZodOptional<z.ZodString>;
|
|
40
|
+
serverFnIndexFilename: z.ZodOptional<z.ZodString>;
|
|
44
41
|
/**
|
|
45
42
|
* If defined a CDK construct file will be generated that can be used to deploy the
|
|
46
43
|
* functions
|
|
@@ -59,12 +56,12 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
59
56
|
serverFnPackage?: string | undefined;
|
|
60
57
|
serverFnClientPath?: string | undefined;
|
|
61
58
|
serverFnClientPackage?: string | undefined;
|
|
62
|
-
serverFnParamsFilename?: string | undefined;
|
|
63
59
|
serverFnClientIndexFilename?: string | undefined;
|
|
64
60
|
serverFnClientFilename?: string | undefined;
|
|
65
61
|
serverFnHandlerName?: string | undefined;
|
|
66
62
|
serverFnLibPackage?: string | undefined;
|
|
67
63
|
serverFnLambdaPackage?: string | undefined;
|
|
64
|
+
serverFnIndexFilename?: string | undefined;
|
|
68
65
|
serverFnCdkConstructFile?: string | undefined;
|
|
69
66
|
serverFnCdkConstructClassName?: string | undefined;
|
|
70
67
|
serverFnDistPath?: string | undefined;
|
|
@@ -73,12 +70,12 @@ declare const ServerFnPluginConfig: z.ZodObject<{
|
|
|
73
70
|
serverFnPackage?: string | undefined;
|
|
74
71
|
serverFnClientPath?: string | undefined;
|
|
75
72
|
serverFnClientPackage?: string | undefined;
|
|
76
|
-
serverFnParamsFilename?: string | undefined;
|
|
77
73
|
serverFnClientIndexFilename?: string | undefined;
|
|
78
74
|
serverFnClientFilename?: string | undefined;
|
|
79
75
|
serverFnHandlerName?: string | undefined;
|
|
80
76
|
serverFnLibPackage?: string | undefined;
|
|
81
77
|
serverFnLambdaPackage?: string | undefined;
|
|
78
|
+
serverFnIndexFilename?: string | undefined;
|
|
82
79
|
serverFnCdkConstructFile?: string | undefined;
|
|
83
80
|
serverFnCdkConstructClassName?: string | undefined;
|
|
84
81
|
serverFnDistPath?: string | undefined;
|
|
@@ -13,7 +13,7 @@ const ServerFnPluginConfig = zod_1.z.object({
|
|
|
13
13
|
*/
|
|
14
14
|
serverFnPath: zod_1.z.string().optional(),
|
|
15
15
|
/**
|
|
16
|
-
* @default "
|
|
16
|
+
* @default "fns"
|
|
17
17
|
*/
|
|
18
18
|
serverFnPackage: zod_1.z.string().optional(),
|
|
19
19
|
/**
|
|
@@ -21,19 +21,15 @@ const ServerFnPluginConfig = zod_1.z.object({
|
|
|
21
21
|
*/
|
|
22
22
|
serverFnClientPath: zod_1.z.string().optional(),
|
|
23
23
|
/**
|
|
24
|
-
* @default "
|
|
24
|
+
* @default "fn-clients"
|
|
25
25
|
*/
|
|
26
26
|
serverFnClientPackage: zod_1.z.string().optional(),
|
|
27
27
|
/**
|
|
28
|
-
* @default "
|
|
29
|
-
*/
|
|
30
|
-
serverFnParamsFilename: zod_1.z.string().optional(),
|
|
31
|
-
/**
|
|
32
|
-
* @default "serverFn-client-index.ts"
|
|
28
|
+
* @default "fn-clients-index.ts"
|
|
33
29
|
*/
|
|
34
30
|
serverFnClientIndexFilename: zod_1.z.string().optional(),
|
|
35
31
|
/**
|
|
36
|
-
* @default "
|
|
32
|
+
* @default "fn-clients.ts"
|
|
37
33
|
*/
|
|
38
34
|
serverFnClientFilename: zod_1.z.string().optional(),
|
|
39
35
|
/**
|
|
@@ -48,6 +44,7 @@ const ServerFnPluginConfig = zod_1.z.object({
|
|
|
48
44
|
* @default "@iyio/aws-lambda"
|
|
49
45
|
*/
|
|
50
46
|
serverFnLambdaPackage: zod_1.z.string().optional(),
|
|
47
|
+
serverFnIndexFilename: zod_1.z.string().optional(),
|
|
51
48
|
/**
|
|
52
49
|
* If defined a CDK construct file will be generated that can be used to deploy the
|
|
53
50
|
* functions
|
|
@@ -64,20 +61,17 @@ const ServerFnPluginConfig = zod_1.z.object({
|
|
|
64
61
|
});
|
|
65
62
|
exports.serverFnPlugin = {
|
|
66
63
|
configScheme: ServerFnPluginConfig,
|
|
67
|
-
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, }, { serverFnPackage = '
|
|
68
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
69
|
-
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnPackage, serverFnPath);
|
|
64
|
+
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, }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
66
|
+
const { path } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnPackage, serverFnPath, libStyle, { packagePaths, indexFilename: serverFnIndexFilename });
|
|
70
67
|
const cdkRelPath = ('../'
|
|
71
68
|
.repeat((0, common_1.getSubstringCount)(path, '/') - 1));
|
|
72
|
-
const { path: clientPath, packageName: clientPackageName } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnClientPackage, serverFnClientPath, { packagePaths, indexFilename: serverFnClientIndexFilename });
|
|
69
|
+
const { path: clientPath, packageName: clientPackageName } = (0, protogen_1.getProtoPluginPackAndPath)(namespace, serverFnClientPackage, serverFnClientPath, libStyle, { packagePaths, indexFilename: serverFnClientIndexFilename });
|
|
73
70
|
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
74
71
|
log(`${supported.length} supported node(s)`);
|
|
75
72
|
if (!supported.length) {
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
|
-
const paramsOut = [];
|
|
79
|
-
paramsOut.push('import { defineStringParam } from "@iyio/common";');
|
|
80
|
-
paramsOut.push('');
|
|
81
75
|
const clientOut = [];
|
|
82
76
|
const clientInputs = [];
|
|
83
77
|
const clientParamImports = [];
|
|
@@ -93,10 +87,8 @@ exports.serverFnPlugin = {
|
|
|
93
87
|
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';
|
|
94
88
|
const inputPackage = importMap[inputType + 'Scheme'];
|
|
95
89
|
const outputPackage = importMap[outputType + 'Scheme'];
|
|
96
|
-
const paramName = (0,
|
|
97
|
-
importMap[paramName] = clientPackageName;
|
|
90
|
+
const paramName = (0, protogen_1.protoAddContextParam)(name + 'Arn', paramPackage, paramMap, importMap);
|
|
98
91
|
clientParamImports.push(paramName);
|
|
99
|
-
paramsOut.push(`export const ${paramName}=defineStringParam('${(0, common_1.strFirstToLower)(name)}Arn');`);
|
|
100
92
|
const fnInfo = {
|
|
101
93
|
name,
|
|
102
94
|
createProps: {
|
|
@@ -104,49 +96,12 @@ exports.serverFnPlugin = {
|
|
|
104
96
|
handlerFileName: (0, common_1.joinPaths)(cdkRelPath, filepath),
|
|
105
97
|
handler: 'handler'
|
|
106
98
|
},
|
|
107
|
-
arnParam: paramName
|
|
108
|
-
accessRequests: []
|
|
99
|
+
arnParam: paramName
|
|
109
100
|
};
|
|
110
101
|
infos.push(fnInfo);
|
|
111
|
-
const accessProp = (_j = node.children) === null || _j === void 0 ? void 0 : _j['access'];
|
|
102
|
+
const accessProp = (_j = node.children) === null || _j === void 0 ? void 0 : _j['$access'];
|
|
112
103
|
if (accessProp === null || accessProp === void 0 ? void 0 : accessProp.children) {
|
|
113
|
-
|
|
114
|
-
const child = accessProp.children[c];
|
|
115
|
-
const types = child.name.split('-');
|
|
116
|
-
for (const type of child.types) {
|
|
117
|
-
(_k = fnInfo.accessRequests) === null || _k === void 0 ? void 0 : _k.push({
|
|
118
|
-
grantName: type.type,
|
|
119
|
-
types,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
let child = (_l = accessProp.children) === null || _l === void 0 ? void 0 : _l['read'];
|
|
124
|
-
if (child) {
|
|
125
|
-
for (const type of child.types) {
|
|
126
|
-
(_m = fnInfo.accessRequests) === null || _m === void 0 ? void 0 : _m.push({
|
|
127
|
-
grantName: type.type,
|
|
128
|
-
types: ['read'],
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
child = (_o = accessProp.children) === null || _o === void 0 ? void 0 : _o['write'];
|
|
133
|
-
if (child) {
|
|
134
|
-
for (const type of child.types) {
|
|
135
|
-
(_p = fnInfo.accessRequests) === null || _p === void 0 ? void 0 : _p.push({
|
|
136
|
-
grantName: type.type,
|
|
137
|
-
types: ['write'],
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
child = (_q = accessProp.children) === null || _q === void 0 ? void 0 : _q['readWrite'];
|
|
142
|
-
if (child) {
|
|
143
|
-
for (const type of child.types) {
|
|
144
|
-
(_r = fnInfo.accessRequests) === null || _r === void 0 ? void 0 : _r.push({
|
|
145
|
-
grantName: type.type,
|
|
146
|
-
types: ['read', 'write'],
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
}
|
|
104
|
+
fnInfo.accessRequests = (0, protogen_1.protoNodeChildrenToAccessRequests)(accessProp);
|
|
150
105
|
}
|
|
151
106
|
const clientName = name.endsWith('Fn') ? name.substring(0, name.length - 2) : name;
|
|
152
107
|
importMap[clientName] = clientPackageName;
|
|
@@ -168,7 +123,7 @@ exports.serverFnPlugin = {
|
|
|
168
123
|
clientOut.push(`${tab}})`);
|
|
169
124
|
clientOut.push(')');
|
|
170
125
|
clientOut.push('');
|
|
171
|
-
const handlerName = (
|
|
126
|
+
const handlerName = (_m = (_l = (_k = node.children) === null || _k === void 0 ? void 0 : _k['handlerName']) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : serverFnHandlerName;
|
|
172
127
|
const isDefault = handlerName === 'default';
|
|
173
128
|
if (!(0, protogen_1.protoIsTsBuiltType)(inputType)) {
|
|
174
129
|
imports.push(inputType);
|
|
@@ -206,23 +161,31 @@ exports.serverFnPlugin = {
|
|
|
206
161
|
outputs.push({
|
|
207
162
|
path: filepath,
|
|
208
163
|
content: out.join('\n'),
|
|
164
|
+
mainExport: isDefault ? undefined : handlerName,
|
|
165
|
+
mainExportAs: name,
|
|
209
166
|
autoMerge: true,
|
|
210
167
|
mergeHandler: protogen_1.protoMergeTsImports
|
|
211
168
|
});
|
|
212
169
|
}
|
|
213
|
-
|
|
170
|
+
outputs.push({
|
|
171
|
+
path: (0, common_1.joinPaths)(path, serverFnIndexFilename),
|
|
172
|
+
content: '',
|
|
173
|
+
isPackageIndex: true,
|
|
174
|
+
generator: {
|
|
175
|
+
root: path,
|
|
176
|
+
generator: protogen_1.protoGenerateTsIndex
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
clientOut.unshift(`import { ${clientParamImports.join(', ')} } from '${paramPackage}';`);
|
|
214
180
|
(0, protogen_1.protoPrependTsImports)(clientInputs, importMap, clientOut);
|
|
215
181
|
outputs.push({
|
|
216
182
|
path: (0, common_1.joinPaths)(clientPath, serverFnClientFilename),
|
|
217
183
|
content: clientOut.join('\n'),
|
|
218
184
|
});
|
|
219
|
-
outputs.push({
|
|
220
|
-
path: (0, common_1.joinPaths)(clientPath, serverFnParamsFilename),
|
|
221
|
-
content: paramsOut.join('\n'),
|
|
222
|
-
});
|
|
223
185
|
outputs.push({
|
|
224
186
|
path: (0, common_1.joinPaths)(clientPath, serverFnClientIndexFilename),
|
|
225
187
|
content: '',
|
|
188
|
+
isPackageIndex: true,
|
|
226
189
|
generator: {
|
|
227
190
|
root: clientPath,
|
|
228
191
|
generator: protogen_1.protoGenerateTsIndex
|