@pikku/core 0.12.69 → 0.12.70
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/CHANGELOG.md +334 -0
- package/README.md +34 -2
- package/dist/function/functions.types.d.ts +27 -0
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/pikku-state.js +1 -0
- package/dist/services/http-scenario-actors.d.ts +12 -4
- package/dist/services/http-scenario-actors.js +47 -45
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +1 -0
- package/dist/services/meta-service.d.ts +5 -1
- package/dist/services/meta-service.js +44 -18
- package/dist/services/scenario-actors-service.d.ts +108 -2
- package/dist/services/scenario-actors-service.js +40 -1
- package/dist/types/core.types.d.ts +21 -3
- package/dist/types/state.types.d.ts +3 -1
- package/dist/wirings/actor-flow/actor-flow.types.d.ts +1 -1
- package/dist/wirings/actor-flow/index.d.ts +1 -1
- package/dist/wirings/actor-flow/run-conversation.d.ts +10 -10
- package/dist/wirings/actor-flow/run-conversation.js +27 -27
- package/dist/wirings/cli/command-parser.js +11 -1
- package/dist/wirings/rpc/rpc-runner.js +1 -1
- package/dist/wirings/workflow/dsl/workflow-dsl.types.d.ts +52 -3
- package/dist/wirings/workflow/feature.d.ts +28 -0
- package/dist/wirings/workflow/feature.js +57 -0
- package/dist/wirings/workflow/index.d.ts +13 -2
- package/dist/wirings/workflow/index.js +15 -0
- package/dist/wirings/workflow/pikku-scenario-service.d.ts +121 -0
- package/dist/wirings/workflow/pikku-scenario-service.js +419 -0
- package/dist/wirings/workflow/pikku-workflow-service.d.ts +103 -10
- package/dist/wirings/workflow/pikku-workflow-service.js +80 -135
- package/dist/wirings/workflow/scenario-cookie-jar.d.ts +29 -0
- package/dist/wirings/workflow/scenario-cookie-jar.js +51 -0
- package/dist/wirings/workflow/scenario-poll.d.ts +20 -0
- package/dist/wirings/workflow/scenario-poll.js +25 -0
- package/dist/wirings/workflow/scenario-prose.d.ts +38 -0
- package/dist/wirings/workflow/scenario-prose.js +45 -0
- package/dist/wirings/workflow/scenario-step-guards.d.ts +16 -0
- package/dist/wirings/workflow/scenario-step-guards.js +29 -0
- package/dist/wirings/workflow/scenario-step.types.d.ts +148 -0
- package/dist/wirings/workflow/scenario-step.types.js +1 -0
- package/dist/wirings/workflow/workflow.types.d.ts +81 -2
- package/package.json +3 -1
- package/src/function/functions.types.ts +32 -0
- package/src/index.ts +1 -0
- package/src/internal.ts +5 -1
- package/src/pikku-state.ts +1 -0
- package/src/services/http-scenario-actors.test.ts +85 -1
- package/src/services/http-scenario-actors.ts +65 -51
- package/src/services/index.ts +5 -0
- package/src/services/meta-service.test.ts +79 -0
- package/src/services/meta-service.ts +61 -26
- package/src/services/scenario-actors-service.ts +157 -2
- package/src/types/core.types.ts +27 -2
- package/src/types/state.types.ts +3 -0
- package/src/wirings/actor-flow/actor-flow.types.ts +1 -1
- package/src/wirings/actor-flow/index.ts +1 -1
- package/src/wirings/actor-flow/run-conversation.test.ts +12 -6
- package/src/wirings/actor-flow/run-conversation.ts +36 -41
- package/src/wirings/cli/command-parser.test.ts +60 -0
- package/src/wirings/cli/command-parser.ts +12 -1
- package/src/wirings/rpc/rpc-runner.test.ts +28 -5
- package/src/wirings/rpc/rpc-runner.ts +1 -1
- package/src/wirings/workflow/dsl/workflow-dsl.types.ts +86 -2
- package/src/wirings/workflow/feature.test.ts +131 -0
- package/src/wirings/workflow/feature.ts +78 -0
- package/src/wirings/workflow/index.ts +73 -0
- package/src/wirings/workflow/pikku-scenario-service.ts +682 -0
- package/src/wirings/workflow/pikku-workflow-service.test.ts +55 -0
- package/src/wirings/workflow/pikku-workflow-service.ts +196 -208
- package/src/wirings/workflow/scenario-cookie-jar.test.ts +108 -0
- package/src/wirings/workflow/scenario-cookie-jar.ts +65 -0
- package/src/wirings/workflow/scenario-hooks.test.ts +212 -0
- package/src/wirings/workflow/scenario-poll.test.ts +66 -0
- package/src/wirings/workflow/scenario-poll.ts +36 -0
- package/src/wirings/workflow/scenario-prose.test.ts +152 -0
- package/src/wirings/workflow/scenario-prose.ts +79 -0
- package/src/wirings/workflow/scenario-service.test.ts +155 -0
- package/src/wirings/workflow/scenario-step-guards.ts +43 -0
- package/src/wirings/workflow/scenario-step.test.ts +441 -8
- package/src/wirings/workflow/scenario-step.types.ts +157 -0
- package/src/wirings/workflow/workflow.types.ts +98 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { pikkuState } from '../../pikku-state.js'
|
|
2
|
+
import type {
|
|
3
|
+
CoreFeature,
|
|
4
|
+
CoreWorkflow,
|
|
5
|
+
FeaturePlanEntry,
|
|
6
|
+
} from './workflow.types.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Register a feature under the name it is exported as. Called from generated
|
|
10
|
+
* wiring, the same way `addWorkflow` is.
|
|
11
|
+
*/
|
|
12
|
+
export const addFeature = (
|
|
13
|
+
featureId: string,
|
|
14
|
+
feature: CoreFeature,
|
|
15
|
+
packageName: string | null = null
|
|
16
|
+
) => {
|
|
17
|
+
pikkuState(packageName, 'workflows', 'features').set(featureId, feature)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolve every feature's scenario references back to the names their
|
|
22
|
+
* scenarios are registered under.
|
|
23
|
+
*
|
|
24
|
+
* Matching is by **object identity**: `pikkuScenario` returns its config
|
|
25
|
+
* verbatim and `addWorkflow` registers that same object, so a feature holding
|
|
26
|
+
* the imported identifier holds the very object that was registered. Nothing
|
|
27
|
+
* is matched by shape, by name, or by any other guess — which is also why a
|
|
28
|
+
* scenario built inline inside a feature (and therefore never registered)
|
|
29
|
+
* comes back as unresolved rather than silently running as something else.
|
|
30
|
+
*
|
|
31
|
+
* Entries are returned in declaration order, features in registration order.
|
|
32
|
+
* A scenario's effective tags are its own plus the containing feature's, so
|
|
33
|
+
* `--tags credential` selects through the feature.
|
|
34
|
+
*/
|
|
35
|
+
export const resolveFeatureScenarios = (
|
|
36
|
+
features: Map<string, CoreFeature>,
|
|
37
|
+
registrations: Map<string, CoreWorkflow>
|
|
38
|
+
): {
|
|
39
|
+
entries: FeaturePlanEntry[]
|
|
40
|
+
unresolved: Array<{ featureId: string; index: number }>
|
|
41
|
+
} => {
|
|
42
|
+
const nameByConfig = new Map<unknown, string>()
|
|
43
|
+
for (const [name, registration] of registrations) {
|
|
44
|
+
nameByConfig.set(registration.func, name)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const entries: FeaturePlanEntry[] = []
|
|
48
|
+
const unresolved: Array<{ featureId: string; index: number }> = []
|
|
49
|
+
|
|
50
|
+
for (const [featureId, feature] of features) {
|
|
51
|
+
const scenarios = feature.scenarios ?? []
|
|
52
|
+
for (let index = 0; index < scenarios.length; index++) {
|
|
53
|
+
const entry = scenarios[index]!
|
|
54
|
+
const paired =
|
|
55
|
+
typeof entry === 'object' && entry !== null && 'scenario' in entry
|
|
56
|
+
const config = paired ? (entry as any).scenario : entry
|
|
57
|
+
const scenarioName = nameByConfig.get(config)
|
|
58
|
+
if (!scenarioName) {
|
|
59
|
+
unresolved.push({ featureId, index })
|
|
60
|
+
continue
|
|
61
|
+
}
|
|
62
|
+
entries.push({
|
|
63
|
+
featureId,
|
|
64
|
+
featureName: feature.name ?? featureId,
|
|
65
|
+
scenarioName,
|
|
66
|
+
data: paired ? (entry as any).data : undefined,
|
|
67
|
+
tags: [
|
|
68
|
+
...new Set([
|
|
69
|
+
...((registrations.get(scenarioName)?.func as any)?.tags ?? []),
|
|
70
|
+
...(feature.tags ?? []),
|
|
71
|
+
]),
|
|
72
|
+
],
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return { entries, unresolved }
|
|
78
|
+
}
|
|
@@ -11,6 +11,11 @@ export {
|
|
|
11
11
|
WorkflowApprovalResolvedError,
|
|
12
12
|
DEFAULT_STEP_RETRIES,
|
|
13
13
|
} from './pikku-workflow-service.js'
|
|
14
|
+
export type {
|
|
15
|
+
RunLifecycleContext,
|
|
16
|
+
WorkflowRunEngine,
|
|
17
|
+
WorkflowRunExtension,
|
|
18
|
+
} from './pikku-workflow-service.js'
|
|
14
19
|
export { deriveInvocationId, uuidv5 } from './workflow-invocation-id.js'
|
|
15
20
|
|
|
16
21
|
// Time-travel: reconstruct run state at any point from durable history
|
|
@@ -29,6 +34,7 @@ export type {
|
|
|
29
34
|
|
|
30
35
|
// Internal registration functions (used by generated code)
|
|
31
36
|
export { addWorkflow } from './dsl/workflow-runner.js'
|
|
37
|
+
export { addFeature, resolveFeatureScenarios } from './feature.js'
|
|
32
38
|
|
|
33
39
|
// Graph helpers (template, pikkuWorkflowGraph)
|
|
34
40
|
export { template, type TemplateString } from './graph/template.js'
|
|
@@ -72,6 +78,12 @@ export type {
|
|
|
72
78
|
WorkflowRunService,
|
|
73
79
|
WorkflowRunMirror,
|
|
74
80
|
CoreWorkflow,
|
|
81
|
+
CoreFeature,
|
|
82
|
+
CoreFeatureScenario,
|
|
83
|
+
FeatureMeta,
|
|
84
|
+
FeatureMetaEntry,
|
|
85
|
+
FeaturesMeta,
|
|
86
|
+
FeaturePlanEntry,
|
|
75
87
|
PikkuWorkflow,
|
|
76
88
|
ContextVariable,
|
|
77
89
|
WorkflowContext,
|
|
@@ -113,8 +125,69 @@ export type {
|
|
|
113
125
|
SwitchStepMeta,
|
|
114
126
|
FilterStepMeta,
|
|
115
127
|
ArrayPredicateStepMeta,
|
|
128
|
+
ScenarioStepInvocation,
|
|
129
|
+
ScenarioStepMeta,
|
|
116
130
|
WorkflowStepMeta,
|
|
117
131
|
WorkflowStepWire,
|
|
118
132
|
PikkuWorkflowWire,
|
|
119
133
|
PikkuScenarioWire,
|
|
120
134
|
} from './workflow.types.js'
|
|
135
|
+
|
|
136
|
+
/* ------------------------------------------------------------------ *
|
|
137
|
+
* Scenarios — writing a step
|
|
138
|
+
*
|
|
139
|
+
* What a step file imports. Everything here is reached from inside a
|
|
140
|
+
* `pikkuScenarioStep` body.
|
|
141
|
+
* ------------------------------------------------------------------ */
|
|
142
|
+
|
|
143
|
+
// The step's own wire, and the shape of what it was given
|
|
144
|
+
export type {
|
|
145
|
+
ScenarioStepPhase,
|
|
146
|
+
ScenarioStepOptions,
|
|
147
|
+
PikkuScenarioStepWire,
|
|
148
|
+
ScenarioEnvironment,
|
|
149
|
+
} from './scenario-step.types.js'
|
|
150
|
+
|
|
151
|
+
// Narrows the optional halves of the step wire, with a message that says what to do
|
|
152
|
+
export { requireActor, requireScenarioEnv } from './scenario-step-guards.js'
|
|
153
|
+
|
|
154
|
+
// Waits for the target to catch up, without every step writing the loop again
|
|
155
|
+
export { pollUntil, type PollOptions } from './scenario-poll.js'
|
|
156
|
+
|
|
157
|
+
// Persists cookies across a step's requests, the way a browser would
|
|
158
|
+
export { createCookieJar } from './scenario-cookie-jar.js'
|
|
159
|
+
export type { ScenarioCookieJar } from './scenario-cookie-jar.js'
|
|
160
|
+
|
|
161
|
+
// What the transport answered — an actor's `invokeRaw`, or a route reached
|
|
162
|
+
// directly — and the one way to POST JSON at a route and keep its status
|
|
163
|
+
export type {
|
|
164
|
+
ScenarioHttpResponse,
|
|
165
|
+
ScenarioJsonRequest,
|
|
166
|
+
} from '../../services/scenario-actors-service.js'
|
|
167
|
+
export {
|
|
168
|
+
readScenarioHttpResponse,
|
|
169
|
+
postScenarioJson,
|
|
170
|
+
} from '../../services/scenario-actors-service.js'
|
|
171
|
+
|
|
172
|
+
/* ------------------------------------------------------------------ *
|
|
173
|
+
* Scenarios — driving a browser
|
|
174
|
+
*
|
|
175
|
+
* How a step names an element, and what a driver package
|
|
176
|
+
* (`@pikku/playwright`, or another) implements.
|
|
177
|
+
* ------------------------------------------------------------------ */
|
|
178
|
+
|
|
179
|
+
export type {
|
|
180
|
+
PikkuBrowserWire,
|
|
181
|
+
TestIdSelector,
|
|
182
|
+
ScenarioBrowserProvider,
|
|
183
|
+
ScenarioBrowserFailure,
|
|
184
|
+
} from './scenario-step.types.js'
|
|
185
|
+
|
|
186
|
+
/* ------------------------------------------------------------------ *
|
|
187
|
+
* Scenarios — reporting a run
|
|
188
|
+
*
|
|
189
|
+
* Used by the CLI reporter and the console, so the two render the same
|
|
190
|
+
* sentence for the same step. A step body needs none of it.
|
|
191
|
+
* ------------------------------------------------------------------ */
|
|
192
|
+
|
|
193
|
+
export { composeStepProse, renderStepTemplate } from './scenario-prose.js'
|