@pikku/cli 0.12.78 → 0.12.80
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/dist/.pikku/agent/pikku-agent-types.gen.d.ts +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/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-contracts-meta.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.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.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 +4 -4
- 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.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/pikku-bootstrap.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/pikku-meta-service.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/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-rpc-wirings-meta.internal.gen.js +1 -1
- 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/schemas/register.gen.js +1 -1
- 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 +10 -5
- 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.js +1 -1
- package/dist/bin/pikku-bin.mjs +2 -2
- package/dist/src/functions/wirings/functions/serialize-function-types.js +3 -3
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +24 -7
- package/dist/src/utils/assert-single-core-version.d.ts +25 -8
- package/dist/src/utils/assert-single-core-version.js +130 -9
- package/dist/src/utils/precise-coverage-map.js +3 -1
- package/package.json +4 -4
|
@@ -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.80
|
|
3
3
|
*/
|
|
4
4
|
import { CoreAIAgent, PikkuAIMiddlewareHooks } from '@pikku/core/ai-agent';
|
|
5
5
|
import type { PikkuPermission, PikkuMiddleware, Services, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js';
|
|
@@ -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.80
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Core function, middleware, and permission types for all wirings
|
|
@@ -16,7 +16,7 @@ import type { Services } from '../../types/application-types.d.js';
|
|
|
16
16
|
import type { Config } from '../../types/application-types.d.js';
|
|
17
17
|
import type { TypedPikkuRPC, FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js';
|
|
18
18
|
import type { RequiredSingletonServices, RequiredWireServices } from '../pikku-services.gen.js';
|
|
19
|
-
import type { TypedWorkflow } from '../workflow/pikku-workflow-types.gen.js';
|
|
19
|
+
import type { TypedWorkflow, TypedScenario } from '../workflow/pikku-workflow-types.gen.js';
|
|
20
20
|
export type { SingletonServices as SingletonServices };
|
|
21
21
|
export type { Services as Services };
|
|
22
22
|
export type Session = UserSession;
|
|
@@ -215,7 +215,7 @@ export declare const pikkuApprovalDescription: <In = unknown, RequiredServices e
|
|
|
215
215
|
* @template Out - The output type that the function returns
|
|
216
216
|
* @template RequiredServices - Services required by this function
|
|
217
217
|
*/
|
|
218
|
-
export type PikkuFunctionSessionless<In = unknown, Out = never, RequiredWires extends keyof PikkuWire = never, RequiredServices extends Services = Services> = CorePikkuFunctionSessionless<In, Out, RequiredServices, Session, PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>>;
|
|
218
|
+
export type PikkuFunctionSessionless<In = unknown, Out = never, RequiredWires extends keyof PikkuWire = never, RequiredServices extends Services = Services> = CorePikkuFunctionSessionless<In, Out, RequiredServices, Session, PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario>, RequiredWires>>;
|
|
219
219
|
/**
|
|
220
220
|
* A session-aware API function that requires user authentication.
|
|
221
221
|
* Use this for protected endpoints that need access to user session data.
|
|
@@ -224,7 +224,7 @@ export type PikkuFunctionSessionless<In = unknown, Out = never, RequiredWires ex
|
|
|
224
224
|
* @template Out - The output type that the function returns
|
|
225
225
|
* @template RequiredServices - Services required by this function
|
|
226
226
|
*/
|
|
227
|
-
export type PikkuFunction<In = unknown, Out = never, RequiredWires extends keyof PikkuWire = 'session', RequiredServices extends Services = Services> = CorePikkuFunction<In, Out, RequiredServices, Session, PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>>;
|
|
227
|
+
export type PikkuFunction<In = unknown, Out = never, RequiredWires extends keyof PikkuWire = 'session', RequiredServices extends Services = Services> = CorePikkuFunction<In, Out, RequiredServices, Session, PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario>, RequiredWires>>;
|
|
228
228
|
/**
|
|
229
229
|
* Helper type to infer the output type from a Standard Schema
|
|
230
230
|
*/
|
|
@@ -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.80
|
|
3
3
|
*/
|
|
4
4
|
export { wireVariable } from '@pikku/core/variable';
|
|
5
5
|
export type { CoreVariable, VariableDefinitionMeta, VariableDefinitionsMeta } from '@pikku/core/variable';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.80
|
|
3
3
|
*/
|
|
4
4
|
import { WorkflowCancelledException } from '@pikku/core/workflow';
|
|
5
5
|
import { template } from '@pikku/core/workflow';
|
|
6
6
|
import { type PikkuWorkflowGraphConfig, type PikkuWorkflowGraphResult } from '@pikku/core/workflow';
|
|
7
|
-
import type { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow';
|
|
7
|
+
import type { PikkuWorkflowWire, PikkuScenarioWire, WorkflowStepOptions } from '@pikku/core/workflow';
|
|
8
8
|
export { WorkflowCancelledException };
|
|
9
9
|
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js';
|
|
10
10
|
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js';
|
|
@@ -16,11 +16,13 @@ export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
|
16
16
|
do<K extends keyof FlattenedWorkflowMap>(stepName: string, workflowName: K, data: FlattenedWorkflowMap[K]['input'], options?: WorkflowStepOptions): Promise<FlattenedWorkflowMap[K]['output']>;
|
|
17
17
|
do<T>(stepName: string, fn: () => T | Promise<T>, options?: WorkflowStepOptions): Promise<T>;
|
|
18
18
|
}
|
|
19
|
+
export type TypedScenario = TypedWorkflow & Omit<PikkuScenarioWire, keyof PikkuWorkflowWire>;
|
|
19
20
|
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
20
21
|
import type { InferSchemaOutput, PikkuPermission, PikkuMiddleware, NodeConfig, PikkuApprovalDescription } from '../function/pikku-function-types.gen.js';
|
|
21
22
|
import { PikkuError } from '@pikku/core/errors';
|
|
22
23
|
import type { CorePermissionGroup } from '@pikku/core';
|
|
23
24
|
export type PikkuFunctionWorkflow<In = unknown, Out = never> = PikkuFunctionSessionless<In, Out, 'workflow'>;
|
|
25
|
+
export type PikkuFunctionScenario<In = unknown, Out = never> = PikkuFunctionSessionless<In, Out, 'scenario' | 'actors'>;
|
|
24
26
|
export type PikkuWorkflowConfigWithSchema<InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined> = {
|
|
25
27
|
title?: string;
|
|
26
28
|
description?: string;
|
|
@@ -48,14 +50,17 @@ export declare function pikkuWorkflowFunc<InputSchema extends StandardSchemaV1 |
|
|
|
48
50
|
export declare function pikkuWorkflowFunc<In, Out = unknown>(func: PikkuFunctionWorkflow<In, Out> | PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>): PikkuFunctionConfig<In, Out, 'workflow'>;
|
|
49
51
|
export declare function pikkuWorkflowComplexFunc<InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined>(config: PikkuWorkflowConfigWithSchema<InputSchema, OutputSchema>): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'workflow', PikkuFunctionWorkflow<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>, InputSchema, OutputSchema>;
|
|
50
52
|
export declare function pikkuWorkflowComplexFunc<In, Out = unknown>(func: PikkuFunctionWorkflow<In, Out> | PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>): PikkuFunctionConfig<In, Out, 'workflow'>;
|
|
53
|
+
export type PikkuScenarioConfigWithSchema<InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined> = Omit<PikkuWorkflowConfigWithSchema<InputSchema, OutputSchema>, 'func'> & {
|
|
54
|
+
func: PikkuFunctionScenario<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>;
|
|
55
|
+
};
|
|
51
56
|
/**
|
|
52
57
|
* A scenario: a complex workflow that drives the app the way users do.
|
|
53
|
-
* Steps run as actors over the REAL transport — `
|
|
58
|
+
* Steps run as actors over the REAL transport — `scenario.do(step, rpc,
|
|
54
59
|
* data, { actor: actors.yasser })` — so flows double as e2e tests and
|
|
55
60
|
* staged/production health checks (no state reset; scope what you create).
|
|
56
61
|
*/
|
|
57
|
-
export declare function pikkuScenario<InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined>(config:
|
|
58
|
-
export declare function pikkuScenario<In, Out = unknown>(func:
|
|
62
|
+
export declare function pikkuScenario<InputSchema extends StandardSchemaV1 | undefined = undefined, OutputSchema extends StandardSchemaV1 | undefined = undefined>(config: PikkuScenarioConfigWithSchema<InputSchema, OutputSchema>): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'scenario' | 'actors', PikkuFunctionScenario<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>, InputSchema, OutputSchema>;
|
|
63
|
+
export declare function pikkuScenario<In, Out = unknown>(func: PikkuFunctionScenario<In, Out> | PikkuFunctionConfig<In, Out, 'scenario' | 'actors', PikkuFunctionScenario<In, Out>>): PikkuFunctionConfig<In, Out, 'scenario' | 'actors'>;
|
|
59
64
|
type TypedRef<T> = {
|
|
60
65
|
$ref: string;
|
|
61
66
|
path?: string;
|
package/dist/bin/pikku-bin.mjs
CHANGED
|
@@ -11,8 +11,8 @@ async function checkForUpdate() {
|
|
|
11
11
|
})
|
|
12
12
|
if (!res.ok) return
|
|
13
13
|
const { version: latest } = await res.json()
|
|
14
|
-
if (latest !== '0.12.
|
|
15
|
-
process.stderr.write(`\n Update available 0.12.
|
|
14
|
+
if (latest !== '0.12.80') {
|
|
15
|
+
process.stderr.write(`\n Update available 0.12.80 → ${latest}\n brew upgrade pikku or npm install -g @pikku/cli\n\n`)
|
|
16
16
|
}
|
|
17
17
|
} catch {}
|
|
18
18
|
}
|
|
@@ -7,7 +7,7 @@ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeNam
|
|
|
7
7
|
? nodeCategories.map((c) => `'${c}'`).join(' | ')
|
|
8
8
|
: 'string';
|
|
9
9
|
const workflowImport = workflowTypesImport ||
|
|
10
|
-
`import type { TypedWorkflow } from '../workflow/pikku-workflow-types.gen.js'`;
|
|
10
|
+
`import type { TypedWorkflow, TypedScenario } from '../workflow/pikku-workflow-types.gen.js'`;
|
|
11
11
|
return `/**
|
|
12
12
|
* Core function, middleware, and permission types for all wirings
|
|
13
13
|
*/
|
|
@@ -285,7 +285,7 @@ export type PikkuFunctionSessionless<
|
|
|
285
285
|
Out,
|
|
286
286
|
RequiredServices,
|
|
287
287
|
Session,
|
|
288
|
-
PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
|
288
|
+
PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario>, RequiredWires>
|
|
289
289
|
>
|
|
290
290
|
|
|
291
291
|
/**
|
|
@@ -306,7 +306,7 @@ export type PikkuFunction<
|
|
|
306
306
|
Out,
|
|
307
307
|
RequiredServices,
|
|
308
308
|
Session,
|
|
309
|
-
PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
|
309
|
+
PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario>, RequiredWires>
|
|
310
310
|
>
|
|
311
311
|
|
|
312
312
|
/**
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type PikkuWorkflowGraphConfig,
|
|
7
7
|
type PikkuWorkflowGraphResult,
|
|
8
8
|
} from '@pikku/core/workflow'
|
|
9
|
-
import type { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
|
9
|
+
import type { PikkuWorkflowWire, PikkuScenarioWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
|
10
10
|
|
|
11
11
|
export { WorkflowCancelledException }
|
|
12
12
|
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '${functionTypesImportPath}'
|
|
@@ -38,6 +38,8 @@ export interface TypedWorkflow extends PikkuWorkflowWire {
|
|
|
38
38
|
): Promise<T>
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
export type TypedScenario = TypedWorkflow & Omit<PikkuScenarioWire, keyof PikkuWorkflowWire>
|
|
42
|
+
|
|
41
43
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
42
44
|
import type { InferSchemaOutput, PikkuPermission, PikkuMiddleware, NodeConfig, PikkuApprovalDescription } from '${functionTypesImportPath}'
|
|
43
45
|
import { PikkuError } from '@pikku/core/errors'
|
|
@@ -48,6 +50,11 @@ export type PikkuFunctionWorkflow<
|
|
|
48
50
|
Out = never
|
|
49
51
|
> = PikkuFunctionSessionless<In, Out, 'workflow'>
|
|
50
52
|
|
|
53
|
+
export type PikkuFunctionScenario<
|
|
54
|
+
In = unknown,
|
|
55
|
+
Out = never
|
|
56
|
+
> = PikkuFunctionSessionless<In, Out, 'scenario' | 'actors'>
|
|
57
|
+
|
|
51
58
|
export type PikkuWorkflowConfigWithSchema<
|
|
52
59
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
53
60
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
@@ -108,9 +115,19 @@ export function pikkuWorkflowComplexFunc(func: any) {
|
|
|
108
115
|
return typeof func === 'function' ? { func } : func
|
|
109
116
|
}
|
|
110
117
|
|
|
118
|
+
export type PikkuScenarioConfigWithSchema<
|
|
119
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
120
|
+
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
121
|
+
> = Omit<PikkuWorkflowConfigWithSchema<InputSchema, OutputSchema>, 'func'> & {
|
|
122
|
+
func: PikkuFunctionScenario<
|
|
123
|
+
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
|
124
|
+
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown
|
|
125
|
+
>
|
|
126
|
+
}
|
|
127
|
+
|
|
111
128
|
/**
|
|
112
129
|
* A scenario: a complex workflow that drives the app the way users do.
|
|
113
|
-
* Steps run as actors over the REAL transport — \`
|
|
130
|
+
* Steps run as actors over the REAL transport — \`scenario.do(step, rpc,
|
|
114
131
|
* data, { actor: actors.yasser })\` — so flows double as e2e tests and
|
|
115
132
|
* staged/production health checks (no state reset; scope what you create).
|
|
116
133
|
*/
|
|
@@ -118,13 +135,13 @@ export function pikkuScenario<
|
|
|
118
135
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
119
136
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
120
137
|
>(
|
|
121
|
-
config:
|
|
122
|
-
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, '
|
|
138
|
+
config: PikkuScenarioConfigWithSchema<InputSchema, OutputSchema>
|
|
139
|
+
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'scenario' | 'actors', PikkuFunctionScenario<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown>, InputSchema, OutputSchema>
|
|
123
140
|
export function pikkuScenario<In, Out = unknown>(
|
|
124
141
|
func:
|
|
125
|
-
|
|
|
126
|
-
| PikkuFunctionConfig<In, Out, '
|
|
127
|
-
): PikkuFunctionConfig<In, Out, '
|
|
142
|
+
| PikkuFunctionScenario<In, Out>
|
|
143
|
+
| PikkuFunctionConfig<In, Out, 'scenario' | 'actors', PikkuFunctionScenario<In, Out>>
|
|
144
|
+
): PikkuFunctionConfig<In, Out, 'scenario' | 'actors'>
|
|
128
145
|
export function pikkuScenario(func: any) {
|
|
129
146
|
return typeof func === 'function' ? { func } : func
|
|
130
147
|
}
|
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Minimal semver range check for the shapes @pikku/cli publishes in its own
|
|
3
|
+
* peerDependencies (exact, ^, ~, >=/>/<=/< comparators, space-joined ANDs,
|
|
4
|
+
* || unions). Returns null when the range is not understood so the caller
|
|
5
|
+
* skips the check instead of false-blocking a build. No prerelease handling —
|
|
6
|
+
* a prerelease compares as its base version.
|
|
7
|
+
*/
|
|
8
|
+
export declare function coreSatisfiesRange(version: string, range: string): boolean | null;
|
|
9
|
+
/**
|
|
10
|
+
* Fail the build when the installed @pikku/core cannot work with this CLI.
|
|
11
|
+
*
|
|
12
|
+
* Two distinct failure classes, checked in order:
|
|
13
|
+
*
|
|
14
|
+
* 1. SPLIT (PKU717): more than one @pikku/core version installed. Two module
|
|
15
|
+
* instances means two separate pikkuState registries at runtime — wirings
|
|
16
|
+
* (workflows, RPCs, queue workers, middleware) register into whichever copy
|
|
17
|
+
* the wiring files import, while the runner may read the other, so they
|
|
18
|
+
* silently fail to resolve (the classic symptom being `WorkflowNotFoundError`
|
|
19
|
+
* for a workflow that is plainly registered). Distinct versions are the
|
|
20
|
+
* reliable signal: package managers dedupe identical versions to one physical
|
|
21
|
+
* copy, so >1 version guarantees a split.
|
|
3
22
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* registered). Distinct versions are the reliable signal: package managers dedupe
|
|
10
|
-
* identical versions to one physical copy, so >1 version guarantees a split.
|
|
23
|
+
* 2. SKEW (PKU718): exactly one @pikku/core, but its version violates the CLI's
|
|
24
|
+
* own @pikku/core peer range. Some package managers (bun, yarn) install past
|
|
25
|
+
* an unsatisfied peer range instead of failing, and the resulting pair breaks
|
|
26
|
+
* codegen/runtime with cryptic missing-export errors. Fail here with the
|
|
27
|
+
* exact versions instead.
|
|
11
28
|
*/
|
|
12
29
|
export declare function assertSingleCoreVersion(rootDir: string, logger: {
|
|
13
30
|
warn: (message: string) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { realpathSync } from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { glob } from 'tinyglobby';
|
|
5
6
|
import { ErrorCode } from '@pikku/inspector';
|
|
6
7
|
// Bounded globs (no unbounded `**`) covering the real @pikku/core copies each
|
|
@@ -14,15 +15,109 @@ const PATTERNS = [
|
|
|
14
15
|
'@*/*/node_modules/@pikku/core/package.json',
|
|
15
16
|
];
|
|
16
17
|
/**
|
|
17
|
-
*
|
|
18
|
+
* Minimal semver range check for the shapes @pikku/cli publishes in its own
|
|
19
|
+
* peerDependencies (exact, ^, ~, >=/>/<=/< comparators, space-joined ANDs,
|
|
20
|
+
* || unions). Returns null when the range is not understood so the caller
|
|
21
|
+
* skips the check instead of false-blocking a build. No prerelease handling —
|
|
22
|
+
* a prerelease compares as its base version.
|
|
23
|
+
*/
|
|
24
|
+
export function coreSatisfiesRange(version, range) {
|
|
25
|
+
const parse = (v) => {
|
|
26
|
+
const m = /^(\d+)\.(\d+)\.(\d+)/.exec(v);
|
|
27
|
+
return m ? [Number(m[1]), Number(m[2]), Number(m[3])] : null;
|
|
28
|
+
};
|
|
29
|
+
const cmp = (a, b) => {
|
|
30
|
+
for (let i = 0; i < 3; i++)
|
|
31
|
+
if (a[i] !== b[i])
|
|
32
|
+
return a[i] - b[i];
|
|
33
|
+
return 0;
|
|
34
|
+
};
|
|
35
|
+
const ver = parse(version);
|
|
36
|
+
if (!ver)
|
|
37
|
+
return null;
|
|
38
|
+
const comparator = (c) => {
|
|
39
|
+
const m = /^(\^|~|>=|<=|>|<|=)?\s*(\d+\.\d+\.\d+)$/.exec(c.trim());
|
|
40
|
+
if (!m)
|
|
41
|
+
return null;
|
|
42
|
+
const op = m[1] ?? '=';
|
|
43
|
+
const bound = parse(m[2]);
|
|
44
|
+
if (op === '>=')
|
|
45
|
+
return cmp(ver, bound) >= 0;
|
|
46
|
+
if (op === '>')
|
|
47
|
+
return cmp(ver, bound) > 0;
|
|
48
|
+
if (op === '<=')
|
|
49
|
+
return cmp(ver, bound) <= 0;
|
|
50
|
+
if (op === '<')
|
|
51
|
+
return cmp(ver, bound) < 0;
|
|
52
|
+
if (op === '=')
|
|
53
|
+
return cmp(ver, bound) === 0;
|
|
54
|
+
if (cmp(ver, bound) < 0)
|
|
55
|
+
return false;
|
|
56
|
+
// upper bound: ^ bumps the leftmost non-zero part; ~ bumps the minor
|
|
57
|
+
let upper;
|
|
58
|
+
if (op === '~')
|
|
59
|
+
upper = [bound[0], bound[1] + 1, 0];
|
|
60
|
+
else if (bound[0] > 0)
|
|
61
|
+
upper = [bound[0] + 1, 0, 0];
|
|
62
|
+
else if (bound[1] > 0)
|
|
63
|
+
upper = [0, bound[1] + 1, 0];
|
|
64
|
+
else
|
|
65
|
+
upper = [0, 0, bound[2] + 1];
|
|
66
|
+
return cmp(ver, upper) < 0;
|
|
67
|
+
};
|
|
68
|
+
for (const clause of range.split('||')) {
|
|
69
|
+
const comparators = clause.trim().split(/\s+/).filter(Boolean);
|
|
70
|
+
if (comparators.length === 0)
|
|
71
|
+
continue;
|
|
72
|
+
const results = comparators.map(comparator);
|
|
73
|
+
if (results.includes(null))
|
|
74
|
+
return null;
|
|
75
|
+
if (results.every(Boolean))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
// The CLI's own package.json — version + declared @pikku/core peer range.
|
|
81
|
+
// Dual path like get-cli-version.ts: ../../ from src/, ../../../ from dist/src/.
|
|
82
|
+
async function getCliManifest() {
|
|
83
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
84
|
+
for (const rel of ['../..', '../../..']) {
|
|
85
|
+
const raw = await readFile(path.join(here, rel, 'package.json'), 'utf-8').catch(() => '');
|
|
86
|
+
if (!raw)
|
|
87
|
+
continue;
|
|
88
|
+
try {
|
|
89
|
+
const pkg = JSON.parse(raw);
|
|
90
|
+
if (pkg.name !== '@pikku/cli')
|
|
91
|
+
continue;
|
|
92
|
+
const corePeerRange = pkg.peerDependencies?.['@pikku/core'];
|
|
93
|
+
if (typeof pkg.version === 'string' && typeof corePeerRange === 'string')
|
|
94
|
+
return { version: pkg.version, corePeerRange };
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Unparseable manifest — try the other layout.
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Fail the build when the installed @pikku/core cannot work with this CLI.
|
|
104
|
+
*
|
|
105
|
+
* Two distinct failure classes, checked in order:
|
|
18
106
|
*
|
|
19
|
-
*
|
|
20
|
-
* separate pikkuState registries
|
|
21
|
-
* workers, middleware) register into whichever copy
|
|
22
|
-
* while the runner may read the other, so they
|
|
23
|
-
* classic symptom being `WorkflowNotFoundError`
|
|
24
|
-
* registered). Distinct versions are the
|
|
25
|
-
* identical versions to one physical
|
|
107
|
+
* 1. SPLIT (PKU717): more than one @pikku/core version installed. Two module
|
|
108
|
+
* instances means two separate pikkuState registries at runtime — wirings
|
|
109
|
+
* (workflows, RPCs, queue workers, middleware) register into whichever copy
|
|
110
|
+
* the wiring files import, while the runner may read the other, so they
|
|
111
|
+
* silently fail to resolve (the classic symptom being `WorkflowNotFoundError`
|
|
112
|
+
* for a workflow that is plainly registered). Distinct versions are the
|
|
113
|
+
* reliable signal: package managers dedupe identical versions to one physical
|
|
114
|
+
* copy, so >1 version guarantees a split.
|
|
115
|
+
*
|
|
116
|
+
* 2. SKEW (PKU718): exactly one @pikku/core, but its version violates the CLI's
|
|
117
|
+
* own @pikku/core peer range. Some package managers (bun, yarn) install past
|
|
118
|
+
* an unsatisfied peer range instead of failing, and the resulting pair breaks
|
|
119
|
+
* codegen/runtime with cryptic missing-export errors. Fail here with the
|
|
120
|
+
* exact versions instead.
|
|
26
121
|
*/
|
|
27
122
|
export async function assertSingleCoreVersion(rootDir, logger) {
|
|
28
123
|
const nodeModules = path.join(path.resolve(rootDir), 'node_modules');
|
|
@@ -57,8 +152,10 @@ export async function assertSingleCoreVersion(rootDir, logger) {
|
|
|
57
152
|
}
|
|
58
153
|
}
|
|
59
154
|
const versions = new Set(byRealPath.values());
|
|
60
|
-
if (versions.size <= 1)
|
|
155
|
+
if (versions.size <= 1) {
|
|
156
|
+
await assertCoreVersionInPeerRange([...versions][0], logger);
|
|
61
157
|
return;
|
|
158
|
+
}
|
|
62
159
|
const found_ = [...byRealPath.entries()]
|
|
63
160
|
.sort((a, b) => a[1].localeCompare(b[1]))
|
|
64
161
|
.map(([p, v]) => ` ${v} ${path.dirname(p)}`)
|
|
@@ -78,3 +175,27 @@ export async function assertSingleCoreVersion(rootDir, logger) {
|
|
|
78
175
|
}
|
|
79
176
|
throw new Error(message);
|
|
80
177
|
}
|
|
178
|
+
// SKEW (PKU718): a single installed core that violates the CLI's own peer range.
|
|
179
|
+
async function assertCoreVersionInPeerRange(coreVersion, logger) {
|
|
180
|
+
if (!coreVersion)
|
|
181
|
+
return; // no core found — nothing to validate against
|
|
182
|
+
const cli = await getCliManifest();
|
|
183
|
+
if (!cli)
|
|
184
|
+
return; // manifest not found/parseable — never false-block a build
|
|
185
|
+
const ok = coreSatisfiesRange(coreVersion, cli.corePeerRange);
|
|
186
|
+
if (ok !== false)
|
|
187
|
+
return; // satisfied, or range not understood — skip
|
|
188
|
+
const message = `[${ErrorCode.CORE_VERSION_SKEW}] @pikku/cli@${cli.version} requires @pikku/core@${cli.corePeerRange} ` +
|
|
189
|
+
`(peerDependencies), but ${coreVersion} is installed.\n` +
|
|
190
|
+
`Some package managers (bun, yarn) install past an unsatisfied peer range instead of\n` +
|
|
191
|
+
`failing, and a cli/core version skew breaks codegen and runtime with cryptic\n` +
|
|
192
|
+
`missing-export errors.\n\n` +
|
|
193
|
+
`Fix: @pikku/cli and @pikku/core move together — bump both to the same release (update\n` +
|
|
194
|
+
`any overrides/resolutions pins too), then reinstall. Set PIKKU_ALLOW_CORE_SKEW=1 to\n` +
|
|
195
|
+
`downgrade this to a warning if you have verified the installed pair is compatible.`;
|
|
196
|
+
if (process.env?.PIKKU_ALLOW_CORE_SKEW) {
|
|
197
|
+
logger.warn(message);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
throw new Error(message);
|
|
201
|
+
}
|
|
@@ -118,7 +118,9 @@ export async function mapPreciseCoverage(scripts, getScriptSource, functionsMeta
|
|
|
118
118
|
}
|
|
119
119
|
export function mapLineHitsToReport(lineHits, functionsMeta) {
|
|
120
120
|
const functions = Object.values(functionsMeta)
|
|
121
|
-
.filter((m) => m.sourceFile &&
|
|
121
|
+
.filter((m) => m.sourceFile &&
|
|
122
|
+
!m.sourceFile.endsWith('.gen.ts') &&
|
|
123
|
+
m.funcWrapper !== 'pikkuScenario')
|
|
122
124
|
.map((m) => {
|
|
123
125
|
const hits = lineHits.get(m.bodySourceFile ?? m.sourceFile);
|
|
124
126
|
const covered = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.80",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"imports": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@pikku/bun-server": "^0.12.4",
|
|
33
33
|
"@pikku/deploy-cloudflare": "^0.12.8",
|
|
34
34
|
"@pikku/fetch": "^0.12.7",
|
|
35
|
-
"@pikku/inspector": "^0.12.
|
|
35
|
+
"@pikku/inspector": "^0.12.41",
|
|
36
36
|
"@pikku/kysely": "^0.13.0",
|
|
37
37
|
"@pikku/kysely-node-sqlite": "^0.12.3",
|
|
38
38
|
"@pikku/node-http-server": "^0.12.6",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"zod-to-ts": "^2.1.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@pikku/core": "^0.12.
|
|
62
|
+
"@pikku/core": "^0.12.62"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@pikku/core": "^0.12.
|
|
65
|
+
"@pikku/core": "^0.12.62",
|
|
66
66
|
"@types/istanbul-lib-instrument": "^1.7.7",
|
|
67
67
|
"@types/node": "^24.11.0",
|
|
68
68
|
"@types/pg": "^8.11.0",
|