@geekmidas/cli 10.0.0-alpha.12 → 10.0.0-alpha.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/dist/{HostingerProvider-BcyFRbqV.mjs → HostingerProvider-BY26bWwB.mjs} +20 -21
- package/dist/HostingerProvider-BY26bWwB.mjs.map +1 -0
- package/dist/{HostingerProvider-BOvsgATO.cjs → HostingerProvider-BZFGYYVA.cjs} +21 -22
- package/dist/HostingerProvider-BZFGYYVA.cjs.map +1 -0
- package/dist/{LocalStateProvider-yjXZXZDM.cjs → LocalStateProvider-7HR6SS2t.cjs} +11 -6
- package/dist/LocalStateProvider-7HR6SS2t.cjs.map +1 -0
- package/dist/{LocalStateProvider-Bq-0C0sg.mjs → LocalStateProvider-D7QyJoLM.mjs} +10 -4
- package/dist/LocalStateProvider-D7QyJoLM.mjs.map +1 -0
- package/dist/{Route53Provider-C0xmer8U.mjs → Route53Provider-Cvj40A8I.mjs} +12 -12
- package/dist/Route53Provider-Cvj40A8I.mjs.map +1 -0
- package/dist/{Route53Provider-CH9XH7bz.cjs → Route53Provider-DVILBsvV.cjs} +20 -21
- package/dist/Route53Provider-DVILBsvV.cjs.map +1 -0
- package/dist/{SSMStateProvider-DOZifZfE.mjs → SSMStateProvider-B0Hu1MKZ.mjs} +13 -4
- package/dist/SSMStateProvider-B0Hu1MKZ.mjs.map +1 -0
- package/dist/{SSMStateProvider-CXtNgPfy.cjs → SSMStateProvider-VrQ-yeqd.cjs} +17 -9
- package/dist/SSMStateProvider-VrQ-yeqd.cjs.map +1 -0
- package/dist/{backup-provisioner-cE2PuCTb.cjs → backup-provisioner-BmhIO_Yr.cjs} +21 -19
- package/dist/backup-provisioner-BmhIO_Yr.cjs.map +1 -0
- package/dist/{backup-provisioner-DXXg6FIL.mjs → backup-provisioner-DIVCbfee.mjs} +10 -7
- package/dist/backup-provisioner-DIVCbfee.mjs.map +1 -0
- package/dist/{bundler-BMekgx7a.cjs → bundler-BeNDZdHQ.cjs} +9 -12
- package/dist/bundler-BeNDZdHQ.cjs.map +1 -0
- package/dist/{bundler-Bux2iF-v.mjs → bundler-BodTL4kf.mjs} +8 -10
- package/dist/bundler-BodTL4kf.mjs.map +1 -0
- package/dist/{config-RYR9j6EF.cjs → config-Q1rvKHvw.cjs} +74 -69
- package/dist/config-Q1rvKHvw.cjs.map +1 -0
- package/dist/{config-DTsVjKZD.mjs → config-pqGD3hF9.mjs} +26 -14
- package/dist/config-pqGD3hF9.mjs.map +1 -0
- package/dist/config.cjs +4 -5
- package/dist/config.d.cts +14 -17
- package/dist/config.d.cts.map +1 -1
- package/dist/config.d.mts +14 -17
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +3 -5
- package/dist/{credentials-jMJC63qs.mjs → credentials-BekkKtY_.mjs} +234 -79
- package/dist/credentials-BekkKtY_.mjs.map +1 -0
- package/dist/{credentials-DQRvPz2S.cjs → credentials-Q6F0uqJq.cjs} +384 -236
- package/dist/credentials-Q6F0uqJq.cjs.map +1 -0
- package/dist/deploy/sniffer-envkit-patch.cjs +18 -10
- package/dist/deploy/sniffer-envkit-patch.cjs.map +1 -1
- package/dist/deploy/sniffer-envkit-patch.d.cts +0 -2
- package/dist/deploy/sniffer-envkit-patch.d.cts.map +1 -1
- package/dist/deploy/sniffer-envkit-patch.d.mts +0 -2
- package/dist/deploy/sniffer-envkit-patch.d.mts.map +1 -1
- package/dist/deploy/sniffer-envkit-patch.mjs +10 -2
- package/dist/deploy/sniffer-envkit-patch.mjs.map +1 -1
- package/dist/deploy/sniffer-hooks.cjs +13 -7
- package/dist/deploy/sniffer-hooks.cjs.map +1 -1
- package/dist/deploy/sniffer-hooks.d.cts +1 -2
- package/dist/deploy/sniffer-hooks.d.cts.map +1 -1
- package/dist/deploy/sniffer-hooks.d.mts +1 -2
- package/dist/deploy/sniffer-hooks.d.mts.map +1 -1
- package/dist/deploy/sniffer-hooks.mjs +9 -2
- package/dist/deploy/sniffer-hooks.mjs.map +1 -1
- package/dist/deploy/sniffer-loader.cjs +16 -7
- package/dist/deploy/sniffer-loader.cjs.map +1 -1
- package/dist/deploy/sniffer-loader.d.cts +1 -1
- package/dist/deploy/sniffer-loader.d.mts +1 -1
- package/dist/deploy/sniffer-loader.mjs +13 -2
- package/dist/deploy/sniffer-loader.mjs.map +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +11 -11
- package/dist/deploy/sniffer-routes-worker.cjs.map +1 -1
- package/dist/deploy/sniffer-routes-worker.d.cts +1 -1
- package/dist/deploy/sniffer-routes-worker.d.mts +1 -1
- package/dist/deploy/sniffer-routes-worker.mjs +2 -2
- package/dist/deploy/sniffer-routes-worker.mjs.map +1 -1
- package/dist/deploy/sniffer-worker.cjs +15 -6
- package/dist/deploy/sniffer-worker.cjs.map +1 -1
- package/dist/deploy/sniffer-worker.d.cts +1 -3
- package/dist/deploy/sniffer-worker.d.cts.map +1 -1
- package/dist/deploy/sniffer-worker.d.mts +1 -3
- package/dist/deploy/sniffer-worker.d.mts.map +1 -1
- package/dist/deploy/sniffer-worker.mjs +15 -4
- package/dist/deploy/sniffer-worker.mjs.map +1 -1
- package/dist/{discover-DmW9Bscc.cjs → discover-BERGFg8v.cjs} +68 -70
- package/dist/discover-BERGFg8v.cjs.map +1 -0
- package/dist/{discover-BYHQwQqu.mjs → discover-CK-n3w6b.mjs} +22 -20
- package/dist/discover-CK-n3w6b.mjs.map +1 -0
- package/dist/{emit-CUD1BWls.cjs → emit-BdoPFjZf.cjs} +53 -36
- package/dist/emit-BdoPFjZf.cjs.map +1 -0
- package/dist/{emit-CIlvnDvV.mjs → emit-Bzq7JsMP.mjs} +24 -6
- package/dist/emit-Bzq7JsMP.mjs.map +1 -0
- package/dist/{fullstack-secrets-B6KBHf-g.mjs → fullstack-secrets-BET8gqwK.mjs} +9 -15
- package/dist/fullstack-secrets-BET8gqwK.mjs.map +1 -0
- package/dist/{fullstack-secrets-DL8v0y4D.cjs → fullstack-secrets-DXsWO-5m.cjs} +19 -26
- package/dist/fullstack-secrets-DXsWO-5m.cjs.map +1 -0
- package/dist/{generator-VE2JrFlY.mjs → generator-LfZU7NlU.mjs} +8 -14
- package/dist/generator-LfZU7NlU.mjs.map +1 -0
- package/dist/{generator-CNzBw7g5.cjs → generator-Wdfp0jCS.cjs} +38 -45
- package/dist/generator-Wdfp0jCS.cjs.map +1 -0
- package/dist/{github-BThvbf2W.cjs → github-BfflNPVe.cjs} +36 -30
- package/dist/{github-BThvbf2W.cjs.map → github-BfflNPVe.cjs.map} +1 -1
- package/dist/{github-DpMZurEK.mjs → github-CRwnxKmD.mjs} +27 -20
- package/dist/github-CRwnxKmD.mjs.map +1 -0
- package/dist/{index-BzJ7QJ9c.d.mts → index-Cd-qeOam.d.mts} +3 -8
- package/dist/index-Cd-qeOam.d.mts.map +1 -0
- package/dist/{index-CfMjtdVC.d.cts → index-D-iAVHx-.d.cts} +3 -8
- package/dist/index-D-iAVHx-.d.cts.map +1 -0
- package/dist/index.cjs +2894 -1582
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2765 -1470
- package/dist/index.mjs.map +1 -1
- package/dist/{keystore-TxeYM7an.mjs → keystore-B4PRlbgE.mjs} +5 -7
- package/dist/keystore-B4PRlbgE.mjs.map +1 -0
- package/dist/{keystore-C9rint2E.cjs → keystore-DgGRj2Yy.cjs} +23 -26
- package/dist/keystore-DgGRj2Yy.cjs.map +1 -0
- package/dist/{openapi-DWLTsYLL.cjs → openapi-Dcbme-Us.cjs} +134 -171
- package/dist/openapi-Dcbme-Us.cjs.map +1 -0
- package/dist/openapi-react-query.cjs +156 -2
- package/dist/openapi-react-query.cjs.map +1 -0
- package/dist/openapi-react-query.d.cts +1 -3
- package/dist/openapi-react-query.d.cts.map +1 -1
- package/dist/openapi-react-query.d.mts +1 -3
- package/dist/openapi-react-query.d.mts.map +1 -1
- package/dist/openapi-react-query.mjs +156 -2
- package/dist/openapi-react-query.mjs.map +1 -0
- package/dist/{openapi-Bs3-5q_r.mjs → openapi-vy4JzhUv.mjs} +76 -106
- package/dist/openapi-vy4JzhUv.mjs.map +1 -0
- package/dist/openapi.cjs +3 -6
- package/dist/openapi.d.cts +8 -11
- package/dist/openapi.d.cts.map +1 -1
- package/dist/openapi.d.mts +8 -11
- package/dist/openapi.d.mts.map +1 -1
- package/dist/openapi.mjs +2 -6
- package/dist/reconcile/public.cjs +4 -4
- package/dist/reconcile/public.d.cts +8 -26
- package/dist/reconcile/public.d.cts.map +1 -1
- package/dist/reconcile/public.d.mts +8 -26
- package/dist/reconcile/public.d.mts.map +1 -1
- package/dist/reconcile/public.mjs +3 -4
- package/dist/{reconcile-Bhw5fmKu.cjs → reconcile-Dd2iyILf.cjs} +4 -7
- package/dist/reconcile-Dd2iyILf.cjs.map +1 -0
- package/dist/{reconcile-BI0tWkwz.mjs → reconcile-DhQ00DpU.mjs} +4 -7
- package/dist/reconcile-DhQ00DpU.mjs.map +1 -0
- package/dist/rolldown-runtime-BhDjJH2R.mjs +15 -0
- package/dist/{chunk-CUT6urMc.cjs → rolldown-runtime-C0BPl7ul.cjs} +23 -10
- package/dist/{storage-CSNplaJn.cjs → storage-C-30BD1e.cjs} +59 -69
- package/dist/storage-C-30BD1e.cjs.map +1 -0
- package/dist/{storage-B020InPW.mjs → storage-P_b3w7uj.mjs} +22 -13
- package/dist/storage-P_b3w7uj.mjs.map +1 -0
- package/dist/{sync-CzHXiR9c.mjs → sync-B3xxXtJT.mjs} +18 -6
- package/dist/sync-B3xxXtJT.mjs.map +1 -0
- package/dist/{sync-0ILCb-1S.cjs → sync-D7uTIIEi.cjs} +43 -25
- package/dist/sync-D7uTIIEi.cjs.map +1 -0
- package/dist/types-BGo5TaNE.d.mts +6164 -0
- package/dist/types-BGo5TaNE.d.mts.map +1 -0
- package/dist/types-C5ZNpUad.d.cts +6165 -0
- package/dist/types-C5ZNpUad.d.cts.map +1 -0
- package/dist/workspace/index.cjs +3 -3
- package/dist/workspace/index.d.cts +3 -3
- package/dist/workspace/index.d.mts +3 -3
- package/dist/workspace/index.mjs +2 -3
- package/dist/{workspace-CtnZnWsa.mjs → workspace-CgwmXEtc.mjs} +712 -806
- package/dist/workspace-CgwmXEtc.mjs.map +1 -0
- package/dist/{workspace-DPV7FtAv.cjs → workspace-mFpI_ky_.cjs} +881 -976
- package/dist/workspace-mFpI_ky_.cjs.map +1 -0
- package/package.json +14 -14
- package/dist/CachedStateProvider-BEBl2wQT.cjs +0 -60
- package/dist/CachedStateProvider-BEBl2wQT.cjs.map +0 -1
- package/dist/CachedStateProvider-C-8wtlto.mjs +0 -3
- package/dist/CachedStateProvider-Co4n5Wvs.mjs +0 -54
- package/dist/CachedStateProvider-Co4n5Wvs.mjs.map +0 -1
- package/dist/CachedStateProvider-DqhGpzsm.cjs +0 -3
- package/dist/HostingerProvider-BOvsgATO.cjs.map +0 -1
- package/dist/HostingerProvider-BcyFRbqV.mjs.map +0 -1
- package/dist/LocalStateProvider-Bq-0C0sg.mjs.map +0 -1
- package/dist/LocalStateProvider-yjXZXZDM.cjs.map +0 -1
- package/dist/Route53Provider-C0xmer8U.mjs.map +0 -1
- package/dist/Route53Provider-CH9XH7bz.cjs.map +0 -1
- package/dist/SSMStateProvider-CXtNgPfy.cjs.map +0 -1
- package/dist/SSMStateProvider-DOZifZfE.mjs.map +0 -1
- package/dist/backup-provisioner-DXXg6FIL.mjs.map +0 -1
- package/dist/backup-provisioner-cE2PuCTb.cjs.map +0 -1
- package/dist/bundler-BMekgx7a.cjs.map +0 -1
- package/dist/bundler-Bux2iF-v.mjs.map +0 -1
- package/dist/chunk-Duj1WY3L.mjs +0 -7
- package/dist/config-DTsVjKZD.mjs.map +0 -1
- package/dist/config-RYR9j6EF.cjs.map +0 -1
- package/dist/credentials-B5zRHdAl.mjs +0 -141
- package/dist/credentials-B5zRHdAl.mjs.map +0 -1
- package/dist/credentials-BapzjyV5.cjs +0 -195
- package/dist/credentials-BapzjyV5.cjs.map +0 -1
- package/dist/credentials-DQRvPz2S.cjs.map +0 -1
- package/dist/credentials-jMJC63qs.mjs.map +0 -1
- package/dist/discover-BYHQwQqu.mjs.map +0 -1
- package/dist/discover-DmW9Bscc.cjs.map +0 -1
- package/dist/dokploy-api-5cK2InBm.cjs +0 -3
- package/dist/dokploy-api-D2Ny4Jrc.mjs +0 -3
- package/dist/dokploy-api-pdaBryoY.mjs +0 -706
- package/dist/dokploy-api-pdaBryoY.mjs.map +0 -1
- package/dist/dokploy-api-zqKe9lHH.cjs +0 -718
- package/dist/dokploy-api-zqKe9lHH.cjs.map +0 -1
- package/dist/emit-CIlvnDvV.mjs.map +0 -1
- package/dist/emit-CUD1BWls.cjs.map +0 -1
- package/dist/encryption-D2pL3tHH.cjs +0 -54
- package/dist/encryption-D2pL3tHH.cjs.map +0 -1
- package/dist/encryption-YDsXXi6w.mjs +0 -3
- package/dist/encryption-_4zwjOAR.mjs +0 -42
- package/dist/encryption-_4zwjOAR.mjs.map +0 -1
- package/dist/encryption-sQ2Oxx0d.cjs +0 -4
- package/dist/fullstack-secrets-B6KBHf-g.mjs.map +0 -1
- package/dist/fullstack-secrets-DL8v0y4D.cjs.map +0 -1
- package/dist/generator-CNzBw7g5.cjs.map +0 -1
- package/dist/generator-VE2JrFlY.mjs.map +0 -1
- package/dist/github-DpMZurEK.mjs.map +0 -1
- package/dist/index-BzJ7QJ9c.d.mts.map +0 -1
- package/dist/index-CfMjtdVC.d.cts.map +0 -1
- package/dist/keystore-C9rint2E.cjs.map +0 -1
- package/dist/keystore-TxeYM7an.mjs.map +0 -1
- package/dist/openapi-Bs3-5q_r.mjs.map +0 -1
- package/dist/openapi-DWLTsYLL.cjs.map +0 -1
- package/dist/openapi-react-query-Byltvm_7.mjs +0 -167
- package/dist/openapi-react-query-Byltvm_7.mjs.map +0 -1
- package/dist/openapi-react-query-CmJ1xDbn.cjs +0 -173
- package/dist/openapi-react-query-CmJ1xDbn.cjs.map +0 -1
- package/dist/reconcile-BI0tWkwz.mjs.map +0 -1
- package/dist/reconcile-Bhw5fmKu.cjs.map +0 -1
- package/dist/setup-BmLoNrDX.mjs +0 -12
- package/dist/setup-BrR1_xGy.cjs +0 -12
- package/dist/setup-BsNR2LBG.cjs +0 -467
- package/dist/setup-BsNR2LBG.cjs.map +0 -1
- package/dist/setup-D5-JMknk.mjs +0 -437
- package/dist/setup-D5-JMknk.mjs.map +0 -1
- package/dist/storage-B020InPW.mjs.map +0 -1
- package/dist/storage-CSNplaJn.cjs.map +0 -1
- package/dist/storage-DGBzMLZa.mjs +0 -4
- package/dist/storage-DlVol_oj.cjs +0 -8
- package/dist/sync-0ILCb-1S.cjs.map +0 -1
- package/dist/sync-CzHXiR9c.mjs.map +0 -1
- package/dist/sync-DYENfOt4.cjs +0 -4
- package/dist/sync-HAau6h_R.mjs +0 -3
- package/dist/types-DVIx8I1N.d.mts +0 -1950
- package/dist/types-DVIx8I1N.d.mts.map +0 -1
- package/dist/types-PMP_qXRY.d.cts +0 -1950
- package/dist/types-PMP_qXRY.d.cts.map +0 -1
- package/dist/workspace-Cji6lE8E.cjs +0 -10
- package/dist/workspace-CkJAtRIX.mjs +0 -9
- package/dist/workspace-CtnZnWsa.mjs.map +0 -1
- package/dist/workspace-DPV7FtAv.cjs.map +0 -1
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const __geekmidas_schema_conversion = require_chunk.__toESM(require("@geekmidas/schema/conversion"));
|
|
11
|
-
|
|
1
|
+
const require_discover = require("./discover-BERGFg8v.cjs");
|
|
2
|
+
const require_config = require("./config-Q1rvKHvw.cjs");
|
|
3
|
+
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_child_process = require("node:child_process");
|
|
6
|
+
let _geekmidas_manifest = require("@geekmidas/manifest");
|
|
7
|
+
let _geekmidas_constructs_endpoints = require("@geekmidas/constructs/endpoints");
|
|
8
|
+
let node_url = require("node:url");
|
|
9
|
+
let _geekmidas_schema_conversion = require("@geekmidas/schema/conversion");
|
|
12
10
|
//#region src/build/endpoint-analyzer.ts
|
|
13
11
|
/**
|
|
14
12
|
* Analyze an endpoint to extract its features
|
|
@@ -85,7 +83,6 @@ function summarizeAnalysis(analyses) {
|
|
|
85
83
|
byFeature
|
|
86
84
|
};
|
|
87
85
|
}
|
|
88
|
-
|
|
89
86
|
//#endregion
|
|
90
87
|
//#region src/build/handler-templates.ts
|
|
91
88
|
/**
|
|
@@ -107,8 +104,7 @@ function generateMinimalHandler(analysis) {
|
|
|
107
104
|
const { exportName, features } = analysis;
|
|
108
105
|
const method = analysis.method.toLowerCase();
|
|
109
106
|
const validators = generateValidators(exportName, features);
|
|
110
|
-
|
|
111
|
-
if (!hasValidators && !features.hasOutputValidation) return `
|
|
107
|
+
if (!(validators.length > 0) && !features.hasOutputValidation) return `
|
|
112
108
|
// Minimal handler: ${analysis.route} (${analysis.method})
|
|
113
109
|
app.${method}('${analysis.route}', async (c) => {
|
|
114
110
|
const result = await ${exportName}.handler(
|
|
@@ -256,10 +252,10 @@ function generateValidatorsFile(analyses) {
|
|
|
256
252
|
const needsQuery = analyses.some((a) => a.features.hasQueryValidation);
|
|
257
253
|
const needsParams = analyses.some((a) => a.features.hasParamValidation);
|
|
258
254
|
if (!needsBody && !needsQuery && !needsParams) return `// No validators needed for this build\nexport {};\n`;
|
|
259
|
-
const exports
|
|
255
|
+
const exports = [];
|
|
260
256
|
const factories = [];
|
|
261
257
|
if (needsBody) {
|
|
262
|
-
exports
|
|
258
|
+
exports.push("validateBody");
|
|
263
259
|
factories.push(`
|
|
264
260
|
export const validateBody = (endpoint: any) =>
|
|
265
261
|
validator('json', async (value, c) => {
|
|
@@ -270,7 +266,7 @@ export const validateBody = (endpoint: any) =>
|
|
|
270
266
|
});`);
|
|
271
267
|
}
|
|
272
268
|
if (needsQuery) {
|
|
273
|
-
exports
|
|
269
|
+
exports.push("validateQuery");
|
|
274
270
|
factories.push(`
|
|
275
271
|
export const validateQuery = (endpoint: any) =>
|
|
276
272
|
validator('query', async (_, c) => {
|
|
@@ -282,7 +278,7 @@ export const validateQuery = (endpoint: any) =>
|
|
|
282
278
|
});`);
|
|
283
279
|
}
|
|
284
280
|
if (needsParams) {
|
|
285
|
-
exports
|
|
281
|
+
exports.push("validateParams");
|
|
286
282
|
factories.push(`
|
|
287
283
|
export const validateParams = (endpoint: any) =>
|
|
288
284
|
validator('param', async (params, c) => {
|
|
@@ -306,8 +302,7 @@ ${factories.join("\n")}
|
|
|
306
302
|
*/
|
|
307
303
|
function generateMinimalEndpointFile(analysis, endpointImport) {
|
|
308
304
|
const { exportName, features } = analysis;
|
|
309
|
-
const
|
|
310
|
-
const validatorImport = needsValidators ? generateValidatorImportsForEndpoint(analysis) : "";
|
|
305
|
+
const validatorImport = features.hasBodyValidation || features.hasQueryValidation || features.hasParamValidation ? generateValidatorImportsForEndpoint(analysis) : "";
|
|
311
306
|
const handler = generateMinimalHandler(analysis);
|
|
312
307
|
return `/**
|
|
313
308
|
* Minimal endpoint: ${analysis.route} (${analysis.method})
|
|
@@ -332,8 +327,7 @@ ${handler}
|
|
|
332
327
|
*/
|
|
333
328
|
function generateStandardEndpointFile(analysis, endpointImport) {
|
|
334
329
|
const { exportName, features } = analysis;
|
|
335
|
-
const
|
|
336
|
-
const validatorImport = needsValidators ? generateValidatorImportsForEndpoint(analysis) : "";
|
|
330
|
+
const validatorImport = features.hasBodyValidation || features.hasQueryValidation || features.hasParamValidation ? generateValidatorImportsForEndpoint(analysis) : "";
|
|
337
331
|
const eventsImport = features.hasEvents ? `import { publishConstructEvents } from '@geekmidas/constructs/endpoints';` : "";
|
|
338
332
|
const handler = generateStandardHandler(analysis);
|
|
339
333
|
return `/**
|
|
@@ -425,7 +419,7 @@ export function setupFullEndpoints(
|
|
|
425
419
|
}
|
|
426
420
|
const imports = tierEndpoints.map((a) => `import { setup${capitalize(a.exportName)} } from './${a.exportName}.js';`).join("\n");
|
|
427
421
|
if (tier === "minimal") {
|
|
428
|
-
const calls
|
|
422
|
+
const calls = tierEndpoints.map((a) => ` setup${capitalize(a.exportName)}(app, logger);`).join("\n");
|
|
429
423
|
return `/**
|
|
430
424
|
* Minimal-tier endpoint index (${tierEndpoints.length} endpoints)
|
|
431
425
|
* Near-raw-Hono performance
|
|
@@ -438,12 +432,12 @@ export function setupMinimalEndpoints(
|
|
|
438
432
|
app: Hono,
|
|
439
433
|
logger: Logger,
|
|
440
434
|
): void {
|
|
441
|
-
${calls
|
|
435
|
+
${calls}
|
|
442
436
|
}
|
|
443
437
|
`;
|
|
444
438
|
}
|
|
445
439
|
if (tier === "standard") {
|
|
446
|
-
const calls
|
|
440
|
+
const calls = tierEndpoints.map((a) => ` setup${capitalize(a.exportName)}(app, serviceDiscovery, logger);`).join("\n");
|
|
447
441
|
return `/**
|
|
448
442
|
* Standard-tier endpoint index (${tierEndpoints.length} endpoints)
|
|
449
443
|
* Auth and/or services enabled
|
|
@@ -458,7 +452,7 @@ export function setupStandardEndpoints(
|
|
|
458
452
|
serviceDiscovery: ServiceDiscovery<any, any>,
|
|
459
453
|
logger: Logger,
|
|
460
454
|
): void {
|
|
461
|
-
${calls
|
|
455
|
+
${calls}
|
|
462
456
|
}
|
|
463
457
|
`;
|
|
464
458
|
}
|
|
@@ -528,9 +522,7 @@ function generateEndpointFilesNested(analyses, endpointImports) {
|
|
|
528
522
|
case "standard":
|
|
529
523
|
files[fileName] = generateStandardEndpointFile(analysis, endpointImport);
|
|
530
524
|
break;
|
|
531
|
-
case "full":
|
|
532
|
-
files[fileName] = generateFullEndpointFile(analysis, endpointImport);
|
|
533
|
-
break;
|
|
525
|
+
case "full": files[fileName] = generateFullEndpointFile(analysis, endpointImport);
|
|
534
526
|
}
|
|
535
527
|
}
|
|
536
528
|
return files;
|
|
@@ -587,7 +579,6 @@ export async function setupEndpoints(
|
|
|
587
579
|
}
|
|
588
580
|
`;
|
|
589
581
|
}
|
|
590
|
-
|
|
591
582
|
//#endregion
|
|
592
583
|
//#region src/generators/EndpointGenerator.ts
|
|
593
584
|
/**
|
|
@@ -605,11 +596,11 @@ export async function setupEndpoints(
|
|
|
605
596
|
* Falls back to the configured paths for an app that declares no surface.
|
|
606
597
|
*/
|
|
607
598
|
function runtimeFor(context, fromDir, owner) {
|
|
608
|
-
const module
|
|
609
|
-
if (module
|
|
610
|
-
const specifier = importSpecifier(fromDir, module
|
|
599
|
+
const module = owner ? context.owners?.[owner] ?? context.surface?.module : context.surface?.module;
|
|
600
|
+
if (module) {
|
|
601
|
+
const specifier = importSpecifier(fromDir, module.specifier);
|
|
611
602
|
return {
|
|
612
|
-
imports: `import { ${module
|
|
603
|
+
imports: `import { ${module.exportName} as __surface } from '${specifier}';`,
|
|
613
604
|
bindings: [
|
|
614
605
|
"// What this construct was declared with. Objects, not module paths:",
|
|
615
606
|
"// the entry imports the owner, so there is nothing to print.",
|
|
@@ -677,7 +668,7 @@ function corsFor(surface) {
|
|
|
677
668
|
}
|
|
678
669
|
var EndpointGenerator = class extends require_discover.ConstructGenerator {
|
|
679
670
|
isConstruct(value) {
|
|
680
|
-
return
|
|
671
|
+
return _geekmidas_constructs_endpoints.Endpoint.isEndpoint(value);
|
|
681
672
|
}
|
|
682
673
|
async build(context, constructs, outputDir, options) {
|
|
683
674
|
const provider = options?.provider || "aws-apigatewayv2";
|
|
@@ -733,8 +724,7 @@ var EndpointGenerator = class extends require_discover.ConstructGenerator {
|
|
|
733
724
|
async generateHandlerFile(outputDir, sourceFile, exportName, provider, _endpoint, context) {
|
|
734
725
|
const handlerFileName = `${exportName}.ts`;
|
|
735
726
|
const handlerPath = (0, node_path.join)(outputDir, handlerFileName);
|
|
736
|
-
const
|
|
737
|
-
const importPath = relativePath.replace(/\.ts$/, ".js");
|
|
727
|
+
const importPath = (0, node_path.relative)((0, node_path.dirname)(handlerPath), sourceFile).replace(/\.ts$/, ".js");
|
|
738
728
|
let content;
|
|
739
729
|
switch (provider) {
|
|
740
730
|
case "aws-apigatewayv1":
|
|
@@ -752,16 +742,14 @@ var EndpointGenerator = class extends require_discover.ConstructGenerator {
|
|
|
752
742
|
return handlerPath;
|
|
753
743
|
}
|
|
754
744
|
async generateEndpointsFile(outputDir, endpoints, context) {
|
|
755
|
-
const
|
|
756
|
-
const endpointsPath = (0, node_path.join)(outputDir, endpointsFileName);
|
|
745
|
+
const endpointsPath = (0, node_path.join)(outputDir, "endpoints.ts");
|
|
757
746
|
const importsByFile = /* @__PURE__ */ new Map();
|
|
758
747
|
for (const { path, key } of endpoints) {
|
|
759
|
-
const
|
|
760
|
-
const importPath = relativePath.replace(/\.ts$/, ".js");
|
|
748
|
+
const importPath = (0, node_path.relative)((0, node_path.dirname)(endpointsPath), path.relative).replace(/\.ts$/, ".js");
|
|
761
749
|
if (!importsByFile.has(importPath)) importsByFile.set(importPath, []);
|
|
762
750
|
importsByFile.get(importPath)?.push(key);
|
|
763
751
|
}
|
|
764
|
-
const endpointImports = Array.from(importsByFile.entries()).map(([importPath, exports
|
|
752
|
+
const endpointImports = Array.from(importsByFile.entries()).map(([importPath, exports]) => `import { ${exports.join(", ")} } from '${importPath}';`).join("\n");
|
|
765
753
|
const allExportNames = endpoints.map(({ key }) => key);
|
|
766
754
|
if (context.production?.enabled && context.production.optimizedHandlers) return this.generateOptimizedEndpointsFile(endpointsPath, endpoints, endpointImports, allExportNames);
|
|
767
755
|
const content = `import type { EnvironmentParser } from '@geekmidas/envkit';
|
|
@@ -823,11 +811,9 @@ export async function setupEndpoints(
|
|
|
823
811
|
const analyses = endpoints.map(({ key, construct }) => analyzeEndpoint(construct, key));
|
|
824
812
|
const endpointImports = endpoints.map(({ key, path }) => {
|
|
825
813
|
const tierDir = (0, node_path.join)(endpointsDir, "standard");
|
|
826
|
-
const relativePath = (0, node_path.relative)(tierDir, path.relative);
|
|
827
|
-
const importPath = relativePath.replace(/\.ts$/, ".js");
|
|
828
814
|
return {
|
|
829
815
|
exportName: key,
|
|
830
|
-
importPath
|
|
816
|
+
importPath: (0, node_path.relative)(tierDir, path.relative).replace(/\.ts$/, ".js")
|
|
831
817
|
};
|
|
832
818
|
});
|
|
833
819
|
const summary = summarizeAnalysis(analyses);
|
|
@@ -849,8 +835,7 @@ export async function setupEndpoints(
|
|
|
849
835
|
}
|
|
850
836
|
async generateAppFile(outputDir, context) {
|
|
851
837
|
if (context.production?.enabled) return this.generateProductionAppFile(outputDir, context);
|
|
852
|
-
const
|
|
853
|
-
const appPath = (0, node_path.join)(outputDir, appFileName);
|
|
838
|
+
const appPath = (0, node_path.join)(outputDir, "app.ts");
|
|
854
839
|
const runtime = runtimeFor(context, (0, node_path.dirname)(appPath));
|
|
855
840
|
const telescopeEnabled = context.telescope?.enabled;
|
|
856
841
|
const telescopeWebSocketEnabled = context.telescope?.websocket;
|
|
@@ -860,32 +845,35 @@ export async function setupEndpoints(
|
|
|
860
845
|
const studioFromDatabase = !usesExternalStudio && !!context.studio?.database;
|
|
861
846
|
const telescopeFromSurface = !!context.surface?.module && !usesExternalTelescope;
|
|
862
847
|
let telescopeImports = "";
|
|
863
|
-
if (telescopeEnabled)
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
848
|
+
if (telescopeEnabled) {
|
|
849
|
+
if (telescopeFromSurface) telescopeImports = "import { createMiddleware, createUI } from '@geekmidas/telescope/hono';";
|
|
850
|
+
else if (usesExternalTelescope) {
|
|
851
|
+
const relativeTelescopePath = (0, node_path.relative)((0, node_path.dirname)(appPath), context.telescope?.telescopePath);
|
|
852
|
+
telescopeImports = `import ${context.telescope?.telescopeImportPattern} from '${relativeTelescopePath}';
|
|
867
853
|
import { createMiddleware, createUI } from '@geekmidas/telescope/hono';`;
|
|
868
|
-
|
|
854
|
+
} else telescopeImports = `import { Telescope, InMemoryStorage } from '@geekmidas/telescope';
|
|
869
855
|
import { createMiddleware, createUI } from '@geekmidas/telescope/hono';`;
|
|
856
|
+
}
|
|
870
857
|
let studioImports = "";
|
|
871
|
-
if (studioEnabled)
|
|
872
|
-
|
|
873
|
-
|
|
858
|
+
if (studioEnabled) {
|
|
859
|
+
if (usesExternalStudio) {
|
|
860
|
+
const relativeStudioPath = (0, node_path.relative)((0, node_path.dirname)(appPath), context.studio?.studioPath);
|
|
861
|
+
studioImports = `import ${context.studio?.studioImportPattern} from '${relativeStudioPath}';
|
|
874
862
|
import { createStudioApp } from '@geekmidas/studio/server/hono';`;
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
863
|
+
} else if (studioFromDatabase) {
|
|
864
|
+
const dbSpecifier = importSpecifier((0, node_path.dirname)(appPath), context.studio.database.specifier);
|
|
865
|
+
studioImports = `import { snifferContext } from '@geekmidas/constructs';
|
|
878
866
|
import { Direction, InMemoryMonitoringStorage, Studio } from '@geekmidas/studio';
|
|
879
867
|
import { ${context.studio.database.exportName} as __studioDb } from '${dbSpecifier}';
|
|
880
868
|
import { createStudioApp } from '@geekmidas/studio/server/hono';`;
|
|
881
|
-
|
|
869
|
+
} else studioImports = "";
|
|
870
|
+
}
|
|
882
871
|
const cors = corsFor(context.surface);
|
|
883
872
|
let hooksImports = "";
|
|
884
873
|
let beforeSetupCall = "";
|
|
885
874
|
let afterSetupCall = "";
|
|
886
875
|
if (context.hooks?.serverHooksPath) {
|
|
887
|
-
|
|
888
|
-
hooksImports = `import * as serverHooks from '${relativeHooksPath}';`;
|
|
876
|
+
hooksImports = `import * as serverHooks from '${(0, node_path.relative)((0, node_path.dirname)(appPath), context.hooks.serverHooksPath)}';`;
|
|
889
877
|
beforeSetupCall = `
|
|
890
878
|
// Call beforeSetup hook if defined
|
|
891
879
|
if (typeof serverHooks.beforeSetup === 'function') {
|
|
@@ -931,7 +919,8 @@ import { createStudioApp } from '@geekmidas/studio/server/hono';`;
|
|
|
931
919
|
}
|
|
932
920
|
` : "";
|
|
933
921
|
let telescopeSetup = "";
|
|
934
|
-
if (telescopeEnabled)
|
|
922
|
+
if (telescopeEnabled) {
|
|
923
|
+
if (telescopeFromSurface || usesExternalTelescope) telescopeSetup = `
|
|
935
924
|
${telescopeWebSocketSetupCode}
|
|
936
925
|
// Add telescope middleware (before endpoints to capture all requests)
|
|
937
926
|
honoApp.use('*', createMiddleware(telescope));
|
|
@@ -940,7 +929,7 @@ ${telescopeWebSocketSetupCode}
|
|
|
940
929
|
const telescopeUI = createUI(telescope);
|
|
941
930
|
honoApp.route('${context.telescope?.path}', telescopeUI);
|
|
942
931
|
`;
|
|
943
|
-
|
|
932
|
+
else telescopeSetup = `
|
|
944
933
|
// Setup Telescope for debugging/monitoring
|
|
945
934
|
const telescopeStorage = new InMemoryStorage({ maxEntries: ${context.telescope?.maxEntries} });
|
|
946
935
|
const telescope = new Telescope({
|
|
@@ -958,6 +947,7 @@ ${telescopeWebSocketSetupCode}
|
|
|
958
947
|
const telescopeUI = createUI(telescope);
|
|
959
948
|
honoApp.route('${context.telescope?.path}', telescopeUI);
|
|
960
949
|
`;
|
|
950
|
+
}
|
|
961
951
|
let studioSetup = "";
|
|
962
952
|
if (studioEnabled && studioFromDatabase) studioSetup = `
|
|
963
953
|
// Studio, built from the declared database. The client comes from the
|
|
@@ -1153,8 +1143,7 @@ export const handler = ${exportName};
|
|
|
1153
1143
|
* No dev tools (Telescope, Studio, WebSocket), includes health checks and graceful shutdown
|
|
1154
1144
|
*/
|
|
1155
1145
|
async generateProductionAppFile(outputDir, context) {
|
|
1156
|
-
const
|
|
1157
|
-
const appPath = (0, node_path.join)(outputDir, appFileName);
|
|
1146
|
+
const appPath = (0, node_path.join)(outputDir, "app.ts");
|
|
1158
1147
|
const runtime = runtimeFor(context, (0, node_path.dirname)(appPath));
|
|
1159
1148
|
const production = context.production;
|
|
1160
1149
|
const healthCheckPath = production.healthCheck;
|
|
@@ -1166,8 +1155,7 @@ export const handler = ${exportName};
|
|
|
1166
1155
|
let beforeSetupCall = "";
|
|
1167
1156
|
let afterSetupCall = "";
|
|
1168
1157
|
if (context.hooks?.serverHooksPath) {
|
|
1169
|
-
|
|
1170
|
-
hooksImports = `import * as serverHooks from '${relativeHooksPath}';`;
|
|
1158
|
+
hooksImports = `import * as serverHooks from '${(0, node_path.relative)((0, node_path.dirname)(appPath), context.hooks.serverHooksPath)}';`;
|
|
1171
1159
|
beforeSetupCall = `
|
|
1172
1160
|
// Call beforeSetup hook if defined
|
|
1173
1161
|
if (typeof serverHooks.beforeSetup === 'function') {
|
|
@@ -1216,7 +1204,6 @@ import { setupCrons } from './crons.js';` : "";
|
|
|
1216
1204
|
process.on('SIGTERM', shutdown);
|
|
1217
1205
|
process.on('SIGINT', shutdown);
|
|
1218
1206
|
` : "";
|
|
1219
|
-
const endpointsImportPath = production.optimizedHandlers ? "./endpoints/index.js" : "./endpoints.js";
|
|
1220
1207
|
const content = `/**
|
|
1221
1208
|
* Generated production server application
|
|
1222
1209
|
*
|
|
@@ -1228,7 +1215,7 @@ import { setupCrons } from './crons.js';` : "";
|
|
|
1228
1215
|
*/
|
|
1229
1216
|
import { Hono } from 'hono';
|
|
1230
1217
|
import type { Hono as HonoType } from 'hono';
|
|
1231
|
-
import { setupEndpoints } from '${
|
|
1218
|
+
import { setupEndpoints } from '${production.optimizedHandlers ? "./endpoints/index.js" : "./endpoints.js"}';
|
|
1232
1219
|
${subscriberImport}
|
|
1233
1220
|
${runtime.imports}
|
|
1234
1221
|
${runtime.bindings}
|
|
@@ -1295,7 +1282,7 @@ export default createApp;
|
|
|
1295
1282
|
*/
|
|
1296
1283
|
async generateProductionServerEntry(outputDir) {
|
|
1297
1284
|
const serverPath = (0, node_path.join)(outputDir, "server.ts");
|
|
1298
|
-
|
|
1285
|
+
await (0, node_fs_promises.writeFile)(serverPath, `#!/usr/bin/env node
|
|
1299
1286
|
/**
|
|
1300
1287
|
* Production server entry point
|
|
1301
1288
|
* Generated by 'gkm build --provider server --production'
|
|
@@ -1311,11 +1298,9 @@ await start({
|
|
|
1311
1298
|
port,
|
|
1312
1299
|
serve: (app, port) => { serve({ fetch: app.fetch, port }); },
|
|
1313
1300
|
});
|
|
1314
|
-
|
|
1315
|
-
await (0, node_fs_promises.writeFile)(serverPath, content);
|
|
1301
|
+
`);
|
|
1316
1302
|
}
|
|
1317
1303
|
};
|
|
1318
|
-
|
|
1319
1304
|
//#endregion
|
|
1320
1305
|
//#region src/generators/OpenApiTsGenerator.ts
|
|
1321
1306
|
/**
|
|
@@ -1466,11 +1451,11 @@ var OpenApiTsGenerator = class {
|
|
|
1466
1451
|
}
|
|
1467
1452
|
}
|
|
1468
1453
|
}
|
|
1469
|
-
const registrySchemas = await (0,
|
|
1454
|
+
const registrySchemas = await (0, _geekmidas_schema_conversion.getRegisteredZodJsonSchemas)();
|
|
1470
1455
|
for (const [rawName, rawSchema] of Object.entries(registrySchemas)) {
|
|
1471
1456
|
const defName = this.pascalCase(rawName);
|
|
1472
1457
|
if (collectedDefs.has(defName) || generatedNames.has(defName)) continue;
|
|
1473
|
-
const { id: _id, $defs: _defs
|
|
1458
|
+
const { id: _id, $defs: _defs, ...rest } = rawSchema;
|
|
1474
1459
|
collectedDefs.set(defName, rest);
|
|
1475
1460
|
}
|
|
1476
1461
|
for (const [defName, defSchema] of collectedDefs) if (!generatedNames.has(defName)) {
|
|
@@ -1486,7 +1471,7 @@ var OpenApiTsGenerator = class {
|
|
|
1486
1471
|
*/
|
|
1487
1472
|
async getSchemaName(schema, defaultName) {
|
|
1488
1473
|
try {
|
|
1489
|
-
const metadata = await (0,
|
|
1474
|
+
const metadata = await (0, _geekmidas_schema_conversion.getSchemaMetadata)(schema);
|
|
1490
1475
|
if (metadata?.id) return this.pascalCase(metadata.id);
|
|
1491
1476
|
} catch {}
|
|
1492
1477
|
return defaultName;
|
|
@@ -1506,17 +1491,17 @@ var OpenApiTsGenerator = class {
|
|
|
1506
1491
|
async schemaToInterfaceWithDefs(schema, name, collectedDefs) {
|
|
1507
1492
|
try {
|
|
1508
1493
|
const vendor = schema["~standard"]?.vendor;
|
|
1509
|
-
if (!vendor || !(vendor in
|
|
1510
|
-
const toJsonSchema =
|
|
1494
|
+
if (!vendor || !(vendor in _geekmidas_schema_conversion.StandardSchemaJsonSchema)) return unknownType(name);
|
|
1495
|
+
const toJsonSchema = _geekmidas_schema_conversion.StandardSchemaJsonSchema[vendor];
|
|
1511
1496
|
const jsonSchema = await toJsonSchema(schema);
|
|
1512
|
-
if (!jsonSchema) return
|
|
1497
|
+
if (!jsonSchema) return unknownType(name);
|
|
1513
1498
|
if (jsonSchema.$defs && typeof jsonSchema.$defs === "object") {
|
|
1514
1499
|
for (const [defName, defSchema] of Object.entries(jsonSchema.$defs)) if (!collectedDefs.has(defName)) {
|
|
1515
|
-
const { id
|
|
1500
|
+
const { id, ...schemaWithoutId } = defSchema;
|
|
1516
1501
|
collectedDefs.set(defName, schemaWithoutId);
|
|
1517
1502
|
}
|
|
1518
1503
|
}
|
|
1519
|
-
const { $defs
|
|
1504
|
+
const { $defs, ...schemaWithoutDefs } = jsonSchema;
|
|
1520
1505
|
const ref = schemaWithoutDefs.$ref;
|
|
1521
1506
|
if (ref && Object.keys(schemaWithoutDefs).every((k) => k === "$ref" || k === "$schema")) {
|
|
1522
1507
|
const target = ref.split("/").pop();
|
|
@@ -1524,14 +1509,11 @@ var OpenApiTsGenerator = class {
|
|
|
1524
1509
|
}
|
|
1525
1510
|
return this.jsonSchemaToInterface(schemaWithoutDefs, name);
|
|
1526
1511
|
} catch {
|
|
1527
|
-
return
|
|
1512
|
+
return unknownType(name);
|
|
1528
1513
|
}
|
|
1529
1514
|
}
|
|
1530
1515
|
jsonSchemaToInterface(schema, name) {
|
|
1531
|
-
if (schema.type !== "object" || !schema.properties) {
|
|
1532
|
-
const typeStr = this.jsonSchemaTypeToTs(schema);
|
|
1533
|
-
return `export type ${name} = ${typeStr};`;
|
|
1534
|
-
}
|
|
1516
|
+
if (schema.type !== "object" || !schema.properties) return `export type ${name} = ${this.jsonSchemaTypeToTs(schema)};`;
|
|
1535
1517
|
const props = [];
|
|
1536
1518
|
const required = new Set(schema.required || []);
|
|
1537
1519
|
for (const [propName, propSchema] of Object.entries(schema.properties)) {
|
|
@@ -1544,13 +1526,15 @@ var OpenApiTsGenerator = class {
|
|
|
1544
1526
|
}
|
|
1545
1527
|
jsonSchemaTypeToTs(schema) {
|
|
1546
1528
|
if (!schema) return "unknown";
|
|
1547
|
-
if (schema.$ref)
|
|
1548
|
-
|
|
1549
|
-
return refName;
|
|
1550
|
-
}
|
|
1529
|
+
if (schema.$ref) return schema.$ref.split("/").pop() || "unknown";
|
|
1530
|
+
if (schema.const !== void 0) return typeof schema.const === "string" ? `'${schema.const}'` : String(schema.const);
|
|
1551
1531
|
if (schema.anyOf) return schema.anyOf.map((s) => this.jsonSchemaTypeToTs(s)).join(" | ");
|
|
1552
1532
|
if (schema.oneOf) return schema.oneOf.map((s) => this.jsonSchemaTypeToTs(s)).join(" | ");
|
|
1553
1533
|
if (schema.allOf) return schema.allOf.map((s) => this.jsonSchemaTypeToTs(s)).join(" & ");
|
|
1534
|
+
if (Array.isArray(schema.type)) return schema.type.map((type) => this.jsonSchemaTypeToTs({
|
|
1535
|
+
...schema,
|
|
1536
|
+
type
|
|
1537
|
+
})).join(" | ");
|
|
1554
1538
|
switch (schema.type) {
|
|
1555
1539
|
case "string":
|
|
1556
1540
|
if (schema.enum) return schema.enum.map((e) => `'${e}'`).join(" | ");
|
|
@@ -1574,10 +1558,7 @@ var OpenApiTsGenerator = class {
|
|
|
1574
1558
|
}
|
|
1575
1559
|
return `{ ${props.join("; ")} }`;
|
|
1576
1560
|
}
|
|
1577
|
-
if (schema.additionalProperties) {
|
|
1578
|
-
const valueType = this.jsonSchemaTypeToTs(schema.additionalProperties);
|
|
1579
|
-
return `Record<string, ${valueType}>`;
|
|
1580
|
-
}
|
|
1561
|
+
if (schema.additionalProperties) return `Record<string, ${this.jsonSchemaTypeToTs(schema.additionalProperties)}>`;
|
|
1581
1562
|
return "Record<string, unknown>";
|
|
1582
1563
|
default: return "unknown";
|
|
1583
1564
|
}
|
|
@@ -1598,10 +1579,7 @@ var OpenApiTsGenerator = class {
|
|
|
1598
1579
|
}
|
|
1599
1580
|
const firstWithParams = infos.find((i) => i.input?.params);
|
|
1600
1581
|
let paramsEntry = "";
|
|
1601
|
-
if (firstWithParams?.input?.params) {
|
|
1602
|
-
const paramsName = await this.getSchemaName(firstWithParams.input.params, `${this.getSchemaBaseName(firstWithParams)}Params`);
|
|
1603
|
-
paramsEntry = `\n parameters: {\n path: ${paramsName};\n };`;
|
|
1604
|
-
}
|
|
1582
|
+
if (firstWithParams?.input?.params) paramsEntry = `\n parameters: {\n path: ${await this.getSchemaName(firstWithParams.input.params, `${this.getSchemaBaseName(firstWithParams)}Params`)};\n };`;
|
|
1605
1583
|
pathEntries.push(` '${route}': {${paramsEntry}\n${methodEntries.join("\n")}\n };`);
|
|
1606
1584
|
}
|
|
1607
1585
|
return `export interface paths {\n${pathEntries.join("\n")}\n}`;
|
|
@@ -1640,8 +1618,7 @@ var OpenApiTsGenerator = class {
|
|
|
1640
1618
|
return acc;
|
|
1641
1619
|
}, {});
|
|
1642
1620
|
const schemeNames = securitySchemes.map((s) => `'${s.name}'`).join(" | ");
|
|
1643
|
-
const
|
|
1644
|
-
const createApiSection = hasSecuritySchemes ? `
|
|
1621
|
+
const createApiSection = schemeNames.length > 0 ? `
|
|
1645
1622
|
// ============================================================
|
|
1646
1623
|
// API Client Factory
|
|
1647
1624
|
// ============================================================
|
|
@@ -1818,20 +1795,14 @@ ${createApiSection}
|
|
|
1818
1795
|
`;
|
|
1819
1796
|
}
|
|
1820
1797
|
};
|
|
1821
|
-
|
|
1822
|
-
//#endregion
|
|
1823
|
-
//#region src/workspace/client-generator.ts
|
|
1824
1798
|
/**
|
|
1825
|
-
*
|
|
1826
|
-
*
|
|
1827
|
-
*
|
|
1799
|
+
* The declaration for a schema that cannot be converted — a vendor with no
|
|
1800
|
+
* converter, or one that fails. The paths interface names it either way, so
|
|
1801
|
+
* leaving it undeclared made the generated client fail to compile.
|
|
1828
1802
|
*/
|
|
1829
|
-
function
|
|
1830
|
-
|
|
1831
|
-
if (require_discover.isPartitionedRoutes(routes)) return Array.isArray(routes.paths) ? routes.paths : [routes.paths];
|
|
1832
|
-
return Array.isArray(routes) ? routes : [routes];
|
|
1803
|
+
function unknownType(name) {
|
|
1804
|
+
return `export type ${name} = unknown;`;
|
|
1833
1805
|
}
|
|
1834
|
-
|
|
1835
1806
|
//#endregion
|
|
1836
1807
|
//#region src/openapi.ts
|
|
1837
1808
|
/**
|
|
@@ -1846,7 +1817,7 @@ const OPENAPI_OUTPUT_PATH = "./.gkm/openapi.ts";
|
|
|
1846
1817
|
* name and its `WEBHOOKS_URL`.
|
|
1847
1818
|
*/
|
|
1848
1819
|
function openApiPathFor(surfaceId) {
|
|
1849
|
-
return `./.gkm/openapi/${(0,
|
|
1820
|
+
return `./.gkm/openapi/${(0, _geekmidas_manifest.kebabCase)(surfaceId)}.ts`;
|
|
1850
1821
|
}
|
|
1851
1822
|
/**
|
|
1852
1823
|
* Resolve OpenAPI config from GkmConfig
|
|
@@ -1874,8 +1845,7 @@ function resolveOpenApiConfig(config) {
|
|
|
1874
1845
|
* directories under it — not a `routes` field anybody wrote.
|
|
1875
1846
|
*/
|
|
1876
1847
|
async function generateOpenApiFrom(routes, options = {}) {
|
|
1877
|
-
|
|
1878
|
-
return generateOpenApi(loaded.map(({ construct }) => construct), options);
|
|
1848
|
+
return generateOpenApi((await new EndpointGenerator().load(routes, void 0, options.bustCache)).map(({ construct }) => construct), options);
|
|
1879
1849
|
}
|
|
1880
1850
|
/**
|
|
1881
1851
|
* Generate an OpenAPI spec for each surface these endpoints name.
|
|
@@ -1911,8 +1881,8 @@ async function generateOpenApi(endpoints, options = {}) {
|
|
|
1911
1881
|
const tsGenerator = new OpenApiTsGenerator();
|
|
1912
1882
|
const written = [];
|
|
1913
1883
|
for (const [surfaceId, surfaceEndpoints] of bySurface) {
|
|
1914
|
-
const relative
|
|
1915
|
-
const outputPath = (0, node_path.join)(process.cwd(), relative
|
|
1884
|
+
const relative = openApiPathFor(surfaceId);
|
|
1885
|
+
const outputPath = (0, node_path.join)(process.cwd(), relative);
|
|
1916
1886
|
await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
|
|
1917
1887
|
const tsContent = await tsGenerator.generate(surfaceEndpoints, {
|
|
1918
1888
|
title: openApiConfig.title ?? surfaceId,
|
|
@@ -1920,8 +1890,8 @@ async function generateOpenApi(endpoints, options = {}) {
|
|
|
1920
1890
|
description: openApiConfig.description
|
|
1921
1891
|
});
|
|
1922
1892
|
await (0, node_fs_promises.writeFile)(outputPath, tsContent);
|
|
1923
|
-
written.push(relative
|
|
1924
|
-
logger.log(`📄 OpenAPI client generated: ${relative
|
|
1893
|
+
written.push(relative);
|
|
1894
|
+
logger.log(`📄 OpenAPI client generated: ${relative} (${surfaceEndpoints.length} endpoints)`);
|
|
1925
1895
|
}
|
|
1926
1896
|
return {
|
|
1927
1897
|
outputPath: (0, node_path.join)(process.cwd(), written[0]),
|
|
@@ -1976,8 +1946,7 @@ async function openapiCommand(options = {}) {
|
|
|
1976
1946
|
async function generateOpenApiForApp(workspaceRoot, _appName, app, silent = true) {
|
|
1977
1947
|
if (app.type !== "backend") return null;
|
|
1978
1948
|
const appPath = (0, node_path.join)(workspaceRoot, app.path);
|
|
1979
|
-
|
|
1980
|
-
return generateOpenApiFrom(globs, {
|
|
1949
|
+
return generateOpenApiFrom([(0, node_path.join)(appPath, "**/*.ts")], {
|
|
1981
1950
|
openapi: app.openapi ?? { enabled: true },
|
|
1982
1951
|
silent
|
|
1983
1952
|
});
|
|
@@ -1998,7 +1967,7 @@ function resolveGkmBinPath() {
|
|
|
1998
1967
|
*/
|
|
1999
1968
|
async function runOpenApiInSubprocess(appCwd, appName) {
|
|
2000
1969
|
const binPath = resolveGkmBinPath();
|
|
2001
|
-
await new Promise((resolve
|
|
1970
|
+
await new Promise((resolve, reject) => {
|
|
2002
1971
|
const child = (0, node_child_process.spawn)(process.execPath, [
|
|
2003
1972
|
binPath,
|
|
2004
1973
|
"openapi",
|
|
@@ -2011,65 +1980,59 @@ async function runOpenApiInSubprocess(appCwd, appName) {
|
|
|
2011
1980
|
});
|
|
2012
1981
|
child.on("error", reject);
|
|
2013
1982
|
child.on("close", (code) => {
|
|
2014
|
-
if (code === 0) resolve
|
|
2015
|
-
else reject(new Error(`OpenAPI generation for app "${appName}" exited with code ${code}`));
|
|
1983
|
+
if (code === 0) resolve();
|
|
1984
|
+
else reject(/* @__PURE__ */ new Error(`OpenAPI generation for app "${appName}" exited with code ${code}`));
|
|
2016
1985
|
});
|
|
2017
1986
|
});
|
|
2018
1987
|
}
|
|
2019
|
-
|
|
2020
1988
|
//#endregion
|
|
2021
|
-
Object.defineProperty(exports,
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
});
|
|
2027
|
-
Object.defineProperty(exports, 'OPENAPI_OUTPUT_PATH', {
|
|
2028
|
-
enumerable: true,
|
|
2029
|
-
get: function () {
|
|
2030
|
-
return OPENAPI_OUTPUT_PATH;
|
|
2031
|
-
}
|
|
1989
|
+
Object.defineProperty(exports, "EndpointGenerator", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function() {
|
|
1992
|
+
return EndpointGenerator;
|
|
1993
|
+
}
|
|
2032
1994
|
});
|
|
2033
|
-
Object.defineProperty(exports,
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
1995
|
+
Object.defineProperty(exports, "OPENAPI_OUTPUT_PATH", {
|
|
1996
|
+
enumerable: true,
|
|
1997
|
+
get: function() {
|
|
1998
|
+
return OPENAPI_OUTPUT_PATH;
|
|
1999
|
+
}
|
|
2038
2000
|
});
|
|
2039
|
-
Object.defineProperty(exports,
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2001
|
+
Object.defineProperty(exports, "generateOpenApi", {
|
|
2002
|
+
enumerable: true,
|
|
2003
|
+
get: function() {
|
|
2004
|
+
return generateOpenApi;
|
|
2005
|
+
}
|
|
2044
2006
|
});
|
|
2045
|
-
Object.defineProperty(exports,
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2007
|
+
Object.defineProperty(exports, "generateOpenApiFrom", {
|
|
2008
|
+
enumerable: true,
|
|
2009
|
+
get: function() {
|
|
2010
|
+
return generateOpenApiFrom;
|
|
2011
|
+
}
|
|
2050
2012
|
});
|
|
2051
|
-
Object.defineProperty(exports,
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2013
|
+
Object.defineProperty(exports, "openApiPathFor", {
|
|
2014
|
+
enumerable: true,
|
|
2015
|
+
get: function() {
|
|
2016
|
+
return openApiPathFor;
|
|
2017
|
+
}
|
|
2056
2018
|
});
|
|
2057
|
-
Object.defineProperty(exports,
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2019
|
+
Object.defineProperty(exports, "openapiCommand", {
|
|
2020
|
+
enumerable: true,
|
|
2021
|
+
get: function() {
|
|
2022
|
+
return openapiCommand;
|
|
2023
|
+
}
|
|
2062
2024
|
});
|
|
2063
|
-
Object.defineProperty(exports,
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2025
|
+
Object.defineProperty(exports, "resolveOpenApiConfig", {
|
|
2026
|
+
enumerable: true,
|
|
2027
|
+
get: function() {
|
|
2028
|
+
return resolveOpenApiConfig;
|
|
2029
|
+
}
|
|
2068
2030
|
});
|
|
2069
|
-
Object.defineProperty(exports,
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2031
|
+
Object.defineProperty(exports, "runtimeFor", {
|
|
2032
|
+
enumerable: true,
|
|
2033
|
+
get: function() {
|
|
2034
|
+
return runtimeFor;
|
|
2035
|
+
}
|
|
2074
2036
|
});
|
|
2075
|
-
|
|
2037
|
+
|
|
2038
|
+
//# sourceMappingURL=openapi-Dcbme-Us.cjs.map
|