@pikku/cli 0.9.16-next.0 → 0.10.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/.pikku/channel/pikku-channel-types.gen.ts +28 -29
- package/.pikku/channel/pikku-channels-map.gen.d.ts +44 -0
- package/.pikku/channel/pikku-channels-meta.gen.ts +5 -0
- package/.pikku/channel/pikku-channels.gen.ts +4 -0
- package/.pikku/cli/pikku-cli-channel.gen.ts +34 -0
- package/.pikku/cli/pikku-cli-client.gen.ts +43 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +14 -15
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +142 -2
- package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -2
- package/.pikku/cli/pikku-cli.gen.ts +41 -0
- package/.pikku/function/pikku-function-types.gen.ts +167 -19
- package/.pikku/function/pikku-functions-meta.gen.ts +220 -192
- package/.pikku/function/pikku-functions-meta.min.gen.ts +61 -56
- package/.pikku/function/pikku-functions.gen.ts +3 -1
- package/.pikku/http/pikku-http-types.gen.ts +28 -3
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +43 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +13 -0
- package/.pikku/http/pikku-http-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +15 -13
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +7 -0
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp.gen.json +5 -0
- package/.pikku/pikku-bootstrap.gen.ts +11 -1
- package/.pikku/pikku-services.gen.ts +1 -5
- package/.pikku/pikku-types.gen.ts +1 -2
- package/.pikku/pikku-websocket.gen.ts +76 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +1 -2
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +57 -0
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -0
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +4 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +5 -4
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +19 -17
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +15 -14
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +1 -2
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -0
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +4 -0
- package/.pikku/schemas/register.gen.ts +15 -11
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/CHANGELOG.md +6 -0
- package/bin/pikku.ts +63 -11
- package/build.sh +1 -1
- package/cli.schema.json +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +11 -20
- package/dist/.pikku/channel/pikku-channel-types.gen.js +9 -11
- package/dist/.pikku/channel/pikku-channels-meta.gen.d.ts +1 -0
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +5 -0
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +4 -0
- package/dist/.pikku/channel/pikku-channels.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.js +33 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.js +34 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +9 -12
- package/dist/.pikku/cli/pikku-cli-types.gen.js +5 -4
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +142 -2
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +3 -2
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +4 -3
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli.gen.js +38 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +141 -20
- package/dist/.pikku/function/pikku-function-types.gen.js +108 -12
- package/dist/.pikku/function/pikku-functions-meta.gen.js +220 -192
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +61 -56
- package/dist/.pikku/function/pikku-functions.gen.js +3 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +21 -2
- package/dist/.pikku/http/pikku-http-types.gen.js +24 -3
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +13 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +4 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.js +5 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +11 -8
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +6 -6
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +7 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +4 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +5 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +11 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +11 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -4
- package/dist/.pikku/pikku-services.gen.js +0 -6
- package/dist/.pikku/pikku-types.gen.d.ts +1 -2
- package/dist/.pikku/pikku-types.gen.js +1 -2
- package/dist/.pikku/pikku-websocket.gen.d.ts +31 -0
- package/dist/.pikku/pikku-websocket.gen.js +49 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -2
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -2
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +15 -14
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +5 -0
- package/dist/.pikku/schemas/register.gen.js +9 -7
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/dist/bin/pikku.d.ts +1 -1
- package/dist/bin/pikku.js +37 -6
- package/dist/src/cli.wiring.js +99 -75
- package/dist/src/functions/commands/all.js +10 -0
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +10 -8
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-channels.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +0 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +0 -5
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +6 -3
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +27 -28
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +4 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +31 -8
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +0 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +0 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +6 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +88 -11
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +1 -18
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +13 -14
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +19 -14
- package/dist/src/functions/wirings/fetch/index.js +6 -3
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +6 -5
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +0 -2
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +0 -2
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.js +11 -21
- package/dist/src/functions/wirings/functions/pikku-function-types.js +0 -2
- package/dist/src/functions/wirings/functions/schemas.js +0 -2
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +167 -19
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +0 -1
- package/dist/src/functions/wirings/http/openapi-spec-generator.d.ts +2 -1
- package/dist/src/functions/wirings/http/pikku-command-http-map.js +0 -5
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +0 -5
- package/dist/src/functions/wirings/http/pikku-command-http-types.js +0 -2
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +7 -4
- package/dist/src/functions/wirings/http/pikku-http-routes.js +0 -5
- package/dist/src/functions/wirings/http/serialize-http-types.js +27 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +0 -5
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +0 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +0 -5
- package/dist/src/functions/wirings/mcp/serialize-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +14 -12
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +0 -2
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +1 -7
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +28 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.d.ts +2 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +43 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +6 -3
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +0 -2
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-queue.js +1 -5
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +0 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +5 -3
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +0 -4
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +0 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +0 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +0 -5
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +0 -1
- package/dist/src/middleware/log-command-info-and-time.d.ts +2 -8
- package/dist/src/middleware/log-command-info-and-time.js +2 -14
- package/dist/src/services/cli-logger-forwarder.service.d.ts +6 -2
- package/dist/src/services/cli-logger-forwarder.service.js +9 -0
- package/dist/src/services/cli-logger.service.d.ts +4 -0
- package/dist/src/services/cli-logger.service.js +11 -0
- package/dist/src/services.d.ts +5 -0
- package/dist/src/services.js +111 -13
- package/dist/src/utils/custom-types-generator.js +8 -2
- package/dist/src/utils/file-writer.d.ts +4 -1
- package/dist/src/utils/file-writer.js +13 -3
- package/dist/src/utils/get-cli-version.d.ts +5 -0
- package/dist/src/utils/get-cli-version.js +27 -0
- package/dist/src/utils/pikku-cli-config.d.ts +1 -2
- package/dist/src/utils/pikku-cli-config.js +9 -28
- package/dist/src/utils/schema-generator.js +3 -2
- package/dist/src/utils/serialize-import-map.js +0 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -8
- package/pikku.config.json +4 -2
- package/src/cli.wiring.ts +101 -74
- package/src/functions/commands/all.ts +12 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +12 -12
- package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
- package/src/functions/wirings/channels/pikku-channels.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +0 -2
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-channels.ts +0 -5
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +7 -3
- package/src/functions/wirings/channels/serialize-channel-types.ts +27 -28
- package/src/functions/wirings/channels/serialize-typed-channel-map.ts +4 -1
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +52 -9
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +0 -2
- package/src/functions/wirings/cli/pikku-command-cli.ts +0 -2
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +111 -12
- package/src/functions/wirings/cli/serialize-channel-cli.ts +2 -23
- package/src/functions/wirings/cli/serialize-cli-types.ts +13 -14
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +19 -14
- package/src/functions/wirings/fetch/index.ts +7 -3
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +14 -5
- package/src/functions/wirings/functions/pikku-command-function-types.ts +0 -2
- package/src/functions/wirings/functions/pikku-command-functions.ts +0 -2
- package/src/functions/wirings/functions/pikku-command-services.ts +13 -24
- package/src/functions/wirings/functions/pikku-function-types.ts +0 -2
- package/src/functions/wirings/functions/schemas.ts +0 -2
- package/src/functions/wirings/functions/serialize-function-types.ts +169 -19
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +0 -1
- package/src/functions/wirings/http/openapi-spec-generator.ts +2 -1
- package/src/functions/wirings/http/pikku-command-http-map.ts +0 -5
- package/src/functions/wirings/http/pikku-command-http-routes.ts +0 -5
- package/src/functions/wirings/http/pikku-command-http-types.ts +0 -2
- package/src/functions/wirings/http/pikku-command-openapi.ts +9 -4
- package/src/functions/wirings/http/pikku-http-routes.ts +0 -5
- package/src/functions/wirings/http/serialize-http-types.ts +27 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +0 -5
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +0 -2
- package/src/functions/wirings/mcp/pikku-command-mcp.ts +0 -5
- package/src/functions/wirings/mcp/serialize-mcp-json.ts +1 -1
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +14 -12
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +0 -2
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +1 -7
- package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +0 -5
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +7 -3
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +0 -2
- package/src/functions/wirings/queue/pikku-command-queue.ts +0 -5
- package/src/functions/wirings/queue/pikku-queue-map.ts +0 -5
- package/src/functions/wirings/queue/pikku-queue.ts +3 -6
- package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
- package/src/functions/wirings/queue/serialize-queue-types.ts +0 -1
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +6 -3
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +0 -4
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +0 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +0 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +0 -5
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +0 -1
- package/src/middleware/log-command-info-and-time.ts +2 -28
- package/src/services/cli-logger-forwarder.service.ts +15 -2
- package/src/services/cli-logger.service.ts +15 -0
- package/src/services.ts +148 -19
- package/src/utils/custom-types-generator.ts +8 -2
- package/src/utils/file-writer.ts +19 -3
- package/src/utils/get-cli-version.ts +28 -0
- package/src/utils/pikku-cli-config.ts +6 -35
- package/src/utils/schema-generator.ts +7 -3
- package/src/utils/serialize-import-map.ts +0 -4
- package/types/application-types.d.ts +4 -1
- package/types/config.d.ts +15 -3
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +0 -6
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +0 -6
- package/dist/src/serialize-pikku-types.d.ts +0 -4
- package/dist/src/serialize-pikku-types.js +0 -605
- package/src/serialize-pikku-types.ts +0 -613
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* WebSocket channel backend for 'pikku' CLI commands
|
|
6
|
+
*/
|
|
7
|
+
import { wireChannel } from '../channel/pikku-channel-types.gen.js';
|
|
8
|
+
import { all } from '../../src/functions/commands/all.js';
|
|
9
|
+
import { pikkuSchemas } from '../../src/functions/wirings/functions/schemas.js';
|
|
10
|
+
import { pikkuFetch } from '../../src/functions/wirings/fetch/index.js';
|
|
11
|
+
import { pikkuWebSocketTyped } from '../../src/functions/wirings/channels/pikku-command-websocket-typed.js';
|
|
12
|
+
import { pikkuRPCClient } from '../../src/functions/wirings/rpc/pikku-command-rpc-client.js';
|
|
13
|
+
import { pikkuQueueService } from '../../src/functions/wirings/queue/pikku-command-queue-service.js';
|
|
14
|
+
import { pikkuOpenAPI } from '../../src/functions/wirings/http/pikku-command-openapi.js';
|
|
15
|
+
import { pikkuNext } from '../../src/functions/runtimes/nextjs/pikku-command-nextjs.js';
|
|
16
|
+
wireChannel({
|
|
17
|
+
name: 'pikku-cli',
|
|
18
|
+
route: '/cli/pikku',
|
|
19
|
+
auth: false,
|
|
20
|
+
onMessageWiring: {
|
|
21
|
+
command: {
|
|
22
|
+
'all': all,
|
|
23
|
+
'schemas': pikkuSchemas,
|
|
24
|
+
'fetch': pikkuFetch,
|
|
25
|
+
'websocket': pikkuWebSocketTyped,
|
|
26
|
+
'rpc': pikkuRPCClient,
|
|
27
|
+
'queue-service': pikkuQueueService,
|
|
28
|
+
'openapi': pikkuOpenAPI,
|
|
29
|
+
'nextjs': pikkuNext
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
tags: ['cli', 'pikku']
|
|
33
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
|
+
*/
|
|
4
|
+
import '../pikku-bootstrap.gen.js';
|
|
5
|
+
/**
|
|
6
|
+
* Pikku CLI Client (via WebSocket Channel)
|
|
7
|
+
* Executes CLI commands over a WebSocket connection
|
|
8
|
+
*/
|
|
9
|
+
export declare function PikkuCLIClient(url: string, args?: string[]): Promise<void>;
|
|
10
|
+
export default PikkuCLIClient;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
|
+
*/
|
|
4
|
+
import { executeCLIViaChannel } from '@pikku/core/cli/channel';
|
|
5
|
+
import { CorePikkuWebsocket } from '@pikku/websocket';
|
|
6
|
+
import '../pikku-bootstrap.gen.js';
|
|
7
|
+
import { clientCLIRenderer } from '../../src/services.js';
|
|
8
|
+
/**
|
|
9
|
+
* Pikku CLI Client (via WebSocket Channel)
|
|
10
|
+
* Executes CLI commands over a WebSocket connection
|
|
11
|
+
*/
|
|
12
|
+
export async function PikkuCLIClient(url, args) {
|
|
13
|
+
// Create WebSocket connection
|
|
14
|
+
const pikkuWS = new CorePikkuWebsocket(url);
|
|
15
|
+
// Register renderers for CLI commands
|
|
16
|
+
const renderers = {};
|
|
17
|
+
await executeCLIViaChannel({
|
|
18
|
+
programName: 'pikku',
|
|
19
|
+
pikkuWS,
|
|
20
|
+
args,
|
|
21
|
+
renderers,
|
|
22
|
+
defaultRenderer: clientCLIRenderer,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
// Export as default for easy importing
|
|
26
|
+
export default PikkuCLIClient;
|
|
27
|
+
// For direct execution (if this file is run directly)
|
|
28
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
29
|
+
const url = process.env.PIKKU_WS_URL || 'ws://localhost:3000/cli/pikku';
|
|
30
|
+
PikkuCLIClient(url, process.argv.slice(2)).catch(error => {
|
|
31
|
+
console.error('Fatal error:', error.message);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
* CLI-specific type definitions for tree-shaking optimization
|
|
7
7
|
*/
|
|
8
|
-
import { CoreCLI, CorePikkuCLIRender, CoreCLICommandConfig } from '@pikku/core';
|
|
8
|
+
import { CoreCLI, CorePikkuCLIRender, CoreCLICommandConfig } from '@pikku/core/cli';
|
|
9
9
|
import type { PikkuFunctionConfig, PikkuMiddleware } from '../function/pikku-function-types.gen.js';
|
|
10
10
|
import type { UserSession } from '../../types/application-types.d.js';
|
|
11
11
|
import type { SingletonServices } from '../../types/application-types.d.js';
|
|
@@ -22,18 +22,14 @@ type PikkuCLIRender<Data, RequiredServices extends SingletonServices = Singleton
|
|
|
22
22
|
* CLI command configuration with project-specific types.
|
|
23
23
|
* Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
|
|
24
24
|
*/
|
|
25
|
-
type CLICommandConfig<Func extends PikkuFunctionConfig<any, any
|
|
26
|
-
/**
|
|
27
|
-
* Result type for CLI command configuration
|
|
28
|
-
*/
|
|
29
|
-
type CLICommandResult<Func extends PikkuFunctionConfig<any, any>> = CLICommandConfig<Func>;
|
|
25
|
+
type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>;
|
|
30
26
|
/**
|
|
31
27
|
* Type definition for CLI applications with commands and global options.
|
|
32
28
|
*
|
|
33
29
|
* @template Commands - Type describing the command structure
|
|
34
30
|
* @template GlobalOptions - Type for global CLI options
|
|
35
31
|
*/
|
|
36
|
-
type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any
|
|
32
|
+
type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions> = CoreCLI<Commands, GlobalOptions, PikkuMiddleware, PikkuCLIRender<any>>;
|
|
37
33
|
/**
|
|
38
34
|
* Registers a CLI application with the Pikku framework.
|
|
39
35
|
* Creates command-line interfaces with type-safe commands and options.
|
|
@@ -42,14 +38,15 @@ type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMi
|
|
|
42
38
|
* @template GlobalOptions - Type for global CLI options
|
|
43
39
|
* @param cli - CLI definition with program name, commands, and global options
|
|
44
40
|
*/
|
|
45
|
-
export declare const wireCLI: <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any
|
|
41
|
+
export declare const wireCLI: <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions>(cli: CLIWiring<Commands, GlobalOptions>) => void;
|
|
46
42
|
/**
|
|
47
43
|
* Creates a CLI command definition with automatic option inference from the function's input type.
|
|
48
44
|
* This allows TypeScript to automatically derive CLI options from the function signature.
|
|
49
45
|
*
|
|
50
|
-
* @template
|
|
46
|
+
* @template FuncConfig - The Pikku function config type
|
|
47
|
+
* @template Params - The parameters string literal type
|
|
51
48
|
* @param config - CLI command configuration
|
|
52
49
|
* @returns CLI command configuration with inferred types
|
|
53
50
|
*/
|
|
54
|
-
export declare const pikkuCLICommand: <
|
|
51
|
+
export declare const pikkuCLICommand: <FuncConfig extends PikkuFunctionConfig<any, any>, Params extends string>(config: CLICommandConfig<FuncConfig, any, any, Params>) => CoreCLICommandConfig<FuncConfig, PikkuMiddleware, PikkuCLIRender<any>, string>;
|
|
55
52
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
* CLI-specific type definitions for tree-shaking optimization
|
|
7
7
|
*/
|
|
8
|
-
import { wireCLI as wireCLICore } from '@pikku/core';
|
|
8
|
+
import { wireCLI as wireCLICore } from '@pikku/core/cli';
|
|
9
9
|
/**
|
|
10
10
|
* Registers a CLI application with the Pikku framework.
|
|
11
11
|
* Creates command-line interfaces with type-safe commands and options.
|
|
@@ -21,7 +21,8 @@ export const wireCLI = (cli) => {
|
|
|
21
21
|
* Creates a CLI command definition with automatic option inference from the function's input type.
|
|
22
22
|
* This allows TypeScript to automatically derive CLI options from the function signature.
|
|
23
23
|
*
|
|
24
|
-
* @template
|
|
24
|
+
* @template FuncConfig - The Pikku function config type
|
|
25
|
+
* @template Params - The parameters string literal type
|
|
25
26
|
* @param config - CLI command configuration
|
|
26
27
|
* @returns CLI command configuration with inferred types
|
|
27
28
|
*/
|
|
@@ -1,5 +1,145 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
3
|
*/
|
|
4
4
|
import { pikkuState } from '@pikku/core';
|
|
5
|
-
pikkuState('cli', 'meta', {
|
|
5
|
+
pikkuState('cli', 'meta', {
|
|
6
|
+
"programs": {
|
|
7
|
+
"pikku": {
|
|
8
|
+
"program": "pikku",
|
|
9
|
+
"commands": {
|
|
10
|
+
"all": {
|
|
11
|
+
"pikkuFuncName": "all",
|
|
12
|
+
"positionals": [],
|
|
13
|
+
"options": {
|
|
14
|
+
"tags": {
|
|
15
|
+
"description": "Filter functions by tags (comma-separated)",
|
|
16
|
+
"short": "t"
|
|
17
|
+
},
|
|
18
|
+
"types": {
|
|
19
|
+
"description": "Filter functions by types (comma-separated)"
|
|
20
|
+
},
|
|
21
|
+
"directories": {
|
|
22
|
+
"description": "Filter functions by directories (comma-separated)",
|
|
23
|
+
"short": "d"
|
|
24
|
+
},
|
|
25
|
+
"httpMethods": {
|
|
26
|
+
"description": "Filter HTTP routes by methods (comma-separated)"
|
|
27
|
+
},
|
|
28
|
+
"httpRoutes": {
|
|
29
|
+
"description": "Filter HTTP routes by route patterns (comma-separated)"
|
|
30
|
+
},
|
|
31
|
+
"names": {
|
|
32
|
+
"description": "Filter functions by name patterns (supports wildcards)",
|
|
33
|
+
"short": "n"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"description": "Generate all Pikku files (types, schemas, wirings, etc.)",
|
|
37
|
+
"isDefault": true
|
|
38
|
+
},
|
|
39
|
+
"schemas": {
|
|
40
|
+
"pikkuFuncName": "pikkuSchemas",
|
|
41
|
+
"positionals": [],
|
|
42
|
+
"options": {},
|
|
43
|
+
"description": "Generate JSON schemas for function input/output types"
|
|
44
|
+
},
|
|
45
|
+
"fetch": {
|
|
46
|
+
"pikkuFuncName": "pikkuFetch",
|
|
47
|
+
"positionals": [],
|
|
48
|
+
"options": {},
|
|
49
|
+
"description": "Generate type-safe HTTP fetch client"
|
|
50
|
+
},
|
|
51
|
+
"websocket": {
|
|
52
|
+
"pikkuFuncName": "pikkuWebSocketTyped",
|
|
53
|
+
"positionals": [],
|
|
54
|
+
"options": {},
|
|
55
|
+
"description": "Generate type-safe WebSocket client"
|
|
56
|
+
},
|
|
57
|
+
"rpc": {
|
|
58
|
+
"pikkuFuncName": "pikkuRPCClient",
|
|
59
|
+
"positionals": [],
|
|
60
|
+
"options": {},
|
|
61
|
+
"description": "Generate RPC client wrappers"
|
|
62
|
+
},
|
|
63
|
+
"queue-service": {
|
|
64
|
+
"pikkuFuncName": "pikkuQueueService",
|
|
65
|
+
"positionals": [],
|
|
66
|
+
"options": {},
|
|
67
|
+
"description": "Generate queue service wrapper"
|
|
68
|
+
},
|
|
69
|
+
"openapi": {
|
|
70
|
+
"pikkuFuncName": "pikkuOpenAPI",
|
|
71
|
+
"positionals": [],
|
|
72
|
+
"options": {},
|
|
73
|
+
"description": "Generate OpenAPI specification from HTTP routes"
|
|
74
|
+
},
|
|
75
|
+
"nextjs": {
|
|
76
|
+
"pikkuFuncName": "pikkuNext",
|
|
77
|
+
"positionals": [],
|
|
78
|
+
"options": {},
|
|
79
|
+
"description": "Generate Next.js backend and HTTP wrappers"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"options": {
|
|
83
|
+
"config": {
|
|
84
|
+
"description": "Path to pikku.config.json file",
|
|
85
|
+
"short": "c"
|
|
86
|
+
},
|
|
87
|
+
"logLevel": {
|
|
88
|
+
"description": "Set log level",
|
|
89
|
+
"short": "l",
|
|
90
|
+
"choices": [
|
|
91
|
+
"trace",
|
|
92
|
+
"debug",
|
|
93
|
+
"info",
|
|
94
|
+
"warn",
|
|
95
|
+
"error",
|
|
96
|
+
"critical"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"userSessionType": {
|
|
100
|
+
"description": "Specify which UserSession type to use (when multiple exist)"
|
|
101
|
+
},
|
|
102
|
+
"singletonServicesFactoryType": {
|
|
103
|
+
"description": "Specify which singleton services factory to use"
|
|
104
|
+
},
|
|
105
|
+
"sessionServicesFactoryType": {
|
|
106
|
+
"description": "Specify which session services factory to use"
|
|
107
|
+
},
|
|
108
|
+
"stateOutput": {
|
|
109
|
+
"description": "Save inspector state to JSON file for reuse"
|
|
110
|
+
},
|
|
111
|
+
"stateInput": {
|
|
112
|
+
"description": "Load inspector state from JSON file (skips inspection)"
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
"defaultRenderName": "clientCLIRenderer"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"renderers": {
|
|
119
|
+
"defaultCLIRenderer": {
|
|
120
|
+
"name": "defaultCLIRenderer",
|
|
121
|
+
"exportedName": "defaultCLIRenderer",
|
|
122
|
+
"services": {
|
|
123
|
+
"optimized": true,
|
|
124
|
+
"services": [
|
|
125
|
+
"logger",
|
|
126
|
+
"getInspectorState",
|
|
127
|
+
"schema",
|
|
128
|
+
"jwt",
|
|
129
|
+
"config",
|
|
130
|
+
"variables"
|
|
131
|
+
]
|
|
132
|
+
},
|
|
133
|
+
"filePath": "/home/runner/work/pikku/pikku/packages/cli/src/services.ts"
|
|
134
|
+
},
|
|
135
|
+
"clientCLIRenderer": {
|
|
136
|
+
"name": "clientCLIRenderer",
|
|
137
|
+
"exportedName": "clientCLIRenderer",
|
|
138
|
+
"services": {
|
|
139
|
+
"optimized": true,
|
|
140
|
+
"services": []
|
|
141
|
+
},
|
|
142
|
+
"filePath": "/home/runner/work/pikku/pikku/packages/cli/src/services.ts"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export {};
|
|
2
1
|
/**
|
|
3
|
-
* This file was generated by
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
4
3
|
*/
|
|
5
|
-
/* The files with an wireCLI function call */
|
|
4
|
+
/* The files with an wireCLI function call */
|
|
5
|
+
import '../../src/services.js';
|
|
6
|
+
import '../../src/cli.wiring.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
|
+
*/
|
|
4
|
+
import '../pikku-bootstrap.gen.js';
|
|
5
|
+
/**
|
|
6
|
+
* Pikku CLI function
|
|
7
|
+
* Handles command line arguments and executes the appropriate function
|
|
8
|
+
*/
|
|
9
|
+
export declare function PikkuCLI(args: string[]): Promise<void>;
|
|
10
|
+
export default PikkuCLI;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
|
+
*/
|
|
4
|
+
import { executeCLI, CLIError } from '@pikku/core/cli';
|
|
5
|
+
import { createConfig as createConfig } from '../../src/services.js';
|
|
6
|
+
import { createSingletonServices as createSingletonServices } from '../../src/services.js';
|
|
7
|
+
import { createSessionServices as createSessionServices } from '../../src/services.js';
|
|
8
|
+
import '../pikku-bootstrap.gen.js';
|
|
9
|
+
/**
|
|
10
|
+
* Pikku CLI function
|
|
11
|
+
* Handles command line arguments and executes the appropriate function
|
|
12
|
+
*/
|
|
13
|
+
export async function PikkuCLI(args) {
|
|
14
|
+
try {
|
|
15
|
+
await executeCLI({
|
|
16
|
+
programName: 'pikku',
|
|
17
|
+
args: args || process.argv.slice(2),
|
|
18
|
+
createConfig,
|
|
19
|
+
createSingletonServices,
|
|
20
|
+
createSessionServices,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (error instanceof CLIError) {
|
|
25
|
+
process.exit(error.exitCode);
|
|
26
|
+
}
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// Export as default for easy importing
|
|
31
|
+
export default PikkuCLI;
|
|
32
|
+
// For direct execution (if this file is run directly)
|
|
33
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
34
|
+
PikkuCLI(process.argv.slice(2)).catch(error => {
|
|
35
|
+
console.error('Fatal error:', error.message);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by
|
|
2
|
+
* This file was generated by @pikku/cli@0.10.0
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
|
-
* This file was generated by the @pikku/cli
|
|
6
5
|
* Core function, middleware, and permission types for all wirings
|
|
7
6
|
*/
|
|
8
|
-
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware } from '@pikku/core';
|
|
7
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup } from '@pikku/core';
|
|
9
8
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function';
|
|
10
|
-
import { PikkuChannel
|
|
9
|
+
import { PikkuChannel } from '@pikku/core/channel';
|
|
10
|
+
import { PikkuMCP } from '@pikku/core/mcp';
|
|
11
11
|
import type { UserSession } from '../../types/application-types.d.js';
|
|
12
12
|
import type { SingletonServices } from '../../types/application-types.d.js';
|
|
13
13
|
import type { Services } from '../../types/application-types.d.js';
|
|
14
|
+
import type { Config } from '../../types/application-types.d.js';
|
|
14
15
|
import type { TypedPikkuRPC } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js';
|
|
16
|
+
import type { RequiredSingletonServices, RequiredSessionServices } from '../pikku-services.gen.js';
|
|
15
17
|
type Session = UserSession;
|
|
16
18
|
/**
|
|
17
19
|
* Type-safe API permission definition that integrates with your application's session type.
|
|
@@ -28,31 +30,74 @@ export type PikkuPermission<In = unknown, RequiredServices extends Services = Se
|
|
|
28
30
|
* @template RequiredServices - The services required for this middleware
|
|
29
31
|
*/
|
|
30
32
|
export type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices, Session>;
|
|
33
|
+
/**
|
|
34
|
+
* Configuration object for creating a permission with metadata
|
|
35
|
+
*/
|
|
36
|
+
export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = Services> = {
|
|
37
|
+
/** The permission function */
|
|
38
|
+
func: PikkuPermission<In, RequiredServices>;
|
|
39
|
+
/** Optional human-readable name for the permission */
|
|
40
|
+
name?: string;
|
|
41
|
+
/** Optional description of what the permission checks */
|
|
42
|
+
description?: string;
|
|
43
|
+
};
|
|
31
44
|
/**
|
|
32
45
|
* Factory function for creating permissions with tree-shaking support.
|
|
33
|
-
*
|
|
46
|
+
* Supports both direct function and configuration object syntax.
|
|
34
47
|
*
|
|
35
48
|
* @example
|
|
36
49
|
* ```typescript
|
|
50
|
+
* // Direct function syntax
|
|
37
51
|
* const permission = pikkuPermission(({ logger }, data, session) => {
|
|
38
|
-
* return session?.
|
|
52
|
+
* return session?.role === 'admin'
|
|
53
|
+
* })
|
|
54
|
+
*
|
|
55
|
+
* // Configuration object syntax with metadata
|
|
56
|
+
* const adminPermission = pikkuPermission({
|
|
57
|
+
* name: 'Admin Permission',
|
|
58
|
+
* description: 'Checks if user has admin role',
|
|
59
|
+
* func: async ({ logger }, data, session) => {
|
|
60
|
+
* return session?.role === 'admin'
|
|
61
|
+
* }
|
|
39
62
|
* })
|
|
40
63
|
* ```
|
|
41
64
|
*/
|
|
42
|
-
export declare const pikkuPermission: <In>(
|
|
65
|
+
export declare const pikkuPermission: <In>(permission: PikkuPermission<In> | PikkuPermissionConfig<In>) => PikkuPermission<In>;
|
|
66
|
+
/**
|
|
67
|
+
* Configuration object for creating middleware with metadata
|
|
68
|
+
*/
|
|
69
|
+
export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = SingletonServices> = {
|
|
70
|
+
/** The middleware function */
|
|
71
|
+
func: PikkuMiddleware<RequiredServices>;
|
|
72
|
+
/** Optional human-readable name for the middleware */
|
|
73
|
+
name?: string;
|
|
74
|
+
/** Optional description of what the middleware does */
|
|
75
|
+
description?: string;
|
|
76
|
+
};
|
|
43
77
|
/**
|
|
44
78
|
* Factory function for creating middleware with tree-shaking support.
|
|
45
|
-
*
|
|
79
|
+
* Supports both direct function and configuration object syntax.
|
|
46
80
|
*
|
|
47
81
|
* @example
|
|
48
82
|
* ```typescript
|
|
83
|
+
* // Direct function syntax
|
|
49
84
|
* const middleware = pikkuMiddleware(({ logger }, interactions, next) => {
|
|
50
85
|
* logger.info('Middleware executed')
|
|
51
86
|
* await next()
|
|
52
87
|
* })
|
|
88
|
+
*
|
|
89
|
+
* // Configuration object syntax with metadata
|
|
90
|
+
* const logMiddleware = pikkuMiddleware({
|
|
91
|
+
* name: 'Request Logger',
|
|
92
|
+
* description: 'Logs all incoming requests',
|
|
93
|
+
* func: async ({ logger }, interactions, next) => {
|
|
94
|
+
* logger.info('Request started')
|
|
95
|
+
* await next()
|
|
96
|
+
* }
|
|
97
|
+
* })
|
|
53
98
|
* ```
|
|
54
99
|
*/
|
|
55
|
-
export declare const pikkuMiddleware: (
|
|
100
|
+
export declare const pikkuMiddleware: <RequiredServices extends SingletonServices = SingletonServices>(middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>) => PikkuMiddleware<RequiredServices>;
|
|
56
101
|
/**
|
|
57
102
|
* Factory function for creating middleware factories
|
|
58
103
|
* Use this when your middleware needs configuration/input parameters
|
|
@@ -71,6 +116,26 @@ export declare const pikkuMiddleware: (func: PikkuMiddleware) => PikkuMiddleware
|
|
|
71
116
|
* ```
|
|
72
117
|
*/
|
|
73
118
|
export declare const pikkuMiddlewareFactory: <In = any>(factory: (input: In) => PikkuMiddleware) => ((input: In) => PikkuMiddleware);
|
|
119
|
+
/**
|
|
120
|
+
* Factory function for creating permission factories
|
|
121
|
+
* Use this when your permission needs configuration/input parameters
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```typescript
|
|
125
|
+
* export const requireRole = pikkuPermissionFactory<{ role: string }>(({
|
|
126
|
+
* role
|
|
127
|
+
* }) => {
|
|
128
|
+
* return pikkuPermission(async ({ logger }, data, session) => {
|
|
129
|
+
* if (!session || session.role !== role) {
|
|
130
|
+
* logger.warn(`Permission denied: required role '${role}'`)
|
|
131
|
+
* return false
|
|
132
|
+
* }
|
|
133
|
+
* return true
|
|
134
|
+
* })
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const pikkuPermissionFactory: <In = any>(factory: (input: In) => PikkuPermission<any>) => ((input: In) => PikkuPermission<any>);
|
|
74
139
|
/**
|
|
75
140
|
* A sessionless API function that doesn't require user authentication.
|
|
76
141
|
* Use this for public endpoints, health checks, or operations that don't need user context.
|
|
@@ -83,7 +148,7 @@ export declare const pikkuMiddlewareFactory: <In = any>(factory: (input: In) =>
|
|
|
83
148
|
*/
|
|
84
149
|
export type PikkuFunctionSessionless<In = unknown, Out = never, ChannelData = null, // null means optional channel
|
|
85
150
|
MCPData = null, // null means optional MCP
|
|
86
|
-
RequiredServices extends Services = Services & {
|
|
151
|
+
RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> & {
|
|
87
152
|
rpc: TypedPikkuRPC;
|
|
88
153
|
} & ([
|
|
89
154
|
ChannelData
|
|
@@ -108,7 +173,7 @@ RequiredServices extends Services = Services & {
|
|
|
108
173
|
*/
|
|
109
174
|
export type PikkuFunction<In = unknown, Out = never, ChannelData = null, // null means optional channel
|
|
110
175
|
MCPData = null, // null means optional MCP
|
|
111
|
-
RequiredServices extends Services = Omit<Services, 'rpc'> & {
|
|
176
|
+
RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> & {
|
|
112
177
|
rpc: TypedPikkuRPC;
|
|
113
178
|
} & ([
|
|
114
179
|
ChannelData
|
|
@@ -127,9 +192,11 @@ RequiredServices extends Services = Omit<Services, 'rpc'> & {
|
|
|
127
192
|
*
|
|
128
193
|
* @template In - The input type
|
|
129
194
|
* @template Out - The output type
|
|
195
|
+
* @template ChannelData - Channel data type
|
|
196
|
+
* @template MCPData - MCP data type
|
|
130
197
|
* @template PikkuFunc - The function type (can be narrowed to PikkuFunction or PikkuFunctionSessionless)
|
|
131
198
|
*/
|
|
132
|
-
export type PikkuFunctionConfig<In = unknown, Out = unknown, PikkuFunc extends PikkuFunction<In, Out> | PikkuFunctionSessionless<In, Out> = PikkuFunction<In, Out> | PikkuFunctionSessionless<In, Out>> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware>;
|
|
199
|
+
export type PikkuFunctionConfig<In = unknown, Out = unknown, ChannelData = unknown, MCPData = unknown, PikkuFunc extends PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData> = PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData>> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware>;
|
|
133
200
|
/**
|
|
134
201
|
* Creates a Pikku function that can be either session-aware or sessionless.
|
|
135
202
|
* This is the main function wrapper for creating API endpoints.
|
|
@@ -151,13 +218,13 @@ export type PikkuFunctionConfig<In = unknown, Out = unknown, PikkuFunc extends P
|
|
|
151
218
|
* })
|
|
152
219
|
* \`\`\`
|
|
153
220
|
*/
|
|
154
|
-
export declare const pikkuFunc: <In, Out = unknown>(func: PikkuFunction<In, Out> | CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In
|
|
221
|
+
export declare const pikkuFunc: <In, Out = unknown>(func: PikkuFunction<In, Out> | CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>, PikkuMiddleware>) => CorePikkuFunctionConfig<PikkuFunction<In, Out, null, null, Omit<Services, "rpc" | "channel" | "mcp"> & {
|
|
155
222
|
rpc: TypedPikkuRPC;
|
|
156
223
|
} & {
|
|
157
224
|
channel?: PikkuChannel<unknown, Out> | undefined;
|
|
158
225
|
} & {
|
|
159
226
|
mcp?: PikkuMCP;
|
|
160
|
-
}>, PikkuPermission<In, Services>>;
|
|
227
|
+
}>, PikkuPermission<In, Services>, PikkuMiddleware<SingletonServices>>;
|
|
161
228
|
/**
|
|
162
229
|
* Creates a sessionless Pikku function that doesn't require user authentication.
|
|
163
230
|
* Use this for public endpoints, webhooks, or background tasks.
|
|
@@ -178,7 +245,7 @@ export declare const pikkuFunc: <In, Out = unknown>(func: PikkuFunction<In, Out>
|
|
|
178
245
|
* })
|
|
179
246
|
* \`\`\`
|
|
180
247
|
*/
|
|
181
|
-
export declare const pikkuSessionlessFunc: <In, Out = unknown>(func: PikkuFunctionSessionless<In, Out> | CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>) => CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out, null, null, Services & {
|
|
248
|
+
export declare const pikkuSessionlessFunc: <In, Out = unknown>(func: PikkuFunctionSessionless<In, Out> | CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>) => CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out, null, null, Omit<Services, "rpc" | "channel" | "mcp"> & {
|
|
182
249
|
rpc: TypedPikkuRPC;
|
|
183
250
|
} & {
|
|
184
251
|
channel?: PikkuChannel<unknown, Out> | undefined;
|
|
@@ -201,13 +268,67 @@ export declare const pikkuSessionlessFunc: <In, Out = unknown>(func: PikkuFuncti
|
|
|
201
268
|
* })
|
|
202
269
|
* \`\`\`
|
|
203
270
|
*/
|
|
204
|
-
export declare const pikkuVoidFunc: (func: PikkuFunctionSessionless<void, void> | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>) => CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, null, null, Services & {
|
|
271
|
+
export declare const pikkuVoidFunc: (func: PikkuFunctionSessionless<void, void> | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>) => CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, null, null, Omit<Services, "rpc" | "channel" | "mcp"> & {
|
|
205
272
|
rpc: TypedPikkuRPC;
|
|
206
273
|
} & {
|
|
207
274
|
channel?: PikkuChannel<unknown, void> | undefined;
|
|
208
275
|
} & {
|
|
209
276
|
mcp?: PikkuMCP;
|
|
210
277
|
}>, PikkuPermission<void, Services>>;
|
|
278
|
+
/**
|
|
279
|
+
* Creates a Pikku config factory.
|
|
280
|
+
* Use this to define your application's configuration factory.
|
|
281
|
+
*
|
|
282
|
+
* @param func - Config factory function that returns your application's config
|
|
283
|
+
* @returns The config factory function
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* export const createConfig = pikkuConfig(async () => {
|
|
288
|
+
* return {
|
|
289
|
+
* apiUrl: process.env.API_URL || 'http://localhost:3000',
|
|
290
|
+
* dbUrl: process.env.DATABASE_URL
|
|
291
|
+
* }
|
|
292
|
+
* })
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export declare const pikkuConfig: (func: (variables?: any, ...args: any[]) => Promise<Config>) => (variables?: any, ...args: any[]) => Promise<Config>;
|
|
296
|
+
/**
|
|
297
|
+
* Creates a Pikku singleton services factory.
|
|
298
|
+
* Use this to define services that are created once and shared across all requests.
|
|
299
|
+
*
|
|
300
|
+
* @param func - Singleton services factory function
|
|
301
|
+
* @returns The singleton services factory function
|
|
302
|
+
*
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* export const createSingletonServices = pikkuServices(async (config, existingServices) => {
|
|
306
|
+
* return {
|
|
307
|
+
* config,
|
|
308
|
+
* logger: new CustomLogger(),
|
|
309
|
+
* db: await createDatabaseConnection(config.dbUrl)
|
|
310
|
+
* }
|
|
311
|
+
* })
|
|
312
|
+
* ```
|
|
313
|
+
*/
|
|
314
|
+
export declare const pikkuServices: (func: (config: Config, existingServices?: Partial<SingletonServices>) => Promise<RequiredSingletonServices>) => (config: Config, existingServices?: Partial<SingletonServices>) => Promise<RequiredSingletonServices>;
|
|
315
|
+
/**
|
|
316
|
+
* Creates a Pikku session services factory.
|
|
317
|
+
* Use this to define services that are created per-request/session.
|
|
318
|
+
*
|
|
319
|
+
* @param func - Session services factory function
|
|
320
|
+
* @returns The session services factory function
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* export const createSessionServices = pikkuSessionServices(async (services, interaction, session) => {
|
|
325
|
+
* return {
|
|
326
|
+
* userCache: new UserCache(session?.userId)
|
|
327
|
+
* }
|
|
328
|
+
* })
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
export declare const pikkuSessionServices: (func: (services: SingletonServices, interaction: any, session: Session | undefined) => Promise<RequiredSessionServices>) => (services: SingletonServices, interaction: any, session: Session | undefined) => Promise<RequiredSessionServices>;
|
|
211
332
|
/**
|
|
212
333
|
* Adds global middleware for a specific tag.
|
|
213
334
|
*
|
|
@@ -239,7 +360,7 @@ export declare const addMiddleware: (tag: string, middleware: PikkuMiddleware[])
|
|
|
239
360
|
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
240
361
|
*
|
|
241
362
|
* @param tag - The tag that the permissions should apply to.
|
|
242
|
-
* @param permissions - The permissions array to apply for the specified tag.
|
|
363
|
+
* @param permissions - The permissions array or object to apply for the specified tag.
|
|
243
364
|
*
|
|
244
365
|
* @throws Error if permissions for the tag already exist.
|
|
245
366
|
*
|
|
@@ -251,9 +372,9 @@ export declare const addMiddleware: (tag: string, middleware: PikkuMiddleware[])
|
|
|
251
372
|
* // Add authentication permissions for auth endpoints
|
|
252
373
|
* addPermission('auth', [authPermission])
|
|
253
374
|
*
|
|
254
|
-
* // Add read permissions for all API endpoints
|
|
255
|
-
* addPermission('api',
|
|
375
|
+
* // Add read permissions for all API endpoints (as object)
|
|
376
|
+
* addPermission('api', { read: readPermission })
|
|
256
377
|
* ```
|
|
257
378
|
*/
|
|
258
|
-
export declare const addPermission: <In = unknown>(tag: string, permissions: PikkuPermission<In>[]) => void;
|
|
379
|
+
export declare const addPermission: <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => void;
|
|
259
380
|
export {};
|