@pikku/cli 0.12.0 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.schema.json +1 -1
- package/console-app/assets/index-DRJQtv3c.js +676 -0
- package/console-app/index.html +6 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +30 -3
- package/dist/.pikku/agent/pikku-agent-types.gen.js +13 -0
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +2 -2
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +2 -2
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +77 -3
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +2 -2
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +280 -10
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +14 -11
- package/dist/.pikku/function/pikku-function-types.gen.js +25 -13
- package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions-meta.gen.json +426 -93
- package/dist/.pikku/function/pikku-functions.gen.js +5 -3
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +2 -2
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +2 -2
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -2
- package/dist/.pikku/pikku-services.gen.d.ts +2 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +2 -2
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +16 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +2 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +15 -3
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuGatewayOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewAddonInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewFunctionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewMiddlewareInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewPermissionInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuNewWiringInput.schema.json +1 -0
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +2 -2
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/cli.wiring.js +236 -9
- package/dist/src/functions/commands/all.js +13 -8
- package/dist/src/functions/commands/enable.d.ts +4 -0
- package/dist/src/functions/commands/enable.js +39 -0
- package/dist/src/functions/commands/info.d.ts +9 -0
- package/dist/src/functions/commands/info.js +283 -0
- package/dist/src/functions/commands/new-addon.d.ts +34 -0
- package/dist/src/functions/commands/new-addon.js +636 -0
- package/dist/src/functions/commands/new-function.d.ts +10 -0
- package/dist/src/functions/commands/new-function.js +79 -0
- package/dist/src/functions/commands/new-middleware.d.ts +10 -0
- package/dist/src/functions/commands/new-middleware.js +48 -0
- package/dist/src/functions/commands/new-permission.d.ts +10 -0
- package/dist/src/functions/commands/new-permission.js +45 -0
- package/dist/src/functions/commands/new-wiring.d.ts +10 -0
- package/dist/src/functions/commands/new-wiring.js +102 -0
- package/dist/src/functions/commands/pikku-command-bootstrap.js +11 -40
- package/dist/src/functions/commands/versions-check.js +85 -3
- package/dist/src/functions/commands/versions-update.js +1 -1
- package/dist/src/functions/runtimes/fetch/index.js +2 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +4 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +0 -4
- package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.js +2 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.js +3 -2
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +5 -5
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.js +3 -5
- package/dist/src/functions/wirings/ai-agent/serialize-agent-map.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +48 -3
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +30 -52
- package/dist/src/functions/wirings/channels/pikku-channels.js +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +1 -1
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.d.ts +4 -4
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +2 -2
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +4 -5
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.js +2 -2
- package/dist/src/functions/wirings/console/serialize-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +18 -157
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.js +33 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +4 -4
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +8 -14
- package/dist/src/functions/wirings/functions/schemas.js +1 -1
- package/dist/src/functions/wirings/functions/serialize-addon-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/{serialize-external-types.js → serialize-addon-types.js} +16 -15
- package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +3 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.js +28 -14
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +2 -2
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.d.ts +1 -0
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.js +22 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/pikku-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/serialize-typed-http-map.d.ts +3 -3
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +1 -1
- package/dist/src/functions/wirings/package/pikku-command-package.js +5 -5
- package/dist/src/functions/wirings/package/serialize-package.js +2 -2
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +0 -5
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +2 -1
- package/dist/src/functions/wirings/queue/serialize-queue-map.d.ts +2 -2
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +3 -5
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +2 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +6 -6
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +2 -4
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +25 -16
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +43 -7
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +8 -3
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +41 -31
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.d.ts +1 -1
- package/dist/src/functions/wirings/secrets/serialize-secrets-types.d.ts +2 -2
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/serialize-trigger-meta.js +2 -2
- package/dist/src/functions/wirings/variables/serialize-variables-types.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +5 -12
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +2 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +2 -2
- package/dist/src/services/cli-logger-forwarder.service.d.ts +4 -3
- package/dist/src/services/cli-logger.service.d.ts +3 -2
- package/dist/src/services.d.ts +4 -3
- package/dist/src/services.js +14 -3
- package/dist/src/utils/check-required-types.d.ts +1 -1
- package/dist/src/utils/contract-versions.d.ts +1 -1
- package/dist/src/utils/file-writer.d.ts +6 -1
- package/dist/src/utils/file-writer.js +14 -1
- package/dist/src/utils/generate-bootstrap-file.d.ts +2 -2
- package/dist/src/utils/openapi/codegen.d.ts +19 -0
- package/dist/src/utils/openapi/codegen.js +288 -0
- package/dist/src/utils/openapi/naming.d.ts +30 -0
- package/dist/src/utils/openapi/naming.js +167 -0
- package/dist/src/utils/openapi/parse-openapi.d.ts +36 -0
- package/dist/src/utils/openapi/parse-openapi.js +196 -0
- package/dist/src/utils/openapi/zod-codegen.d.ts +53 -0
- package/dist/src/utils/openapi/zod-codegen.js +251 -0
- package/dist/src/utils/pikku-cli-config.d.ts +2 -2
- package/dist/src/utils/pikku-cli-config.js +51 -30
- package/dist/src/utils/pikku-files-and-methods.d.ts +1 -1
- package/dist/src/utils/pikku-files-and-methods.js +1 -1
- package/dist/src/utils/serialize-import-map.d.ts +2 -2
- package/dist/src/utils/serialize-import-map.js +1 -1
- package/dist/src/utils/serialize-meta-ts.js +1 -1
- package/dist/src/utils/serialize-schemas.d.ts +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/console-app/assets/index-C19L3UJu.js +0 -637
- package/dist/src/functions/wirings/functions/pikku-command-external-types.d.ts +0 -1
- package/dist/src/functions/wirings/functions/pikku-command-external-types.js +0 -33
- package/dist/src/functions/wirings/functions/serialize-external-types.d.ts +0 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import { TypesMap
|
|
2
|
-
import { Logger } from '@pikku/core/services';
|
|
1
|
+
import type { TypesMap } from '@pikku/inspector';
|
|
2
|
+
import type { Logger } from '@pikku/core/services';
|
|
3
|
+
type WireAddonDeclarations = Map<string, {
|
|
4
|
+
package: string;
|
|
5
|
+
rpcEndpoint?: string;
|
|
6
|
+
}>;
|
|
3
7
|
export declare const serializeTypedRPCMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, rpcMeta: Record<string, string>, resolvedIOTypes: Record<string, {
|
|
4
8
|
inputType: string;
|
|
5
9
|
outputType: string;
|
|
6
|
-
}>,
|
|
10
|
+
}>, wireAddonDeclarations?: WireAddonDeclarations, workflowMapPath?: string, agentMapPath?: string) => string;
|
|
11
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serializeImportMap } from '../../../utils/serialize-import-map.js';
|
|
2
|
-
import { generateCustomTypes
|
|
3
|
-
export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, typesMap, rpcMeta, resolvedIOTypes,
|
|
2
|
+
import { generateCustomTypes } from '@pikku/inspector';
|
|
3
|
+
export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, typesMap, rpcMeta, resolvedIOTypes, wireAddonDeclarations, workflowMapPath, agentMapPath) => {
|
|
4
4
|
const requiredTypes = new Set();
|
|
5
5
|
const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes);
|
|
6
6
|
const serializedRPCs = generateRPCs(rpcMeta, resolvedIOTypes, requiredTypes);
|
|
@@ -21,8 +21,8 @@ export const serializeTypedRPCMap = (logger, relativeToPath, packageMappings, ty
|
|
|
21
21
|
.split('\n')
|
|
22
22
|
.filter((line) => !line.startsWith('import '))
|
|
23
23
|
.join('\n');
|
|
24
|
-
const
|
|
25
|
-
const mergedRPCMap = generateMergedRPCMap(
|
|
24
|
+
const addonImports = generateAddonImports(wireAddonDeclarations, relativeToPath);
|
|
25
|
+
const mergedRPCMap = generateMergedRPCMap(wireAddonDeclarations);
|
|
26
26
|
return `/**
|
|
27
27
|
* This provides the structure needed for typescript to be aware of RPCs and their return types
|
|
28
28
|
*/
|
|
@@ -37,7 +37,7 @@ interface RPCHandler<I, O> {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
${serializedRPCs}
|
|
40
|
-
${
|
|
40
|
+
${addonImports}
|
|
41
41
|
${mergedRPCMap}
|
|
42
42
|
|
|
43
43
|
export type RPCInvoke = <Name extends keyof FlattenedRPCMap>(
|
|
@@ -53,8 +53,8 @@ export type RPCRemote = <Name extends keyof FlattenedRPCMap>(
|
|
|
53
53
|
${workflowMapPath ? `import type { WorkflowMap } from '${workflowMapPath}'` : `type WorkflowMap = {}`}
|
|
54
54
|
|
|
55
55
|
${agentMapPath ? `import type { AgentMap } from '${agentMapPath}'` : `type AgentMap = {}`}
|
|
56
|
-
${
|
|
57
|
-
${generateMergedAgentMap(
|
|
56
|
+
${generateAddonAgentImports(wireAddonDeclarations)}
|
|
57
|
+
${generateMergedAgentMap(wireAddonDeclarations)}
|
|
58
58
|
|
|
59
59
|
import type { PikkuRPC } from '@pikku/core/rpc'
|
|
60
60
|
|
|
@@ -64,36 +64,46 @@ interface AIAgentInput {
|
|
|
64
64
|
resourceId: string
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
type TypedStartWorkflow = <Name extends keyof WorkflowMap>(
|
|
67
|
+
export type TypedStartWorkflow = <Name extends keyof WorkflowMap>(
|
|
68
68
|
name: Name,
|
|
69
69
|
input: WorkflowMap[Name]['input'],
|
|
70
70
|
options?: { startNode?: string }
|
|
71
71
|
) => Promise<{ runId: string }>
|
|
72
72
|
|
|
73
|
-
type
|
|
74
|
-
name:
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
type TypedAgentRun = [keyof FlattenedAgentMap] extends [never]
|
|
74
|
+
? (name: string, input: AIAgentInput) => Promise<any>
|
|
75
|
+
: <Name extends keyof FlattenedAgentMap>(
|
|
76
|
+
name: Name,
|
|
77
|
+
input: AIAgentInput
|
|
78
|
+
) => Promise<{ runId: string; result: FlattenedAgentMap[Name]['output']; usage: { inputTokens: number; outputTokens: number } }>
|
|
79
|
+
|
|
80
|
+
type TypedAgentStream = [keyof FlattenedAgentMap] extends [never]
|
|
81
|
+
? (name: string, input: AIAgentInput, options?: { requiresToolApproval?: 'all' | 'explicit' | false }) => Promise<void>
|
|
82
|
+
: <Name extends keyof FlattenedAgentMap>(
|
|
83
|
+
name: Name,
|
|
84
|
+
input: AIAgentInput,
|
|
85
|
+
options?: { requiresToolApproval?: 'all' | 'explicit' | false }
|
|
86
|
+
) => Promise<void>
|
|
77
87
|
|
|
78
|
-
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow,
|
|
88
|
+
export type TypedPikkuRPC = PikkuRPC<RPCInvoke, RPCRemote, TypedStartWorkflow, TypedAgentRun, TypedAgentStream>
|
|
79
89
|
`;
|
|
80
90
|
};
|
|
81
|
-
function
|
|
82
|
-
if (!
|
|
91
|
+
function generateAddonImports(wireAddonDeclarations, relativeToPath) {
|
|
92
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
83
93
|
return '';
|
|
84
94
|
}
|
|
85
|
-
let imports = '\n//
|
|
86
|
-
for (const [namespace,
|
|
87
|
-
// Import the RPCMap from each
|
|
95
|
+
let imports = '\n// Addon package RPC maps\n';
|
|
96
|
+
for (const [namespace, decl] of wireAddonDeclarations.entries()) {
|
|
97
|
+
// Import the RPCMap from each addon package's internal RPC map
|
|
88
98
|
// Use .js extension - package.json exports will resolve to .d.ts for types
|
|
89
|
-
imports += `import type { RPCMap as ${toPascalCase(namespace)}RPCMap } from '${
|
|
99
|
+
imports += `import type { RPCMap as ${toPascalCase(namespace)}RPCMap } from '${decl.package}/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.js'\n`;
|
|
90
100
|
}
|
|
91
101
|
return imports;
|
|
92
102
|
}
|
|
93
|
-
function generateMergedRPCMap(
|
|
94
|
-
if (!
|
|
103
|
+
function generateMergedRPCMap(wireAddonDeclarations) {
|
|
104
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
95
105
|
return `
|
|
96
|
-
// No
|
|
106
|
+
// No addon packages, use RPCMap directly
|
|
97
107
|
export type FlattenedRPCMap = RPCMap
|
|
98
108
|
`;
|
|
99
109
|
}
|
|
@@ -106,7 +116,7 @@ type PrefixKeys<T, Prefix extends string> = {
|
|
|
106
116
|
|
|
107
117
|
// Merge all RPC maps with namespace prefixes
|
|
108
118
|
export type FlattenedRPCMap =
|
|
109
|
-
RPCMap${
|
|
119
|
+
RPCMap${Array.from(wireAddonDeclarations.keys())
|
|
110
120
|
.map((namespace) => ` & PrefixKeys<${toPascalCase(namespace)}RPCMap, '${namespace}'>`)
|
|
111
121
|
.join('')}
|
|
112
122
|
`;
|
|
@@ -118,25 +128,25 @@ function toPascalCase(str) {
|
|
|
118
128
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
119
129
|
.join('');
|
|
120
130
|
}
|
|
121
|
-
function
|
|
122
|
-
if (!
|
|
131
|
+
function generateAddonAgentImports(wireAddonDeclarations) {
|
|
132
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
123
133
|
return '';
|
|
124
134
|
}
|
|
125
|
-
let imports = '\n//
|
|
126
|
-
for (const [namespace,
|
|
127
|
-
imports += `import type { AgentMap as ${toPascalCase(namespace)}AgentMap } from '${
|
|
135
|
+
let imports = '\n// Addon package Agent maps\n';
|
|
136
|
+
for (const [namespace, decl] of wireAddonDeclarations.entries()) {
|
|
137
|
+
imports += `import type { AgentMap as ${toPascalCase(namespace)}AgentMap } from '${decl.package}/.pikku/agent/pikku-agent-map.gen.d.js'\n`;
|
|
128
138
|
}
|
|
129
139
|
return imports;
|
|
130
140
|
}
|
|
131
|
-
function generateMergedAgentMap(
|
|
132
|
-
if (!
|
|
141
|
+
function generateMergedAgentMap(wireAddonDeclarations) {
|
|
142
|
+
if (!wireAddonDeclarations || wireAddonDeclarations.size === 0) {
|
|
133
143
|
return `
|
|
134
144
|
type FlattenedAgentMap = AgentMap
|
|
135
145
|
`;
|
|
136
146
|
}
|
|
137
147
|
return `
|
|
138
148
|
type FlattenedAgentMap =
|
|
139
|
-
AgentMap${
|
|
149
|
+
AgentMap${Array.from(wireAddonDeclarations.keys())
|
|
140
150
|
.map((namespace) => ` & PrefixKeys<${toPascalCase(namespace)}AgentMap, '${namespace}'>`)
|
|
141
151
|
.join('')}
|
|
142
152
|
`;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ScheduledTasksMeta } from '@pikku/core/scheduler';
|
|
1
|
+
import type { ScheduledTasksMeta } from '@pikku/core/scheduler';
|
|
2
2
|
export declare const serializeSchedulerMeta: (scheduledTasksMeta: ScheduledTasksMeta) => ScheduledTasksMeta;
|
|
3
3
|
export declare const serializeSchedulerMetaTS: (scheduledTasksMeta: ScheduledTasksMeta, jsonImportPath: string, supportsImportAttributes: boolean) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { SecretDefinitions } from '@pikku/core/secret';
|
|
2
|
-
import { SchemaRef } from '@pikku/inspector';
|
|
1
|
+
import type { SecretDefinitions } from '@pikku/core/secret';
|
|
2
|
+
import type { SchemaRef } from '@pikku/inspector';
|
|
3
3
|
export interface SerializeSecretsOptions {
|
|
4
4
|
definitions: SecretDefinitions;
|
|
5
5
|
schemaLookup: Map<string, SchemaRef>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
|
|
1
|
+
import type { TriggerMeta, TriggerSourceMeta } from '@pikku/core/trigger';
|
|
2
2
|
export declare const serializeTriggerMeta: (triggerMeta: TriggerMeta) => TriggerMeta;
|
|
3
3
|
export declare const serializeTriggerMetaTS: (triggerMeta: TriggerMeta, jsonImportPath: string, supportsImportAttributes: boolean) => string;
|
|
4
4
|
export declare const serializeTriggerSourceMeta: (sourceMeta: TriggerSourceMeta) => TriggerSourceMeta;
|
|
@@ -6,7 +6,7 @@ export const serializeTriggerMetaTS = (triggerMeta, jsonImportPath, supportsImpo
|
|
|
6
6
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
7
7
|
: `import metaData from '${jsonImportPath}'`;
|
|
8
8
|
const serializedOutput = [];
|
|
9
|
-
serializedOutput.push("import { pikkuState } from '@pikku/core'");
|
|
9
|
+
serializedOutput.push("import { pikkuState } from '@pikku/core/internal'");
|
|
10
10
|
serializedOutput.push("import { TriggerMeta } from '@pikku/core/trigger'");
|
|
11
11
|
serializedOutput.push(importStatement);
|
|
12
12
|
serializedOutput.push('');
|
|
@@ -26,7 +26,7 @@ export const serializeTriggerSourceMetaTS = (sourceMeta, jsonImportPath, support
|
|
|
26
26
|
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
27
27
|
: `import metaData from '${jsonImportPath}'`;
|
|
28
28
|
const serializedOutput = [];
|
|
29
|
-
serializedOutput.push("import { pikkuState } from '@pikku/core'");
|
|
29
|
+
serializedOutput.push("import { pikkuState } from '@pikku/core/internal'");
|
|
30
30
|
serializedOutput.push("import { TriggerSourceMeta } from '@pikku/core/trigger'");
|
|
31
31
|
serializedOutput.push(importStatement);
|
|
32
32
|
serializedOutput.push('');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { VariableDefinitions } from '@pikku/core/variable';
|
|
2
|
-
import { SchemaRef } from '@pikku/inspector';
|
|
1
|
+
import type { VariableDefinitions } from '@pikku/core/variable';
|
|
2
|
+
import type { SchemaRef } from '@pikku/inspector';
|
|
3
3
|
export interface SerializeVariablesOptions {
|
|
4
4
|
definitions: VariableDefinitions;
|
|
5
5
|
schemaLookup: Map<string, SchemaRef>;
|
|
@@ -37,25 +37,18 @@ export const pikkuWorkflow = pikkuSessionlessFunc({
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
if (workflowsWiringMetaFile && workflowMetaDir) {
|
|
40
|
-
await writeFileInDir(logger, workflowsWiringMetaFile, serializeWorkflowMeta(workflowsWiringMetaFile, workflowMetaDir, allWorkflowNames, packageMappings, schema?.supportsImportAttributes ?? false, config.
|
|
40
|
+
await writeFileInDir(logger, workflowsWiringMetaFile, serializeWorkflowMeta(workflowsWiringMetaFile, workflowMetaDir, allWorkflowNames, packageMappings, schema?.supportsImportAttributes ?? false, config.addonName));
|
|
41
41
|
}
|
|
42
42
|
const metaImportPath = getFileImportRelativePath(workflowsWiringFile, workflowsWiringMetaFile, packageMappings);
|
|
43
|
-
await writeFileInDir(logger, workflowsWiringFile, serializeWorkflowRegistration(workflowsWiringFile, metaImportPath, allWorkflowNames, workflows.files, workflows.graphFiles, packageMappings, config.
|
|
43
|
+
await writeFileInDir(logger, workflowsWiringFile, serializeWorkflowRegistration(workflowsWiringFile, metaImportPath, allWorkflowNames, workflows.files, workflows.graphFiles, packageMappings, config.addonName));
|
|
44
44
|
const functionTypesImportPath = getFileImportRelativePath(workflowTypesFile, functionTypesFile, packageMappings);
|
|
45
45
|
const rpcMapImportPath = getFileImportRelativePath(workflowTypesFile, config.rpcInternalMapDeclarationFile, packageMappings);
|
|
46
46
|
const workflowMapImportPath = getFileImportRelativePath(workflowTypesFile, workflowMapDeclarationFile, packageMappings);
|
|
47
47
|
await writeFileInDir(logger, workflowTypesFile, serializeWorkflowTypes(functionTypesImportPath, rpcMapImportPath, workflowMapImportPath));
|
|
48
48
|
await writeFileInDir(logger, workflowMapDeclarationFile, serializeWorkflowMap(logger, workflowMapDeclarationFile, packageMappings, typesMap, functionState.meta, workflows.meta, workflows.graphMeta));
|
|
49
|
-
if (config.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const pathToPikkuTypes = getFileImportRelativePath(workflowPath, typesDeclarationFile, packageMappings);
|
|
53
|
-
await writeFileInDir(logger, workflowPath, serializeWorkflowWorkers(pathToPikkuTypes));
|
|
54
|
-
}
|
|
55
|
-
else if (workflows.files.size > 0) {
|
|
56
|
-
logger.critical(ErrorCode.WORKFLOW_MULTI_QUEUE_NOT_SUPPORTED, 'Multi-queue workflows are not supported when workflows.singleQueue is false. Please enable singleQueue in your configuration.');
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
49
|
+
if (config.scaffold?.workflow) {
|
|
50
|
+
const pathToPikkuTypes = getFileImportRelativePath(config.workflowWorkersFile, typesDeclarationFile, packageMappings);
|
|
51
|
+
await writeFileInDir(logger, config.workflowWorkersFile, serializeWorkflowWorkers(pathToPikkuTypes));
|
|
59
52
|
}
|
|
60
53
|
return hasWorkflows;
|
|
61
54
|
},
|
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
import type { WorkflowsMeta } from '@pikku/core/workflow';
|
|
5
5
|
import { type TypesMap } from '@pikku/inspector';
|
|
6
6
|
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph';
|
|
7
|
-
import { FunctionsMeta } from '@pikku/core';
|
|
8
|
-
import { Logger } from '@pikku/core/services';
|
|
7
|
+
import type { FunctionsMeta } from '@pikku/core';
|
|
8
|
+
import type { Logger } from '@pikku/core/services';
|
|
9
9
|
export declare const serializeWorkflowMap: (logger: Logger, relativeToPath: string, packageMappings: Record<string, string>, typesMap: TypesMap, functionsMeta: FunctionsMeta, workflowsMeta: WorkflowsMeta, graphMeta: SerializedWorkflowGraphs) => string;
|
|
@@ -7,7 +7,7 @@ import { sanitizeTypeName } from '@pikku/inspector';
|
|
|
7
7
|
export const serializeWorkflowMeta = (outputPath, metaDir, workflowNames, packageMappings, supportsImportAttributes, packageName) => {
|
|
8
8
|
const pkg = packageName ? `'${packageName}'` : 'null';
|
|
9
9
|
if (workflowNames.length === 0) {
|
|
10
|
-
return `import { pikkuState } from '@pikku/core'
|
|
10
|
+
return `import { pikkuState } from '@pikku/core/internal'
|
|
11
11
|
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph'
|
|
12
12
|
|
|
13
13
|
const workflowsMeta: SerializedWorkflowGraphs = {}
|
|
@@ -31,7 +31,7 @@ pikkuState(${pkg}, 'workflows', 'meta', workflowsMeta)`;
|
|
|
31
31
|
return ` '${name}': ${sanitizedIdentifier}Meta,`;
|
|
32
32
|
})
|
|
33
33
|
.join('\n');
|
|
34
|
-
return `import { pikkuState } from '@pikku/core'
|
|
34
|
+
return `import { pikkuState } from '@pikku/core/internal'
|
|
35
35
|
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph'
|
|
36
36
|
|
|
37
37
|
${imports}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { Logger
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Logger } from '@pikku/core/services';
|
|
2
|
+
import { LogLevel } from '@pikku/core/services';
|
|
3
|
+
import type { PikkuChannel } from '@pikku/core/channel';
|
|
4
|
+
import type { ErrorCode } from '@pikku/inspector';
|
|
4
5
|
/**
|
|
5
6
|
* Log message structure sent through the channel
|
|
6
7
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Logger
|
|
2
|
-
import {
|
|
1
|
+
import type { Logger } from '@pikku/core/services';
|
|
2
|
+
import { LogLevel } from '@pikku/core/services';
|
|
3
|
+
import type { ErrorCode } from '@pikku/inspector';
|
|
3
4
|
export declare class CLILogger implements Logger {
|
|
4
5
|
private silent;
|
|
5
6
|
private level;
|
package/dist/src/services.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Config, Services, SingletonServices, UserSession } from '../types/application-types.js';
|
|
2
|
-
import { CreateConfig
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import type { CreateConfig } from '@pikku/core';
|
|
3
|
+
import type { CreateWireServices, CreateSingletonServices } from '@pikku/core/internal';
|
|
4
|
+
import type { PikkuCLIConfig } from '../types/config.js';
|
|
5
|
+
import type { ForwardedLogMessage } from './services/cli-logger-forwarder.service.js';
|
|
5
6
|
/**
|
|
6
7
|
* Default CLI renderer that logs output using the logger
|
|
7
8
|
*/
|
package/dist/src/services.js
CHANGED
|
@@ -5,7 +5,8 @@ import { getPikkuCLIConfig } from './utils/pikku-cli-config.js';
|
|
|
5
5
|
import { inspect, serializeInspectorState, deserializeInspectorState, filterInspectorState, getInitialInspectorState, ErrorCode, } from '@pikku/inspector';
|
|
6
6
|
import { glob } from 'tinyglobby';
|
|
7
7
|
import path from 'path';
|
|
8
|
-
import { CLILoggerForwarder
|
|
8
|
+
import { CLILoggerForwarder } from './services/cli-logger-forwarder.service.js';
|
|
9
|
+
import { existsSync } from 'fs';
|
|
9
10
|
import { readFile, writeFile } from 'fs/promises';
|
|
10
11
|
import { loadManifest } from './utils/contract-versions.js';
|
|
11
12
|
import { join } from 'path';
|
|
@@ -202,6 +203,17 @@ export const createSingletonServices = async (config) => {
|
|
|
202
203
|
ignore: config.ignoreFiles || [],
|
|
203
204
|
absolute: true,
|
|
204
205
|
})))).flat();
|
|
206
|
+
const scaffoldFiles = [
|
|
207
|
+
config.consoleFunctionsFile,
|
|
208
|
+
config.publicRpcFile,
|
|
209
|
+
config.publicAgentFile,
|
|
210
|
+
config.workflowWorkersFile,
|
|
211
|
+
];
|
|
212
|
+
for (const file of scaffoldFiles) {
|
|
213
|
+
if (file && !wiringFiles.includes(file) && existsSync(file)) {
|
|
214
|
+
wiringFiles.push(file);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
205
217
|
const manifest = !setupOnly
|
|
206
218
|
? ((await loadManifest(join(config.outDir, 'versions.json'))) ??
|
|
207
219
|
undefined)
|
|
@@ -209,7 +221,7 @@ export const createSingletonServices = async (config) => {
|
|
|
209
221
|
unfilteredState = await inspect(logger, wiringFiles, {
|
|
210
222
|
setupOnly,
|
|
211
223
|
rootDir,
|
|
212
|
-
|
|
224
|
+
isAddon: config.addon,
|
|
213
225
|
types: {
|
|
214
226
|
configFileType: config.configFile,
|
|
215
227
|
userSessionType: config.userSessionType,
|
|
@@ -217,7 +229,6 @@ export const createSingletonServices = async (config) => {
|
|
|
217
229
|
wireServicesFactoryType: config.wireServicesFactoryType,
|
|
218
230
|
},
|
|
219
231
|
tags: config.tags,
|
|
220
|
-
externalPackages: config.externalPackages,
|
|
221
232
|
schemaConfig: !setupOnly
|
|
222
233
|
? {
|
|
223
234
|
tsconfig: config.tsconfig,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VersionManifest } from '@pikku/inspector';
|
|
2
2
|
import { createEmptyManifest } from '@pikku/inspector';
|
|
3
3
|
export { createEmptyManifest };
|
|
4
|
-
export type { ContractEntry, VersionValidateError, VersionManifest, VersionManifestEntry, } from '@pikku/inspector';
|
|
4
|
+
export type { ContractEntry, VersionHashEntry, VersionValidateError, VersionManifest, VersionManifestEntry, } from '@pikku/inspector';
|
|
5
5
|
export declare function loadManifest(manifestPath: string): Promise<VersionManifest | null>;
|
|
6
6
|
export declare function saveManifest(manifestPath: string, manifest: VersionManifest): Promise<void>;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { CLILogger } from '../services/cli-logger.service.js';
|
|
1
|
+
import type { CLILogger } from '../services/cli-logger.service.js';
|
|
2
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 function kebabCase(str: string): string;
|
|
8
|
+
export declare function scaffoldFilePath(config: {
|
|
9
|
+
rootDir: string;
|
|
10
|
+
srcDirectories: string[];
|
|
11
|
+
}, subdir: string, name: string, suffix: string, overrideDir?: string): string;
|
|
7
12
|
export declare const removeFileInDir: (logger: CLILogger, path: string, { logRemove }?: {
|
|
8
13
|
logRemove?: boolean;
|
|
9
14
|
}) => Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { dirname } from 'path';
|
|
1
|
+
import { dirname, join } from 'path';
|
|
2
2
|
import { mkdir, readFile, writeFile, rm } from 'fs/promises';
|
|
3
3
|
import { existsSync } from 'fs';
|
|
4
4
|
import { getCLIVersion } from './get-cli-version.js';
|
|
@@ -39,6 +39,19 @@ export const writeFileInDir = async (logger, path, content, { ignoreModifyCommen
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
export function kebabCase(str) {
|
|
43
|
+
return str
|
|
44
|
+
.replace(/([a-z])([A-Z])/g, '$1-$2')
|
|
45
|
+
.replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
|
|
46
|
+
.toLowerCase();
|
|
47
|
+
}
|
|
48
|
+
export function scaffoldFilePath(config, subdir, name, suffix, overrideDir) {
|
|
49
|
+
const fileName = kebabCase(name);
|
|
50
|
+
if (overrideDir) {
|
|
51
|
+
return join(overrideDir, subdir, `${fileName}${suffix}`);
|
|
52
|
+
}
|
|
53
|
+
return join(config.rootDir, config.srcDirectories[0], subdir, `${fileName}${suffix}`);
|
|
54
|
+
}
|
|
42
55
|
export const removeFileInDir = async (logger, path, { logRemove = true } = {}) => {
|
|
43
56
|
// Check if file exists before attempting removal
|
|
44
57
|
if (existsSync(path)) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config } from '../../types/application-types.js';
|
|
2
|
-
import { CLILogger } from '../services/cli-logger.service.js';
|
|
1
|
+
import type { Config } from '../../types/application-types.js';
|
|
2
|
+
import type { CLILogger } from '../services/cli-logger.service.js';
|
|
3
3
|
export declare const generateBootstrapFile: (logger: CLILogger, config: Config, bootstrapFile: string, specificImports: string[], schemas?: boolean, hasMiddleware?: boolean) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates addon files from a parsed OpenAPI spec.
|
|
3
|
+
* Returns Record<string, string> compatible with getAddonFiles output.
|
|
4
|
+
*/
|
|
5
|
+
import type { ParsedSpec } from './parse-openapi.js';
|
|
6
|
+
interface AddonVars {
|
|
7
|
+
name: string;
|
|
8
|
+
camelName: string;
|
|
9
|
+
pascalName: string;
|
|
10
|
+
screamingName: string;
|
|
11
|
+
displayName: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
interface CodegenFlags {
|
|
15
|
+
oauth: boolean;
|
|
16
|
+
secret: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function generateAddonFromOpenAPI(spec: ParsedSpec, vars: AddonVars, flags: CodegenFlags): Record<string, string>;
|
|
19
|
+
export {};
|