@pikku/cli 0.12.3 → 0.12.6
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/console-app/assets/{index-Ci24-VT-.js → index-AX4YS8AA.js} +166 -166
- package/console-app/index.html +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +10 -1
- 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 +13 -13
- package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +185 -183
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -1
- 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 +1 -1
- 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 +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +2 -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 +1 -1
- 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 +13 -11
- package/dist/.pikku/schemas/schemas/ConsoleCommandInput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/WatchInput.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 +1 -1
- 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 +10 -0
- package/dist/src/functions/commands/console.d.ts +3 -0
- package/dist/src/functions/commands/console.js +12 -1
- package/dist/src/functions/commands/new-addon.js +4 -12
- package/dist/src/functions/commands/watch.d.ts +7 -1
- package/dist/src/functions/commands/watch.js +10 -3
- package/dist/src/functions/wirings/console/serialize-console-functions.js +13 -0
- package/dist/src/functions/wirings/functions/serialize-function-types.js +15 -15
- package/dist/src/utils/openapi/codegen.js +13 -27
- package/dist/src/utils/openapi/zod-codegen.d.ts +1 -1
- package/dist/src/utils/openapi/zod-codegen.js +1 -1
- package/package.json +3 -3
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
"pikkuQueueMap": "pikkuQueueMap",
|
|
61
61
|
"pikkuQueueTypes": "pikkuQueueTypes",
|
|
62
62
|
"pikkuQueue": "pikkuQueue",
|
|
63
|
+
"pikkuSchedulerTypes": "pikkuSchedulerTypes",
|
|
64
|
+
"pikkuScheduler": "pikkuScheduler",
|
|
63
65
|
"pikkuPublicRPC": "pikkuPublicRPC",
|
|
64
66
|
"pikkuRemoteRPC": "pikkuRemoteRPC",
|
|
65
67
|
"pikkuRPCInternalMap": "pikkuRPCInternalMap",
|
|
66
68
|
"pikkuRPCExposedMap": "pikkuRPCExposedMap",
|
|
67
69
|
"pikkuRPC": "pikkuRPC",
|
|
68
|
-
"pikkuSchedulerTypes": "pikkuSchedulerTypes",
|
|
69
|
-
"pikkuScheduler": "pikkuScheduler",
|
|
70
70
|
"pikkuSecrets": "pikkuSecrets",
|
|
71
71
|
"pikkuTriggerTypes": "pikkuTriggerTypes",
|
|
72
72
|
"pikkuTrigger": "pikkuTrigger",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.6
|
|
3
3
|
*/
|
|
4
4
|
import { addSchema } from '@pikku/core/schema';
|
|
5
5
|
import * as PikkuSchemasOutput from './schemas/PikkuSchemasOutput.schema.json' with { type: 'json' };
|
|
6
6
|
addSchema('PikkuSchemasOutput', PikkuSchemasOutput);
|
|
7
7
|
import * as BootstrapInput from './schemas/BootstrapInput.schema.json' with { type: 'json' };
|
|
8
8
|
addSchema('BootstrapInput', BootstrapInput);
|
|
9
|
+
import * as WatchInput from './schemas/WatchInput.schema.json' with { type: 'json' };
|
|
10
|
+
addSchema('WatchInput', WatchInput);
|
|
9
11
|
import * as ConsoleCommandInput from './schemas/ConsoleCommandInput.schema.json' with { type: 'json' };
|
|
10
12
|
addSchema('ConsoleCommandInput', ConsoleCommandInput);
|
|
11
13
|
import * as PikkuVersionsInitInput from './schemas/PikkuVersionsInitInput.schema.json' with { type: 'json' };
|
|
@@ -22,24 +24,26 @@ import * as PikkuNewAddonInput from './schemas/PikkuNewAddonInput.schema.json' w
|
|
|
22
24
|
addSchema('PikkuNewAddonInput', PikkuNewAddonInput);
|
|
23
25
|
import * as PikkuChannelsOutput from './schemas/PikkuChannelsOutput.schema.json' with { type: 'json' };
|
|
24
26
|
addSchema('PikkuChannelsOutput', PikkuChannelsOutput);
|
|
25
|
-
import * as PikkuCLIOutput from './schemas/PikkuCLIOutput.schema.json' with { type: 'json' };
|
|
26
|
-
addSchema('PikkuCLIOutput', PikkuCLIOutput);
|
|
27
|
-
import * as PikkuConsoleFunctionsOutput from './schemas/PikkuConsoleFunctionsOutput.schema.json' with { type: 'json' };
|
|
28
|
-
addSchema('PikkuConsoleFunctionsOutput', PikkuConsoleFunctionsOutput);
|
|
29
|
-
import * as PikkuNodesMetaOutput from './schemas/PikkuNodesMetaOutput.schema.json' with { type: 'json' };
|
|
30
|
-
addSchema('PikkuNodesMetaOutput', PikkuNodesMetaOutput);
|
|
31
27
|
import * as PikkuAIAgentOutput from './schemas/PikkuAIAgentOutput.schema.json' with { type: 'json' };
|
|
32
28
|
addSchema('PikkuAIAgentOutput', PikkuAIAgentOutput);
|
|
33
29
|
import * as PikkuPublicAgentOutput from './schemas/PikkuPublicAgentOutput.schema.json' with { type: 'json' };
|
|
34
30
|
addSchema('PikkuPublicAgentOutput', PikkuPublicAgentOutput);
|
|
31
|
+
import * as PikkuConsoleFunctionsOutput from './schemas/PikkuConsoleFunctionsOutput.schema.json' with { type: 'json' };
|
|
32
|
+
addSchema('PikkuConsoleFunctionsOutput', PikkuConsoleFunctionsOutput);
|
|
33
|
+
import * as PikkuNodesMetaOutput from './schemas/PikkuNodesMetaOutput.schema.json' with { type: 'json' };
|
|
34
|
+
addSchema('PikkuNodesMetaOutput', PikkuNodesMetaOutput);
|
|
35
35
|
import * as PikkuFunctionsOutput from './schemas/PikkuFunctionsOutput.schema.json' with { type: 'json' };
|
|
36
36
|
addSchema('PikkuFunctionsOutput', PikkuFunctionsOutput);
|
|
37
37
|
import * as PikkuGatewayOutput from './schemas/PikkuGatewayOutput.schema.json' with { type: 'json' };
|
|
38
38
|
addSchema('PikkuGatewayOutput', PikkuGatewayOutput);
|
|
39
|
-
import * as
|
|
40
|
-
addSchema('
|
|
39
|
+
import * as PikkuHTTPOutput from './schemas/PikkuHTTPOutput.schema.json' with { type: 'json' };
|
|
40
|
+
addSchema('PikkuHTTPOutput', PikkuHTTPOutput);
|
|
41
|
+
import * as PikkuCLIOutput from './schemas/PikkuCLIOutput.schema.json' with { type: 'json' };
|
|
42
|
+
addSchema('PikkuCLIOutput', PikkuCLIOutput);
|
|
41
43
|
import * as PikkuMiddlewareOutput from './schemas/PikkuMiddlewareOutput.schema.json' with { type: 'json' };
|
|
42
44
|
addSchema('PikkuMiddlewareOutput', PikkuMiddlewareOutput);
|
|
45
|
+
import * as PikkuMCPOutput from './schemas/PikkuMCPOutput.schema.json' with { type: 'json' };
|
|
46
|
+
addSchema('PikkuMCPOutput', PikkuMCPOutput);
|
|
43
47
|
import * as PikkuPackageOutput from './schemas/PikkuPackageOutput.schema.json' with { type: 'json' };
|
|
44
48
|
addSchema('PikkuPackageOutput', PikkuPackageOutput);
|
|
45
49
|
import * as PikkuPermissionsOutput from './schemas/PikkuPermissionsOutput.schema.json' with { type: 'json' };
|
|
@@ -58,7 +62,5 @@ import * as PikkuTriggerOutput from './schemas/PikkuTriggerOutput.schema.json' w
|
|
|
58
62
|
addSchema('PikkuTriggerOutput', PikkuTriggerOutput);
|
|
59
63
|
import * as PikkuWorkflowOutput from './schemas/PikkuWorkflowOutput.schema.json' with { type: 'json' };
|
|
60
64
|
addSchema('PikkuWorkflowOutput', PikkuWorkflowOutput);
|
|
61
|
-
import * as PikkuHTTPOutput from './schemas/PikkuHTTPOutput.schema.json' with { type: 'json' };
|
|
62
|
-
addSchema('PikkuHTTPOutput', PikkuHTTPOutput);
|
|
63
65
|
import * as PikkuCLIConfig from './schemas/PikkuCLIConfig.schema.json' with { type: 'json' };
|
|
64
66
|
addSchema('PikkuCLIConfig', PikkuCLIConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "port": { "type": "string" }, "open": { "type": "string" } }, "additionalProperties": false, "definitions": {} }
|
|
1
|
+
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "port": { "type": "string" }, "open": { "type": "string" }, "hmr": { "type": "boolean" } }, "additionalProperties": false, "definitions": {} }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{ "$schema": "http://json-schema.org/draft-07/schema#", "type": "object", "properties": { "hmr": { "type": "boolean" } }, "additionalProperties": false, "definitions": {} }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.6
|
|
3
3
|
*/
|
|
4
4
|
export { wireVariable } from '@pikku/core/variable';
|
|
5
5
|
export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.6
|
|
3
3
|
*/
|
|
4
4
|
import { WorkflowCancelledException } from '@pikku/core/workflow';
|
|
5
5
|
import { workflow as coreWorkflow, workflowStart as coreWorkflowStart, workflowStatus as coreWorkflowStatus, graphStart as coreGraphStart, } from '@pikku/core/workflow';
|
package/dist/src/cli.wiring.js
CHANGED
|
@@ -87,6 +87,12 @@ wireCLI({
|
|
|
87
87
|
watch: pikkuCLICommand({
|
|
88
88
|
func: watch,
|
|
89
89
|
description: 'Watch for file changes and regenerate automatically',
|
|
90
|
+
options: {
|
|
91
|
+
hmr: {
|
|
92
|
+
description: 'Enable hot module reload for registered functions',
|
|
93
|
+
default: false,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
90
96
|
}),
|
|
91
97
|
console: pikkuCLICommand({
|
|
92
98
|
func: consoleCommand,
|
|
@@ -102,6 +108,10 @@ wireCLI({
|
|
|
102
108
|
default: 'false',
|
|
103
109
|
short: 'o',
|
|
104
110
|
},
|
|
111
|
+
hmr: {
|
|
112
|
+
description: 'Enable hot module reload for registered functions',
|
|
113
|
+
default: false,
|
|
114
|
+
},
|
|
105
115
|
},
|
|
106
116
|
}),
|
|
107
117
|
schemas: pikkuCLICommand({
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
export declare const consoleCommand: import("#pikku").PikkuFunctionConfig<{
|
|
2
2
|
port?: string;
|
|
3
3
|
open?: string;
|
|
4
|
+
hmr?: boolean;
|
|
4
5
|
}, void, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<{
|
|
5
6
|
port?: string;
|
|
6
7
|
open?: string;
|
|
8
|
+
hmr?: boolean;
|
|
7
9
|
}, void, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<{
|
|
8
10
|
port?: string;
|
|
9
11
|
open?: string;
|
|
12
|
+
hmr?: boolean;
|
|
10
13
|
}, void, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -5,6 +5,7 @@ import { fileURLToPath } from 'url';
|
|
|
5
5
|
import { pikkuSessionlessFunc } from '#pikku';
|
|
6
6
|
import chokidar from 'chokidar';
|
|
7
7
|
import open from 'open';
|
|
8
|
+
import { pikkuDevReloader } from '@pikku/core/dev';
|
|
8
9
|
const MIME_TYPES = {
|
|
9
10
|
'.html': 'text/html',
|
|
10
11
|
'.js': 'application/javascript',
|
|
@@ -21,7 +22,11 @@ const MIME_TYPES = {
|
|
|
21
22
|
};
|
|
22
23
|
export const consoleCommand = pikkuSessionlessFunc({
|
|
23
24
|
remote: true,
|
|
24
|
-
func: async ({ logger, config }, { port, open: openBrowser }, { rpc }) => {
|
|
25
|
+
func: async ({ logger, config }, { port, open: openBrowser, hmr }, { rpc }) => {
|
|
26
|
+
if (!config.scaffold?.console) {
|
|
27
|
+
logger.error('Console is not enabled. Add { "scaffold": { "console": "no-auth" } } to your pikku.config.json');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
25
30
|
const consoleDir = join(fileURLToPath(import.meta.url), '..', '..', '..', '..', '..', 'console-app');
|
|
26
31
|
const resolvedPort = parseInt(port || '51442', 10);
|
|
27
32
|
try {
|
|
@@ -61,6 +66,12 @@ export const consoleCommand = pikkuSessionlessFunc({
|
|
|
61
66
|
open(`http://localhost:${resolvedPort}`);
|
|
62
67
|
}
|
|
63
68
|
});
|
|
69
|
+
if (hmr) {
|
|
70
|
+
await pikkuDevReloader({
|
|
71
|
+
srcDirectories: config.srcDirectories,
|
|
72
|
+
logger,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
64
75
|
const configWatcher = chokidar.watch(config.srcDirectories, {
|
|
65
76
|
ignoreInitial: true,
|
|
66
77
|
ignored: /.*\.gen\.tsx?/,
|
|
@@ -463,24 +463,16 @@ function getTestFiles(vars) {
|
|
|
463
463
|
wireAddon({ name: '${name}', package: '@pikku/addon-${name}' })
|
|
464
464
|
`;
|
|
465
465
|
// test/src/services.ts
|
|
466
|
-
files['src/services.ts'] = `import
|
|
467
|
-
SingletonServices,
|
|
468
|
-
} from '../types/application-types.js'
|
|
469
|
-
import {
|
|
470
|
-
CreateSingletonServices,
|
|
471
|
-
} from '@pikku/core'
|
|
472
|
-
import {
|
|
466
|
+
files['src/services.ts'] = `import {
|
|
473
467
|
ConsoleLogger,
|
|
474
468
|
LocalVariablesService,
|
|
475
469
|
LocalSecretService,
|
|
476
470
|
} from '@pikku/core/services'
|
|
471
|
+
import { pikkuServices } from '#pikku'
|
|
477
472
|
|
|
478
473
|
import '../.pikku/pikku-bootstrap.gen.js'
|
|
479
474
|
|
|
480
|
-
export const createSingletonServices
|
|
481
|
-
{},
|
|
482
|
-
SingletonServices
|
|
483
|
-
> = async (_config, existingServices) => {
|
|
475
|
+
export const createSingletonServices = pikkuServices(async (_config, existingServices) => {
|
|
484
476
|
const variables = existingServices?.variables ?? new LocalVariablesService(process.env)
|
|
485
477
|
const secrets = existingServices?.secrets ?? new LocalSecretService(variables)
|
|
486
478
|
|
|
@@ -489,7 +481,7 @@ export const createSingletonServices: CreateSingletonServices<
|
|
|
489
481
|
variables,
|
|
490
482
|
secrets,
|
|
491
483
|
}
|
|
492
|
-
}
|
|
484
|
+
})
|
|
493
485
|
`;
|
|
494
486
|
// test/src/{name}-tests.function.ts
|
|
495
487
|
files[`src/${name}-tests.function.ts`] =
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
export declare const watch: import("#pikku").PikkuFunctionConfig<
|
|
1
|
+
export declare const watch: import("#pikku").PikkuFunctionConfig<{
|
|
2
|
+
hmr?: boolean;
|
|
3
|
+
}, void, "session" | "rpc", import("#pikku").PikkuFunctionSessionless<{
|
|
4
|
+
hmr?: boolean;
|
|
5
|
+
}, void, "session" | "rpc", import("#pikku").Services> | import("#pikku").PikkuFunction<{
|
|
6
|
+
hmr?: boolean;
|
|
7
|
+
}, void, "session" | "rpc", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pikkuSessionlessFunc } from '#pikku';
|
|
2
2
|
import chokidar from 'chokidar';
|
|
3
|
-
|
|
3
|
+
import { pikkuDevReloader } from '@pikku/core/dev';
|
|
4
|
+
export const watch = pikkuSessionlessFunc({
|
|
4
5
|
remote: true,
|
|
5
|
-
func: async ({ logger, config },
|
|
6
|
+
func: async ({ logger, config }, { hmr }, { rpc }) => {
|
|
7
|
+
if (hmr) {
|
|
8
|
+
await pikkuDevReloader({
|
|
9
|
+
srcDirectories: config.srcDirectories,
|
|
10
|
+
logger,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
6
13
|
const configWatcher = chokidar.watch(config.srcDirectories, {
|
|
7
14
|
ignoreInitial: true,
|
|
8
15
|
ignored: /.*\.gen\.tsx?/,
|
|
@@ -55,6 +55,19 @@ export const pikkuConsoleSetVariable = pikkuSessionlessFunc<
|
|
|
55
55
|
},
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
+
export const pikkuConsoleHasSecret = pikkuSessionlessFunc<
|
|
59
|
+
{ secretId: string },
|
|
60
|
+
{ exists: boolean }
|
|
61
|
+
>({
|
|
62
|
+
description: 'Check if a secret exists without reading its value',
|
|
63
|
+
expose: true,
|
|
64
|
+
auth: false,
|
|
65
|
+
func: async ({ secrets }, { secretId }) => {
|
|
66
|
+
const exists = await secrets.hasSecret(secretId)
|
|
67
|
+
return { exists }
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
|
|
58
71
|
export const pikkuConsoleGetSecret = pikkuSessionlessFunc<
|
|
59
72
|
{ secretId: string },
|
|
60
73
|
{ exists: boolean; value: unknown | null }
|
|
@@ -331,7 +331,7 @@ export type PikkuFunctionConfig<
|
|
|
331
331
|
* Types are automatically inferred from the schemas.
|
|
332
332
|
*/
|
|
333
333
|
export type PikkuFunctionConfigWithSchema<
|
|
334
|
-
InputSchema extends StandardSchemaV1,
|
|
334
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
335
335
|
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
336
336
|
RequiredWires extends keyof PikkuWire = never
|
|
337
337
|
> = {
|
|
@@ -341,20 +341,20 @@ export type PikkuFunctionConfigWithSchema<
|
|
|
341
341
|
mcp?: boolean
|
|
342
342
|
internal?: boolean
|
|
343
343
|
approvalRequired?: boolean
|
|
344
|
-
approvalDescription?: PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
344
|
+
approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
|
|
345
345
|
func: PikkuFunction<
|
|
346
|
-
InferSchemaOutput<InputSchema
|
|
346
|
+
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
|
347
347
|
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
348
348
|
RequiredWires
|
|
349
349
|
> | PikkuFunctionSessionless<
|
|
350
|
-
InferSchemaOutput<InputSchema
|
|
350
|
+
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
|
351
351
|
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
352
352
|
RequiredWires
|
|
353
353
|
>
|
|
354
354
|
auth?: boolean
|
|
355
|
-
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
355
|
+
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
|
356
356
|
middleware?: PikkuMiddleware[]
|
|
357
|
-
input
|
|
357
|
+
input?: InputSchema
|
|
358
358
|
output?: OutputSchema
|
|
359
359
|
node?: NodeConfig
|
|
360
360
|
errors?: Array<typeof PikkuError>
|
|
@@ -399,11 +399,11 @@ export type PikkuFunctionConfigWithSchema<
|
|
|
399
399
|
* \`\`\`
|
|
400
400
|
*/
|
|
401
401
|
export function pikkuFunc<
|
|
402
|
-
InputSchema extends StandardSchemaV1,
|
|
402
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
403
403
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
404
404
|
>(
|
|
405
405
|
config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
|
|
406
|
-
): PikkuFunctionConfig<InferSchemaOutput<InputSchema
|
|
406
|
+
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
|
407
407
|
export function pikkuFunc<In, Out = unknown>(
|
|
408
408
|
func:
|
|
409
409
|
| PikkuFunction<In, Out, 'session' | 'rpc'>
|
|
@@ -417,7 +417,7 @@ export function pikkuFunc(func: any) {
|
|
|
417
417
|
* Configuration object for sessionless Pikku functions with Zod schema validation.
|
|
418
418
|
*/
|
|
419
419
|
export type PikkuFunctionSessionlessConfigWithSchema<
|
|
420
|
-
InputSchema extends StandardSchemaV1,
|
|
420
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
421
421
|
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
422
422
|
RequiredWires extends keyof PikkuWire = never
|
|
423
423
|
> = {
|
|
@@ -429,16 +429,16 @@ export type PikkuFunctionSessionlessConfigWithSchema<
|
|
|
429
429
|
internal?: boolean
|
|
430
430
|
remote?: boolean
|
|
431
431
|
approvalRequired?: boolean
|
|
432
|
-
approvalDescription?: PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
432
|
+
approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
|
|
433
433
|
func: PikkuFunctionSessionless<
|
|
434
|
-
InferSchemaOutput<InputSchema
|
|
434
|
+
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
|
435
435
|
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown,
|
|
436
436
|
RequiredWires
|
|
437
437
|
>
|
|
438
438
|
auth?: boolean
|
|
439
|
-
permissions?: CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
439
|
+
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
|
440
440
|
middleware?: PikkuMiddleware[]
|
|
441
|
-
input
|
|
441
|
+
input?: InputSchema
|
|
442
442
|
output?: OutputSchema
|
|
443
443
|
node?: NodeConfig
|
|
444
444
|
errors?: Array<typeof PikkuError>
|
|
@@ -480,11 +480,11 @@ export type PikkuFunctionSessionlessConfigWithSchema<
|
|
|
480
480
|
* \`\`\`
|
|
481
481
|
*/
|
|
482
482
|
export function pikkuSessionlessFunc<
|
|
483
|
-
InputSchema extends StandardSchemaV1,
|
|
483
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
484
484
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
485
485
|
>(
|
|
486
486
|
config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
|
|
487
|
-
): PikkuFunctionConfig<InferSchemaOutput<InputSchema
|
|
487
|
+
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
|
488
488
|
export function pikkuSessionlessFunc<In, Out = unknown>(
|
|
489
489
|
func:
|
|
490
490
|
| PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { schemaToZod, schemaVarName, createContext, } from './zod-codegen.js';
|
|
1
|
+
import { schemaToZod, schemaVarName, sanitizeTypeName, createContext, } from './zod-codegen.js';
|
|
2
2
|
import { generateOperationNames, detectCommonPrefix, } from './naming.js';
|
|
3
|
+
function safeKey(key) {
|
|
4
|
+
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
5
|
+
}
|
|
3
6
|
const GENERIC_SUMMARIES = new Set([
|
|
4
7
|
'index',
|
|
5
8
|
'show',
|
|
@@ -24,31 +27,12 @@ const STATUS_TO_ERROR = {
|
|
|
24
27
|
function capitalize(str) {
|
|
25
28
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
26
29
|
}
|
|
27
|
-
function humanDescription(
|
|
28
|
-
const summary = parsed.summary?.trim();
|
|
30
|
+
function humanDescription(parsed) {
|
|
29
31
|
const description = parsed.description?.trim();
|
|
30
|
-
// Summary is preferred — it's the operation's intent
|
|
31
|
-
if (summary && !GENERIC_SUMMARIES.has(summary.toLowerCase())) {
|
|
32
|
-
// If description adds info beyond summary, combine them
|
|
33
|
-
if (description &&
|
|
34
|
-
!GENERIC_SUMMARIES.has(description.toLowerCase()) &&
|
|
35
|
-
description.toLowerCase() !== summary.toLowerCase()) {
|
|
36
|
-
const sep = summary.endsWith('.') ? ' ' : '. ';
|
|
37
|
-
return `${capitalize(summary)}${sep}${capitalize(description)}`;
|
|
38
|
-
}
|
|
39
|
-
return capitalize(summary);
|
|
40
|
-
}
|
|
41
32
|
if (description && !GENERIC_SUMMARIES.has(description.toLowerCase())) {
|
|
42
33
|
return capitalize(description);
|
|
43
34
|
}
|
|
44
|
-
|
|
45
|
-
return capitalize(parsed.responseDescription);
|
|
46
|
-
}
|
|
47
|
-
const words = named.functionName
|
|
48
|
-
.replace(/([A-Z])/g, ' $1')
|
|
49
|
-
.trim()
|
|
50
|
-
.toLowerCase();
|
|
51
|
-
return capitalize(words);
|
|
35
|
+
return undefined;
|
|
52
36
|
}
|
|
53
37
|
function getErrorClassesForResponses(errorResponses) {
|
|
54
38
|
const classes = [];
|
|
@@ -109,7 +93,7 @@ function generateTypesFile(spec, ctx) {
|
|
|
109
93
|
const varName = schemaVarName(name);
|
|
110
94
|
const zodCode = schemaToZod(schema, ctx);
|
|
111
95
|
lines.push(`export const ${varName} = ${zodCode}`);
|
|
112
|
-
lines.push(`export type ${name} = z.infer<typeof ${varName}>`);
|
|
96
|
+
lines.push(`export type ${sanitizeTypeName(name)} = z.infer<typeof ${varName}>`);
|
|
113
97
|
lines.push('');
|
|
114
98
|
}
|
|
115
99
|
return lines.join('\n');
|
|
@@ -153,10 +137,12 @@ function generateFunctionFile(named, parsed, vars, ctx, spec, flags) {
|
|
|
153
137
|
lines.push(`export const ${outputName} = ${outputCode}`);
|
|
154
138
|
lines.push('');
|
|
155
139
|
}
|
|
156
|
-
const description = humanDescription(
|
|
140
|
+
const description = humanDescription(parsed);
|
|
157
141
|
const method = parsed.method.toUpperCase();
|
|
158
142
|
const funcConfig = [];
|
|
159
|
-
|
|
143
|
+
if (description) {
|
|
144
|
+
funcConfig.push(` description: ${JSON.stringify(description)},`);
|
|
145
|
+
}
|
|
160
146
|
if (hasInput)
|
|
161
147
|
funcConfig.push(` input: ${inputName},`);
|
|
162
148
|
if (parsed.responseSchema) {
|
|
@@ -203,7 +189,7 @@ function buildInputSchema(parsed, ctx) {
|
|
|
203
189
|
const withDesc = propSchema.description
|
|
204
190
|
? `${zodCode}.describe(${JSON.stringify(propSchema.description)})`
|
|
205
191
|
: zodCode;
|
|
206
|
-
props.push(` ${key}: ${withDesc},`);
|
|
192
|
+
props.push(` ${safeKey(key)}: ${withDesc},`);
|
|
207
193
|
}
|
|
208
194
|
}
|
|
209
195
|
else {
|
|
@@ -223,7 +209,7 @@ function formatParamProp(param, ctx) {
|
|
|
223
209
|
const desc = descParts.length > 0
|
|
224
210
|
? `${zodCode}.describe(${JSON.stringify(descParts.join('. '))})`
|
|
225
211
|
: zodCode;
|
|
226
|
-
return ` ${param.name}: ${desc},`;
|
|
212
|
+
return ` ${safeKey(param.name)}: ${desc},`;
|
|
227
213
|
}
|
|
228
214
|
function buildOutputSchema(schema, ctx) {
|
|
229
215
|
// For output schemas, filter out writeOnly properties
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { type OpenAPISchema, type ZodCodegenContext, createContext, schemaToZod, schemaVarName, } from '@pikku/openapi-to-zod-schema';
|
|
1
|
+
export { type OpenAPISchema, type ZodCodegenContext, createContext, schemaToZod, schemaVarName, sanitizeTypeName, } from '@pikku/openapi-to-zod-schema';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createContext, schemaToZod, schemaVarName, } from '@pikku/openapi-to-zod-schema';
|
|
1
|
+
export { createContext, schemaToZod, schemaVarName, sanitizeTypeName, } from '@pikku/openapi-to-zod-schema';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.6",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"imports": {
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@openapi-contrib/json-schema-to-openapi-schema": "^4.3.1",
|
|
28
|
-
"@pikku/core": "^0.12.
|
|
28
|
+
"@pikku/core": "^0.12.5",
|
|
29
29
|
"@pikku/inspector": "^0.12.3",
|
|
30
|
-
"@pikku/openapi-to-zod-schema": "^0.12.
|
|
30
|
+
"@pikku/openapi-to-zod-schema": "^0.12.3",
|
|
31
31
|
"@types/cookie": "^1.0.0",
|
|
32
32
|
"@types/json-schema": "^7.0.15",
|
|
33
33
|
"chalk": "^5.6.2",
|