@pikku/cli 0.9.1 → 0.9.2
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 +20 -0
- package/bin/pikku-all.ts +3 -3
- package/bin/pikku-nextjs.ts +3 -3
- package/dist/bin/pikku-all.js +3 -3
- package/dist/bin/pikku-nextjs.js +3 -3
- package/dist/src/serialize-pikku-types.js +28 -25
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -11
- package/src/serialize-pikku-types.ts +28 -25
- package/src/wirings/rpc/pikku-command-rpc-client.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @pikku/cli
|
|
2
2
|
|
|
3
|
+
## 0.9.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1256238: feat: pikkufunc in types extends function config to include all the different params
|
|
8
|
+
- d3a9a09: refactor: change addMiddleware to addHTTPMiddleware due to route support'
|
|
9
|
+
|
|
10
|
+
chore: export addHTTPMiddleware from pikku-types for consistency
|
|
11
|
+
|
|
12
|
+
- 840e078: refactor: change APIMiddleware type to PikkuMiddleware
|
|
13
|
+
- a5905a9: chore: updating all dependencies
|
|
14
|
+
- Updated dependencies [1256238]
|
|
15
|
+
- Updated dependencies [6cf8efd]
|
|
16
|
+
- Updated dependencies [d3a9a09]
|
|
17
|
+
- Updated dependencies [840e078]
|
|
18
|
+
- Updated dependencies [667d23c]
|
|
19
|
+
- Updated dependencies [a5905a9]
|
|
20
|
+
- @pikku/core@0.9.2
|
|
21
|
+
- @pikku/inspector@0.9.2
|
|
22
|
+
|
|
3
23
|
## 0.9.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/bin/pikku-all.ts
CHANGED
|
@@ -319,13 +319,13 @@ export const all = (program: Command): void => {
|
|
|
319
319
|
program
|
|
320
320
|
.command('all', { isDefault: true })
|
|
321
321
|
.description('Generate all the files used by pikku')
|
|
322
|
-
.option('
|
|
322
|
+
.option('--pikku-config-type', 'The type of your pikku config object')
|
|
323
323
|
.option(
|
|
324
|
-
'
|
|
324
|
+
'--singleton-services-factory-type',
|
|
325
325
|
'The type of your singleton services factory'
|
|
326
326
|
)
|
|
327
327
|
.option(
|
|
328
|
-
'
|
|
328
|
+
'--session-services-factory-type',
|
|
329
329
|
'The type of your session services factory'
|
|
330
330
|
)
|
|
331
331
|
.option('-c | --config <string>', 'The path to pikku cli config file')
|
package/bin/pikku-nextjs.ts
CHANGED
|
@@ -30,13 +30,13 @@ export const nextjs = (program: Command): void => {
|
|
|
30
30
|
program
|
|
31
31
|
.command('nextjs')
|
|
32
32
|
.description('generate nextjs wrapper')
|
|
33
|
-
.option('
|
|
33
|
+
.option('--pikku-config-type', 'The type of your pikku config object')
|
|
34
34
|
.option(
|
|
35
|
-
'
|
|
35
|
+
'--singleton-services-factory-type',
|
|
36
36
|
'The type of your singleton services factory'
|
|
37
37
|
)
|
|
38
38
|
.option(
|
|
39
|
-
'
|
|
39
|
+
'--session-services-factory-type',
|
|
40
40
|
'The type of your session services factory'
|
|
41
41
|
)
|
|
42
42
|
.option('-c | --config <string>', 'The path to pikku cli config file')
|
package/dist/bin/pikku-all.js
CHANGED
|
@@ -177,9 +177,9 @@ export const all = (program) => {
|
|
|
177
177
|
program
|
|
178
178
|
.command('all', { isDefault: true })
|
|
179
179
|
.description('Generate all the files used by pikku')
|
|
180
|
-
.option('
|
|
181
|
-
.option('
|
|
182
|
-
.option('
|
|
180
|
+
.option('--pikku-config-type', 'The type of your pikku config object')
|
|
181
|
+
.option('--singleton-services-factory-type', 'The type of your singleton services factory')
|
|
182
|
+
.option('--session-services-factory-type', 'The type of your session services factory')
|
|
183
183
|
.option('-c | --config <string>', 'The path to pikku cli config file')
|
|
184
184
|
.option('-t | --tags <tags...>', 'Which tags to filter by')
|
|
185
185
|
.option('--types <types...>', 'Which types to filter by (http, channel, queue, scheduler, rpc, mcp)')
|
package/dist/bin/pikku-nextjs.js
CHANGED
|
@@ -16,9 +16,9 @@ export const nextjs = (program) => {
|
|
|
16
16
|
program
|
|
17
17
|
.command('nextjs')
|
|
18
18
|
.description('generate nextjs wrapper')
|
|
19
|
-
.option('
|
|
20
|
-
.option('
|
|
21
|
-
.option('
|
|
19
|
+
.option('--pikku-config-type', 'The type of your pikku config object')
|
|
20
|
+
.option('--singleton-services-factory-type', 'The type of your singleton services factory')
|
|
21
|
+
.option('--session-services-factory-type', 'The type of your session services factory')
|
|
22
22
|
.option('-c | --config <string>', 'The path to pikku cli config file')
|
|
23
23
|
.action(action);
|
|
24
24
|
};
|
|
@@ -6,7 +6,7 @@ export const serializePikkuTypes = (userSessionTypeImport, userSessionTypeName,
|
|
|
6
6
|
* This is used to provide the application types in the typescript project
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { CorePikkuPermission,
|
|
9
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware } from '@pikku/core'
|
|
10
10
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
11
11
|
import { CoreHTTPFunctionWiring, AssertHTTPWiringParams, wireHTTP as wireHTTPCore } from '@pikku/core/http'
|
|
12
12
|
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
|
@@ -34,7 +34,7 @@ export type PikkuPermission<In = unknown, RequiredServices extends ${singletonSe
|
|
|
34
34
|
*
|
|
35
35
|
* @template RequiredServices - The services required for this middleware
|
|
36
36
|
*/
|
|
37
|
-
export type
|
|
37
|
+
export type PikkuMiddleware<RequiredServices extends ${singletonServicesTypeName} = ${singletonServicesTypeName}> = CorePikkuMiddleware<RequiredServices, ${userSessionTypeName}>
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* A sessionless API function that doesn't require user authentication.
|
|
@@ -96,7 +96,7 @@ type PikkuFunction<
|
|
|
96
96
|
* @template Out - Output type for the HTTP wiring
|
|
97
97
|
* @template Route - String literal type for the HTTP path (e.g., "/users/:id")
|
|
98
98
|
*/
|
|
99
|
-
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>,
|
|
99
|
+
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
102
|
* Type definition for WebSocket channels with typed data exchange.
|
|
@@ -166,16 +166,7 @@ type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionSessionless<In, MCPPromptR
|
|
|
166
166
|
export const pikkuFunc = <In, Out = unknown>(
|
|
167
167
|
func:
|
|
168
168
|
| PikkuFunction<In, Out>
|
|
169
|
-
|
|
|
170
|
-
func: PikkuFunction<In, Out>
|
|
171
|
-
auth?: true
|
|
172
|
-
name?: string
|
|
173
|
-
}
|
|
174
|
-
| {
|
|
175
|
-
func: PikkuFunctionSessionless<In, Out>
|
|
176
|
-
auth: false
|
|
177
|
-
name?: string
|
|
178
|
-
}
|
|
169
|
+
| CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>>
|
|
179
170
|
) => {
|
|
180
171
|
return typeof func === 'function' ? func : func.func
|
|
181
172
|
}
|
|
@@ -203,10 +194,7 @@ export const pikkuFunc = <In, Out = unknown>(
|
|
|
203
194
|
export const pikkuSessionlessFunc = <In, Out = unknown>(
|
|
204
195
|
func:
|
|
205
196
|
| PikkuFunctionSessionless<In, Out>
|
|
206
|
-
|
|
|
207
|
-
func: PikkuFunctionSessionless<In, Out>
|
|
208
|
-
name?: string
|
|
209
|
-
}
|
|
197
|
+
| CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>>
|
|
210
198
|
) => {
|
|
211
199
|
return typeof func === 'function' ? func : func.func
|
|
212
200
|
}
|
|
@@ -293,10 +281,7 @@ export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
|
|
|
293
281
|
export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
|
|
294
282
|
func:
|
|
295
283
|
| PikkuFunctionSessionless<In, Out, ChannelData>
|
|
296
|
-
|
|
|
297
|
-
func: PikkuFunctionSessionless<In, Out, ChannelData>
|
|
298
|
-
name?: string
|
|
299
|
-
}
|
|
284
|
+
| CorePikkuFunctionConfig<PikkuFunction<In, Out, ChannelData>, PikkuPermission<In>>
|
|
300
285
|
) => {
|
|
301
286
|
return typeof func === 'function' ? func : func.func
|
|
302
287
|
}
|
|
@@ -320,10 +305,7 @@ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unkn
|
|
|
320
305
|
export const pikkuVoidFunc = (
|
|
321
306
|
func:
|
|
322
307
|
| PikkuFunctionSessionless<void, void>
|
|
323
|
-
|
|
|
324
|
-
func: PikkuFunctionSessionless<void, void>
|
|
325
|
-
name?: string
|
|
326
|
-
}
|
|
308
|
+
| CorePikkuFunctionConfig<PikkuFunction<void, void>, PikkuPermission<void>>
|
|
327
309
|
) => {
|
|
328
310
|
return typeof func === 'function' ? func : func.func
|
|
329
311
|
}
|
|
@@ -341,6 +323,27 @@ export const wireChannel = <ChannelData, Channel extends string>(
|
|
|
341
323
|
wireChannelCore(channel as any) // TODO
|
|
342
324
|
}
|
|
343
325
|
|
|
326
|
+
/**
|
|
327
|
+
* Registers middleware either globally or for a specific route.
|
|
328
|
+
*
|
|
329
|
+
* When a string route pattern is provided along with middleware, the middleware
|
|
330
|
+
* is applied only to that route. Otherwise, if an array is provided, it is treated
|
|
331
|
+
* as global middleware (applied to all routes).
|
|
332
|
+
*
|
|
333
|
+
* @param routeOrMiddleware - Either a global middleware array or a route pattern string
|
|
334
|
+
* @param middleware - The middleware array to apply when a route pattern is specified
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* \`\`\`typescript
|
|
338
|
+
* // Add global middleware
|
|
339
|
+
* addHTTPMiddleware([authMiddleware, loggingMiddleware])
|
|
340
|
+
*
|
|
341
|
+
* // Add route-specific middleware
|
|
342
|
+
* addHTTPMiddleware('/api/admin/*', [adminAuthMiddleware])
|
|
343
|
+
* \`\`\`
|
|
344
|
+
*/
|
|
345
|
+
export { addHTTPMiddleware }
|
|
346
|
+
|
|
344
347
|
/**
|
|
345
348
|
* Registers an HTTP wiring with the Pikku framework.
|
|
346
349
|
*
|
|
@@ -2,7 +2,7 @@ import { serializeRPCWrapper } from './serialize-rpc-wrapper.js';
|
|
|
2
2
|
import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
|
|
3
3
|
export const pikkuRPCClient = async (logger, { rpcWiringsFile, rpcMapDeclarationFile, packageMappings }) => {
|
|
4
4
|
return await logCommandInfoAndTime(logger, 'Generating RPC wrapper', 'Generated RPC wrapper', [
|
|
5
|
-
rpcWiringsFile === undefined,
|
|
5
|
+
rpcWiringsFile === undefined || rpcWiringsFile === null,
|
|
6
6
|
"rpcWiringsFile isn't set in the pikku config",
|
|
7
7
|
], async () => {
|
|
8
8
|
if (!rpcWiringsFile) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../bin/pikku-all.ts","../bin/pikku-fetch.ts","../bin/pikku-nextjs.ts","../bin/pikku-openapi.ts","../bin/pikku-queue-service.ts","../bin/pikku-schemas.ts","../bin/pikku-websocket.ts","../bin/pikku.ts","../src/inspector-glob.ts","../src/pikku-cli-config.ts","../src/pikku-command-schemas.ts","../src/schema-generator.ts","../src/schemas.ts","../src/serialize-import-map.ts","../src/serialize-pikku-types.ts","../src/types.ts","../src/utils.ts","../src/runtimes/nextjs/pikku-command-nextjs.ts","../src/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/wirings/channels/pikku-channels.ts","../src/wirings/channels/pikku-command-channels-map.ts","../src/wirings/channels/pikku-command-channels.ts","../src/wirings/channels/pikku-command-websocket-typed.ts","../src/wirings/channels/serialize-typed-channel-map.ts","../src/wirings/channels/serialize-websocket-wrapper.ts","../src/wirings/fetch/index.ts","../src/wirings/functions/pikku-command-function-types.ts","../src/wirings/functions/pikku-command-functions.ts","../src/wirings/functions/pikku-command-services.ts","../src/wirings/functions/pikku-function-types.ts","../src/wirings/functions/pikku-functions.ts","../src/wirings/http/openapi-spec-generator.ts","../src/wirings/http/pikku-command-http-map.ts","../src/wirings/http/pikku-command-http-routes.ts","../src/wirings/http/pikku-command-openapi.ts","../src/wirings/http/pikku-http-routes.ts","../src/wirings/http/serialize-fetch-wrapper.ts","../src/wirings/http/serialize-typed-http-map.ts","../src/wirings/mcp/pikku-command-mcp-json.ts","../src/wirings/mcp/pikku-command-mcp.ts","../src/wirings/mcp/serialize-mcp-json.ts","../src/wirings/queue/pikku-command-queue-map.ts","../src/wirings/queue/pikku-command-queue-service.ts","../src/wirings/queue/pikku-command-queue.ts","../src/wirings/queue/pikku-queue-map.ts","../src/wirings/queue/pikku-queue.ts","../src/wirings/queue/serialize-queue-map.ts","../src/wirings/queue/serialize-queue-meta.ts","../src/wirings/queue/serialize-queue-wrapper.ts","../src/wirings/rpc/pikku-command-rpc-client.ts","../src/wirings/rpc/pikku-command-rpc-map.ts","../src/wirings/rpc/pikku-command-rpc.ts","../src/wirings/rpc/pikku-rpc.ts","../src/wirings/rpc/serialize-rpc-wrapper.ts","../src/wirings/rpc/serialize-typed-rpc-map.ts","../src/wirings/scheduler/pikku-command-scheduler.ts","../src/wirings/scheduler/serialize-scheduler-meta.ts"],"version":"5.
|
|
1
|
+
{"root":["../bin/pikku-all.ts","../bin/pikku-fetch.ts","../bin/pikku-nextjs.ts","../bin/pikku-openapi.ts","../bin/pikku-queue-service.ts","../bin/pikku-schemas.ts","../bin/pikku-websocket.ts","../bin/pikku.ts","../src/inspector-glob.ts","../src/pikku-cli-config.ts","../src/pikku-command-schemas.ts","../src/schema-generator.ts","../src/schemas.ts","../src/serialize-import-map.ts","../src/serialize-pikku-types.ts","../src/types.ts","../src/utils.ts","../src/runtimes/nextjs/pikku-command-nextjs.ts","../src/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/wirings/channels/pikku-channels.ts","../src/wirings/channels/pikku-command-channels-map.ts","../src/wirings/channels/pikku-command-channels.ts","../src/wirings/channels/pikku-command-websocket-typed.ts","../src/wirings/channels/serialize-typed-channel-map.ts","../src/wirings/channels/serialize-websocket-wrapper.ts","../src/wirings/fetch/index.ts","../src/wirings/functions/pikku-command-function-types.ts","../src/wirings/functions/pikku-command-functions.ts","../src/wirings/functions/pikku-command-services.ts","../src/wirings/functions/pikku-function-types.ts","../src/wirings/functions/pikku-functions.ts","../src/wirings/http/openapi-spec-generator.ts","../src/wirings/http/pikku-command-http-map.ts","../src/wirings/http/pikku-command-http-routes.ts","../src/wirings/http/pikku-command-openapi.ts","../src/wirings/http/pikku-http-routes.ts","../src/wirings/http/serialize-fetch-wrapper.ts","../src/wirings/http/serialize-typed-http-map.ts","../src/wirings/mcp/pikku-command-mcp-json.ts","../src/wirings/mcp/pikku-command-mcp.ts","../src/wirings/mcp/serialize-mcp-json.ts","../src/wirings/queue/pikku-command-queue-map.ts","../src/wirings/queue/pikku-command-queue-service.ts","../src/wirings/queue/pikku-command-queue.ts","../src/wirings/queue/pikku-queue-map.ts","../src/wirings/queue/pikku-queue.ts","../src/wirings/queue/serialize-queue-map.ts","../src/wirings/queue/serialize-queue-meta.ts","../src/wirings/queue/serialize-queue-wrapper.ts","../src/wirings/rpc/pikku-command-rpc-client.ts","../src/wirings/rpc/pikku-command-rpc-map.ts","../src/wirings/rpc/pikku-command-rpc.ts","../src/wirings/rpc/pikku-rpc.ts","../src/wirings/rpc/serialize-rpc-wrapper.ts","../src/wirings/rpc/serialize-typed-rpc-map.ts","../src/wirings/scheduler/pikku-command-scheduler.ts","../src/wirings/scheduler/serialize-scheduler-meta.ts"],"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -21,22 +21,22 @@
|
|
|
21
21
|
"test:coverage": "bash run-tests.sh --coverage"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@openapi-contrib/json-schema-to-openapi-schema": "^
|
|
25
|
-
"@pikku/core": "^0.9.
|
|
26
|
-
"@pikku/inspector": "^0.9.
|
|
27
|
-
"@types/cookie": "^0.
|
|
24
|
+
"@openapi-contrib/json-schema-to-openapi-schema": "^4.0.2",
|
|
25
|
+
"@pikku/core": "^0.9.2",
|
|
26
|
+
"@pikku/inspector": "^0.9.2",
|
|
27
|
+
"@types/cookie": "^1.0.0",
|
|
28
28
|
"@types/uuid": "^10.0.0",
|
|
29
|
-
"chalk": "^5.
|
|
29
|
+
"chalk": "^5.5.0",
|
|
30
30
|
"chokidar": "^4.0.3",
|
|
31
|
-
"commander": "^
|
|
31
|
+
"commander": "^14",
|
|
32
32
|
"path-to-regexp": "^8.2.0",
|
|
33
33
|
"tinyglobby": "^0.2.12",
|
|
34
|
-
"ts-json-schema-generator": "^2.
|
|
35
|
-
"typescript": "^5.
|
|
36
|
-
"yaml": "^2.
|
|
34
|
+
"ts-json-schema-generator": "^2.4.0",
|
|
35
|
+
"typescript": "^5.9",
|
|
36
|
+
"yaml": "^2.8.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^
|
|
39
|
+
"@types/node": "^24.2.1"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=18"
|
|
@@ -13,7 +13,7 @@ export const serializePikkuTypes = (
|
|
|
13
13
|
* This is used to provide the application types in the typescript project
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
|
-
import { CorePikkuPermission,
|
|
16
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware } from '@pikku/core'
|
|
17
17
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
18
18
|
import { CoreHTTPFunctionWiring, AssertHTTPWiringParams, wireHTTP as wireHTTPCore } from '@pikku/core/http'
|
|
19
19
|
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
|
@@ -41,7 +41,7 @@ export type PikkuPermission<In = unknown, RequiredServices extends ${singletonSe
|
|
|
41
41
|
*
|
|
42
42
|
* @template RequiredServices - The services required for this middleware
|
|
43
43
|
*/
|
|
44
|
-
export type
|
|
44
|
+
export type PikkuMiddleware<RequiredServices extends ${singletonServicesTypeName} = ${singletonServicesTypeName}> = CorePikkuMiddleware<RequiredServices, ${userSessionTypeName}>
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* A sessionless API function that doesn't require user authentication.
|
|
@@ -103,7 +103,7 @@ type PikkuFunction<
|
|
|
103
103
|
* @template Out - Output type for the HTTP wiring
|
|
104
104
|
* @template Route - String literal type for the HTTP path (e.g., "/users/:id")
|
|
105
105
|
*/
|
|
106
|
-
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>,
|
|
106
|
+
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
109
|
* Type definition for WebSocket channels with typed data exchange.
|
|
@@ -173,16 +173,7 @@ type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionSessionless<In, MCPPromptR
|
|
|
173
173
|
export const pikkuFunc = <In, Out = unknown>(
|
|
174
174
|
func:
|
|
175
175
|
| PikkuFunction<In, Out>
|
|
176
|
-
|
|
|
177
|
-
func: PikkuFunction<In, Out>
|
|
178
|
-
auth?: true
|
|
179
|
-
name?: string
|
|
180
|
-
}
|
|
181
|
-
| {
|
|
182
|
-
func: PikkuFunctionSessionless<In, Out>
|
|
183
|
-
auth: false
|
|
184
|
-
name?: string
|
|
185
|
-
}
|
|
176
|
+
| CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>>
|
|
186
177
|
) => {
|
|
187
178
|
return typeof func === 'function' ? func : func.func
|
|
188
179
|
}
|
|
@@ -210,10 +201,7 @@ export const pikkuFunc = <In, Out = unknown>(
|
|
|
210
201
|
export const pikkuSessionlessFunc = <In, Out = unknown>(
|
|
211
202
|
func:
|
|
212
203
|
| PikkuFunctionSessionless<In, Out>
|
|
213
|
-
|
|
|
214
|
-
func: PikkuFunctionSessionless<In, Out>
|
|
215
|
-
name?: string
|
|
216
|
-
}
|
|
204
|
+
| CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>>
|
|
217
205
|
) => {
|
|
218
206
|
return typeof func === 'function' ? func : func.func
|
|
219
207
|
}
|
|
@@ -300,10 +288,7 @@ export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
|
|
|
300
288
|
export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
|
|
301
289
|
func:
|
|
302
290
|
| PikkuFunctionSessionless<In, Out, ChannelData>
|
|
303
|
-
|
|
|
304
|
-
func: PikkuFunctionSessionless<In, Out, ChannelData>
|
|
305
|
-
name?: string
|
|
306
|
-
}
|
|
291
|
+
| CorePikkuFunctionConfig<PikkuFunction<In, Out, ChannelData>, PikkuPermission<In>>
|
|
307
292
|
) => {
|
|
308
293
|
return typeof func === 'function' ? func : func.func
|
|
309
294
|
}
|
|
@@ -327,10 +312,7 @@ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unkn
|
|
|
327
312
|
export const pikkuVoidFunc = (
|
|
328
313
|
func:
|
|
329
314
|
| PikkuFunctionSessionless<void, void>
|
|
330
|
-
|
|
|
331
|
-
func: PikkuFunctionSessionless<void, void>
|
|
332
|
-
name?: string
|
|
333
|
-
}
|
|
315
|
+
| CorePikkuFunctionConfig<PikkuFunction<void, void>, PikkuPermission<void>>
|
|
334
316
|
) => {
|
|
335
317
|
return typeof func === 'function' ? func : func.func
|
|
336
318
|
}
|
|
@@ -348,6 +330,27 @@ export const wireChannel = <ChannelData, Channel extends string>(
|
|
|
348
330
|
wireChannelCore(channel as any) // TODO
|
|
349
331
|
}
|
|
350
332
|
|
|
333
|
+
/**
|
|
334
|
+
* Registers middleware either globally or for a specific route.
|
|
335
|
+
*
|
|
336
|
+
* When a string route pattern is provided along with middleware, the middleware
|
|
337
|
+
* is applied only to that route. Otherwise, if an array is provided, it is treated
|
|
338
|
+
* as global middleware (applied to all routes).
|
|
339
|
+
*
|
|
340
|
+
* @param routeOrMiddleware - Either a global middleware array or a route pattern string
|
|
341
|
+
* @param middleware - The middleware array to apply when a route pattern is specified
|
|
342
|
+
*
|
|
343
|
+
* @example
|
|
344
|
+
* \`\`\`typescript
|
|
345
|
+
* // Add global middleware
|
|
346
|
+
* addHTTPMiddleware([authMiddleware, loggingMiddleware])
|
|
347
|
+
*
|
|
348
|
+
* // Add route-specific middleware
|
|
349
|
+
* addHTTPMiddleware('/api/admin/*', [adminAuthMiddleware])
|
|
350
|
+
* \`\`\`
|
|
351
|
+
*/
|
|
352
|
+
export { addHTTPMiddleware }
|
|
353
|
+
|
|
351
354
|
/**
|
|
352
355
|
* Registers an HTTP wiring with the Pikku framework.
|
|
353
356
|
*
|
|
@@ -15,7 +15,7 @@ export const pikkuRPCClient: PikkuCommandWithoutState = async (
|
|
|
15
15
|
'Generating RPC wrapper',
|
|
16
16
|
'Generated RPC wrapper',
|
|
17
17
|
[
|
|
18
|
-
rpcWiringsFile === undefined,
|
|
18
|
+
rpcWiringsFile === undefined || rpcWiringsFile === null,
|
|
19
19
|
"rpcWiringsFile isn't set in the pikku config",
|
|
20
20
|
],
|
|
21
21
|
async () => {
|