@iyio/protogen-runtime 0.0.4 → 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 +5 -3
- package/esm/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- 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 +6 -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 +5 -3
- package/src/lib/plugins/serverFnCdkTemplate.js.map +1 -1
- 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 +6 -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,170 @@
|
|
|
1
|
+
import { joinPaths } from "@iyio/common";
|
|
2
|
+
export const nxLibraryTemplate = ({ path, packageName, jsxType = 'react-jsx', }) => {
|
|
3
|
+
const parts = packageName.split('/');
|
|
4
|
+
const name = parts[parts.length - 1];
|
|
5
|
+
const outputs = {
|
|
6
|
+
'.bablerc': `{
|
|
7
|
+
"presets": [
|
|
8
|
+
[
|
|
9
|
+
"@nrwl/js/babel",
|
|
10
|
+
{
|
|
11
|
+
"useBuiltIns": "usage"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
]
|
|
15
|
+
}
|
|
16
|
+
`,
|
|
17
|
+
'.eslintrc.json': `{
|
|
18
|
+
"extends": ["../../.eslintrc.json"],
|
|
19
|
+
"ignorePatterns": ["!**/*"],
|
|
20
|
+
"overrides": [
|
|
21
|
+
{
|
|
22
|
+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
|
23
|
+
"rules": {}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"files": ["*.ts", "*.tsx"],
|
|
27
|
+
"rules": {}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"files": ["*.js", "*.jsx"],
|
|
31
|
+
"rules": {}
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
`,
|
|
36
|
+
'jest.config.ts': `/* eslint-disable */
|
|
37
|
+
export default {
|
|
38
|
+
displayName: '${name}',
|
|
39
|
+
preset: '../../jest.preset.js',
|
|
40
|
+
testEnvironment: 'node',
|
|
41
|
+
transform: {
|
|
42
|
+
'^.+\\.[tj]s$': [
|
|
43
|
+
'ts-jest',
|
|
44
|
+
{ tsconfig: '<rootDir>/tsconfig.spec.json' },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
48
|
+
coverageDirectory: '../../coverage/${path}',
|
|
49
|
+
};
|
|
50
|
+
`,
|
|
51
|
+
'package.json': `{
|
|
52
|
+
"name": "${packageName}",
|
|
53
|
+
"version": "0.0.1",
|
|
54
|
+
"type": "commonjs"
|
|
55
|
+
}
|
|
56
|
+
`,
|
|
57
|
+
'project.json': `{
|
|
58
|
+
"name": "${name}",
|
|
59
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
60
|
+
"sourceRoot": "${path}/src",
|
|
61
|
+
"projectType": "library",
|
|
62
|
+
"targets": {
|
|
63
|
+
"build": {
|
|
64
|
+
"executor": "@iyio/nx-common:lib-builder",
|
|
65
|
+
"outputs": ["{options.outputPath}"],
|
|
66
|
+
"options": {
|
|
67
|
+
"outputPath": "dist/${path}",
|
|
68
|
+
"main": "${path}/src/index.ts",
|
|
69
|
+
"tsConfig": "${path}/tsconfig.lib.json",
|
|
70
|
+
"assets": ["${path}/*.md"]
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"publish": {
|
|
74
|
+
"executor": "nx:run-commands",
|
|
75
|
+
"options": {
|
|
76
|
+
"command": "node tools/scripts/publish.mjs ${name} {args.ver} {args.tag}"
|
|
77
|
+
},
|
|
78
|
+
"dependsOn": ["build"]
|
|
79
|
+
},
|
|
80
|
+
"lint": {
|
|
81
|
+
"executor": "@nrwl/linter:eslint",
|
|
82
|
+
"outputs": ["{options.outputFile}"],
|
|
83
|
+
"options": {
|
|
84
|
+
"lintFilePatterns": ["${path}/**/*.ts"]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"test": {
|
|
88
|
+
"executor": "@nrwl/jest:jest",
|
|
89
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
90
|
+
"options": {
|
|
91
|
+
"jestConfig": "${path}/jest.config.ts",
|
|
92
|
+
"passWithNoTests": true
|
|
93
|
+
},
|
|
94
|
+
"configurations": {
|
|
95
|
+
"ci": {
|
|
96
|
+
"ci": true,
|
|
97
|
+
"codeCoverage": true
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
"tags": []
|
|
103
|
+
}
|
|
104
|
+
`,
|
|
105
|
+
'tsconfig.json': `{
|
|
106
|
+
"extends": "../../tsconfig.base.json",
|
|
107
|
+
"compilerOptions": {
|
|
108
|
+
"module": "commonjs",
|
|
109
|
+
"jsx": "${jsxType}",
|
|
110
|
+
"forceConsistentCasingInFileNames": true,
|
|
111
|
+
"strict": true,
|
|
112
|
+
"noUncheckedIndexedAccess": true,
|
|
113
|
+
"noImplicitOverride": true,
|
|
114
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
115
|
+
"noImplicitReturns": true,
|
|
116
|
+
"noFallthroughCasesInSwitch": true
|
|
117
|
+
},
|
|
118
|
+
"files": [],
|
|
119
|
+
"include": [],
|
|
120
|
+
"references": [
|
|
121
|
+
{
|
|
122
|
+
"path": "./tsconfig.lib.json"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"path": "./tsconfig.spec.json"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
}
|
|
129
|
+
`,
|
|
130
|
+
'tsconfig.lib-esm.json': `{
|
|
131
|
+
"extends": "./tsconfig.lib.json",
|
|
132
|
+
"compilerOptions": {
|
|
133
|
+
"module": "ES2015"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
`,
|
|
137
|
+
'tsconfig.spec.json': `{
|
|
138
|
+
"extends": "./tsconfig.json",
|
|
139
|
+
"compilerOptions": {
|
|
140
|
+
"outDir": "../../dist/out-tsc",
|
|
141
|
+
"module": "commonjs",
|
|
142
|
+
"types": ["jest", "node"]
|
|
143
|
+
},
|
|
144
|
+
"include": [
|
|
145
|
+
"jest.config.ts",
|
|
146
|
+
"src/**/*.test.ts",
|
|
147
|
+
"src/**/*.spec.ts",
|
|
148
|
+
"src/**/*.d.ts"
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
`,
|
|
152
|
+
'tsconfig.lib.json': `{
|
|
153
|
+
"extends": "./tsconfig.json",
|
|
154
|
+
"compilerOptions": {
|
|
155
|
+
"outDir": "../../dist/out-tsc",
|
|
156
|
+
"declaration": true,
|
|
157
|
+
"types": ["node"]
|
|
158
|
+
},
|
|
159
|
+
"include": ["src/**/*.ts"],
|
|
160
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
161
|
+
}
|
|
162
|
+
`,
|
|
163
|
+
};
|
|
164
|
+
return Object.keys(outputs).map(name => ({
|
|
165
|
+
path: joinPaths(path, name),
|
|
166
|
+
content: outputs[name],
|
|
167
|
+
overwrite: false,
|
|
168
|
+
}));
|
|
169
|
+
};
|
|
170
|
+
//# 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,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAUzC,MAAM,CAAC,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,SAAS,CAAC,IAAI,EAAC,IAAI,CAAC;QACzB,OAAO,EAAC,OAAO,CAAC,IAAI,CAAC;QACrB,SAAS,EAAC,KAAK;KAClB,CAAC,CAAC,CAAC;AAER,CAAC,CAAA"}
|
|
@@ -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,64 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { joinPaths, objHasValues } from "@iyio/common";
|
|
3
|
+
import { getProtoPluginPackAndPath, protoGenerateTsIndex, protoMergeTsImports } from "@iyio/protogen";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const ParamPluginConfig = z.object({
|
|
6
|
+
/**
|
|
7
|
+
* @default "params-index.ts"
|
|
8
|
+
*/
|
|
9
|
+
paramIndexFilename: z.string().optional(),
|
|
10
|
+
/**
|
|
11
|
+
* @default "params.ts"
|
|
12
|
+
*/
|
|
13
|
+
paramsFilename: z.string().optional(),
|
|
14
|
+
});
|
|
15
|
+
export const paramPlugin = {
|
|
16
|
+
configScheme: ParamPluginConfig,
|
|
17
|
+
generate: ({ outputs, namespace, packagePaths, libStyle, paramPackageName, paramMap, }, { paramsFilename = 'params.ts', paramIndexFilename = 'params-index.ts', }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
if (!objHasValues(paramMap)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const { path } = getProtoPluginPackAndPath(namespace, paramPackageName, paramPackageName, libStyle, { packagePaths: packagePaths, indexFilename: paramIndexFilename });
|
|
22
|
+
const out = [''];
|
|
23
|
+
const types = [];
|
|
24
|
+
const defMap = {
|
|
25
|
+
'string': 'defineStringParam',
|
|
26
|
+
'boolean': 'defineBoolParam',
|
|
27
|
+
'number': 'defineNumberParam',
|
|
28
|
+
};
|
|
29
|
+
for (const paramName in paramMap) {
|
|
30
|
+
const paramType = paramMap[paramName];
|
|
31
|
+
if (!types.includes(paramType)) {
|
|
32
|
+
types.push(paramType);
|
|
33
|
+
}
|
|
34
|
+
const shortName = paramName.endsWith('Param') ? paramName.substring(0, paramName.length - 5) : paramName;
|
|
35
|
+
out.push(`export const ${paramName}=${defMap[paramType]}(${JSON.stringify(shortName)});`);
|
|
36
|
+
}
|
|
37
|
+
if (types.includes('string')) {
|
|
38
|
+
out.unshift('import { defineStringParam } from "@iyio/common";');
|
|
39
|
+
}
|
|
40
|
+
if (types.includes('number')) {
|
|
41
|
+
out.unshift('import { defineNumberParam } from "@iyio/common";');
|
|
42
|
+
}
|
|
43
|
+
if (types.includes('boolean')) {
|
|
44
|
+
out.unshift('import { defineBoolParam } from "@iyio/common";');
|
|
45
|
+
}
|
|
46
|
+
outputs.push({
|
|
47
|
+
path: joinPaths(path, paramsFilename),
|
|
48
|
+
content: out.join('\n'),
|
|
49
|
+
mergeHandler: protoMergeTsImports
|
|
50
|
+
});
|
|
51
|
+
// add index file
|
|
52
|
+
outputs.push({
|
|
53
|
+
path: joinPaths(path, paramIndexFilename),
|
|
54
|
+
content: '',
|
|
55
|
+
isPackageIndex: true,
|
|
56
|
+
generator: {
|
|
57
|
+
root: path,
|
|
58
|
+
recursive: true,
|
|
59
|
+
generator: protoGenerateTsIndex
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
//# 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,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,mBAAmB,EAAmD,MAAM,gBAAgB,CAAC;AACvJ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAC,CAAC,CAAC,MAAM,CAChC;IAEI;;OAEG;IACH,kBAAkB,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAExC;;OAEG;IACH,cAAc,EAAC,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,WAAW,GACxB;IACI,YAAY,EAAC,iBAAiB;IAC9B,QAAQ,EAAC,CAAO,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AC,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,SAAS,CAAC,IAAI,EAAC,cAAc,CAAC;YACnC,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YACtB,YAAY,EAAC,mBAAmB;SACnC,CAAC,CAAA;QAEF,iBAAiB;QACjB,OAAO,CAAC,IAAI,CAAC;YACT,IAAI,EAAC,SAAS,CAAC,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,oBAAoB;aACjC;SACJ,CAAC,CAAA;IACN,CAAC,CAAA;CACJ,CAAA"}
|
|
@@ -24,9 +24,9 @@ const ReactCompPluginConfig = z.object({
|
|
|
24
24
|
export const reactCompPlugin = {
|
|
25
25
|
configScheme: ReactCompPluginConfig,
|
|
26
26
|
generate: (ctx, config) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
const { log, nodes, outputs, packagePaths, namespace, } = ctx;
|
|
27
|
+
const { log, nodes, outputs, packagePaths, namespace, libStyle, } = ctx;
|
|
28
28
|
const { reactCompPackage = 'components', reactCompPath, reactCompIndexFilename = 'react-comp-index.ts' } = config;
|
|
29
|
-
const { path } = getProtoPluginPackAndPath(namespace, reactCompPackage, reactCompPath, { packagePaths, indexFilename: reactCompIndexFilename });
|
|
29
|
+
const { path } = getProtoPluginPackAndPath(namespace, reactCompPackage, reactCompPath, libStyle, { packagePaths, indexFilename: reactCompIndexFilename });
|
|
30
30
|
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
31
31
|
log(`reactPlugin. ${supported.length} supported node(s)`);
|
|
32
32
|
for (const node of supported) {
|
|
@@ -37,6 +37,7 @@ export const reactCompPlugin = {
|
|
|
37
37
|
outputs.push({
|
|
38
38
|
path: joinPaths(path, reactCompIndexFilename),
|
|
39
39
|
content: '',
|
|
40
|
+
isPackageIndex: true,
|
|
40
41
|
generator: {
|
|
41
42
|
root: path,
|
|
42
43
|
recursive: true,
|
|
@@ -46,9 +47,9 @@ export const reactCompPlugin = {
|
|
|
46
47
|
}
|
|
47
48
|
})
|
|
48
49
|
};
|
|
49
|
-
const generateComponentAsync = (node, { tab, importMap, outputs, namespace, }, { reactCompPackage = 'components', reactCompPath, reactCompUseStyledJsx = false, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const generateComponentAsync = (node, { tab, importMap, outputs, namespace, libStyle, }, { reactCompPackage = 'components', reactCompPath, reactCompUseStyledJsx = false, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
50
51
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
51
|
-
const { path, packageName } = getProtoPluginPackAndPath(namespace, reactCompPackage, reactCompPath);
|
|
52
|
+
const { path, packageName } = getProtoPluginPackAndPath(namespace, reactCompPackage, reactCompPath, libStyle);
|
|
52
53
|
const imports = [];
|
|
53
54
|
const addImport = (im, pkg) => {
|
|
54
55
|
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,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,yBAAyB,EAAgB,oBAAoB,EAAE,oBAAoB,EAAE,cAAc,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,mB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AAI,CAAC,GAAG,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC;QAC9B,GAAG,CAAC,IAAI,CAAC,GAAG,OAAO,aAAa,CAAC,CAAC;KACrC;IACD,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,GAAG,QAAQ,CAAC,CAAA;IAC9B,GAAG,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,CAAA;IACnB,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAEb,IAAG,OAAO,CAAC,MAAM,EAAC;QACd,qBAAqB,CAAC,OAAO,EAAC,SAAS,EAAC,GAAG,CAAC,CAAC;KAChD;IAED,OAAO,CAAC,IAAI,CAAC;QACT,IAAI,EAAC,SAAS,CAAC,IAAI,EAAC,QAAQ,CAAC;QAC7B,OAAO,EAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QACtB,SAAS,EAAC,IAAI;QACd,YAAY,EAAC,mBAAmB;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"}
|
|
@@ -5,11 +5,12 @@ export const serverFnCdkTemplate = (constructName, infos, importMap) => {
|
|
|
5
5
|
imports.push(`import { ${t.arnParam} as _fnParam${i}} from '${importMap[t.arnParam]}';`);
|
|
6
6
|
}
|
|
7
7
|
return `import { Construct } from "constructs";
|
|
8
|
-
import { FnsBuilder, FnInfo } from "@iyio/cdk-common";
|
|
8
|
+
import { FnsBuilder, FnInfo, ManagedProps } from "@iyio/cdk-common";
|
|
9
9
|
${imports.join('\n')}
|
|
10
10
|
|
|
11
11
|
export interface ${constructName}Props
|
|
12
12
|
{
|
|
13
|
+
managed?:ManagedProps;
|
|
13
14
|
transform?:(fnInfos:FnInfo[])=>FnInfo[];
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -18,15 +19,16 @@ export class ${constructName} extends FnsBuilder
|
|
|
18
19
|
|
|
19
20
|
public constructor(scope:Construct,name:string,{
|
|
20
21
|
transform,
|
|
22
|
+
...props
|
|
21
23
|
}:${constructName}Props={}){
|
|
22
24
|
|
|
23
|
-
super(scope,name,{fnsInfo:transform?transform(
|
|
25
|
+
super(scope,name,{...props,fnsInfo:transform?transform(getFnsInfo()):getFnsInfo()});
|
|
24
26
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
const
|
|
31
|
+
const getFnsInfo=():FnInfo[]=>[
|
|
30
32
|
${infos.map((info, i) => {
|
|
31
33
|
var _a;
|
|
32
34
|
return ` {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverFnCdkTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/serverFnCdkTemplate.ts"],"names":[],"mappings":"AAMA,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;KAC5F;IAGD,OAAO;;EAET,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;;mBAED,aAAa
|
|
1
|
+
{"version":3,"file":"serverFnCdkTemplate.js","sourceRoot":"","sources":["../../../../../../../packages/protogen-runtime/src/lib/plugins/serverFnCdkTemplate.ts"],"names":[],"mappings":"AAMA,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;KAC5F;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;;yBAEH,IAAI,CAAC,SAAS,CAAC,MAAA,IAAI,CAAC,cAAc,mCAAE,EAAE,CAAC;sBAC1C,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC;MAChD,CAAA;KAAA,CAAC;SACF,IAAI,CAAC,KAAK,CACf;;;CAGC,CAAA;AACD,CAAC,CAAA"}
|
|
@@ -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;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import { getProtoPluginPackAndPath, protoFormatTsComment, protoGenerateTsIndex, protoIsTsBuiltType, protoLabelOutputLines, protoMergeTsImports, protoPrependTsImports } from "@iyio/protogen";
|
|
2
|
+
import { getSubstringCount, joinPaths } from "@iyio/common";
|
|
3
|
+
import { getProtoPluginPackAndPath, protoAddContextParam, protoFormatTsComment, protoGenerateTsIndex, protoIsTsBuiltType, protoLabelOutputLines, protoMergeTsImports, protoNodeChildrenToAccessRequests, protoPrependTsImports } from "@iyio/protogen";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { serverFnCdkTemplate } from "./serverFnCdkTemplate";
|
|
6
6
|
const supportedTypes = ['serverFn'];
|
|
@@ -10,7 +10,7 @@ const ServerFnPluginConfig = z.object({
|
|
|
10
10
|
*/
|
|
11
11
|
serverFnPath: z.string().optional(),
|
|
12
12
|
/**
|
|
13
|
-
* @default "
|
|
13
|
+
* @default "fns"
|
|
14
14
|
*/
|
|
15
15
|
serverFnPackage: z.string().optional(),
|
|
16
16
|
/**
|
|
@@ -18,19 +18,15 @@ const ServerFnPluginConfig = z.object({
|
|
|
18
18
|
*/
|
|
19
19
|
serverFnClientPath: z.string().optional(),
|
|
20
20
|
/**
|
|
21
|
-
* @default "
|
|
21
|
+
* @default "fn-clients"
|
|
22
22
|
*/
|
|
23
23
|
serverFnClientPackage: z.string().optional(),
|
|
24
24
|
/**
|
|
25
|
-
* @default "
|
|
26
|
-
*/
|
|
27
|
-
serverFnParamsFilename: z.string().optional(),
|
|
28
|
-
/**
|
|
29
|
-
* @default "serverFn-client-index.ts"
|
|
25
|
+
* @default "fn-clients-index.ts"
|
|
30
26
|
*/
|
|
31
27
|
serverFnClientIndexFilename: z.string().optional(),
|
|
32
28
|
/**
|
|
33
|
-
* @default "
|
|
29
|
+
* @default "fn-clients.ts"
|
|
34
30
|
*/
|
|
35
31
|
serverFnClientFilename: z.string().optional(),
|
|
36
32
|
/**
|
|
@@ -45,6 +41,7 @@ const ServerFnPluginConfig = z.object({
|
|
|
45
41
|
* @default "@iyio/aws-lambda"
|
|
46
42
|
*/
|
|
47
43
|
serverFnLambdaPackage: z.string().optional(),
|
|
44
|
+
serverFnIndexFilename: z.string().optional(),
|
|
48
45
|
/**
|
|
49
46
|
* If defined a CDK construct file will be generated that can be used to deploy the
|
|
50
47
|
* functions
|
|
@@ -61,20 +58,17 @@ const ServerFnPluginConfig = z.object({
|
|
|
61
58
|
});
|
|
62
59
|
export const serverFnPlugin = {
|
|
63
60
|
configScheme: ServerFnPluginConfig,
|
|
64
|
-
generate: ({ importMap, outputs, tab, log, nodes, namespace, packagePaths, }, { serverFnPackage = '
|
|
65
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m
|
|
66
|
-
const { path } = getProtoPluginPackAndPath(namespace, serverFnPackage, serverFnPath);
|
|
61
|
+
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, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
63
|
+
const { path } = getProtoPluginPackAndPath(namespace, serverFnPackage, serverFnPath, libStyle, { packagePaths, indexFilename: serverFnIndexFilename });
|
|
67
64
|
const cdkRelPath = ('../'
|
|
68
65
|
.repeat(getSubstringCount(path, '/') - 1));
|
|
69
|
-
const { path: clientPath, packageName: clientPackageName } = getProtoPluginPackAndPath(namespace, serverFnClientPackage, serverFnClientPath, { packagePaths, indexFilename: serverFnClientIndexFilename });
|
|
66
|
+
const { path: clientPath, packageName: clientPackageName } = getProtoPluginPackAndPath(namespace, serverFnClientPackage, serverFnClientPath, libStyle, { packagePaths, indexFilename: serverFnClientIndexFilename });
|
|
70
67
|
const supported = nodes.filter(n => supportedTypes.includes(n.type));
|
|
71
68
|
log(`${supported.length} supported node(s)`);
|
|
72
69
|
if (!supported.length) {
|
|
73
70
|
return;
|
|
74
71
|
}
|
|
75
|
-
const paramsOut = [];
|
|
76
|
-
paramsOut.push('import { defineStringParam } from "@iyio/common";');
|
|
77
|
-
paramsOut.push('');
|
|
78
72
|
const clientOut = [];
|
|
79
73
|
const clientInputs = [];
|
|
80
74
|
const clientParamImports = [];
|
|
@@ -90,10 +84,8 @@ export const serverFnPlugin = {
|
|
|
90
84
|
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';
|
|
91
85
|
const inputPackage = importMap[inputType + 'Scheme'];
|
|
92
86
|
const outputPackage = importMap[outputType + 'Scheme'];
|
|
93
|
-
const paramName =
|
|
94
|
-
importMap[paramName] = clientPackageName;
|
|
87
|
+
const paramName = protoAddContextParam(name + 'Arn', paramPackage, paramMap, importMap);
|
|
95
88
|
clientParamImports.push(paramName);
|
|
96
|
-
paramsOut.push(`export const ${paramName}=defineStringParam('${strFirstToLower(name)}Arn');`);
|
|
97
89
|
const fnInfo = {
|
|
98
90
|
name,
|
|
99
91
|
createProps: {
|
|
@@ -101,49 +93,12 @@ export const serverFnPlugin = {
|
|
|
101
93
|
handlerFileName: joinPaths(cdkRelPath, filepath),
|
|
102
94
|
handler: 'handler'
|
|
103
95
|
},
|
|
104
|
-
arnParam: paramName
|
|
105
|
-
accessRequests: []
|
|
96
|
+
arnParam: paramName
|
|
106
97
|
};
|
|
107
98
|
infos.push(fnInfo);
|
|
108
|
-
const accessProp = (_j = node.children) === null || _j === void 0 ? void 0 : _j['access'];
|
|
99
|
+
const accessProp = (_j = node.children) === null || _j === void 0 ? void 0 : _j['$access'];
|
|
109
100
|
if (accessProp === null || accessProp === void 0 ? void 0 : accessProp.children) {
|
|
110
|
-
|
|
111
|
-
const child = accessProp.children[c];
|
|
112
|
-
const types = child.name.split('-');
|
|
113
|
-
for (const type of child.types) {
|
|
114
|
-
(_k = fnInfo.accessRequests) === null || _k === void 0 ? void 0 : _k.push({
|
|
115
|
-
grantName: type.type,
|
|
116
|
-
types,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
let child = (_l = accessProp.children) === null || _l === void 0 ? void 0 : _l['read'];
|
|
121
|
-
if (child) {
|
|
122
|
-
for (const type of child.types) {
|
|
123
|
-
(_m = fnInfo.accessRequests) === null || _m === void 0 ? void 0 : _m.push({
|
|
124
|
-
grantName: type.type,
|
|
125
|
-
types: ['read'],
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
child = (_o = accessProp.children) === null || _o === void 0 ? void 0 : _o['write'];
|
|
130
|
-
if (child) {
|
|
131
|
-
for (const type of child.types) {
|
|
132
|
-
(_p = fnInfo.accessRequests) === null || _p === void 0 ? void 0 : _p.push({
|
|
133
|
-
grantName: type.type,
|
|
134
|
-
types: ['write'],
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
child = (_q = accessProp.children) === null || _q === void 0 ? void 0 : _q['readWrite'];
|
|
139
|
-
if (child) {
|
|
140
|
-
for (const type of child.types) {
|
|
141
|
-
(_r = fnInfo.accessRequests) === null || _r === void 0 ? void 0 : _r.push({
|
|
142
|
-
grantName: type.type,
|
|
143
|
-
types: ['read', 'write'],
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
}
|
|
101
|
+
fnInfo.accessRequests = protoNodeChildrenToAccessRequests(accessProp);
|
|
147
102
|
}
|
|
148
103
|
const clientName = name.endsWith('Fn') ? name.substring(0, name.length - 2) : name;
|
|
149
104
|
importMap[clientName] = clientPackageName;
|
|
@@ -165,7 +120,7 @@ export const serverFnPlugin = {
|
|
|
165
120
|
clientOut.push(`${tab}})`);
|
|
166
121
|
clientOut.push(')');
|
|
167
122
|
clientOut.push('');
|
|
168
|
-
const handlerName = (
|
|
123
|
+
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;
|
|
169
124
|
const isDefault = handlerName === 'default';
|
|
170
125
|
if (!protoIsTsBuiltType(inputType)) {
|
|
171
126
|
imports.push(inputType);
|
|
@@ -203,23 +158,31 @@ export const serverFnPlugin = {
|
|
|
203
158
|
outputs.push({
|
|
204
159
|
path: filepath,
|
|
205
160
|
content: out.join('\n'),
|
|
161
|
+
mainExport: isDefault ? undefined : handlerName,
|
|
162
|
+
mainExportAs: name,
|
|
206
163
|
autoMerge: true,
|
|
207
164
|
mergeHandler: protoMergeTsImports
|
|
208
165
|
});
|
|
209
166
|
}
|
|
210
|
-
|
|
167
|
+
outputs.push({
|
|
168
|
+
path: joinPaths(path, serverFnIndexFilename),
|
|
169
|
+
content: '',
|
|
170
|
+
isPackageIndex: true,
|
|
171
|
+
generator: {
|
|
172
|
+
root: path,
|
|
173
|
+
generator: protoGenerateTsIndex
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
clientOut.unshift(`import { ${clientParamImports.join(', ')} } from '${paramPackage}';`);
|
|
211
177
|
protoPrependTsImports(clientInputs, importMap, clientOut);
|
|
212
178
|
outputs.push({
|
|
213
179
|
path: joinPaths(clientPath, serverFnClientFilename),
|
|
214
180
|
content: clientOut.join('\n'),
|
|
215
181
|
});
|
|
216
|
-
outputs.push({
|
|
217
|
-
path: joinPaths(clientPath, serverFnParamsFilename),
|
|
218
|
-
content: paramsOut.join('\n'),
|
|
219
|
-
});
|
|
220
182
|
outputs.push({
|
|
221
183
|
path: joinPaths(clientPath, serverFnClientIndexFilename),
|
|
222
184
|
content: '',
|
|
185
|
+
isPackageIndex: true,
|
|
223
186
|
generator: {
|
|
224
187
|
root: clientPath,
|
|
225
188
|
generator: protoGenerateTsIndex
|