@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
|
@@ -5,13 +5,7 @@
|
|
|
5
5
|
* This includes services, middleware count, factory status, etc.
|
|
6
6
|
*/
|
|
7
7
|
export const serializeMiddlewareGroupsMeta = (state) => {
|
|
8
|
-
const lines = [
|
|
9
|
-
`/**`,
|
|
10
|
-
` * This file was generated by the @pikku/cli`,
|
|
11
|
-
` */`,
|
|
12
|
-
`import { pikkuState } from '@pikku/core'`,
|
|
13
|
-
``,
|
|
14
|
-
];
|
|
8
|
+
const lines = [`import { pikkuState } from '@pikku/core'`, ``];
|
|
15
9
|
// Serialize HTTP middleware groups metadata
|
|
16
10
|
const httpGroups = {};
|
|
17
11
|
for (const [pattern, meta] of state.http.routeMiddleware.entries()) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuPermissions: any;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js';
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
4
|
+
import { serializePermissionsImports } from './serialize-permissions-imports.js';
|
|
5
|
+
export const pikkuPermissions = pikkuSessionlessFunc({
|
|
6
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
+
const state = await getInspectorState();
|
|
8
|
+
const { permissions } = state;
|
|
9
|
+
const { permissionsFile, packageMappings } = config;
|
|
10
|
+
let filesGenerated = false;
|
|
11
|
+
// Check if there are any permission group factories
|
|
12
|
+
const hasHTTPFactories = Array.from(state.http.routePermissions.values()).some((meta) => meta.exportName && meta.isFactory);
|
|
13
|
+
const hasTagFactories = Array.from(state.permissions.tagPermissions.values()).some((meta) => meta.exportName && meta.isFactory);
|
|
14
|
+
const hasFactories = hasHTTPFactories || hasTagFactories;
|
|
15
|
+
// Generate permissions imports file if there are factories
|
|
16
|
+
if (hasFactories) {
|
|
17
|
+
await writeFileInDir(logger, permissionsFile, serializePermissionsImports(permissionsFile, permissions, state.http, packageMappings));
|
|
18
|
+
filesGenerated = true;
|
|
19
|
+
}
|
|
20
|
+
return filesGenerated;
|
|
21
|
+
},
|
|
22
|
+
middleware: [
|
|
23
|
+
logCommandInfoAndTime({
|
|
24
|
+
commandStart: 'Serializing Pikku permissions',
|
|
25
|
+
commandEnd: 'Serialized Pikku permissions',
|
|
26
|
+
}),
|
|
27
|
+
],
|
|
28
|
+
});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { InspectorPermissionState, InspectorHTTPState, InspectorState } from '@pikku/inspector';
|
|
2
|
+
export declare const serializePermissionsImports: (outputPath: string, permissionsState: InspectorPermissionState, httpState: InspectorHTTPState, packageMappings?: Record<string, string>, fullState?: InspectorState) => string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
2
|
+
export const serializePermissionsImports = (outputPath, permissionsState, httpState, packageMappings = {}, fullState) => {
|
|
3
|
+
const serializedImports = [];
|
|
4
|
+
const serializedFactoryCalls = [];
|
|
5
|
+
// Collect factory imports and calls for HTTP permission groups
|
|
6
|
+
const httpFactories = new Map();
|
|
7
|
+
for (const [, groupMeta] of httpState.routePermissions.entries()) {
|
|
8
|
+
if (groupMeta.exportName && groupMeta.isFactory) {
|
|
9
|
+
const filePath = getFileImportRelativePath(outputPath, groupMeta.sourceFile, packageMappings);
|
|
10
|
+
httpFactories.set(groupMeta.exportName, {
|
|
11
|
+
exportName: groupMeta.exportName,
|
|
12
|
+
filePath,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
// Collect factory imports and calls for tag permission groups
|
|
17
|
+
const tagFactories = new Map();
|
|
18
|
+
for (const [, groupMeta] of permissionsState.tagPermissions.entries()) {
|
|
19
|
+
if (groupMeta.exportName && groupMeta.isFactory) {
|
|
20
|
+
const filePath = getFileImportRelativePath(outputPath, groupMeta.sourceFile, packageMappings);
|
|
21
|
+
tagFactories.set(groupMeta.exportName, {
|
|
22
|
+
exportName: groupMeta.exportName,
|
|
23
|
+
filePath,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Combine all factories and deduplicate by exportName (same factory might be used in multiple groups)
|
|
28
|
+
const allFactories = new Map([...httpFactories, ...tagFactories]);
|
|
29
|
+
// Add factory imports and calls
|
|
30
|
+
if (allFactories.size > 0) {
|
|
31
|
+
serializedImports.push('/* Call permission group factories to register at module evaluation */');
|
|
32
|
+
// Import factories
|
|
33
|
+
for (const [exportName, { filePath }] of allFactories) {
|
|
34
|
+
serializedImports.push(`import { ${exportName} } from '${filePath}'`);
|
|
35
|
+
}
|
|
36
|
+
// Call factories
|
|
37
|
+
for (const [exportName] of allFactories) {
|
|
38
|
+
serializedFactoryCalls.push(`${exportName}()`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Return combined output
|
|
42
|
+
return [...serializedImports, ...serializedFactoryCalls].join('\n');
|
|
43
|
+
};
|
|
@@ -13,11 +13,6 @@ export const pikkuQueueMap = pikkuSessionlessFunc({
|
|
|
13
13
|
logCommandInfoAndTime({
|
|
14
14
|
commandStart: 'Creating Queue map',
|
|
15
15
|
commandEnd: 'Created Queue map',
|
|
16
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
17
|
-
const { queueWorkers } = await getInspectorState();
|
|
18
|
-
return queueWorkers.files.size === 0;
|
|
19
|
-
},
|
|
20
|
-
skipMessage: 'none found',
|
|
21
16
|
}),
|
|
22
17
|
],
|
|
23
18
|
});
|
|
@@ -6,8 +6,13 @@ import { serializeQueueWrapper } from './serialize-queue-wrapper.js';
|
|
|
6
6
|
export const pikkuQueueService = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
8
|
const { queueWiringsFile, queueMapDeclarationFile, packageMappings } = config;
|
|
9
|
+
// If queueWiringsFile is not set, clean up any existing file and return
|
|
9
10
|
if (!queueWiringsFile) {
|
|
10
|
-
|
|
11
|
+
logger.info({
|
|
12
|
+
message: "Skipping generating queue service wrapper since queueWiringsFile isn't set in the pikku config.",
|
|
13
|
+
type: 'skip',
|
|
14
|
+
});
|
|
15
|
+
return;
|
|
11
16
|
}
|
|
12
17
|
const queueMapDeclarationPath = getFileImportRelativePath(queueWiringsFile, queueMapDeclarationFile, packageMappings);
|
|
13
18
|
const content = [serializeQueueWrapper(queueMapDeclarationPath)];
|
|
@@ -17,8 +22,6 @@ export const pikkuQueueService = pikkuSessionlessFunc({
|
|
|
17
22
|
logCommandInfoAndTime({
|
|
18
23
|
commandStart: 'Generating queue service wrapper',
|
|
19
24
|
commandEnd: 'Generated queue service wrapper',
|
|
20
|
-
skipCondition: ({ config }) => config.queueWiringsFile === undefined,
|
|
21
|
-
skipMessage: "queueWiringsFile isn't set in the pikku config",
|
|
22
25
|
}),
|
|
23
26
|
],
|
|
24
27
|
});
|
|
@@ -16,11 +16,6 @@ export const pikkuQueue = pikkuSessionlessFunc({
|
|
|
16
16
|
logCommandInfoAndTime({
|
|
17
17
|
commandStart: 'Finding Queues',
|
|
18
18
|
commandEnd: 'Found Queues',
|
|
19
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
20
|
-
const visitState = await getInspectorState();
|
|
21
|
-
return visitState.queueWorkers.files.size === 0;
|
|
22
|
-
},
|
|
23
|
-
skipMessage: 'none found',
|
|
24
19
|
}),
|
|
25
20
|
],
|
|
26
21
|
});
|
|
@@ -13,11 +13,6 @@ export const pikkuQueueMap = pikkuSessionlessFunc({
|
|
|
13
13
|
logCommandInfoAndTime({
|
|
14
14
|
commandStart: 'Creating Queue map',
|
|
15
15
|
commandEnd: 'Created Queue map',
|
|
16
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
17
|
-
const { queueWorkers } = await getInspectorState();
|
|
18
|
-
return queueWorkers.files.size === 0;
|
|
19
|
-
},
|
|
20
|
-
skipMessage: 'none found',
|
|
21
16
|
}),
|
|
22
17
|
],
|
|
23
18
|
});
|
|
@@ -10,16 +10,12 @@ export const pikkuQueue = pikkuSessionlessFunc({
|
|
|
10
10
|
const { queueWorkers } = visitState;
|
|
11
11
|
await writeFileInDir(logger, queueWorkersWiringMetaFile, serializeQueueMeta(queueWorkers.meta));
|
|
12
12
|
await writeFileInDir(logger, queueWorkersWiringFile, serializeFileImports('addQueueWorkers', queueWorkersWiringFile, queueWorkers.files, packageMappings));
|
|
13
|
+
return true;
|
|
13
14
|
},
|
|
14
15
|
middleware: [
|
|
15
16
|
logCommandInfoAndTime({
|
|
16
17
|
commandStart: 'Finding queues',
|
|
17
18
|
commandEnd: 'Found queue',
|
|
18
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
19
|
-
const { queueWorkers } = await getInspectorState();
|
|
20
|
-
return queueWorkers.files.size === 0;
|
|
21
|
-
},
|
|
22
|
-
skipMessage: 'none found',
|
|
23
19
|
}),
|
|
24
20
|
],
|
|
25
21
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { queueWorkersMeta } from '@pikku/core';
|
|
1
|
+
import { queueWorkersMeta } from '@pikku/core/queue';
|
|
2
2
|
export declare const serializeQueueMeta: (queueWorkersMeta: queueWorkersMeta) => string;
|
|
@@ -6,9 +6,13 @@ import { serializeRPCWrapper } from './serialize-rpc-wrapper.js';
|
|
|
6
6
|
export const pikkuRPCClient = pikkuSessionlessFunc({
|
|
7
7
|
func: async ({ logger, config }) => {
|
|
8
8
|
const { rpcWiringsFile, rpcMapDeclarationFile, packageMappings } = config;
|
|
9
|
+
// If rpcWiringsFile is not set, clean up any existing file and return
|
|
9
10
|
if (!rpcWiringsFile) {
|
|
11
|
+
logger.info({
|
|
12
|
+
message: "Skipping generating RPC wrappers since rpcWiringsFile isn't set in the pikku config.",
|
|
13
|
+
type: 'skip',
|
|
14
|
+
});
|
|
10
15
|
return;
|
|
11
|
-
// TODO: throw new Error("rpcWiringsFile isn't set in the pikku config")
|
|
12
16
|
}
|
|
13
17
|
const rpcMapDeclarationPath = getFileImportRelativePath(rpcWiringsFile, rpcMapDeclarationFile, packageMappings);
|
|
14
18
|
const content = [serializeRPCWrapper(rpcMapDeclarationPath)];
|
|
@@ -18,8 +22,6 @@ export const pikkuRPCClient = pikkuSessionlessFunc({
|
|
|
18
22
|
logCommandInfoAndTime({
|
|
19
23
|
commandStart: 'Generating RPC wrappers',
|
|
20
24
|
commandEnd: 'Generated RPC wrappers',
|
|
21
|
-
skipCondition: ({ config }) => config.rpcWiringsFile === undefined,
|
|
22
|
-
skipMessage: "rpcWiringsFile isn't set in the pikku config",
|
|
23
25
|
}),
|
|
24
26
|
],
|
|
25
27
|
});
|
|
@@ -13,8 +13,6 @@ export const pikkuRPCInternalMap = pikkuSessionlessFunc({
|
|
|
13
13
|
logCommandInfoAndTime({
|
|
14
14
|
commandStart: 'Creating RPC internal map',
|
|
15
15
|
commandEnd: 'Created RPC internal map',
|
|
16
|
-
skipCondition: false,
|
|
17
|
-
skipMessage: '',
|
|
18
16
|
}),
|
|
19
17
|
],
|
|
20
18
|
});
|
|
@@ -29,8 +27,6 @@ export const pikkuRPCExposedMap = pikkuSessionlessFunc({
|
|
|
29
27
|
logCommandInfoAndTime({
|
|
30
28
|
commandStart: 'Creating RPC external map',
|
|
31
29
|
commandEnd: 'Created RPC external map',
|
|
32
|
-
skipCondition: false,
|
|
33
|
-
skipMessage: '',
|
|
34
30
|
}),
|
|
35
31
|
],
|
|
36
32
|
});
|
|
@@ -16,11 +16,6 @@ export const pikkuScheduler = pikkuSessionlessFunc({
|
|
|
16
16
|
logCommandInfoAndTime({
|
|
17
17
|
commandStart: 'Finding Scheduled tasks',
|
|
18
18
|
commandEnd: 'Found Scheduled tasks',
|
|
19
|
-
skipCondition: async ({ getInspectorState }) => {
|
|
20
|
-
const visitState = await getInspectorState();
|
|
21
|
-
return visitState.scheduledTasks.files.size === 0;
|
|
22
|
-
},
|
|
23
|
-
skipMessage: 'none found',
|
|
24
19
|
}),
|
|
25
20
|
],
|
|
26
21
|
});
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Services } from '../../types/application-types.js';
|
|
2
2
|
import type { PikkuInteraction } from '@pikku/core';
|
|
3
3
|
type PikkuMiddleware = (services: Services, interaction: PikkuInteraction, next: () => Promise<void>) => Promise<void>;
|
|
4
4
|
export interface LogCommandInfoOptions {
|
|
5
5
|
commandStart: string;
|
|
6
6
|
commandEnd: string;
|
|
7
|
-
skipCondition?: boolean | ((services: SingletonServices) => boolean | Promise<boolean>);
|
|
8
|
-
skipMessage?: string;
|
|
9
7
|
}
|
|
10
8
|
/**
|
|
11
9
|
* Middleware to log command execution timing and status
|
|
12
10
|
* Replaces the logCommandInfoAndTime wrapper function
|
|
13
|
-
*
|
|
14
|
-
* The skipCondition can be:
|
|
15
|
-
* - A boolean valuewe
|
|
16
|
-
* - A function that receives services and returns a boolean (can access getInspectorState)
|
|
17
11
|
*/
|
|
18
|
-
export declare const logCommandInfoAndTime: ({ commandStart, commandEnd,
|
|
12
|
+
export declare const logCommandInfoAndTime: ({ commandStart, commandEnd, }: LogCommandInfoOptions) => PikkuMiddleware;
|
|
19
13
|
export {};
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Middleware to log command execution timing and status
|
|
3
3
|
* Replaces the logCommandInfoAndTime wrapper function
|
|
4
|
-
*
|
|
5
|
-
* The skipCondition can be:
|
|
6
|
-
* - A boolean valuewe
|
|
7
|
-
* - A function that receives services and returns a boolean (can access getInspectorState)
|
|
8
4
|
*/
|
|
9
|
-
export const logCommandInfoAndTime = ({ commandStart, commandEnd,
|
|
10
|
-
return async ({ logger
|
|
11
|
-
// Evaluate skip condition (can be boolean or function)
|
|
12
|
-
const shouldSkip = typeof skipCondition === 'function'
|
|
13
|
-
? await skipCondition({ logger, ...services })
|
|
14
|
-
: skipCondition;
|
|
15
|
-
if (shouldSkip === true) {
|
|
16
|
-
logger.info(`• Skipping ${commandStart.charAt(0).toLocaleLowerCase()}${commandStart.slice(1)} since ${skipMessage}.`);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
5
|
+
export const logCommandInfoAndTime = ({ commandStart, commandEnd, }) => {
|
|
6
|
+
return async ({ logger }, _interaction, next) => {
|
|
19
7
|
// Log start
|
|
20
8
|
const start = Date.now();
|
|
21
9
|
logger.info(`• ${commandStart}...`);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { Logger, LogLevel
|
|
1
|
+
import { Logger, LogLevel } from '@pikku/core';
|
|
2
|
+
import { PikkuChannel } from '@pikku/core/channel';
|
|
3
|
+
import { ErrorCode } from '@pikku/inspector';
|
|
2
4
|
/**
|
|
3
5
|
* Log message structure sent through the channel
|
|
4
6
|
*/
|
|
@@ -15,7 +17,7 @@ export declare class CLILoggerForwarder implements Logger {
|
|
|
15
17
|
private logger;
|
|
16
18
|
private channel;
|
|
17
19
|
private level;
|
|
18
|
-
constructor(logger: Logger, channel: PikkuChannel<unknown,
|
|
20
|
+
constructor(logger: Logger, channel: PikkuChannel<unknown, any>);
|
|
19
21
|
setLevel(level: LogLevel): void;
|
|
20
22
|
private log;
|
|
21
23
|
info(messageOrObj: string | Record<string, any>, ..._meta: any[]): void;
|
|
@@ -23,4 +25,6 @@ export declare class CLILoggerForwarder implements Logger {
|
|
|
23
25
|
warn(messageOrObj: string | Record<string, any>, ..._meta: any[]): void;
|
|
24
26
|
debug(message: string, ..._meta: any[]): void;
|
|
25
27
|
trace(message: string, ..._meta: any[]): void;
|
|
28
|
+
critical(code: ErrorCode, message: string): void;
|
|
29
|
+
hasCriticalErrors(): boolean;
|
|
26
30
|
}
|
|
@@ -52,4 +52,13 @@ export class CLILoggerForwarder {
|
|
|
52
52
|
trace(message, ..._meta) {
|
|
53
53
|
this.log('trace', LogLevel.trace, message);
|
|
54
54
|
}
|
|
55
|
+
critical(code, message) {
|
|
56
|
+
const url = `https://pikku.dev/docs/cli-errors/${code.toLowerCase()}`;
|
|
57
|
+
const formattedMessage = `[${code}] ${message}\n → ${url}`;
|
|
58
|
+
this.error(formattedMessage);
|
|
59
|
+
}
|
|
60
|
+
hasCriticalErrors() {
|
|
61
|
+
// The underlying logger (CLILogger) tracks critical errors
|
|
62
|
+
return this.logger.hasCriticalErrors?.() ?? false;
|
|
63
|
+
}
|
|
55
64
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Logger, LogLevel } from '@pikku/core';
|
|
2
|
+
import { ErrorCode } from '@pikku/inspector';
|
|
2
3
|
export declare class CLILogger implements Logger {
|
|
3
4
|
private silent;
|
|
4
5
|
private level;
|
|
6
|
+
private criticalErrors;
|
|
5
7
|
constructor({ logLogo, silent, }: {
|
|
6
8
|
logLogo: boolean;
|
|
7
9
|
silent?: boolean;
|
|
@@ -14,6 +16,8 @@ export declare class CLILogger implements Logger {
|
|
|
14
16
|
error(message: string): void;
|
|
15
17
|
warn(message: string): void;
|
|
16
18
|
debug(message: string): void;
|
|
19
|
+
critical(code: ErrorCode, message: string): void;
|
|
20
|
+
hasCriticalErrors(): boolean;
|
|
17
21
|
private logPikkuLogo;
|
|
18
22
|
private primary;
|
|
19
23
|
}
|
|
@@ -8,9 +8,11 @@ const logo = `
|
|
|
8
8
|
| | | | _ (| _ (| _ (| |_| |
|
|
9
9
|
|_| |_|_| _)_| _)____/
|
|
10
10
|
`;
|
|
11
|
+
const BASE_ERROR_URL = 'https://pikku.dev/errors';
|
|
11
12
|
export class CLILogger {
|
|
12
13
|
silent;
|
|
13
14
|
level = LogLevel.info;
|
|
15
|
+
criticalErrors = [];
|
|
14
16
|
constructor({ logLogo, silent = false, }) {
|
|
15
17
|
this.silent = silent;
|
|
16
18
|
if (logLogo && !silent) {
|
|
@@ -49,6 +51,15 @@ export class CLILogger {
|
|
|
49
51
|
return;
|
|
50
52
|
console.log(chalk.gray(message));
|
|
51
53
|
}
|
|
54
|
+
critical(code, message) {
|
|
55
|
+
const url = `${BASE_ERROR_URL}/${code.toLowerCase()}`;
|
|
56
|
+
const formattedMessage = `[${code}] ${message}\n → ${url}`;
|
|
57
|
+
this.criticalErrors.push(formattedMessage);
|
|
58
|
+
console.error(chalk.red.bold(formattedMessage));
|
|
59
|
+
}
|
|
60
|
+
hasCriticalErrors() {
|
|
61
|
+
return this.criticalErrors.length > 0;
|
|
62
|
+
}
|
|
52
63
|
logPikkuLogo() {
|
|
53
64
|
this.primary(logo);
|
|
54
65
|
// // When running from dist/, __filename is dist/src/services/cli-logger.service.js
|
package/dist/src/services.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ import { ForwardedLogMessage } from './services/cli-logger-forwarder.service.js'
|
|
|
6
6
|
* Default CLI renderer that logs output using the logger
|
|
7
7
|
*/
|
|
8
8
|
export declare const defaultCLIRenderer: import("@pikku/core").CorePikkuCLIRender<ForwardedLogMessage, SingletonServices, import("@pikku/core").CoreUserSession>;
|
|
9
|
+
/**
|
|
10
|
+
* Client-safe CLI renderer that outputs to console (no service dependencies)
|
|
11
|
+
* This renderer can be used in CLI-over-channel clients
|
|
12
|
+
*/
|
|
13
|
+
export declare const clientCLIRenderer: import("@pikku/core").CorePikkuCLIRender<ForwardedLogMessage, import("@pikku/core").CoreServices, import("@pikku/core").CoreUserSession>;
|
|
9
14
|
export declare const createConfig: CreateConfig<Config, [PikkuCLIConfig]>;
|
|
10
15
|
/**
|
|
11
16
|
* Singleton services factory for the Pikku CLI
|
package/dist/src/services.js
CHANGED
|
@@ -1,12 +1,65 @@
|
|
|
1
|
-
import { pikkuCLIRender
|
|
1
|
+
import { pikkuCLIRender } from '@pikku/core/cli';
|
|
2
2
|
import { LocalVariablesService } from '@pikku/core/services';
|
|
3
3
|
import { CLILogger } from './services/cli-logger.service.js';
|
|
4
4
|
import { getPikkuCLIConfig } from './utils/pikku-cli-config.js';
|
|
5
|
-
import { inspect } from '@pikku/inspector';
|
|
5
|
+
import { inspect, serializeInspectorState, deserializeInspectorState, filterInspectorState, } from '@pikku/inspector';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { CLILoggerForwarder, } from './services/cli-logger-forwarder.service.js';
|
|
9
|
+
import { readFile, writeFile } from 'fs/promises';
|
|
9
10
|
const logger = new CLILogger({ logLogo: true, silent: false });
|
|
11
|
+
/**
|
|
12
|
+
* Parse a comma-separated string or array into an array of trimmed, non-empty strings
|
|
13
|
+
* Returns undefined if the input is empty/undefined or results in an empty array
|
|
14
|
+
*/
|
|
15
|
+
function parseCommaSeparated(value) {
|
|
16
|
+
if (!value)
|
|
17
|
+
return undefined;
|
|
18
|
+
// If already an array, flatten and split any comma-separated values
|
|
19
|
+
if (Array.isArray(value)) {
|
|
20
|
+
const flattened = value
|
|
21
|
+
.flatMap((item) => item.split(','))
|
|
22
|
+
.map((item) => item.trim())
|
|
23
|
+
.filter((item) => item.length > 0);
|
|
24
|
+
return flattened.length > 0 ? flattened : undefined;
|
|
25
|
+
}
|
|
26
|
+
// If string, split by comma
|
|
27
|
+
const parsed = value
|
|
28
|
+
.split(',')
|
|
29
|
+
.map((item) => item.trim())
|
|
30
|
+
.filter((item) => item.length > 0);
|
|
31
|
+
return parsed.length > 0 ? parsed : undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Parse CLI filter arguments into InspectorFilters format
|
|
35
|
+
*/
|
|
36
|
+
function parseCLIFilters(data) {
|
|
37
|
+
const filters = {};
|
|
38
|
+
if (data.filters) {
|
|
39
|
+
return JSON.parse(data.filters);
|
|
40
|
+
}
|
|
41
|
+
// Parse each filter type from CLI arguments
|
|
42
|
+
const names = parseCommaSeparated(data.names);
|
|
43
|
+
const tags = parseCommaSeparated(data.tags);
|
|
44
|
+
const types = parseCommaSeparated(data.types);
|
|
45
|
+
const directories = parseCommaSeparated(data.directories);
|
|
46
|
+
const httpRoutes = parseCommaSeparated(data.httpRoutes);
|
|
47
|
+
const httpMethods = parseCommaSeparated(data.httpMethods);
|
|
48
|
+
// Only include non-undefined values in the result
|
|
49
|
+
if (names)
|
|
50
|
+
filters.names = names;
|
|
51
|
+
if (tags)
|
|
52
|
+
filters.tags = tags;
|
|
53
|
+
if (types)
|
|
54
|
+
filters.types = types;
|
|
55
|
+
if (directories)
|
|
56
|
+
filters.directories = directories;
|
|
57
|
+
if (httpRoutes)
|
|
58
|
+
filters.httpRoutes = httpRoutes;
|
|
59
|
+
if (httpMethods)
|
|
60
|
+
filters.httpMethods = httpMethods;
|
|
61
|
+
return filters;
|
|
62
|
+
}
|
|
10
63
|
/**
|
|
11
64
|
* Default CLI renderer that logs output using the logger
|
|
12
65
|
*/
|
|
@@ -15,11 +68,39 @@ export const defaultCLIRenderer = pikkuCLIRender((_services, data) => {
|
|
|
15
68
|
logger[data.level]({ message: data.message, type: data.type });
|
|
16
69
|
}
|
|
17
70
|
});
|
|
71
|
+
/**
|
|
72
|
+
* Client-safe CLI renderer that outputs to console (no service dependencies)
|
|
73
|
+
* This renderer can be used in CLI-over-channel clients
|
|
74
|
+
*/
|
|
75
|
+
export const clientCLIRenderer = pikkuCLIRender((_services, data) => {
|
|
76
|
+
if (data) {
|
|
77
|
+
// Simple console output without service dependencies
|
|
78
|
+
const prefix = data.type ? `[${data.type}] ` : '';
|
|
79
|
+
console.log(`${prefix}${data.message}`);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
18
82
|
export const createConfig = async (_variablesService, data) => {
|
|
19
|
-
const cliConfig = await getPikkuCLIConfig(logger, data.configFile, [],
|
|
83
|
+
const cliConfig = await getPikkuCLIConfig(logger, data.configFile, [], true);
|
|
84
|
+
// Load inspector state from file if stateInput is provided
|
|
85
|
+
let preloadedInspectorState = undefined;
|
|
86
|
+
if (data.stateInput) {
|
|
87
|
+
try {
|
|
88
|
+
logger.info(`Loading inspector state from ${data.stateInput}`);
|
|
89
|
+
const stateJson = await readFile(data.stateInput, 'utf-8');
|
|
90
|
+
const serializedState = JSON.parse(stateJson);
|
|
91
|
+
preloadedInspectorState = deserializeInspectorState(serializedState);
|
|
92
|
+
logger.info(`Inspector state loaded successfully`);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
logger.error(`Failed to load inspector state from ${data.stateInput}: ${error.message}`);
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
20
99
|
return {
|
|
21
100
|
...cliConfig,
|
|
22
101
|
...data,
|
|
102
|
+
filters: parseCLIFilters(data),
|
|
103
|
+
preloadedInspectorState,
|
|
23
104
|
};
|
|
24
105
|
};
|
|
25
106
|
/**
|
|
@@ -27,24 +108,41 @@ export const createConfig = async (_variablesService, data) => {
|
|
|
27
108
|
* This function creates the singleton services used by the CLI and is created once on start.
|
|
28
109
|
*/
|
|
29
110
|
export const createSingletonServices = async (config) => {
|
|
30
|
-
const { rootDir, srcDirectories, filters } = config;
|
|
111
|
+
const { rootDir, srcDirectories, filters, preloadedInspectorState, stateOutput, } = config;
|
|
31
112
|
const variables = new LocalVariablesService();
|
|
32
|
-
|
|
113
|
+
// Store unfiltered state
|
|
114
|
+
let unfilteredState = preloadedInspectorState;
|
|
33
115
|
const getInspectorState = async (refresh = false) => {
|
|
34
|
-
|
|
116
|
+
// Get or refresh the unfiltered state
|
|
117
|
+
if (!unfilteredState || refresh) {
|
|
118
|
+
// Run inspector WITHOUT filters to get full state
|
|
35
119
|
const wiringFiles = (await Promise.all(srcDirectories.map((dir) => glob(`${path.join(rootDir, dir)}/**/*.ts`)))).flat();
|
|
36
|
-
|
|
37
|
-
filters
|
|
120
|
+
unfilteredState = await inspect(logger, wiringFiles, {
|
|
121
|
+
// NO filters here - inspector returns full unfiltered state
|
|
38
122
|
types: {
|
|
39
123
|
configFileType: config.configFile,
|
|
40
|
-
userSessionType: config.
|
|
41
|
-
singletonServicesFactoryType:
|
|
42
|
-
sessionServicesFactoryType:
|
|
124
|
+
userSessionType: config.userSessionType,
|
|
125
|
+
singletonServicesFactoryType: config.singletonServicesFactoryType,
|
|
126
|
+
sessionServicesFactoryType: config.sessionServicesFactoryType,
|
|
43
127
|
},
|
|
44
128
|
});
|
|
45
|
-
|
|
129
|
+
// Save unfiltered inspector state to file if stateOutput is provided
|
|
130
|
+
if (stateOutput && 'typesLookup' in unfilteredState) {
|
|
131
|
+
try {
|
|
132
|
+
logger.info(`Saving inspector state to ${stateOutput}`);
|
|
133
|
+
const serialized = serializeInspectorState(unfilteredState);
|
|
134
|
+
await writeFile(stateOutput, JSON.stringify(serialized, null, 2), 'utf-8');
|
|
135
|
+
logger.info(`Inspector state saved successfully`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
logger.error(`Failed to save inspector state to ${stateOutput}: ${error.message}`);
|
|
139
|
+
// Don't throw - state saving is optional/nice-to-have
|
|
140
|
+
}
|
|
141
|
+
}
|
|
46
142
|
}
|
|
47
|
-
|
|
143
|
+
// Apply filters as a post-processing step
|
|
144
|
+
const filteredState = filterInspectorState(unfilteredState, filters, logger);
|
|
145
|
+
return filteredState;
|
|
48
146
|
};
|
|
49
147
|
return {
|
|
50
148
|
config,
|
|
@@ -4,8 +4,14 @@ export function generateCustomTypes(typesMap, requiredTypes) {
|
|
|
4
4
|
// or are broken into simpler types
|
|
5
5
|
${Array.from(typesMap.customTypes.entries())
|
|
6
6
|
.map(([name, { type, references }]) => {
|
|
7
|
-
references.forEach((
|
|
8
|
-
|
|
7
|
+
references.forEach((refName) => {
|
|
8
|
+
// Skip __object types (including those with suffixes like __object_abc123)
|
|
9
|
+
// These are placeholder types created by the inspector for invalid/broken functions
|
|
10
|
+
// (e.g., functions with type errors or missing return statements). Attempting to
|
|
11
|
+
// import these would fail since the source files don't actually export __object.
|
|
12
|
+
if (refName !== '__object' && !refName.startsWith('__object_')) {
|
|
13
|
+
requiredTypes.add(refName);
|
|
14
|
+
}
|
|
9
15
|
});
|
|
10
16
|
// Extract type names from the type string that might not be in references
|
|
11
17
|
const typeString = type;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { CLILogger } from '../services/cli-logger.service.js';
|
|
2
|
-
export declare const DO_NOT_MODIFY_COMMENT
|
|
2
|
+
export declare const DO_NOT_MODIFY_COMMENT: string;
|
|
3
3
|
export declare const writeFileInDir: (logger: CLILogger, path: string, content: string, { ignoreModifyComment, logWrite, }?: {
|
|
4
4
|
ignoreModifyComment?: boolean;
|
|
5
5
|
logWrite?: boolean;
|
|
6
6
|
}) => Promise<void>;
|
|
7
|
+
export declare const removeFileInDir: (logger: CLILogger, path: string, { logRemove }?: {
|
|
8
|
+
logRemove?: boolean;
|
|
9
|
+
}) => Promise<void>;
|