@pikku/core 0.8.2 → 0.9.1

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.
Files changed (143) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/function/functions.types.d.ts +9 -9
  3. package/dist/handle-error.d.ts +1 -1
  4. package/dist/index.d.ts +11 -10
  5. package/dist/index.js +11 -10
  6. package/dist/pikku-state.d.ts +9 -9
  7. package/dist/services/user-session-service.d.ts +1 -1
  8. package/dist/types/core.types.d.ts +5 -5
  9. package/dist/types/core.types.js +9 -9
  10. package/dist/wirings/channel/channel-handler.d.ts +3 -0
  11. package/dist/{events → wirings}/channel/channel-handler.js +3 -3
  12. package/dist/wirings/channel/channel-runner.d.ts +14 -0
  13. package/dist/{events → wirings}/channel/channel-runner.js +13 -13
  14. package/dist/{events → wirings}/channel/channel.types.d.ts +7 -7
  15. package/dist/{events → wirings}/channel/eventhub-service.d.ts +4 -4
  16. package/dist/wirings/channel/eventhub-store.d.ts +5 -0
  17. package/dist/wirings/channel/local/local-channel-runner.d.ts +3 -0
  18. package/dist/{events → wirings}/channel/local/local-eventhub-service.d.ts +4 -4
  19. package/dist/{events → wirings}/channel/local/local-eventhub-service.js +1 -1
  20. package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.d.ts +2 -2
  21. package/dist/{events → wirings}/http/http-runner.d.ts +12 -12
  22. package/dist/{events → wirings}/http/http-runner.js +15 -15
  23. package/dist/{events → wirings}/http/http.types.d.ts +32 -27
  24. package/dist/{events → wirings}/http/index.d.ts +1 -1
  25. package/dist/{events → wirings}/http/index.js +1 -1
  26. package/dist/{events → wirings}/mcp/mcp-runner.d.ts +4 -4
  27. package/dist/{events → wirings}/mcp/mcp-runner.js +3 -3
  28. package/dist/{events → wirings}/mcp/mcp.types.d.ts +7 -7
  29. package/dist/{events → wirings}/queue/index.d.ts +1 -1
  30. package/dist/{events → wirings}/queue/index.js +1 -1
  31. package/dist/{events → wirings}/queue/queue-runner.d.ts +2 -2
  32. package/dist/{events → wirings}/queue/queue-runner.js +1 -1
  33. package/dist/{events → wirings}/queue/queue.types.d.ts +3 -3
  34. package/dist/wirings/scheduler/index.d.ts +3 -0
  35. package/dist/wirings/scheduler/index.js +3 -0
  36. package/dist/{events → wirings}/scheduler/scheduler-runner.d.ts +2 -2
  37. package/dist/{events → wirings}/scheduler/scheduler-runner.js +1 -1
  38. package/dist/{events → wirings}/scheduler/scheduler.types.d.ts +3 -3
  39. package/package.json +9 -9
  40. package/src/function/functions.types.ts +13 -13
  41. package/src/handle-error.ts +1 -1
  42. package/src/index.ts +14 -13
  43. package/src/pikku-state.ts +11 -11
  44. package/src/services/user-session-service.ts +1 -1
  45. package/src/types/core.types.ts +5 -5
  46. package/src/{events → wirings}/channel/channel-handler.ts +5 -5
  47. package/src/{events → wirings}/channel/channel-runner.ts +18 -18
  48. package/src/{events → wirings}/channel/channel.types.ts +16 -16
  49. package/src/{events → wirings}/channel/eventhub-service.ts +12 -8
  50. package/src/wirings/channel/eventhub-store.ts +13 -0
  51. package/src/{events → wirings}/channel/local/local-channel-runner.test.ts +2 -2
  52. package/src/{events → wirings}/channel/local/local-channel-runner.ts +2 -2
  53. package/src/{events → wirings}/channel/local/local-eventhub-service.ts +16 -10
  54. package/src/{events → wirings}/channel/serverless/serverless-channel-runner.ts +2 -2
  55. package/src/{events → wirings}/http/http-runner.test.ts +4 -4
  56. package/src/{events → wirings}/http/http-runner.ts +32 -31
  57. package/src/{events → wirings}/http/http.types.ts +40 -35
  58. package/src/{events → wirings}/http/index.ts +1 -1
  59. package/src/{events → wirings}/mcp/mcp-runner.ts +10 -10
  60. package/src/{events → wirings}/mcp/mcp.types.ts +9 -7
  61. package/src/{events → wirings}/queue/index.ts +1 -1
  62. package/src/{events → wirings}/queue/queue-runner.ts +5 -5
  63. package/src/{events → wirings}/queue/queue.types.ts +3 -3
  64. package/src/{events → wirings}/scheduler/index.ts +1 -1
  65. package/src/{events → wirings}/scheduler/scheduler-runner.ts +4 -4
  66. package/src/{events → wirings}/scheduler/scheduler.types.ts +3 -3
  67. package/tsconfig.tsbuildinfo +1 -1
  68. package/dist/events/channel/channel-handler.d.ts +0 -3
  69. package/dist/events/channel/channel-runner.d.ts +0 -14
  70. package/dist/events/channel/eventhub-store.d.ts +0 -5
  71. package/dist/events/channel/local/local-channel-runner.d.ts +0 -3
  72. package/dist/events/scheduler/index.d.ts +0 -3
  73. package/dist/events/scheduler/index.js +0 -3
  74. package/src/events/channel/eventhub-store.ts +0 -8
  75. /package/dist/{events → wirings}/channel/channel-store.d.ts +0 -0
  76. /package/dist/{events → wirings}/channel/channel-store.js +0 -0
  77. /package/dist/{events → wirings}/channel/channel.types.js +0 -0
  78. /package/dist/{events → wirings}/channel/eventhub-service.js +0 -0
  79. /package/dist/{events → wirings}/channel/eventhub-store.js +0 -0
  80. /package/dist/{events → wirings}/channel/index.d.ts +0 -0
  81. /package/dist/{events → wirings}/channel/index.js +0 -0
  82. /package/dist/{events → wirings}/channel/local/index.d.ts +0 -0
  83. /package/dist/{events → wirings}/channel/local/index.js +0 -0
  84. /package/dist/{events → wirings}/channel/local/local-channel-handler.d.ts +0 -0
  85. /package/dist/{events → wirings}/channel/local/local-channel-handler.js +0 -0
  86. /package/dist/{events → wirings}/channel/local/local-channel-runner.js +0 -0
  87. /package/dist/{events → wirings}/channel/log-channels.d.ts +0 -0
  88. /package/dist/{events → wirings}/channel/log-channels.js +0 -0
  89. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.d.ts +0 -0
  90. /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.js +0 -0
  91. /package/dist/{events → wirings}/channel/serverless/index.d.ts +0 -0
  92. /package/dist/{events → wirings}/channel/serverless/index.js +0 -0
  93. /package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.js +0 -0
  94. /package/dist/{events → wirings}/http/http.types.js +0 -0
  95. /package/dist/{events → wirings}/http/log-http-routes.d.ts +0 -0
  96. /package/dist/{events → wirings}/http/log-http-routes.js +0 -0
  97. /package/dist/{events → wirings}/http/pikku-fetch-http-request.d.ts +0 -0
  98. /package/dist/{events → wirings}/http/pikku-fetch-http-request.js +0 -0
  99. /package/dist/{events → wirings}/http/pikku-fetch-http-response.d.ts +0 -0
  100. /package/dist/{events → wirings}/http/pikku-fetch-http-response.js +0 -0
  101. /package/dist/{events → wirings}/mcp/index.d.ts +0 -0
  102. /package/dist/{events → wirings}/mcp/index.js +0 -0
  103. /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.d.ts +0 -0
  104. /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.js +0 -0
  105. /package/dist/{events → wirings}/mcp/mcp.types.js +0 -0
  106. /package/dist/{events → wirings}/queue/queue.types.js +0 -0
  107. /package/dist/{events → wirings}/queue/register-queue-helper.d.ts +0 -0
  108. /package/dist/{events → wirings}/queue/register-queue-helper.js +0 -0
  109. /package/dist/{events → wirings}/queue/validate-worker-config.d.ts +0 -0
  110. /package/dist/{events → wirings}/queue/validate-worker-config.js +0 -0
  111. /package/dist/{events → wirings}/rpc/index.d.ts +0 -0
  112. /package/dist/{events → wirings}/rpc/index.js +0 -0
  113. /package/dist/{events → wirings}/rpc/rpc-runner.d.ts +0 -0
  114. /package/dist/{events → wirings}/rpc/rpc-runner.js +0 -0
  115. /package/dist/{events → wirings}/rpc/rpc-types.d.ts +0 -0
  116. /package/dist/{events → wirings}/rpc/rpc-types.js +0 -0
  117. /package/dist/{events → wirings}/scheduler/log-schedulers.d.ts +0 -0
  118. /package/dist/{events → wirings}/scheduler/log-schedulers.js +0 -0
  119. /package/dist/{events → wirings}/scheduler/scheduler.types.js +0 -0
  120. /package/src/{events → wirings}/channel/channel-store.ts +0 -0
  121. /package/src/{events → wirings}/channel/index.ts +0 -0
  122. /package/src/{events → wirings}/channel/local/index.ts +0 -0
  123. /package/src/{events → wirings}/channel/local/local-channel-handler.ts +0 -0
  124. /package/src/{events → wirings}/channel/local/local-eventhub-service.test.ts +0 -0
  125. /package/src/{events → wirings}/channel/log-channels.ts +0 -0
  126. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.test.ts +0 -0
  127. /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.ts +0 -0
  128. /package/src/{events → wirings}/channel/serverless/index.ts +0 -0
  129. /package/src/{events → wirings}/http/log-http-routes.ts +0 -0
  130. /package/src/{events → wirings}/http/pikku-fetch-http-request.test.ts +0 -0
  131. /package/src/{events → wirings}/http/pikku-fetch-http-request.ts +0 -0
  132. /package/src/{events → wirings}/http/pikku-fetch-http-response.test.ts +0 -0
  133. /package/src/{events → wirings}/http/pikku-fetch-http-response.ts +0 -0
  134. /package/src/{events → wirings}/mcp/index.ts +0 -0
  135. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.d.ts +0 -0
  136. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.ts +0 -0
  137. /package/src/{events → wirings}/mcp/mcp-endpoint-registry.ts +0 -0
  138. /package/src/{events → wirings}/queue/register-queue-helper.ts +0 -0
  139. /package/src/{events → wirings}/queue/validate-worker-config.ts +0 -0
  140. /package/src/{events → wirings}/rpc/index.ts +0 -0
  141. /package/src/{events → wirings}/rpc/rpc-runner.ts +0 -0
  142. /package/src/{events → wirings}/rpc/rpc-types.ts +0 -0
  143. /package/src/{events → wirings}/scheduler/log-schedulers.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.9.0
2
+
3
+ ## 0.9.1
4
+
5
+ ### Patch Changes
6
+
7
+ - fdb1593: core: bumping everything with a patch to sync up the major release inconsistencies in dependencies
8
+
9
+ ### Breaking Changes
10
+
11
+ - Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
12
+
1
13
  ## 0.8.0
2
14
 
3
15
  ## 0.8.2
@@ -86,7 +98,7 @@ We now use the function first approach internally, which means first all the fun
86
98
  The main breaking changes for the end user are:
87
99
 
88
100
  - We now declare functions using `pikkuFunc<In, Out>(async () => {})
89
- - We renamed addRoute to addHTTPRoutes
101
+ - We renamed addRoute to wireHTTPs
90
102
 
91
103
  We also removed all the different types of functions. Everything is now either an APIFunction of APIFunctionSessionless. The channel (eventHub or any other transport specific service) is now injected in the service itself.
92
104
 
@@ -1,4 +1,4 @@
1
- import { PikkuChannel } from '../events/channel/channel.types.js';
1
+ import { PikkuChannel } from '../wirings/channel/channel.types.js';
2
2
  import type { CoreServices, CoreSingletonServices, CoreUserSession, PikkuFunctionMiddleware } from '../types/core.types.js';
3
3
  /**
4
4
  * Represents a core API function that performs an operation using core services and a user session.
@@ -8,7 +8,7 @@ import type { CoreServices, CoreSingletonServices, CoreUserSession, PikkuFunctio
8
8
  * @template Services - The services type, defaults to `CoreServices`.
9
9
  * @template Session - The session type, defaults to `CoreUserSession`.
10
10
  */
11
- export type CoreAPIFunction<In, Out, ChannelData extends unknown | null = null, Services extends CoreSingletonServices = CoreServices & (ChannelData extends null ? {
11
+ export type CorePikkuFunction<In, Out, ChannelData extends unknown | null = null, Services extends CoreSingletonServices = CoreServices & (ChannelData extends null ? {
12
12
  channel?: PikkuChannel<unknown, Out> | undefined;
13
13
  } : {
14
14
  channel: PikkuChannel<ChannelData, Out>;
@@ -21,23 +21,23 @@ export type CoreAPIFunction<In, Out, ChannelData extends unknown | null = null,
21
21
  * @template Services - The services type, defaults to `CoreServices`.
22
22
  * @template Session - The session type, defaults to `CoreUserSession`.
23
23
  */
24
- export type CoreAPIFunctionSessionless<In, Out, ChannelData extends unknown | null = null, Services extends CoreSingletonServices = CoreServices & (ChannelData extends null ? {
24
+ export type CorePikkuFunctionSessionless<In, Out, ChannelData extends unknown | null = null, Services extends CoreSingletonServices = CoreServices & (ChannelData extends null ? {
25
25
  channel?: PikkuChannel<unknown, Out> | undefined;
26
26
  } : {
27
27
  channel: PikkuChannel<ChannelData, Out>;
28
28
  }), Session extends CoreUserSession = CoreUserSession> = (services: Services, data: In, session?: Session) => ChannelData extends null ? Promise<Out> : Promise<Out> | Promise<void>;
29
29
  /**
30
- * Represents a function that checks permissions for a given API operation.
30
+ * Represents a function that checks permissions for a given operation.
31
31
  *
32
32
  * @template In - The input type.
33
33
  * @template Services - The services type, defaults to `CoreServices`.
34
34
  * @template Session - The session type, defaults to `CoreUserSession`.
35
35
  */
36
- export type CoreAPIPermission<In = any, Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, data: In, session?: Session) => Promise<boolean>;
37
- export type CorePermissionGroup<APIPermission = CoreAPIPermission<any>> = Record<string, APIPermission | APIPermission[]> | undefined;
38
- export type CorePikkuFunctionConfig<APIFunction extends CoreAPIFunction<any, any> | CoreAPIFunctionSessionless<any, any>, APIPermission extends CoreAPIPermission<any> = CoreAPIPermission<any>> = {
39
- func: APIFunction;
36
+ export type CorePikkuPermission<In = any, Services extends CoreSingletonServices = CoreServices, Session extends CoreUserSession = CoreUserSession> = (services: Services, data: In, session?: Session) => Promise<boolean>;
37
+ export type CorePermissionGroup<PikkuPermission = CorePikkuPermission<any>> = Record<string, PikkuPermission | PikkuPermission[]> | undefined;
38
+ export type CorePikkuFunctionConfig<PikkuFunction extends CorePikkuFunction<any, any> | CorePikkuFunctionSessionless<any, any>, PikkuPermission extends CorePikkuPermission<any> = CorePikkuPermission<any>> = {
39
+ func: PikkuFunction;
40
40
  auth?: boolean;
41
- permissions?: CorePermissionGroup<APIPermission>;
41
+ permissions?: CorePermissionGroup<PikkuPermission>;
42
42
  middleware?: PikkuFunctionMiddleware[];
43
43
  };
@@ -1,5 +1,5 @@
1
1
  import { Logger } from './services/logger.js';
2
- import { PikkuHTTP } from './events/http/http.types.js';
2
+ import { PikkuHTTP } from './wirings/http/http.types.js';
3
3
  /**
4
4
  * Handle errors that occur during route processing
5
5
  *
package/dist/index.d.ts CHANGED
@@ -10,19 +10,20 @@ export * from './services/schema-service.js';
10
10
  export * from './services/jwt-service.js';
11
11
  export * from './services/secret-service.js';
12
12
  export * from './services/user-session-service.js';
13
- export * from './events/http/index.js';
14
- export * from './events/channel/index.js';
15
- export * from './events/scheduler/index.js';
16
- export * from './events/rpc/index.js';
17
- export * from './events/queue/index.js';
18
- export * from './events/mcp/index.js';
13
+ export * from './wirings/http/index.js';
14
+ export * from './wirings/channel/index.js';
15
+ export * from './wirings/scheduler/index.js';
16
+ export * from './wirings/rpc/index.js';
17
+ export * from './wirings/queue/index.js';
18
+ export * from './wirings/mcp/index.js';
19
19
  export * from './errors/index.js';
20
20
  export * from './middleware/index.js';
21
21
  export * from './time-utils.js';
22
22
  export * from './utils.js';
23
23
  export { pikkuState } from './pikku-state.js';
24
24
  export { runMiddleware } from './middleware-runner.js';
25
- export { addHTTPRoute, addMiddleware } from './events/http/http-runner.js';
26
- export { addChannel } from './events/channel/channel-runner.js';
27
- export { addScheduledTask } from './events/scheduler/scheduler-runner.js';
28
- export { addMCPResource, addMCPTool, addMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, getMCPTools, getMCPResources, getMCPPrompts, getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './events/mcp/mcp-runner.js';
25
+ export { wireHTTP, addMiddleware } from './wirings/http/http-runner.js';
26
+ export { wireChannel } from './wirings/channel/channel-runner.js';
27
+ export { wireScheduler } from './wirings/scheduler/scheduler-runner.js';
28
+ export { wireQueueWorker } from './wirings/queue/queue-runner.js';
29
+ export { wireMCPResource, wireMCPTool, wireMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, getMCPTools, getMCPResources, getMCPPrompts, getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './wirings/mcp/mcp-runner.js';
package/dist/index.js CHANGED
@@ -10,19 +10,20 @@ export * from './services/schema-service.js';
10
10
  export * from './services/jwt-service.js';
11
11
  export * from './services/secret-service.js';
12
12
  export * from './services/user-session-service.js';
13
- export * from './events/http/index.js';
14
- export * from './events/channel/index.js';
15
- export * from './events/scheduler/index.js';
16
- export * from './events/rpc/index.js';
17
- export * from './events/queue/index.js';
18
- export * from './events/mcp/index.js';
13
+ export * from './wirings/http/index.js';
14
+ export * from './wirings/channel/index.js';
15
+ export * from './wirings/scheduler/index.js';
16
+ export * from './wirings/rpc/index.js';
17
+ export * from './wirings/queue/index.js';
18
+ export * from './wirings/mcp/index.js';
19
19
  export * from './errors/index.js';
20
20
  export * from './middleware/index.js';
21
21
  export * from './time-utils.js';
22
22
  export * from './utils.js';
23
23
  export { pikkuState } from './pikku-state.js';
24
24
  export { runMiddleware } from './middleware-runner.js';
25
- export { addHTTPRoute, addMiddleware } from './events/http/http-runner.js';
26
- export { addChannel } from './events/channel/channel-runner.js';
27
- export { addScheduledTask } from './events/scheduler/scheduler-runner.js';
28
- export { addMCPResource, addMCPTool, addMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, getMCPTools, getMCPResources, getMCPPrompts, getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './events/mcp/mcp-runner.js';
25
+ export { wireHTTP, addMiddleware } from './wirings/http/http-runner.js';
26
+ export { wireChannel } from './wirings/channel/channel-runner.js';
27
+ export { wireScheduler } from './wirings/scheduler/scheduler-runner.js';
28
+ export { wireQueueWorker } from './wirings/queue/queue-runner.js';
29
+ export { wireMCPResource, wireMCPTool, wireMCPPrompt, runMCPResource, runMCPTool, runMCPPrompt, getMCPTools, getMCPResources, getMCPPrompts, getMCPResourcesMeta, getMCPToolsMeta, getMCPPromptsMeta, } from './wirings/mcp/mcp-runner.js';
@@ -1,12 +1,12 @@
1
- import { ChannelsMeta, CoreAPIChannel } from './events/channel/channel.types.js';
2
- import { CoreHTTPFunctionRoute, HTTPMethod, HTTPRoutesMeta } from './events/http/http.types.js';
1
+ import { ChannelsMeta, CoreChannel } from './wirings/channel/channel.types.js';
2
+ import { CoreHTTPFunctionWiring, HTTPMethod, HTTPWiringsMeta } from './wirings/http/http.types.js';
3
3
  import { FunctionsMeta, PikkuMiddleware } from './types/core.types.js';
4
- import { CoreScheduledTask, ScheduledTasksMeta } from './events/scheduler/scheduler.types.js';
4
+ import { CoreScheduledTask, ScheduledTasksMeta } from './wirings/scheduler/scheduler.types.js';
5
5
  import { ErrorDetails, PikkuError } from './errors/error-handler.js';
6
6
  import { CorePikkuFunctionConfig } from './function/functions.types.js';
7
- import { RPCMeta } from './events/rpc/rpc-types.js';
8
- import { queueWorkersMeta, CoreQueueWorker } from './events/queue/queue.types.js';
9
- import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from './events/mcp/mcp.types.js';
7
+ import { RPCMeta } from './wirings/rpc/rpc-types.js';
8
+ import { queueWorkersMeta, CoreQueueWorker } from './wirings/queue/queue.types.js';
9
+ import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from './wirings/mcp/mcp.types.js';
10
10
  interface PikkuState {
11
11
  function: {
12
12
  meta: FunctionsMeta;
@@ -24,11 +24,11 @@ interface PikkuState {
24
24
  route: string;
25
25
  middleware: PikkuMiddleware[];
26
26
  }>;
27
- routes: Map<HTTPMethod, Map<string, CoreHTTPFunctionRoute<any, any, any>>>;
28
- meta: HTTPRoutesMeta;
27
+ routes: Map<HTTPMethod, Map<string, CoreHTTPFunctionWiring<any, any, any>>>;
28
+ meta: HTTPWiringsMeta;
29
29
  };
30
30
  channel: {
31
- channels: Map<string, CoreAPIChannel<any, any>>;
31
+ channels: Map<string, CoreChannel<any, any>>;
32
32
  meta: ChannelsMeta;
33
33
  };
34
34
  scheduler: {
@@ -1,4 +1,4 @@
1
- import { ChannelStore } from '../events/channel/channel-store.js';
1
+ import { ChannelStore } from '../wirings/channel/channel-store.js';
2
2
  import { CoreUserSession } from '../types/core.types.js';
3
3
  export interface UserSessionService<UserSession extends CoreUserSession> {
4
4
  sessionChanged: boolean;
@@ -1,12 +1,12 @@
1
1
  import type { Logger, LogLevel } from '../services/logger.js';
2
2
  import { VariablesService } from '../services/variables-service.js';
3
3
  import { SchemaService } from '../services/schema-service.js';
4
- import { PikkuHTTP } from '../events/http/http.types.js';
4
+ import { PikkuHTTP } from '../wirings/http/http.types.js';
5
5
  import { UserSessionService } from '../services/user-session-service.js';
6
- import { PikkuChannel } from '../events/channel/channel.types.js';
7
- import { PikkuRPC } from '../events/rpc/rpc-types.js';
8
- import { PikkuMCP } from '../events/mcp/mcp.types.js';
9
- export declare enum PikkuEventTypes {
6
+ import { PikkuChannel } from '../wirings/channel/channel.types.js';
7
+ import { PikkuRPC } from '../wirings/rpc/rpc-types.js';
8
+ import { PikkuMCP } from '../wirings/mcp/mcp.types.js';
9
+ export declare enum PikkuWiringTypes {
10
10
  http = "http",
11
11
  scheduler = "scheduler",
12
12
  channel = "channel",
@@ -1,9 +1,9 @@
1
- export var PikkuEventTypes;
2
- (function (PikkuEventTypes) {
3
- PikkuEventTypes["http"] = "http";
4
- PikkuEventTypes["scheduler"] = "scheduler";
5
- PikkuEventTypes["channel"] = "channel";
6
- PikkuEventTypes["rpc"] = "rpc";
7
- PikkuEventTypes["queue"] = "queue";
8
- PikkuEventTypes["mcp"] = "mcp";
9
- })(PikkuEventTypes || (PikkuEventTypes = {}));
1
+ export var PikkuWiringTypes;
2
+ (function (PikkuWiringTypes) {
3
+ PikkuWiringTypes["http"] = "http";
4
+ PikkuWiringTypes["scheduler"] = "scheduler";
5
+ PikkuWiringTypes["channel"] = "channel";
6
+ PikkuWiringTypes["rpc"] = "rpc";
7
+ PikkuWiringTypes["queue"] = "queue";
8
+ PikkuWiringTypes["mcp"] = "mcp";
9
+ })(PikkuWiringTypes || (PikkuWiringTypes = {}));
@@ -0,0 +1,3 @@
1
+ import { CoreServices, CoreUserSession } from '../../types/core.types.js';
2
+ import { CoreChannel, PikkuChannelHandler } from './channel.types.js';
3
+ export declare const processMessageHandlers: (services: CoreServices, session: CoreUserSession | undefined, channelConfig: CoreChannel<any, any>, channelHandler: PikkuChannelHandler) => (rawData: any) => Promise<unknown>;
@@ -14,7 +14,7 @@ const getRouteMeta = (channelName, routingProperty, routerValue) => {
14
14
  if (!routerValue) {
15
15
  throw new Error(`Channel ${channelName} requires a router value for ${routingProperty}`);
16
16
  }
17
- const route = channelMeta.messageRoutes[routingProperty]?.[routerValue];
17
+ const route = channelMeta.messageWirings[routingProperty]?.[routerValue];
18
18
  if (!route) {
19
19
  throw new Error(`Channel ${channelName} has no route for ${routingProperty}:${routerValue}`);
20
20
  }
@@ -62,10 +62,10 @@ export const processMessageHandlers = (services, session, channelConfig, channel
62
62
  let result;
63
63
  let processed = false;
64
64
  // Route-specific handling
65
- if (typeof rawData === 'string' && channelConfig.onMessageRoute) {
65
+ if (typeof rawData === 'string' && channelConfig.onMessageWiring) {
66
66
  try {
67
67
  const messageData = JSON.parse(rawData);
68
- const entries = Object.entries(channelConfig.onMessageRoute);
68
+ const entries = Object.entries(channelConfig.onMessageWiring);
69
69
  for (const [routingProperty, routes] of entries) {
70
70
  const routerValue = messageData[routingProperty];
71
71
  if (routerValue && routes[routerValue]) {
@@ -0,0 +1,14 @@
1
+ import { UserSessionService } from '../../services/user-session-service.js';
2
+ import { ChannelMeta, CoreChannel, RunChannelOptions, RunChannelParams } from './channel.types.js';
3
+ /**
4
+ * Adds a channel and registers all functions referenced in it using the
5
+ * function names already stored in the channel metadata
6
+ */
7
+ export declare const wireChannel: <In, Channel extends string, ChannelFunction, ChannelFunctionSessionless, PikkuPermission>(channel: CoreChannel<In, Channel, ChannelFunction, PikkuPermission>) => void;
8
+ export declare const openChannel: ({ route, singletonServices, coerceDataFromSchema, request, }: Pick<CoreChannel<unknown, string>, "route"> & RunChannelParams<unknown> & {
9
+ userSession: UserSessionService<any>;
10
+ } & RunChannelOptions) => Promise<{
11
+ openingData: unknown;
12
+ channelConfig: CoreChannel<unknown, any>;
13
+ meta: ChannelMeta;
14
+ }>;
@@ -7,7 +7,7 @@ import { match } from 'path-to-regexp';
7
7
  * Adds a channel and registers all functions referenced in it using the
8
8
  * function names already stored in the channel metadata
9
9
  */
10
- export const addChannel = (channel) => {
10
+ export const wireChannel = (channel) => {
11
11
  // Get the channel metadata
12
12
  const channelsMeta = pikkuState('channel', 'meta');
13
13
  const channelMeta = channelsMeta[channel.name];
@@ -36,20 +36,20 @@ export const addChannel = (channel) => {
36
36
  func: messageFunc,
37
37
  });
38
38
  }
39
- // Register functions in onMessageRoute
40
- if (channel.onMessageRoute && channelMeta.messageRoutes) {
41
- // Iterate through each channel in onMessageRoute
42
- Object.entries(channel.onMessageRoute).forEach(([channelKey, routes]) => {
43
- const channelRoutes = channelMeta.messageRoutes[channelKey];
44
- if (!channelRoutes)
39
+ // Register functions in onMessageWiring
40
+ if (channel.onMessageWiring && channelMeta.messageWirings) {
41
+ // Iterate through each channel in onMessageWiring
42
+ Object.entries(channel.onMessageWiring).forEach(([channelKey, wirings]) => {
43
+ const channelWirings = channelMeta.messageWirings[channelKey];
44
+ if (!channelWirings)
45
45
  return;
46
- // Iterate through each route in the channel
47
- Object.entries(routes).forEach(([routeKey, handler]) => {
48
- const routeMeta = channelRoutes[routeKey];
49
- if (!routeMeta)
46
+ // Iterate through each wiring in the channel
47
+ Object.entries(wirings).forEach(([wiringKey, handler]) => {
48
+ const wiringMeta = channelWirings[wiringKey];
49
+ if (!wiringMeta)
50
50
  return;
51
51
  // Extract the function from the handler
52
- const routeFunc = typeof handler === 'function'
52
+ const wiringFunc = typeof handler === 'function'
53
53
  ? { func: handler }
54
54
  : {
55
55
  func: handler.func,
@@ -57,7 +57,7 @@ export const addChannel = (channel) => {
57
57
  permissions: handler.permissions,
58
58
  };
59
59
  // Register the function using the pikku name from metadata
60
- addFunction(routeMeta.pikkuFuncName, routeFunc);
60
+ addFunction(wiringMeta.pikkuFuncName, wiringFunc);
61
61
  });
62
62
  });
63
63
  }
@@ -1,7 +1,7 @@
1
1
  import { PikkuError } from '../../errors/error-handler.js';
2
2
  import { HTTPFunctionMetaInputTypes, PikkuHTTPRequest, PikkuHTTPResponse } from '../http/http.types.js';
3
3
  import { APIDocs, CoreSingletonServices, CreateSessionServices, PikkuMiddleware } from '../../types/core.types.js';
4
- import { CoreAPIFunction, CoreAPIFunctionSessionless, CoreAPIPermission } from '../../function/functions.types.js';
4
+ import { CorePikkuFunction, CorePikkuFunctionSessionless, CorePikkuPermission } from '../../function/functions.types.js';
5
5
  export type RunChannelOptions = Partial<{
6
6
  skipUserSession: boolean;
7
7
  respondWith404: boolean;
@@ -30,28 +30,28 @@ export interface ChannelMeta {
30
30
  connect: ChannelMessageMeta | null;
31
31
  disconnect: ChannelMessageMeta | null;
32
32
  message: ChannelMessageMeta | null;
33
- messageRoutes: Record<string, Record<string, ChannelMessageMeta>>;
33
+ messageWirings: Record<string, Record<string, ChannelMessageMeta>>;
34
34
  docs?: APIDocs;
35
35
  tags?: string[];
36
36
  }
37
37
  export type ChannelsMeta = Record<string, ChannelMeta>;
38
- export type CoreAPIChannel<ChannelData, Channel extends string, ChannelConnect = CoreAPIFunction<void, unknown, ChannelData> | CoreAPIFunctionSessionless<void, unknown, ChannelData>, ChannelDisconnect = CoreAPIFunction<void, void, ChannelData> | CoreAPIFunctionSessionless<void, void, ChannelData>, ChannelFunctionMessage = CoreAPIFunction<unknown, unknown, ChannelData> | CoreAPIFunctionSessionless<unknown, unknown, ChannelData>, APIPermission = CoreAPIPermission<ChannelData>> = {
38
+ export type CoreChannel<ChannelData, Channel extends string, ChannelConnect = CorePikkuFunction<void, unknown, ChannelData> | CorePikkuFunctionSessionless<void, unknown, ChannelData>, ChannelDisconnect = CorePikkuFunction<void, void, ChannelData> | CorePikkuFunctionSessionless<void, void, ChannelData>, ChannelFunctionMessage = CorePikkuFunction<unknown, unknown, ChannelData> | CorePikkuFunctionSessionless<unknown, unknown, ChannelData>, PikkuPermission = CorePikkuPermission<ChannelData>> = {
39
39
  name: string;
40
40
  route: Channel;
41
41
  onConnect?: ChannelConnect;
42
42
  onDisconnect?: ChannelDisconnect;
43
43
  onMessage?: {
44
44
  func: ChannelFunctionMessage;
45
- permissions?: Record<string, APIPermission[] | APIPermission>;
45
+ permissions?: Record<string, PikkuPermission[] | PikkuPermission>;
46
46
  auth?: boolean;
47
47
  } | ChannelFunctionMessage;
48
- onMessageRoute?: Record<string, Record<string, ChannelFunctionMessage | {
48
+ onMessageWiring?: Record<string, Record<string, ChannelFunctionMessage | {
49
49
  func: ChannelFunctionMessage;
50
- permissions?: Record<string, APIPermission[] | APIPermission>;
50
+ permissions?: Record<string, PikkuPermission[] | PikkuPermission>;
51
51
  auth?: boolean;
52
52
  }>>;
53
53
  middleware?: PikkuMiddleware[];
54
- permissions?: Record<string, APIPermission[] | APIPermission>;
54
+ permissions?: Record<string, PikkuPermission[] | PikkuPermission>;
55
55
  auth?: boolean;
56
56
  docs?: Partial<{
57
57
  description: string;
@@ -1,23 +1,23 @@
1
1
  /**
2
2
  * Interface defining the methods of a EventHub Service.
3
3
  */
4
- export interface EventHubService<Out = unknown> {
4
+ export interface EventHubService<Topics extends Record<string, any>> {
5
5
  /**
6
6
  * Subscribes a connection to a specific topic.
7
7
  * @param topic - The topic to subscribe to.
8
8
  * @param channelId - The unique ID of the connection to subscribe.
9
9
  */
10
- subscribe(topic: string, channelId: string): Promise<void> | void;
10
+ subscribe<T extends keyof Topics>(topic: T, channelId: string): Promise<void> | void;
11
11
  /**
12
12
  * Unsubscribes a connection from a specific topic.
13
13
  * @param topic - The topic to unsubscribe from.
14
14
  * @param channelId - The unique ID of the connection to unsubscribe.
15
15
  */
16
- unsubscribe(topic: string, channelId: string): Promise<void> | void;
16
+ unsubscribe<T extends keyof Topics>(topic: T, channelId: string): Promise<void> | void;
17
17
  /**
18
18
  * Sends data to all connections subscribed to a topic.
19
19
  * @param topic - The topic to send data to.
20
20
  * @param data - The data to send to the subscribers.
21
21
  */
22
- publish(topic: string, channelId: string | null, data: Out, isBinary?: boolean): Promise<void> | void;
22
+ publish<T extends keyof Topics>(topic: T, channelId: string | null, data: Topics[T], isBinary?: boolean): Promise<void> | void;
23
23
  }
@@ -0,0 +1,5 @@
1
+ export declare abstract class EventHubStore<EventTopics extends Record<string, any> = {}> {
2
+ abstract getChannelIdsForTopic(topic: string): Promise<string[]>;
3
+ abstract subscribe<T extends keyof EventTopics>(topic: T, channelId: string): Promise<boolean>;
4
+ abstract unsubscribe<T extends keyof EventTopics>(topic: T, channelId: string): Promise<boolean>;
5
+ }
@@ -0,0 +1,3 @@
1
+ import { CoreChannel, RunChannelOptions, RunChannelParams } from '../channel.types.js';
2
+ import { PikkuLocalChannelHandler } from './local-channel-handler.js';
3
+ export declare const runLocalChannel: ({ singletonServices, channelId, request, response, route, createSessionServices, skipUserSession, respondWith404, coerceDataFromSchema, logWarningsForStatusCodes, bubbleErrors, }: Partial<Pick<CoreChannel<unknown, any>, "route">> & RunChannelOptions & RunChannelParams<unknown>) => Promise<PikkuLocalChannelHandler | void>;
@@ -4,7 +4,7 @@ import { EventHubService } from '../eventhub-service.js';
4
4
  * Implementation of the SubscriptionService interface.
5
5
  * Manages subscriptions and publishes messages to subscribers.
6
6
  */
7
- export declare class LocalEventHubService<Data = unknown> implements EventHubService<Data> {
7
+ export declare class LocalEventHubService<Data extends Record<string, any> = {}> implements EventHubService<Data> {
8
8
  private channels;
9
9
  /**
10
10
  * A map storing topics and their associated connection IDs.
@@ -16,20 +16,20 @@ export declare class LocalEventHubService<Data = unknown> implements EventHubSer
16
16
  * @param topic - The topic to subscribe to.
17
17
  * @param channelId - The unique ID of the connection to subscribe.
18
18
  */
19
- subscribe(topic: string, channelId: string): void;
19
+ subscribe<T extends keyof Data>(topic: T, channelId: string): void | Promise<void>;
20
20
  /**
21
21
  * Unsubscribes a connection from a specific topic.
22
22
  * Removes the topic if it has no more subscribers.
23
23
  * @param topic - The topic to unsubscribe from.
24
24
  * @param channelId - The unique ID of the connection to unsubscribe.
25
25
  */
26
- unsubscribe(topic: string, channelId: string): void;
26
+ unsubscribe<T extends keyof Data>(topic: T, channelId: string): void | Promise<void>;
27
27
  /**
28
28
  * Sends data to all connections subscribed to a topic.
29
29
  * @param topic - The topic to send data to.
30
30
  * @param data - The data to send to the subscribers.
31
31
  */
32
- publish(topic: string, channelId: string, data: Data, isBinary?: boolean): void;
32
+ publish<T extends keyof Data>(topic: T, channelId: string | null, data: Data[T], isBinary?: boolean): void | Promise<void>;
33
33
  /**
34
34
  * Registers a channel on open
35
35
  */
@@ -31,7 +31,7 @@ export class LocalEventHubService {
31
31
  if (topicSubscriptions) {
32
32
  topicSubscriptions.delete(channelId);
33
33
  if (topicSubscriptions.size === 0) {
34
- this.subscriptions.delete(topic); // Cleanup empty subscriptions
34
+ this.subscriptions.delete(topic);
35
35
  }
36
36
  }
37
37
  }
@@ -1,10 +1,10 @@
1
- import type { CoreAPIChannel, RunChannelOptions, RunChannelParams, PikkuChannelHandlerFactory } from '../channel.types.js';
1
+ import type { CoreChannel, RunChannelOptions, RunChannelParams, PikkuChannelHandlerFactory } from '../channel.types.js';
2
2
  import { ChannelStore } from '../channel-store.js';
3
3
  export interface RunServerlessChannelParams<ChannelData> extends RunChannelParams<ChannelData> {
4
4
  channelStore: ChannelStore;
5
5
  channelHandlerFactory: PikkuChannelHandlerFactory;
6
6
  channelObject?: unknown;
7
7
  }
8
- export declare const runChannelConnect: ({ singletonServices, channelId, channelObject, request, response, route, createSessionServices, channelStore, channelHandlerFactory, coerceDataFromSchema, logWarningsForStatusCodes, respondWith404, bubbleErrors, }: Pick<CoreAPIChannel<unknown, any>, "route"> & RunChannelOptions & RunServerlessChannelParams<unknown>) => Promise<void>;
8
+ export declare const runChannelConnect: ({ singletonServices, channelId, channelObject, request, response, route, createSessionServices, channelStore, channelHandlerFactory, coerceDataFromSchema, logWarningsForStatusCodes, respondWith404, bubbleErrors, }: Pick<CoreChannel<unknown, any>, "route"> & RunChannelOptions & RunServerlessChannelParams<unknown>) => Promise<void>;
9
9
  export declare const runChannelDisconnect: ({ singletonServices, ...params }: RunServerlessChannelParams<unknown>) => Promise<void>;
10
10
  export declare const runChannelMessage: ({ singletonServices, ...params }: RunServerlessChannelParams<unknown>, data: unknown) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- import { CoreHTTPFunctionRoute, RunRouteOptions, RunRouteParams, PikkuHTTP, PikkuHTTPRequest, PikkuHTTPResponse } from './http.types.js';
1
+ import { CoreHTTPFunctionWiring, RunHTTPWiringOptions, RunHTTPWiringParams, PikkuHTTP, PikkuHTTPRequest, PikkuHTTPResponse } from './http.types.js';
2
2
  import { PikkuMiddleware } from '../../types/core.types.js';
3
3
  import { PikkuFetchHTTPResponse } from './pikku-fetch-http-response.js';
4
4
  /**
@@ -22,13 +22,13 @@ export declare const addMiddleware: <APIMiddleware extends PikkuMiddleware>(rout
22
22
  * @template In Expected input type.
23
23
  * @template Out Expected output type.
24
24
  * @template Route Route pattern as a string.
25
- * @template APIFunction Type for the route handler function.
26
- * @template APIFunctionSessionless Type for a sessionless handler.
27
- * @template APIPermissionGroup Type representing required permissions.
25
+ * @template PikkuFunction Type for the route handler function.
26
+ * @template PikkuFunctionSessionless Type for a sessionless handler.
27
+ * @template PikkuPermissionGroup Type representing required permissions.
28
28
  * @template APIMiddleware Middleware type to be used with the route.
29
- * @param {CoreHTTPFunctionRoute<In, Out, Route, APIFunction, APIFunctionSessionless, APIPermission, APIMiddleware>} route - The route configuration object.
29
+ * @param {CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction, PikkuFunctionSessionless, PikkuPermission, APIMiddleware>} httpWiring - The HTTP wiring configuration object.
30
30
  */
31
- export declare const addHTTPRoute: <In, Out, Route extends string, APIFunction, APIFunctionSessionless, APIPermissionGroup, APIMiddleware>(httpRoute: CoreHTTPFunctionRoute<In, Out, Route, APIFunction, APIFunctionSessionless, APIPermissionGroup, APIMiddleware>) => void;
31
+ export declare const wireHTTP: <In, Out, Route extends string, PikkuFunction, PikkuFunctionSessionless, PikkuPermissionGroup, APIMiddleware>(httpWiring: CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction, PikkuFunctionSessionless, PikkuPermissionGroup, APIMiddleware>) => void;
32
32
  /**
33
33
  * Combines the request and response objects into a single HTTP interaction object.
34
34
  *
@@ -52,10 +52,10 @@ export declare const createHTTPInteraction: (request: PikkuHTTPRequest | undefin
52
52
  * @template In Expected input data type.
53
53
  * @template Out Expected output data type.
54
54
  * @param {Request} request - The native Fetch API Request object.
55
- * @param {RunRouteOptions & RunRouteParams} params - Additional options including services and session management.
55
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} params - Additional options including services and session management.
56
56
  * @returns {Promise<Response>} A promise that resolves to a Fetch API Response object.
57
57
  */
58
- export declare const fetch: <In, Out>(request: Request, params: RunRouteOptions & RunRouteParams) => Promise<Response>;
58
+ export declare const fetch: <In, Out>(request: Request, params: RunHTTPWiringOptions & RunHTTPWiringParams) => Promise<Response>;
59
59
  /**
60
60
  * Executes an HTTP route using a Pikku-specific request wrapper.
61
61
  *
@@ -65,10 +65,10 @@ export declare const fetch: <In, Out>(request: Request, params: RunRouteOptions
65
65
  * @template In Expected input data type.
66
66
  * @template Out Expected output data type.
67
67
  * @param {Request | PikkuHTTPRequest} request - The request object.
68
- * @param {RunRouteOptions & RunRouteParams} params - Execution options including services and session configuration.
68
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} params - Execution options including services and session configuration.
69
69
  * @returns {Promise<PikkuFetchHTTPResponse>} A promise that resolves to a PikkuFetchHTTPResponse object.
70
70
  */
71
- export declare const pikkuFetch: <In, Out>(request: Request | PikkuHTTPRequest, params: RunRouteOptions & RunRouteParams) => Promise<PikkuFetchHTTPResponse>;
71
+ export declare const pikkuFetch: <In, Out>(request: Request | PikkuHTTPRequest, params: RunHTTPWiringOptions & RunHTTPWiringParams) => Promise<PikkuFetchHTTPResponse>;
72
72
  /**
73
73
  * Core function to process an HTTP request through route matching, validation,
74
74
  * middleware execution, error handling, and session service cleanup.
@@ -84,7 +84,7 @@ export declare const pikkuFetch: <In, Out>(request: Request | PikkuHTTPRequest,
84
84
  * @template Out Expected output data type.
85
85
  * @param {Request | PikkuHTTPRequest} request - The incoming HTTP request.
86
86
  * @param {PikkuHTTPResponse} response - The response object to be populated.
87
- * @param {RunRouteOptions & RunRouteParams} options - Options such as singleton services, session handling, and error configuration.
87
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} options - Options such as singleton services, session handling, and error configuration.
88
88
  * @returns {Promise<Out | void>} The output from the route handler or void if an error occurred.
89
89
  */
90
- export declare const fetchData: <In, Out>(request: Request | PikkuHTTPRequest, response: PikkuHTTPResponse, { singletonServices, createSessionServices, skipUserSession, respondWith404, logWarningsForStatusCodes, coerceDataFromSchema, bubbleErrors, generateRequestId, ignoreMiddleware, }: RunRouteOptions & RunRouteParams) => Promise<Out | void>;
90
+ export declare const fetchData: <In, Out>(request: Request | PikkuHTTPRequest, response: PikkuHTTPResponse, { singletonServices, createSessionServices, skipUserSession, respondWith404, logWarningsForStatusCodes, coerceDataFromSchema, bubbleErrors, generateRequestId, ignoreMiddleware, }: RunHTTPWiringOptions & RunHTTPWiringParams) => Promise<Out | void>;
@@ -52,28 +52,28 @@ export const addMiddleware = (routeOrMiddleware, middleware) => {
52
52
  * @template In Expected input type.
53
53
  * @template Out Expected output type.
54
54
  * @template Route Route pattern as a string.
55
- * @template APIFunction Type for the route handler function.
56
- * @template APIFunctionSessionless Type for a sessionless handler.
57
- * @template APIPermissionGroup Type representing required permissions.
55
+ * @template PikkuFunction Type for the route handler function.
56
+ * @template PikkuFunctionSessionless Type for a sessionless handler.
57
+ * @template PikkuPermissionGroup Type representing required permissions.
58
58
  * @template APIMiddleware Middleware type to be used with the route.
59
- * @param {CoreHTTPFunctionRoute<In, Out, Route, APIFunction, APIFunctionSessionless, APIPermission, APIMiddleware>} route - The route configuration object.
59
+ * @param {CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction, PikkuFunctionSessionless, PikkuPermission, APIMiddleware>} httpWiring - The HTTP wiring configuration object.
60
60
  */
61
- export const addHTTPRoute = (httpRoute) => {
61
+ export const wireHTTP = (httpWiring) => {
62
62
  const httpMeta = pikkuState('http', 'meta');
63
- const routeMeta = httpMeta.find((meta) => meta.route === httpRoute.route && meta.method === httpRoute.method);
63
+ const routeMeta = httpMeta.find((meta) => meta.route === httpWiring.route && meta.method === httpWiring.method);
64
64
  if (!routeMeta) {
65
65
  throw new Error('Route metadata not found');
66
66
  }
67
67
  addFunction(routeMeta.pikkuFuncName, {
68
- func: httpRoute.func,
68
+ func: httpWiring.func,
69
69
  });
70
70
  const routes = pikkuState('http', 'routes');
71
- if (!routes.has(httpRoute.method)) {
72
- routes.set(httpRoute.method, new Map());
71
+ if (!routes.has(httpWiring.method)) {
72
+ routes.set(httpWiring.method, new Map());
73
73
  }
74
74
  pikkuState('http', 'routes')
75
- .get(httpRoute.method)
76
- ?.set(httpRoute.route, httpRoute);
75
+ .get(httpWiring.method)
76
+ ?.set(httpWiring.route, httpWiring);
77
77
  };
78
78
  /**
79
79
  * Finds a matching route based on the HTTP method and URL path.
@@ -185,7 +185,7 @@ const executeRouteWithMiddleware = async (services, matchedRoute, http, options)
185
185
  });
186
186
  throw new MissingSessionError();
187
187
  }
188
- const data = http.request.data();
188
+ const data = await http.request.data();
189
189
  const getAllServices = async () => {
190
190
  let channel;
191
191
  if (matchedRoute.route.sse) {
@@ -258,7 +258,7 @@ const executeRouteWithMiddleware = async (services, matchedRoute, http, options)
258
258
  * @template In Expected input data type.
259
259
  * @template Out Expected output data type.
260
260
  * @param {Request} request - The native Fetch API Request object.
261
- * @param {RunRouteOptions & RunRouteParams} params - Additional options including services and session management.
261
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} params - Additional options including services and session management.
262
262
  * @returns {Promise<Response>} A promise that resolves to a Fetch API Response object.
263
263
  */
264
264
  export const fetch = async (request, params) => {
@@ -275,7 +275,7 @@ export const fetch = async (request, params) => {
275
275
  * @template In Expected input data type.
276
276
  * @template Out Expected output data type.
277
277
  * @param {Request | PikkuHTTPRequest} request - The request object.
278
- * @param {RunRouteOptions & RunRouteParams} params - Execution options including services and session configuration.
278
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} params - Execution options including services and session configuration.
279
279
  * @returns {Promise<PikkuFetchHTTPResponse>} A promise that resolves to a PikkuFetchHTTPResponse object.
280
280
  */
281
281
  export const pikkuFetch = async (request, params) => {
@@ -298,7 +298,7 @@ export const pikkuFetch = async (request, params) => {
298
298
  * @template Out Expected output data type.
299
299
  * @param {Request | PikkuHTTPRequest} request - The incoming HTTP request.
300
300
  * @param {PikkuHTTPResponse} response - The response object to be populated.
301
- * @param {RunRouteOptions & RunRouteParams} options - Options such as singleton services, session handling, and error configuration.
301
+ * @param {RunHTTPWiringOptions & RunHTTPWiringParams} options - Options such as singleton services, session handling, and error configuration.
302
302
  * @returns {Promise<Out | void>} The output from the route handler or void if an error occurred.
303
303
  */
304
304
  export const fetchData = async (request, response, { singletonServices, createSessionServices, skipUserSession = false, respondWith404 = true, logWarningsForStatusCodes = [], coerceDataFromSchema = true, bubbleErrors = false, generateRequestId, ignoreMiddleware = false, }) => {