@geekmidas/constructs 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/dist/{AWSLambdaFunction-nic3vzt3.mjs → AWSLambdaFunction-DWIZYsCy.mjs} +2 -2
- package/dist/{AWSLambdaFunction-nic3vzt3.mjs.map → AWSLambdaFunction-DWIZYsCy.mjs.map} +1 -1
- package/dist/{AWSLambdaFunction-DW9qrBNR.cjs → AWSLambdaFunction-qA5LqPsv.cjs} +2 -2
- package/dist/{AWSLambdaFunction-DW9qrBNR.cjs.map → AWSLambdaFunction-qA5LqPsv.cjs.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-ZuQAhW9_.cjs → AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-ZuQAhW9_.cjs.map → AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs.map} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-BhqrpTVc.mjs → AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs} +1 -1
- package/dist/{AWSLambdaSubscriberAdaptor-BhqrpTVc.mjs.map → AWSLambdaSubscriberAdaptor-G8y3YkWj.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-BEzWkW5m.cjs → AmazonApiGatewayEndpointAdaptor-B8mozTcG.cjs} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-BEzWkW5m.cjs.map → AmazonApiGatewayEndpointAdaptor-B8mozTcG.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayEndpointAdaptor-CASfHEj9.mjs → AmazonApiGatewayEndpointAdaptor-Bmz6Cy1e.mjs} +3 -3
- package/dist/{AmazonApiGatewayEndpointAdaptor-CASfHEj9.mjs.map → AmazonApiGatewayEndpointAdaptor-Bmz6Cy1e.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-RPnkGENb.mjs → AmazonApiGatewayV1EndpointAdaptor-24g3dLn5.mjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-RPnkGENb.mjs.map → AmazonApiGatewayV1EndpointAdaptor-24g3dLn5.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-l1df4rFt.cjs → AmazonApiGatewayV1EndpointAdaptor-D4eZ-fx5.cjs} +3 -3
- package/dist/{AmazonApiGatewayV1EndpointAdaptor-l1df4rFt.cjs.map → AmazonApiGatewayV1EndpointAdaptor-D4eZ-fx5.cjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-C5Ctz7C_.mjs → AmazonApiGatewayV2EndpointAdaptor-Cc40RThv.mjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-C5Ctz7C_.mjs.map → AmazonApiGatewayV2EndpointAdaptor-Cc40RThv.mjs.map} +1 -1
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DH9yJsC8.cjs → AmazonApiGatewayV2EndpointAdaptor-J6tACl-N.cjs} +3 -3
- package/dist/{AmazonApiGatewayV2EndpointAdaptor-DH9yJsC8.cjs.map → AmazonApiGatewayV2EndpointAdaptor-J6tACl-N.cjs.map} +1 -1
- package/dist/{Cron-JYYGj5ik.cjs → Cron-CmZ6esMM.cjs} +1 -1
- package/dist/{Cron-JYYGj5ik.cjs.map → Cron-CmZ6esMM.cjs.map} +1 -1
- package/dist/{Cron-BgJo6EW6.mjs → Cron-D6hnZLk7.mjs} +1 -1
- package/dist/{Cron-BgJo6EW6.mjs.map → Cron-D6hnZLk7.mjs.map} +1 -1
- package/dist/{CronBuilder-DVuhB_kA.mjs → CronBuilder-Dfv5JguE.mjs} +2 -2
- package/dist/{CronBuilder-DVuhB_kA.mjs.map → CronBuilder-Dfv5JguE.mjs.map} +1 -1
- package/dist/{CronBuilder-BDDS21OP.cjs → CronBuilder-Di7QK8Rt.cjs} +2 -2
- package/dist/{CronBuilder-BDDS21OP.cjs.map → CronBuilder-Di7QK8Rt.cjs.map} +1 -1
- package/dist/{Endpoint-BVZJb4OR.cjs → Endpoint-COGAflGh.cjs} +1 -1
- package/dist/{Endpoint-BVZJb4OR.cjs.map → Endpoint-COGAflGh.cjs.map} +1 -1
- package/dist/{Endpoint-DVEmKo6G.mjs → Endpoint-DLLZvqoh.mjs} +1 -1
- package/dist/{Endpoint-DVEmKo6G.mjs.map → Endpoint-DLLZvqoh.mjs.map} +1 -1
- package/dist/{EndpointBuilder-DDnqW7rT.cjs → EndpointBuilder-FJktpPOu.cjs} +2 -2
- package/dist/{EndpointBuilder-DDnqW7rT.cjs.map → EndpointBuilder-FJktpPOu.cjs.map} +1 -1
- package/dist/{EndpointBuilder-Bhy91l_c.mjs → EndpointBuilder-oXO_ka1-.mjs} +2 -2
- package/dist/{EndpointBuilder-Bhy91l_c.mjs.map → EndpointBuilder-oXO_ka1-.mjs.map} +1 -1
- package/dist/{EndpointFactory-Cw_6-53M.cjs → EndpointFactory-Kk1tpifs.cjs} +2 -2
- package/dist/{EndpointFactory-Cw_6-53M.cjs.map → EndpointFactory-Kk1tpifs.cjs.map} +1 -1
- package/dist/{EndpointFactory-CNz3Wa08.mjs → EndpointFactory-eG8bDhOh.mjs} +2 -2
- package/dist/{EndpointFactory-CNz3Wa08.mjs.map → EndpointFactory-eG8bDhOh.mjs.map} +1 -1
- package/dist/{FunctionExecutionWrapper-UzfHDM2R.cjs → FunctionExecutionWrapper-CElXEjPe.cjs} +1 -1
- package/dist/{FunctionExecutionWrapper-UzfHDM2R.cjs.map → FunctionExecutionWrapper-CElXEjPe.cjs.map} +1 -1
- package/dist/{FunctionExecutionWrapper-CPzSbfaI.mjs → FunctionExecutionWrapper-XGrSAAPD.mjs} +1 -1
- package/dist/{FunctionExecutionWrapper-CPzSbfaI.mjs.map → FunctionExecutionWrapper-XGrSAAPD.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-Y4AD3E9g.mjs → HonoEndpointAdaptor-BlT1rWHV.mjs} +4 -4
- package/dist/{HonoEndpointAdaptor-Y4AD3E9g.mjs.map → HonoEndpointAdaptor-BlT1rWHV.mjs.map} +1 -1
- package/dist/{HonoEndpointAdaptor-OtKS5Dsd.d.cts → HonoEndpointAdaptor-BrbM9vxd.d.cts} +3 -3
- package/dist/{HonoEndpointAdaptor-BY2Ovj31.d.mts → HonoEndpointAdaptor-CxcYKdzT.d.mts} +3 -3
- package/dist/{HonoEndpointAdaptor-BsGMcxYb.cjs → HonoEndpointAdaptor-Ds433Q8w.cjs} +4 -4
- package/dist/{HonoEndpointAdaptor-BsGMcxYb.cjs.map → HonoEndpointAdaptor-Ds433Q8w.cjs.map} +1 -1
- package/dist/{TestEndpointAdaptor-DD3aygPp.mjs → TestEndpointAdaptor-Ct4I-gDo.mjs} +33 -7
- package/dist/TestEndpointAdaptor-Ct4I-gDo.mjs.map +1 -0
- package/dist/{TestEndpointAdaptor-CbNeUT3Y.cjs → TestEndpointAdaptor-FJUob2W_.cjs} +33 -7
- package/dist/TestEndpointAdaptor-FJUob2W_.cjs.map +1 -0
- package/dist/{TestEndpointAdaptor-Db0cm1fb.d.mts → TestEndpointAdaptor-vboVyJ0w.d.mts} +10 -4
- package/dist/{TestEndpointAdaptor-v7A-7hTs.d.cts → TestEndpointAdaptor-wwEaVHAt.d.cts} +10 -4
- package/dist/adaptors/aws.cjs +8 -8
- package/dist/adaptors/aws.d.cts +1 -1
- package/dist/adaptors/aws.d.mts +1 -1
- package/dist/adaptors/aws.mjs +8 -8
- package/dist/adaptors/hono.cjs +4 -4
- package/dist/adaptors/hono.d.cts +2 -2
- package/dist/adaptors/hono.d.mts +2 -2
- package/dist/adaptors/hono.mjs +4 -4
- package/dist/adaptors/testing.cjs +2 -2
- package/dist/adaptors/testing.d.cts +2 -2
- package/dist/adaptors/testing.d.mts +2 -2
- package/dist/adaptors/testing.mjs +2 -2
- package/dist/crons/Cron.cjs +1 -1
- package/dist/crons/Cron.d.cts +1 -1
- package/dist/crons/Cron.d.mts +1 -1
- package/dist/crons/Cron.mjs +1 -1
- package/dist/crons/CronBuilder.cjs +2 -2
- package/dist/crons/CronBuilder.d.cts +1 -1
- package/dist/crons/CronBuilder.d.mts +1 -1
- package/dist/crons/CronBuilder.mjs +2 -2
- package/dist/crons/index.cjs +2 -2
- package/dist/crons/index.d.cts +5 -5
- package/dist/crons/index.d.mts +5 -5
- package/dist/crons/index.mjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/AmazonApiGatewayEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.cjs +4 -4
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/AmazonApiGatewayV1EndpointAdaptor.mjs +4 -4
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.cjs +4 -4
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.cts +1 -1
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.d.mts +1 -1
- package/dist/endpoints/AmazonApiGatewayV2EndpointAdaptor.mjs +4 -4
- package/dist/endpoints/Endpoint.cjs +1 -1
- package/dist/endpoints/Endpoint.d.cts +1 -1
- package/dist/endpoints/Endpoint.d.mts +1 -1
- package/dist/endpoints/Endpoint.mjs +1 -1
- package/dist/endpoints/EndpointBuilder.cjs +2 -2
- package/dist/endpoints/EndpointBuilder.d.cts +1 -1
- package/dist/endpoints/EndpointBuilder.d.mts +1 -1
- package/dist/endpoints/EndpointBuilder.mjs +2 -2
- package/dist/endpoints/EndpointFactory.cjs +3 -3
- package/dist/endpoints/EndpointFactory.d.cts +1 -1
- package/dist/endpoints/EndpointFactory.d.mts +1 -1
- package/dist/endpoints/EndpointFactory.mjs +3 -3
- package/dist/endpoints/HonoEndpointAdaptor.cjs +4 -4
- package/dist/endpoints/HonoEndpointAdaptor.d.cts +2 -2
- package/dist/endpoints/HonoEndpointAdaptor.d.mts +2 -2
- package/dist/endpoints/HonoEndpointAdaptor.mjs +4 -4
- package/dist/endpoints/TestEndpointAdaptor.cjs +2 -2
- package/dist/endpoints/TestEndpointAdaptor.d.cts +3 -3
- package/dist/endpoints/TestEndpointAdaptor.d.mts +3 -3
- package/dist/endpoints/TestEndpointAdaptor.mjs +2 -2
- package/dist/endpoints/helpers.cjs +2 -2
- package/dist/endpoints/helpers.d.cts +1 -1
- package/dist/endpoints/helpers.d.mts +1 -1
- package/dist/endpoints/helpers.mjs +2 -2
- package/dist/endpoints/index.cjs +5 -3
- package/dist/endpoints/index.cjs.map +1 -1
- package/dist/endpoints/index.d.cts +6 -6
- package/dist/endpoints/index.d.mts +6 -6
- package/dist/endpoints/index.mjs +4 -4
- package/dist/endpoints/index.mjs.map +1 -1
- package/dist/endpoints/parseHonoQuery.cjs +1 -1
- package/dist/endpoints/parseHonoQuery.mjs +1 -1
- package/dist/endpoints/parseQueryParams.cjs +1 -1
- package/dist/endpoints/parseQueryParams.mjs +1 -1
- package/dist/functions/AWSLambdaFunction.cjs +2 -2
- package/dist/functions/AWSLambdaFunction.mjs +2 -2
- package/dist/functions/FunctionExecutionWrapper.cjs +1 -1
- package/dist/functions/FunctionExecutionWrapper.mjs +1 -1
- package/dist/functions/index.d.cts +1 -1
- package/dist/functions/index.d.mts +1 -1
- package/dist/{helpers-C9WBx7ms.mjs → helpers-CM0U-4Vk.mjs} +2 -2
- package/dist/{helpers-C9WBx7ms.mjs.map → helpers-CM0U-4Vk.mjs.map} +1 -1
- package/dist/{helpers-BSzj2AiQ.cjs → helpers-go4jiRvV.cjs} +2 -2
- package/dist/{helpers-BSzj2AiQ.cjs.map → helpers-go4jiRvV.cjs.map} +1 -1
- package/dist/index-BGr5gFrX.d.cts +9 -0
- package/dist/index-YM4W9XUq.d.mts +9 -0
- package/dist/{parseHonoQuery-BiPp8bEJ.cjs → parseHonoQuery-DopC24vB.cjs} +1 -1
- package/dist/{parseHonoQuery-BiPp8bEJ.cjs.map → parseHonoQuery-DopC24vB.cjs.map} +1 -1
- package/dist/{parseHonoQuery-yWRoKFFl.mjs → parseHonoQuery-znDKBhdE.mjs} +1 -1
- package/dist/{parseHonoQuery-yWRoKFFl.mjs.map → parseHonoQuery-znDKBhdE.mjs.map} +1 -1
- package/dist/{parseQueryParams-DSk9xl09.mjs → parseQueryParams-BJaRh3OB.mjs} +1 -1
- package/dist/{parseQueryParams-DSk9xl09.mjs.map → parseQueryParams-BJaRh3OB.mjs.map} +1 -1
- package/dist/{parseQueryParams-C2EjouGt.cjs → parseQueryParams-BzPop4I1.cjs} +1 -1
- package/dist/{parseQueryParams-C2EjouGt.cjs.map → parseQueryParams-BzPop4I1.cjs.map} +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.cjs +1 -1
- package/dist/subscribers/AWSLambdaSubscriberAdaptor.mjs +1 -1
- package/dist/subscribers/index.d.cts +2 -2
- package/package.json +6 -7
- package/src/endpoints/TestEndpointAdaptor.ts +75 -14
- package/src/endpoints/__tests__/TestEndpointAdaptor.spec.ts +309 -42
- package/src/endpoints/index.ts +9 -1
- package/dist/TestEndpointAdaptor-CbNeUT3Y.cjs.map +0 -1
- package/dist/TestEndpointAdaptor-DD3aygPp.mjs.map +0 -1
- package/dist/index-BXTN4mwI.d.mts +0 -9
- package/dist/index-BxApEwAF.d.cts +0 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
-
const require_Endpoint = require('./Endpoint-
|
|
2
|
+
const require_Endpoint = require('./Endpoint-COGAflGh.cjs');
|
|
3
3
|
const node_path = require_chunk.__toESM(require("node:path"));
|
|
4
4
|
const fast_glob = require_chunk.__toESM(require("fast-glob"));
|
|
5
5
|
|
|
@@ -92,4 +92,4 @@ Object.defineProperty(exports, 'getProjectRoot', {
|
|
|
92
92
|
return getProjectRoot;
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
|
-
//# sourceMappingURL=helpers-
|
|
95
|
+
//# sourceMappingURL=helpers-go4jiRvV.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers-
|
|
1
|
+
{"version":3,"file":"helpers-go4jiRvV.cjs","names":["cwd: string","routes: string[]","endpoints: Endpoint<string, HttpMethod, any, any, TServices>[]"],"sources":["../src/endpoints/helpers.ts"],"sourcesContent":["import path from 'node:path';\nimport fg from 'fast-glob';\nimport { Endpoint } from './Endpoint';\n\nimport type { Service } from '@geekmidas/services';\nimport type { HttpMethod } from '../types';\n\n// Re-export utility functions\n\n/**\n * Recursively finds the project root directory by looking for lock files.\n * Traverses up the directory tree until it finds a package manager lock file.\n *\n * @param cwd - The current working directory to start searching from\n * @returns Promise resolving to the absolute path of the project root\n *\n * @example\n * ```typescript\n * const projectRoot = await getProjectRoot(process.cwd());\n * console.log(`Project root: ${projectRoot}`);\n * // Output: Project root: /Users/user/my-project\n * ```\n */\nexport async function getProjectRoot(cwd: string): Promise<string> {\n if (cwd === '/') {\n return cwd;\n }\n\n const stream = fg.stream(\n ['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json', 'deno.lock'],\n { dot: true, cwd },\n );\n\n let isRoot = false;\n\n for await (const _ of stream) {\n isRoot = true;\n break;\n }\n\n if (isRoot) {\n return cwd;\n }\n\n return getProjectRoot(path.resolve(cwd, '..'));\n}\n\n/**\n * Discovers and imports all Endpoint instances from the specified route patterns.\n * Uses fast-glob to find files matching the patterns and extracts exported Endpoints.\n *\n * @template TServices - Array of service types used by the endpoints\n * @param routes - Array of glob patterns to match route files (e.g., ['src/routes/*.ts'])\n * @param cwd - The current working directory to resolve paths from\n * @returns Promise resolving to an array of Endpoint instances found in the matched files\n *\n * @example\n * ```typescript\n * // Find all endpoints in the routes directory\n * const endpoints = await getEndpointsFromRoutes(\n * ['src/routes/**\\/*.ts'],\n * process.cwd()\n * );\n *\n * // Register endpoints with your server\n * for (const endpoint of endpoints) {\n * server.register(endpoint);\n * }\n * ```\n *\n * @remarks\n * - Only exports that are valid Endpoint instances are included\n * - Files are imported dynamically, so they must be valid ES modules\n * - The function filters out non-Endpoint exports automatically\n */\nexport async function getEndpointsFromRoutes<TServices extends Service[]>(\n routes: string[],\n cwd: string,\n): Promise<Endpoint<string, HttpMethod, any, any, TServices>[]> {\n const stream = fg.stream(routes, { cwd });\n\n const endpoints: Endpoint<string, HttpMethod, any, any, TServices>[] = [];\n\n for await (const f of stream) {\n // Resolve the absolute path for the route file\n const routePath = path.resolve(cwd, f.toString());\n // Dynamically import the route module\n const route = await import(routePath);\n\n // Filter exported values to find only Endpoint instances\n const handlers = Object.values(route).filter((value) => {\n return Endpoint.isEndpoint(value);\n }) as unknown as Endpoint<string, HttpMethod, any, any, TServices>[];\n\n endpoints.push(...handlers);\n }\n\n return endpoints;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,eAAsB,eAAeA,KAA8B;AACjE,KAAI,QAAQ,IACV,QAAO;CAGT,MAAM,SAAS,kBAAG,OAChB;EAAC;EAAa;EAAkB;EAAqB;CAAY,GACjE;EAAE,KAAK;EAAM;CAAK,EACnB;CAED,IAAI,SAAS;AAEb,YAAW,MAAM,KAAK,QAAQ;AAC5B,WAAS;AACT;CACD;AAED,KAAI,OACF,QAAO;AAGT,QAAO,eAAe,kBAAK,QAAQ,KAAK,KAAK,CAAC;AAC/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BD,eAAsB,uBACpBC,QACAD,KAC8D;CAC9D,MAAM,SAAS,kBAAG,OAAO,QAAQ,EAAE,IAAK,EAAC;CAEzC,MAAME,YAAiE,CAAE;AAEzE,YAAW,MAAM,KAAK,QAAQ;EAE5B,MAAM,YAAY,kBAAK,QAAQ,KAAK,EAAE,UAAU,CAAC;EAEjD,MAAM,QAAQ,MAAM,OAAO;EAG3B,MAAM,WAAW,OAAO,OAAO,MAAM,CAAC,OAAO,CAAC,UAAU;AACtD,UAAO,0BAAS,WAAW,MAAM;EAClC,EAAC;AAEF,YAAU,KAAK,GAAG,SAAS;CAC5B;AAED,QAAO;AACR"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-BS1KgxA_.cjs";
|
|
2
|
+
import * as _geekmidas_logger1 from "@geekmidas/logger";
|
|
3
|
+
import * as _geekmidas_schema0 from "@geekmidas/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/functions/index.d.ts
|
|
6
|
+
declare const f: FunctionBuilder<_geekmidas_schema0.ComposableStandardSchema, undefined, [], _geekmidas_logger1.Logger, undefined, string>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { f };
|
|
9
|
+
//# sourceMappingURL=index-BGr5gFrX.d.cts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionBuilder } from "./FunctionBuilder-DBwR7jg7.mjs";
|
|
2
|
+
import * as _geekmidas_logger3 from "@geekmidas/logger";
|
|
3
|
+
import * as _geekmidas_schema2 from "@geekmidas/schema";
|
|
4
|
+
|
|
5
|
+
//#region src/functions/index.d.ts
|
|
6
|
+
declare const f: FunctionBuilder<_geekmidas_schema2.ComposableStandardSchema, undefined, [], _geekmidas_logger3.Logger, undefined, string>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { f };
|
|
9
|
+
//# sourceMappingURL=index-YM4W9XUq.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseHonoQuery-
|
|
1
|
+
{"version":3,"file":"parseHonoQuery-DopC24vB.cjs","names":["c: Context","result: Record<string, any>"],"sources":["../src/endpoints/parseHonoQuery.ts"],"sourcesContent":["import type { Context } from 'hono';\n\n/**\n * Parse Hono query parameters to handle arrays and nested objects\n * Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects\n */\nexport function parseHonoQuery(c: Context): Record<string, any> {\n const allParams = c.req.query();\n const result: Record<string, any> = {};\n\n // First, handle all query parameters\n for (const [key, value] of Object.entries(allParams)) {\n if (key.includes('.')) {\n // Handle dot notation for objects\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value, checking for arrays in nested keys\n const lastPart = parts[parts.length - 1];\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n current[lastPart] = multipleValues;\n } else {\n current[lastPart] = value;\n }\n } else {\n // For regular keys, check if there are multiple values\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n result[key] = multipleValues;\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;AAMA,SAAgB,eAAeA,GAAiC;CAC9D,MAAM,YAAY,EAAE,IAAI,OAAO;CAC/B,MAAMC,SAA8B,CAAE;AAGtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,UAAU,CAClD,KAAI,IAAI,SAAS,IAAI,EAAE;EAErB,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,IAAI,UAAU;AAGd,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;GACzC,MAAM,OAAO,MAAM;AACnB,QACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,aAAU,QAAQ;EACnB;EAGD,MAAM,WAAW,MAAM,MAAM,SAAS;EACtC,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,SAAQ,YAAY;MAEpB,SAAQ,YAAY;CAEvB,OAAM;EAEL,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,QAAO,OAAO;MAEd,QAAO,OAAO;CAEjB;AAGH,QAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseHonoQuery-
|
|
1
|
+
{"version":3,"file":"parseHonoQuery-znDKBhdE.mjs","names":["c: Context","result: Record<string, any>"],"sources":["../src/endpoints/parseHonoQuery.ts"],"sourcesContent":["import type { Context } from 'hono';\n\n/**\n * Parse Hono query parameters to handle arrays and nested objects\n * Hono provides c.req.queries() for arrays, but we need to handle dot notation for objects\n */\nexport function parseHonoQuery(c: Context): Record<string, any> {\n const allParams = c.req.query();\n const result: Record<string, any> = {};\n\n // First, handle all query parameters\n for (const [key, value] of Object.entries(allParams)) {\n if (key.includes('.')) {\n // Handle dot notation for objects\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value, checking for arrays in nested keys\n const lastPart = parts[parts.length - 1];\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n current[lastPart] = multipleValues;\n } else {\n current[lastPart] = value;\n }\n } else {\n // For regular keys, check if there are multiple values\n const multipleValues = c.req.queries(key);\n if (multipleValues && multipleValues.length > 1) {\n result[key] = multipleValues;\n } else {\n result[key] = value;\n }\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAeA,GAAiC;CAC9D,MAAM,YAAY,EAAE,IAAI,OAAO;CAC/B,MAAMC,SAA8B,CAAE;AAGtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,UAAU,CAClD,KAAI,IAAI,SAAS,IAAI,EAAE;EAErB,MAAM,QAAQ,IAAI,MAAM,IAAI;EAC5B,IAAI,UAAU;AAGd,OAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;GACzC,MAAM,OAAO,MAAM;AACnB,QACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,aAAU,QAAQ;EACnB;EAGD,MAAM,WAAW,MAAM,MAAM,SAAS;EACtC,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,SAAQ,YAAY;MAEpB,SAAQ,YAAY;CAEvB,OAAM;EAEL,MAAM,iBAAiB,EAAE,IAAI,QAAQ,IAAI;AACzC,MAAI,kBAAkB,eAAe,SAAS,EAC5C,QAAO,OAAO;MAEd,QAAO,OAAO;CAEjB;AAGH,QAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseQueryParams-
|
|
1
|
+
{"version":3,"file":"parseQueryParams-BJaRh3OB.mjs","names":["queryParams: Record<string, string | string[] | undefined> | null","result: Record<string, any>"],"sources":["../src/endpoints/parseQueryParams.ts"],"sourcesContent":["/**\n * Parse query parameters from a flat object into a nested structure\n * Handles arrays (multiple values with same key) and objects (dot notation)\n *\n * @example\n * parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n queryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n if (!queryParams) {\n return {};\n }\n\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(queryParams)) {\n if (value === undefined) {\n continue;\n }\n\n // Check if the key contains dot notation\n if (key.includes('.')) {\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value\n const lastPart = parts[parts.length - 1];\n current[lastPart] = value;\n } else {\n // Simple key, just assign the value\n result[key] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,iBACdA,aACqB;AACrB,MAAK,YACH,QAAO,CAAE;CAGX,MAAMC,SAA8B,CAAE;AAEtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,YAAY,EAAE;AACtD,MAAI,iBACF;AAIF,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,QAAQ,IAAI,MAAM,IAAI;GAC5B,IAAI,UAAU;AAGd,QAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;IACzC,MAAM,OAAO,MAAM;AACnB,SACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,cAAU,QAAQ;GACnB;GAGD,MAAM,WAAW,MAAM,MAAM,SAAS;AACtC,WAAQ,YAAY;EACrB,MAEC,QAAO,OAAO;CAEjB;AAED,QAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseQueryParams-
|
|
1
|
+
{"version":3,"file":"parseQueryParams-BzPop4I1.cjs","names":["queryParams: Record<string, string | string[] | undefined> | null","result: Record<string, any>"],"sources":["../src/endpoints/parseQueryParams.ts"],"sourcesContent":["/**\n * Parse query parameters from a flat object into a nested structure\n * Handles arrays (multiple values with same key) and objects (dot notation)\n *\n * @example\n * parseQueryParams({ 'tags': ['a', 'b'], 'filter.name': 'john' })\n * // Returns: { tags: ['a', 'b'], filter: { name: 'john' } }\n */\nexport function parseQueryParams(\n queryParams: Record<string, string | string[] | undefined> | null,\n): Record<string, any> {\n if (!queryParams) {\n return {};\n }\n\n const result: Record<string, any> = {};\n\n for (const [key, value] of Object.entries(queryParams)) {\n if (value === undefined) {\n continue;\n }\n\n // Check if the key contains dot notation\n if (key.includes('.')) {\n const parts = key.split('.');\n let current = result;\n\n // Navigate/create the nested structure\n for (let i = 0; i < parts.length - 1; i++) {\n const part = parts[i];\n if (\n !current[part] ||\n typeof current[part] !== 'object' ||\n Array.isArray(current[part])\n ) {\n current[part] = {};\n }\n current = current[part];\n }\n\n // Set the final value\n const lastPart = parts[parts.length - 1];\n current[lastPart] = value;\n } else {\n // Simple key, just assign the value\n result[key] = value;\n }\n }\n\n return result;\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,iBACdA,aACqB;AACrB,MAAK,YACH,QAAO,CAAE;CAGX,MAAMC,SAA8B,CAAE;AAEtC,MAAK,MAAM,CAAC,KAAK,MAAM,IAAI,OAAO,QAAQ,YAAY,EAAE;AACtD,MAAI,iBACF;AAIF,MAAI,IAAI,SAAS,IAAI,EAAE;GACrB,MAAM,QAAQ,IAAI,MAAM,IAAI;GAC5B,IAAI,UAAU;AAGd,QAAK,IAAI,IAAI,GAAG,IAAI,MAAM,SAAS,GAAG,KAAK;IACzC,MAAM,OAAO,MAAM;AACnB,SACG,QAAQ,gBACF,QAAQ,UAAU,YACzB,MAAM,QAAQ,QAAQ,MAAM,CAE5B,SAAQ,QAAQ,CAAE;AAEpB,cAAU,QAAQ;GACnB;GAGD,MAAM,WAAW,MAAM,MAAM,SAAS;AACtC,WAAQ,YAAY;EACrB,MAEC,QAAO,OAAO;CAEjB;AAED,QAAO;AACR"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const require_AWSLambdaSubscriberAdaptor = require('../AWSLambdaSubscriberAdaptor-
|
|
1
|
+
const require_AWSLambdaSubscriberAdaptor = require('../AWSLambdaSubscriberAdaptor-CmPZ10JF.cjs');
|
|
2
2
|
|
|
3
3
|
exports.AWSLambdaSubscriber = require_AWSLambdaSubscriberAdaptor.AWSLambdaSubscriber;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../Construct-Bm-PSO2V.cjs";
|
|
2
2
|
import { Subscriber } from "../Subscriber-BoFm12i_.cjs";
|
|
3
3
|
import { SubscriberBuilder } from "../SubscriberBuilder-DgljKtYu.cjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as _geekmidas_logger8 from "@geekmidas/logger";
|
|
5
5
|
|
|
6
6
|
//#region src/subscribers/index.d.ts
|
|
7
|
-
declare const s: SubscriberBuilder<[],
|
|
7
|
+
declare const s: SubscriberBuilder<[], _geekmidas_logger8.Logger, undefined, undefined, string, []>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { Subscriber, SubscriberBuilder, s };
|
|
10
10
|
//# sourceMappingURL=index.d.cts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geekmidas/constructs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"lodash.compact": "~3.0.1",
|
|
67
67
|
"openapi-types": "~12.1.3",
|
|
68
68
|
"fast-glob": "~3.3.3",
|
|
69
|
-
"@geekmidas/schema": "0.0.1",
|
|
70
|
-
"@geekmidas/services": "0.0.1",
|
|
71
69
|
"@geekmidas/logger": "0.0.1",
|
|
72
|
-
"@geekmidas/events": "0.0.
|
|
70
|
+
"@geekmidas/events": "0.0.2",
|
|
71
|
+
"@geekmidas/schema": "0.0.2",
|
|
72
|
+
"@geekmidas/services": "0.0.1",
|
|
73
73
|
"@geekmidas/cache": "0.0.7",
|
|
74
|
-
"@geekmidas/
|
|
75
|
-
"@geekmidas/
|
|
74
|
+
"@geekmidas/errors": "0.0.1",
|
|
75
|
+
"@geekmidas/rate-limit": "0.1.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/lodash.pick": "~4.4.9",
|
|
@@ -84,7 +84,6 @@
|
|
|
84
84
|
"@geekmidas/testkit": "0.0.16"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
|
-
"@standard-schema/spec": ">=1.0.0",
|
|
88
87
|
"@middy/core": ">=6.3.1",
|
|
89
88
|
"@types/aws-lambda": ">=8.10.92",
|
|
90
89
|
"hono": ">=4.8.2",
|
|
@@ -14,12 +14,55 @@ import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
|
14
14
|
import { publishConstructEvents } from '../publisher';
|
|
15
15
|
import type { HttpMethod } from '../types';
|
|
16
16
|
import {
|
|
17
|
+
type CookieOptions,
|
|
17
18
|
Endpoint,
|
|
18
19
|
type EndpointSchemas,
|
|
19
20
|
ResponseBuilder,
|
|
20
|
-
type ResponseWithMetadata,
|
|
21
21
|
} from './Endpoint';
|
|
22
22
|
|
|
23
|
+
export type TestHttpResponse<TBody = any> = {
|
|
24
|
+
body: TBody;
|
|
25
|
+
status: number;
|
|
26
|
+
headers: Record<string, string | string[]>;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Serializes a cookie into a Set-Cookie header string
|
|
31
|
+
*/
|
|
32
|
+
function serializeCookie(
|
|
33
|
+
name: string,
|
|
34
|
+
value: string,
|
|
35
|
+
options?: CookieOptions,
|
|
36
|
+
): string {
|
|
37
|
+
let cookieString = `${name}=${value}`;
|
|
38
|
+
|
|
39
|
+
if (options) {
|
|
40
|
+
if (options.maxAge !== undefined) {
|
|
41
|
+
cookieString += `; Max-Age=${options.maxAge}`;
|
|
42
|
+
}
|
|
43
|
+
if (options.expires) {
|
|
44
|
+
cookieString += `; Expires=${options.expires.toUTCString()}`;
|
|
45
|
+
}
|
|
46
|
+
if (options.domain) {
|
|
47
|
+
cookieString += `; Domain=${options.domain}`;
|
|
48
|
+
}
|
|
49
|
+
if (options.path) {
|
|
50
|
+
cookieString += `; Path=${options.path}`;
|
|
51
|
+
}
|
|
52
|
+
if (options.httpOnly) {
|
|
53
|
+
cookieString += '; HttpOnly';
|
|
54
|
+
}
|
|
55
|
+
if (options.secure) {
|
|
56
|
+
cookieString += '; Secure';
|
|
57
|
+
}
|
|
58
|
+
if (options.sameSite) {
|
|
59
|
+
cookieString += `; SameSite=${options.sameSite}`;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return cookieString;
|
|
64
|
+
}
|
|
65
|
+
|
|
23
66
|
export class TestEndpointAdaptor<
|
|
24
67
|
TRoute extends string,
|
|
25
68
|
TMethod extends HttpMethod,
|
|
@@ -77,17 +120,14 @@ export class TestEndpointAdaptor<
|
|
|
77
120
|
> = TestEndpointAdaptor.getDefaultServiceDiscover(endpoint),
|
|
78
121
|
) {}
|
|
79
122
|
|
|
80
|
-
async
|
|
123
|
+
async fullRequest(
|
|
81
124
|
ctx: TestRequestAdaptor<
|
|
82
125
|
TInput,
|
|
83
126
|
TServices,
|
|
84
127
|
TEventPublisher,
|
|
85
128
|
TEventPublisherServiceName
|
|
86
129
|
>,
|
|
87
|
-
): Promise<
|
|
88
|
-
| InferStandardSchema<TOutSchema>
|
|
89
|
-
| ResponseWithMetadata<InferStandardSchema<TOutSchema>>
|
|
90
|
-
> {
|
|
130
|
+
): Promise<TestHttpResponse<InferStandardSchema<TOutSchema>>> {
|
|
91
131
|
const body = await this.endpoint.parseInput((ctx as any).body, 'body');
|
|
92
132
|
const query = await this.endpoint.parseInput((ctx as any).query, 'query');
|
|
93
133
|
const params = await this.endpoint.parseInput(
|
|
@@ -138,16 +178,37 @@ export class TestEndpointAdaptor<
|
|
|
138
178
|
|
|
139
179
|
await publishConstructEvents(this.endpoint, output, this.serviceDiscovery);
|
|
140
180
|
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
(metadata.headers
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
) {
|
|
147
|
-
|
|
181
|
+
// Convert cookies to Set-Cookie headers
|
|
182
|
+
const headers: Record<string, string | string[]> = {
|
|
183
|
+
...(metadata.headers || {}),
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
if (metadata.cookies && metadata.cookies.size > 0) {
|
|
187
|
+
const setCookieValues: string[] = [];
|
|
188
|
+
for (const [name, cookie] of metadata.cookies.entries()) {
|
|
189
|
+
setCookieValues.push(serializeCookie(name, cookie.value, cookie.options));
|
|
190
|
+
}
|
|
191
|
+
headers['set-cookie'] = setCookieValues;
|
|
148
192
|
}
|
|
149
193
|
|
|
150
|
-
|
|
194
|
+
// Return HTTP response format
|
|
195
|
+
return {
|
|
196
|
+
body: output,
|
|
197
|
+
status: metadata.status || 200,
|
|
198
|
+
headers,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async request(
|
|
203
|
+
ctx: TestRequestAdaptor<
|
|
204
|
+
TInput,
|
|
205
|
+
TServices,
|
|
206
|
+
TEventPublisher,
|
|
207
|
+
TEventPublisherServiceName
|
|
208
|
+
>,
|
|
209
|
+
): Promise<InferStandardSchema<TOutSchema>> {
|
|
210
|
+
const response = await this.fullRequest(ctx);
|
|
211
|
+
return response.body;
|
|
151
212
|
}
|
|
152
213
|
}
|
|
153
214
|
|