@pikku/core 0.8.2 → 0.9.0
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/CHANGELOG.md +7 -1
- package/dist/function/functions.types.d.ts +9 -9
- package/dist/handle-error.d.ts +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.js +11 -10
- package/dist/pikku-state.d.ts +9 -9
- package/dist/services/user-session-service.d.ts +1 -1
- package/dist/types/core.types.d.ts +5 -5
- package/dist/types/core.types.js +9 -9
- package/dist/wirings/channel/channel-handler.d.ts +3 -0
- package/dist/{events → wirings}/channel/channel-handler.js +3 -3
- package/dist/wirings/channel/channel-runner.d.ts +14 -0
- package/dist/{events → wirings}/channel/channel-runner.js +13 -13
- package/dist/{events → wirings}/channel/channel.types.d.ts +7 -7
- package/dist/{events → wirings}/channel/eventhub-service.d.ts +4 -4
- package/dist/wirings/channel/eventhub-store.d.ts +5 -0
- package/dist/wirings/channel/local/local-channel-runner.d.ts +3 -0
- package/dist/{events → wirings}/channel/local/local-eventhub-service.d.ts +4 -4
- package/dist/{events → wirings}/channel/local/local-eventhub-service.js +1 -1
- package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.d.ts +2 -2
- package/dist/{events → wirings}/http/http-runner.d.ts +12 -12
- package/dist/{events → wirings}/http/http-runner.js +15 -15
- package/dist/{events → wirings}/http/http.types.d.ts +32 -27
- package/dist/{events → wirings}/http/index.d.ts +1 -1
- package/dist/{events → wirings}/http/index.js +1 -1
- package/dist/{events → wirings}/mcp/mcp-runner.d.ts +4 -4
- package/dist/{events → wirings}/mcp/mcp-runner.js +4 -4
- package/dist/{events → wirings}/mcp/mcp.types.d.ts +7 -7
- package/dist/{events → wirings}/queue/index.d.ts +1 -1
- package/dist/{events → wirings}/queue/index.js +1 -1
- package/dist/{events → wirings}/queue/queue-runner.d.ts +2 -2
- package/dist/{events → wirings}/queue/queue-runner.js +1 -1
- package/dist/{events → wirings}/queue/queue.types.d.ts +3 -3
- package/dist/wirings/scheduler/index.d.ts +3 -0
- package/dist/wirings/scheduler/index.js +3 -0
- package/dist/{events → wirings}/scheduler/scheduler-runner.d.ts +2 -2
- package/dist/{events → wirings}/scheduler/scheduler-runner.js +1 -1
- package/dist/{events → wirings}/scheduler/scheduler.types.d.ts +3 -3
- package/lcov.info +5680 -0
- package/package.json +9 -9
- package/src/function/functions.types.ts +13 -13
- package/src/handle-error.ts +1 -1
- package/src/index.ts +14 -13
- package/src/pikku-state.ts +11 -11
- package/src/services/user-session-service.ts +1 -1
- package/src/types/core.types.ts +5 -5
- package/src/{events → wirings}/channel/channel-handler.ts +5 -5
- package/src/{events → wirings}/channel/channel-runner.ts +18 -18
- package/src/{events → wirings}/channel/channel.types.ts +16 -16
- package/src/{events → wirings}/channel/eventhub-service.ts +12 -8
- package/src/wirings/channel/eventhub-store.ts +13 -0
- package/src/{events → wirings}/channel/local/local-channel-runner.test.ts +2 -2
- package/src/{events → wirings}/channel/local/local-channel-runner.ts +2 -2
- package/src/{events → wirings}/channel/local/local-eventhub-service.ts +16 -10
- package/src/{events → wirings}/channel/serverless/serverless-channel-runner.ts +2 -2
- package/src/{events → wirings}/http/http-runner.test.ts +4 -4
- package/src/{events → wirings}/http/http-runner.ts +32 -31
- package/src/{events → wirings}/http/http.types.ts +40 -35
- package/src/{events → wirings}/http/index.ts +1 -1
- package/src/wirings/mcp/mcp-endpoint-registry.test.js +338 -0
- package/src/wirings/mcp/mcp-endpoint-registry.test.js.map +1 -0
- package/src/{events → wirings}/mcp/mcp-runner.ts +10 -10
- package/src/{events → wirings}/mcp/mcp.types.ts +9 -7
- package/src/{events → wirings}/queue/index.ts +1 -1
- package/src/{events → wirings}/queue/queue-runner.ts +5 -5
- package/src/{events → wirings}/queue/queue.types.ts +3 -3
- package/src/{events → wirings}/scheduler/index.ts +1 -1
- package/src/{events → wirings}/scheduler/scheduler-runner.ts +4 -4
- package/src/{events → wirings}/scheduler/scheduler.types.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/events/channel/channel-handler.d.ts +0 -3
- package/dist/events/channel/channel-runner.d.ts +0 -14
- package/dist/events/channel/eventhub-store.d.ts +0 -5
- package/dist/events/channel/local/local-channel-runner.d.ts +0 -3
- package/dist/events/scheduler/index.d.ts +0 -3
- package/dist/events/scheduler/index.js +0 -3
- package/src/events/channel/eventhub-store.ts +0 -8
- /package/dist/{events → wirings}/channel/channel-store.d.ts +0 -0
- /package/dist/{events → wirings}/channel/channel-store.js +0 -0
- /package/dist/{events → wirings}/channel/channel.types.js +0 -0
- /package/dist/{events → wirings}/channel/eventhub-service.js +0 -0
- /package/dist/{events → wirings}/channel/eventhub-store.js +0 -0
- /package/dist/{events → wirings}/channel/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/index.js +0 -0
- /package/dist/{events → wirings}/channel/local/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/local/index.js +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-handler.d.ts +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-handler.js +0 -0
- /package/dist/{events → wirings}/channel/local/local-channel-runner.js +0 -0
- /package/dist/{events → wirings}/channel/log-channels.d.ts +0 -0
- /package/dist/{events → wirings}/channel/log-channels.js +0 -0
- /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.d.ts +0 -0
- /package/dist/{events → wirings}/channel/pikku-abstract-channel-handler.js +0 -0
- /package/dist/{events → wirings}/channel/serverless/index.d.ts +0 -0
- /package/dist/{events → wirings}/channel/serverless/index.js +0 -0
- /package/dist/{events → wirings}/channel/serverless/serverless-channel-runner.js +0 -0
- /package/dist/{events → wirings}/http/http.types.js +0 -0
- /package/dist/{events → wirings}/http/log-http-routes.d.ts +0 -0
- /package/dist/{events → wirings}/http/log-http-routes.js +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-request.d.ts +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-request.js +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-response.d.ts +0 -0
- /package/dist/{events → wirings}/http/pikku-fetch-http-response.js +0 -0
- /package/dist/{events → wirings}/mcp/index.d.ts +0 -0
- /package/dist/{events → wirings}/mcp/index.js +0 -0
- /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.d.ts +0 -0
- /package/dist/{events → wirings}/mcp/mcp-endpoint-registry.js +0 -0
- /package/dist/{events → wirings}/mcp/mcp.types.js +0 -0
- /package/dist/{events → wirings}/queue/queue.types.js +0 -0
- /package/dist/{events → wirings}/queue/register-queue-helper.d.ts +0 -0
- /package/dist/{events → wirings}/queue/register-queue-helper.js +0 -0
- /package/dist/{events → wirings}/queue/validate-worker-config.d.ts +0 -0
- /package/dist/{events → wirings}/queue/validate-worker-config.js +0 -0
- /package/dist/{events → wirings}/rpc/index.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/index.js +0 -0
- /package/dist/{events → wirings}/rpc/rpc-runner.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/rpc-runner.js +0 -0
- /package/dist/{events → wirings}/rpc/rpc-types.d.ts +0 -0
- /package/dist/{events → wirings}/rpc/rpc-types.js +0 -0
- /package/dist/{events → wirings}/scheduler/log-schedulers.d.ts +0 -0
- /package/dist/{events → wirings}/scheduler/log-schedulers.js +0 -0
- /package/dist/{events → wirings}/scheduler/scheduler.types.js +0 -0
- /package/src/{events → wirings}/channel/channel-store.ts +0 -0
- /package/src/{events → wirings}/channel/index.ts +0 -0
- /package/src/{events → wirings}/channel/local/index.ts +0 -0
- /package/src/{events → wirings}/channel/local/local-channel-handler.ts +0 -0
- /package/src/{events → wirings}/channel/local/local-eventhub-service.test.ts +0 -0
- /package/src/{events → wirings}/channel/log-channels.ts +0 -0
- /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.test.ts +0 -0
- /package/src/{events → wirings}/channel/pikku-abstract-channel-handler.ts +0 -0
- /package/src/{events → wirings}/channel/serverless/index.ts +0 -0
- /package/src/{events → wirings}/http/log-http-routes.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-request.test.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-request.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-response.test.ts +0 -0
- /package/src/{events → wirings}/http/pikku-fetch-http-response.ts +0 -0
- /package/src/{events → wirings}/mcp/index.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.d.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.test.ts +0 -0
- /package/src/{events → wirings}/mcp/mcp-endpoint-registry.ts +0 -0
- /package/src/{events → wirings}/queue/register-queue-helper.ts +0 -0
- /package/src/{events → wirings}/queue/validate-worker-config.ts +0 -0
- /package/src/{events → wirings}/rpc/index.ts +0 -0
- /package/src/{events → wirings}/rpc/rpc-runner.ts +0 -0
- /package/src/{events → wirings}/rpc/rpc-types.ts +0 -0
- /package/src/{events → wirings}/scheduler/log-schedulers.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## 0.9.0
|
|
2
|
+
|
|
3
|
+
### Breaking Changes
|
|
4
|
+
|
|
5
|
+
- Normalized all transports to use "wirings" instead of events/routes/transports for consistency across the framework
|
|
6
|
+
|
|
1
7
|
## 0.8.0
|
|
2
8
|
|
|
3
9
|
## 0.8.2
|
|
@@ -86,7 +92,7 @@ We now use the function first approach internally, which means first all the fun
|
|
|
86
92
|
The main breaking changes for the end user are:
|
|
87
93
|
|
|
88
94
|
- We now declare functions using `pikkuFunc<In, Out>(async () => {})
|
|
89
|
-
- We renamed addRoute to
|
|
95
|
+
- We renamed addRoute to wireHTTPs
|
|
90
96
|
|
|
91
97
|
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
98
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PikkuChannel } from '../
|
|
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
|
|
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
|
|
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
|
|
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
|
|
37
|
-
export type CorePermissionGroup<
|
|
38
|
-
export type CorePikkuFunctionConfig<
|
|
39
|
-
func:
|
|
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<
|
|
41
|
+
permissions?: CorePermissionGroup<PikkuPermission>;
|
|
42
42
|
middleware?: PikkuFunctionMiddleware[];
|
|
43
43
|
};
|
package/dist/handle-error.d.ts
CHANGED
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 './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
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 {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
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 './
|
|
14
|
-
export * from './
|
|
15
|
-
export * from './
|
|
16
|
-
export * from './
|
|
17
|
-
export * from './
|
|
18
|
-
export * from './
|
|
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 {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
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/pikku-state.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ChannelsMeta,
|
|
2
|
-
import {
|
|
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 './
|
|
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 './
|
|
8
|
-
import { queueWorkersMeta, CoreQueueWorker } from './
|
|
9
|
-
import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from './
|
|
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,
|
|
28
|
-
meta:
|
|
27
|
+
routes: Map<HTTPMethod, Map<string, CoreHTTPFunctionWiring<any, any, any>>>;
|
|
28
|
+
meta: HTTPWiringsMeta;
|
|
29
29
|
};
|
|
30
30
|
channel: {
|
|
31
|
-
channels: Map<string,
|
|
31
|
+
channels: Map<string, CoreChannel<any, any>>;
|
|
32
32
|
meta: ChannelsMeta;
|
|
33
33
|
};
|
|
34
34
|
scheduler: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChannelStore } from '../
|
|
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 '../
|
|
4
|
+
import { PikkuHTTP } from '../wirings/http/http.types.js';
|
|
5
5
|
import { UserSessionService } from '../services/user-session-service.js';
|
|
6
|
-
import { PikkuChannel } from '../
|
|
7
|
-
import { PikkuRPC } from '../
|
|
8
|
-
import { PikkuMCP } from '../
|
|
9
|
-
export declare enum
|
|
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",
|
package/dist/types/core.types.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export var
|
|
2
|
-
(function (
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(
|
|
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.
|
|
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.
|
|
65
|
+
if (typeof rawData === 'string' && channelConfig.onMessageWiring) {
|
|
66
66
|
try {
|
|
67
67
|
const messageData = JSON.parse(rawData);
|
|
68
|
-
const entries = Object.entries(channelConfig.
|
|
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
|
|
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
|
|
40
|
-
if (channel.
|
|
41
|
-
// Iterate through each channel in
|
|
42
|
-
Object.entries(channel.
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
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
|
|
47
|
-
Object.entries(
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
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
|
|
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(
|
|
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 {
|
|
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
|
-
|
|
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
|
|
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,
|
|
45
|
+
permissions?: Record<string, PikkuPermission[] | PikkuPermission>;
|
|
46
46
|
auth?: boolean;
|
|
47
47
|
} | ChannelFunctionMessage;
|
|
48
|
-
|
|
48
|
+
onMessageWiring?: Record<string, Record<string, ChannelFunctionMessage | {
|
|
49
49
|
func: ChannelFunctionMessage;
|
|
50
|
-
permissions?: Record<string,
|
|
50
|
+
permissions?: Record<string, PikkuPermission[] | PikkuPermission>;
|
|
51
51
|
auth?: boolean;
|
|
52
52
|
}>>;
|
|
53
53
|
middleware?: PikkuMiddleware[];
|
|
54
|
-
permissions?: Record<string,
|
|
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<
|
|
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:
|
|
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:
|
|
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:
|
|
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 =
|
|
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:
|
|
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:
|
|
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:
|
|
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);
|
|
34
|
+
this.subscriptions.delete(topic);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
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<
|
|
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 {
|
|
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
|
|
26
|
-
* @template
|
|
27
|
-
* @template
|
|
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 {
|
|
29
|
+
* @param {CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction, PikkuFunctionSessionless, PikkuPermission, APIMiddleware>} httpWiring - The HTTP wiring configuration object.
|
|
30
30
|
*/
|
|
31
|
-
export declare const
|
|
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 {
|
|
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:
|
|
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 {
|
|
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:
|
|
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 {
|
|
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, }:
|
|
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
|
|
56
|
-
* @template
|
|
57
|
-
* @template
|
|
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 {
|
|
59
|
+
* @param {CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction, PikkuFunctionSessionless, PikkuPermission, APIMiddleware>} httpWiring - The HTTP wiring configuration object.
|
|
60
60
|
*/
|
|
61
|
-
export const
|
|
61
|
+
export const wireHTTP = (httpWiring) => {
|
|
62
62
|
const httpMeta = pikkuState('http', 'meta');
|
|
63
|
-
const routeMeta = httpMeta.find((meta) => meta.route ===
|
|
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:
|
|
68
|
+
func: httpWiring.func,
|
|
69
69
|
});
|
|
70
70
|
const routes = pikkuState('http', 'routes');
|
|
71
|
-
if (!routes.has(
|
|
72
|
-
routes.set(
|
|
71
|
+
if (!routes.has(httpWiring.method)) {
|
|
72
|
+
routes.set(httpWiring.method, new Map());
|
|
73
73
|
}
|
|
74
74
|
pikkuState('http', 'routes')
|
|
75
|
-
.get(
|
|
76
|
-
?.set(
|
|
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 {
|
|
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 {
|
|
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 {
|
|
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, }) => {
|