@pikku/core 0.12.92 → 0.12.94

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/dist/errors/error-handler.d.ts +11 -0
  3. package/dist/errors/error-handler.js +8 -0
  4. package/dist/errors/serialized-error.d.ts +3 -0
  5. package/dist/function/function-runner.d.ts +1 -1
  6. package/dist/function/function-runner.js +3 -3
  7. package/dist/function/functions.types.d.ts +33 -21
  8. package/dist/middleware/auth-apikey.d.ts +7 -0
  9. package/dist/middleware/auth-apikey.js +6 -0
  10. package/dist/middleware/auth-bearer.d.ts +3 -0
  11. package/dist/middleware/auth-bearer.js +2 -0
  12. package/dist/middleware/auth-cookie.d.ts +9 -0
  13. package/dist/middleware/auth-cookie.js +6 -4
  14. package/dist/middleware/cors.d.ts +8 -0
  15. package/dist/middleware/cors.js +2 -0
  16. package/dist/middleware/middleware-factories.d.ts +14 -0
  17. package/dist/middleware/middleware-factories.js +14 -0
  18. package/dist/services/local-secrets.js +1 -1
  19. package/dist/services/personas-service.d.ts +4 -0
  20. package/dist/services/personas-service.js +4 -0
  21. package/dist/services/secret-service.d.ts +0 -1
  22. package/dist/testing/service-tests/secret-service-tests.js +1 -1
  23. package/dist/types/core.types.d.ts +5 -0
  24. package/dist/wirings/addon/wire-addon.d.ts +17 -15
  25. package/dist/wirings/addon/wire-addon.js +6 -0
  26. package/dist/wirings/addon/wire-remote-addon.d.ts +4 -0
  27. package/dist/wirings/addon/wire-remote-addon.js +4 -0
  28. package/dist/wirings/agent/agent-prepare.js +2 -2
  29. package/dist/wirings/agent/agent.types.d.ts +31 -27
  30. package/dist/wirings/agent-scorer/agent-scorer.d.ts +4 -0
  31. package/dist/wirings/agent-scorer/agent-scorer.js +4 -0
  32. package/dist/wirings/channel/channel.types.d.ts +11 -0
  33. package/dist/wirings/cli/cli.types.d.ts +43 -1
  34. package/dist/wirings/cli/define-cli-commands.d.ts +6 -1
  35. package/dist/wirings/cli/define-cli-commands.js +6 -1
  36. package/dist/wirings/credential/credential.types.d.ts +7 -0
  37. package/dist/wirings/gateway/gateway.types.d.ts +23 -0
  38. package/dist/wirings/http/http.types.d.ts +51 -37
  39. package/dist/wirings/mcp/mcp.types.d.ts +27 -0
  40. package/dist/wirings/persona/index.d.ts +1 -0
  41. package/dist/wirings/persona/index.js +1 -0
  42. package/dist/wirings/persona/persona-app-scopes.d.ts +41 -0
  43. package/dist/wirings/persona/persona-app-scopes.js +61 -0
  44. package/dist/wirings/queue/queue.types.d.ts +6 -0
  45. package/dist/wirings/scheduler/scheduler.types.d.ts +5 -0
  46. package/dist/wirings/secret/secret.types.d.ts +9 -14
  47. package/dist/wirings/secret/secret.types.js +7 -0
  48. package/dist/wirings/trigger/trigger.types.d.ts +4 -1
  49. package/dist/wirings/variable/variable.types.d.ts +14 -13
  50. package/dist/wirings/variable/variable.types.js +7 -0
  51. package/dist/wirings/workflow/graph/wire-workflow-graph.d.ts +7 -0
  52. package/dist/wirings/workflow/scenario-cookie-jar.d.ts +6 -0
  53. package/dist/wirings/workflow/scenario-cookie-jar.js +6 -0
  54. package/dist/wirings/workflow/scenario-poll.d.ts +6 -0
  55. package/dist/wirings/workflow/scenario-poll.js +6 -0
  56. package/dist/wirings/workflow/scenario-step-guards.d.ts +6 -0
  57. package/dist/wirings/workflow/scenario-step-guards.js +6 -0
  58. package/dist/wirings/workflow/workflow-errors.d.ts +4 -0
  59. package/dist/wirings/workflow/workflow-errors.js +4 -0
  60. package/package.json +1 -1
  61. package/src/app-leaf-surface.test.ts +2 -2
  62. package/src/errors/error-handler.ts +11 -0
  63. package/src/errors/serialized-error.ts +3 -0
  64. package/src/function/function-runner.ts +4 -4
  65. package/src/function/functions.types.ts +33 -21
  66. package/src/middleware/auth-apikey.ts +7 -0
  67. package/src/middleware/auth-bearer.ts +3 -0
  68. package/src/middleware/auth-cookie.ts +9 -4
  69. package/src/middleware/cors.ts +8 -0
  70. package/src/middleware/middleware-factories.ts +14 -0
  71. package/src/public-surface.json +3 -0
  72. package/src/services/local-secrets.test.ts +2 -2
  73. package/src/services/local-secrets.ts +1 -1
  74. package/src/services/personas-service.ts +4 -0
  75. package/src/services/secret-service.ts +0 -1
  76. package/src/testing/service-tests/secret-service-tests.ts +1 -1
  77. package/src/types/core.types.ts +5 -0
  78. package/src/wirings/addon/addon-auth-tags.test.ts +4 -4
  79. package/src/wirings/addon/wire-addon.ts +17 -15
  80. package/src/wirings/addon/wire-remote-addon.ts +4 -0
  81. package/src/wirings/agent/agent-authorization.test.ts +7 -3
  82. package/src/wirings/agent/agent-prepare.ts +2 -2
  83. package/src/wirings/agent/agent.types.ts +31 -27
  84. package/src/wirings/agent-scorer/agent-scorer.ts +4 -0
  85. package/src/wirings/channel/channel.types.ts +11 -0
  86. package/src/wirings/cli/cli.types.ts +44 -1
  87. package/src/wirings/cli/define-cli-commands.ts +6 -1
  88. package/src/wirings/credential/credential.types.ts +7 -0
  89. package/src/wirings/gateway/gateway-authorization.test.ts +3 -3
  90. package/src/wirings/gateway/gateway.types.ts +23 -0
  91. package/src/wirings/http/http-runner-addon-ref.test.ts +1 -1
  92. package/src/wirings/http/http.types.ts +94 -69
  93. package/src/wirings/mcp/mcp.types.ts +27 -0
  94. package/src/wirings/persona/index.ts +5 -0
  95. package/src/wirings/persona/persona-app-scopes.test.ts +47 -0
  96. package/src/wirings/persona/persona-app-scopes.ts +74 -0
  97. package/src/wirings/queue/queue.types.ts +6 -0
  98. package/src/wirings/scheduler/scheduler.types.ts +5 -0
  99. package/src/wirings/secret/secret.types.ts +9 -14
  100. package/src/wirings/trigger/trigger.types.ts +4 -1
  101. package/src/wirings/variable/variable.types.ts +14 -13
  102. package/src/wirings/workflow/graph/wire-workflow-graph.ts +7 -0
  103. package/src/wirings/workflow/scenario-cookie-jar.ts +6 -0
  104. package/src/wirings/workflow/scenario-poll.ts +6 -0
  105. package/src/wirings/workflow/scenario-step-guards.ts +6 -0
  106. package/src/wirings/workflow/workflow-errors.ts +4 -0
  107. package/tsconfig.tsbuildinfo +1 -1
@@ -2,12 +2,19 @@ export interface PikkuWorkflowGraphConfig<
2
2
  FuncMap extends Record<string, string>,
3
3
  T,
4
4
  > {
5
+ /** Keeps the graph in the codebase but out of the build. */
5
6
  disabled?: true
7
+ /** Unique across the project. It is how the graph is started and how its runs are grouped. */
6
8
  name?: string
9
+ /** What the graph does, for whoever is reading it rather than editing it. */
7
10
  description?: string
11
+ /** Filters this graph in and out of a build — see the `tags` option on `pikku all`. It has no effect at runtime. */
8
12
  tags?: string[]
13
+ /** The graph's steps, keyed by node id, each naming a function. `pikku meta` lists the names available here. */
9
14
  nodes: FuncMap
15
+ /** Per-node settings — retries, timeouts, the edges between them. */
10
16
  config?: T
17
+ /** Free text carried onto the rendered graph, for a reader who needs the reasoning the shape cannot show. */
11
18
  notes?: string[]
12
19
  }
13
20
 
@@ -4,6 +4,12 @@ export interface ScenarioCookieJar {
4
4
  readonly empty: boolean
5
5
  }
6
6
 
7
+ /**
8
+ * A cookie store for a scenario run, so a step that signs in leaves the session
9
+ * cookie behind for the steps after it.
10
+ *
11
+ * @example snippet: scenarioCookieJar
12
+ */
7
13
  export const createCookieJar = (apiUrl: string): ScenarioCookieJar => {
8
14
  const jar = new Map<string, string>()
9
15
  const origin = new URL(apiUrl).origin
@@ -3,6 +3,12 @@ export interface PollOptions {
3
3
  intervalMs?: number
4
4
  }
5
5
 
6
+ /**
7
+ * Retries an assertion until it passes or the timeout runs out — for the
8
+ * eventually-consistent parts of a scenario (a queued job, a projection).
9
+ *
10
+ * @example snippet: scenarioPolling
11
+ */
6
12
  export const pollUntil = async <T>(
7
13
  attempt: () => Promise<T | undefined> | T | undefined,
8
14
  { timeoutMs = 15_000, intervalMs = 250 }: PollOptions = {}
@@ -3,6 +3,12 @@ import type {
3
3
  ScenarioEnvironment,
4
4
  } from './scenario-step.types.js'
5
5
 
6
+ /**
7
+ * The environment the current scenario run targets, or a throw explaining that
8
+ * the run carries none. Use it in a step that needs the target's URLs.
9
+ *
10
+ * @example snippet: scenarioHttpStep
11
+ */
6
12
  export const requireScenarioEnv = (
7
13
  scenarioStep: PikkuScenarioStepWire | undefined
8
14
  ): ScenarioEnvironment => {
@@ -15,6 +15,10 @@ export class WorkflowAsyncException extends Error {
15
15
  }
16
16
  }
17
17
 
18
+ /**
19
+ * Thrown inside a workflow step when the run has been cancelled, so the step
20
+ * stops rather than finishing work nobody wants.
21
+ */
18
22
  export class WorkflowCancelledException extends Error {
19
23
  constructor(
20
24
  public readonly runId: string,