@pikku/addon-meta-conversions 0.1.1 → 0.1.3
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/.pikku/addon/pikku-addon-types.gen.ts +105 -0
- package/.pikku/addon/pikku-package.gen.ts +11 -0
- package/.pikku/agent/pikku-agent-map.gen.d.ts +4 -0
- package/.pikku/agent/pikku-agent-types.gen.ts +84 -0
- package/.pikku/channel/pikku-channel-types.gen.ts +177 -0
- package/.pikku/console/pikku-addon-meta.gen.json +36 -0
- package/.pikku/console/pikku-node-types.gen.ts +8 -0
- package/.pikku/function/pikku-function-types.gen.ts +797 -0
- package/.pikku/function/pikku-functions-meta-verbose.gen.json +33 -0
- package/.pikku/function/pikku-functions-meta.gen.json +27 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +7 -0
- package/.pikku/function/pikku-functions.gen.ts +8 -0
- package/.pikku/http/pikku-http-types.gen.ts +119 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
- package/.pikku/pikku-bootstrap-scenarios.gen.ts +9 -0
- package/.pikku/pikku-bootstrap.gen.ts +8 -0
- package/.pikku/pikku-meta-service.gen.ts +10 -0
- package/.pikku/pikku-services.gen.ts +50 -0
- package/.pikku/pikku-types.gen.ts +24 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +135 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +136 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +135 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +3 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
- package/.pikku/scenarios/features.gen.json +1 -0
- package/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +1 -0
- package/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +12 -0
- package/.pikku/scenarios/pikku-scenario-functions.gen.ts +4 -0
- package/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +15 -0
- package/.pikku/scenarios/pikku-scenario-wirings.gen.ts +4 -0
- package/.pikku/scenarios/schemas/register.gen.ts +4 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/.pikku/schemas/register.gen.ts +15 -0
- package/.pikku/schemas/schemas/EventSendInput.schema.json +1 -0
- package/.pikku/schemas/schemas/EventSendOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/SecretSchema_metaConversions.schema.json +1 -0
- package/.pikku/scopes/pikku-personas-meta.gen.json +1 -0
- package/.pikku/scopes/pikku-personas.gen.ts +52 -0
- package/.pikku/scopes/pikku-roles-meta.gen.json +1 -0
- package/.pikku/scopes/pikku-roles.gen.ts +41 -0
- package/.pikku/scopes/pikku-scope-types.gen.ts +7 -0
- package/.pikku/scopes/pikku-scopes-meta.gen.json +1 -0
- package/.pikku/scopes/pikku-scopes.gen.ts +58 -0
- package/.pikku/secrets/pikku-secret-types.gen.ts +5 -0
- package/.pikku/secrets/pikku-secrets-meta.gen.json +10 -0
- package/.pikku/secrets/pikku-secrets.gen.ts +36 -0
- package/.pikku/trigger/pikku-trigger-types.gen.ts +160 -0
- package/.pikku/variables/pikku-variable-types.gen.ts +5 -0
- package/.pikku/variables/pikku-variables-meta.gen.json +1 -0
- package/.pikku/variables/pikku-variables.gen.ts +34 -0
- package/.pikku/workflow/personas.gen.json +1 -0
- package/.pikku/workflow/pikku-personas.gen.ts +38 -0
- package/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +18 -0
- package/.pikku/workflow/pikku-workflow-map.gen.d.ts +38 -0
- package/.pikku/workflow/pikku-workflow-types.gen.ts +591 -0
- package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +9 -0
- package/.pikku/workflow/pikku-workflow-wirings.gen.ts +3 -0
- package/dist/.pikku/addon/pikku-addon-types.gen.d.ts +4 -4
- package/dist/.pikku/addon/pikku-addon-types.gen.d.ts.map +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.js +7 -3
- package/dist/.pikku/addon/pikku-addon-types.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-addon-types.gen.ts +11 -6
- package/dist/.pikku/addon/pikku-package.gen.js +2 -1
- package/dist/.pikku/addon/pikku-package.gen.js.map +1 -1
- package/dist/.pikku/addon/pikku-package.gen.ts +3 -1
- package/dist/.pikku/agent/pikku-agent-map.gen.d.ts +2 -14
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +8 -6
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.js.map +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.ts +15 -7
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +112 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts.map +1 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +60 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js.map +1 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.ts +177 -0
- package/dist/.pikku/console/pikku-addon-meta.gen.json +4 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +133 -133
- package/dist/.pikku/function/pikku-function-types.gen.d.ts.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +98 -61
- package/dist/.pikku/function/pikku-function-types.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.ts +268 -157
- package/dist/.pikku/function/pikku-functions-meta-verbose.gen.json +5 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +8 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.ts +1 -1
- package/dist/.pikku/function/pikku-functions.gen.js +2 -2
- package/dist/.pikku/function/pikku-functions.gen.js.map +1 -1
- package/dist/.pikku/function/pikku-functions.gen.ts +2 -2
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +98 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts.map +1 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +50 -0
- package/dist/.pikku/http/pikku-http-types.gen.js.map +1 -0
- package/dist/.pikku/http/pikku-http-types.gen.ts +119 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +131 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts.map +1 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +38 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js.map +1 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.ts +183 -0
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts +10 -0
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.d.ts.map +1 -0
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +10 -0
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.js.map +1 -0
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.ts +9 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +4 -2
- package/dist/.pikku/pikku-bootstrap.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +2 -10
- package/dist/.pikku/pikku-bootstrap.gen.js.map +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.ts +2 -9
- package/dist/.pikku/pikku-meta-service.gen.d.ts +8 -0
- package/dist/.pikku/pikku-meta-service.gen.d.ts.map +1 -0
- package/dist/.pikku/pikku-meta-service.gen.js +10 -0
- package/dist/.pikku/pikku-meta-service.gen.js.map +1 -0
- package/dist/.pikku/pikku-meta-service.gen.ts +10 -0
- package/dist/.pikku/pikku-services.gen.d.ts +15 -2
- package/dist/.pikku/pikku-services.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-services.gen.js +14 -0
- package/dist/.pikku/pikku-services.gen.js.map +1 -1
- package/dist/.pikku/pikku-services.gen.ts +17 -2
- package/dist/.pikku/pikku-types.gen.d.ts +2 -1
- package/dist/.pikku/pikku-types.gen.d.ts.map +1 -1
- package/dist/.pikku/pikku-types.gen.js +3 -1
- package/dist/.pikku/pikku-types.gen.js.map +1 -1
- package/dist/.pikku/pikku-types.gen.ts +4 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts.map +1 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js.map +1 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +28 -8
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +28 -8
- package/dist/.pikku/rpc/pikku-rpc-wirings-map.remote.gen.d.ts +135 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +2 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts.map +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +7 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js.map +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +3 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +6 -0
- package/dist/.pikku/scenarios/features.gen.json +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.d.ts +2 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.d.ts.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +11 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.json +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.ts +12 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +5 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.js +2 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.js.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.ts +4 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.d.ts +2 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.d.ts.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +11 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.ts +15 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +5 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.js +2 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.js.map +1 -0
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.ts +4 -0
- package/dist/.pikku/scenarios/schemas/register.gen.d.ts +5 -0
- package/dist/.pikku/scenarios/schemas/register.gen.d.ts.map +1 -0
- package/dist/.pikku/scenarios/schemas/register.gen.js +5 -0
- package/dist/.pikku/scenarios/schemas/register.gen.js.map +1 -0
- package/dist/.pikku/scenarios/schemas/register.gen.ts +4 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts.map +1 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js.map +1 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/dist/.pikku/schemas/register.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.ts +1 -1
- package/dist/.pikku/scopes/pikku-personas-meta.gen.json +1 -0
- package/dist/.pikku/scopes/pikku-personas.gen.d.ts +37 -0
- package/dist/.pikku/scopes/pikku-personas.gen.d.ts.map +1 -0
- package/dist/.pikku/scopes/pikku-personas.gen.js +18 -0
- package/dist/.pikku/scopes/pikku-personas.gen.js.map +1 -0
- package/dist/.pikku/scopes/pikku-personas.gen.ts +52 -0
- package/dist/.pikku/scopes/pikku-roles-meta.gen.json +1 -0
- package/dist/.pikku/scopes/pikku-roles.gen.d.ts +31 -0
- package/dist/.pikku/scopes/pikku-roles.gen.d.ts.map +1 -0
- package/dist/.pikku/scopes/pikku-roles.gen.js +19 -0
- package/dist/.pikku/scopes/pikku-roles.gen.js.map +1 -0
- package/dist/.pikku/scopes/pikku-roles.gen.ts +41 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +8 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts.map +1 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.js +6 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.js.map +1 -0
- package/dist/.pikku/scopes/pikku-scope-types.gen.ts +7 -0
- package/dist/.pikku/scopes/pikku-scopes-meta.gen.json +1 -0
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +36 -0
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts.map +1 -0
- package/dist/.pikku/scopes/pikku-scopes.gen.js +28 -0
- package/dist/.pikku/scopes/pikku-scopes.gen.js.map +1 -0
- package/dist/.pikku/scopes/pikku-scopes.gen.ts +58 -0
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +2 -2
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts.map +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +2 -2
- package/dist/.pikku/secrets/pikku-secret-types.gen.js.map +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.ts +2 -2
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +11 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts.map +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +12 -2
- package/dist/.pikku/secrets/pikku-secrets.gen.js.map +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.ts +15 -2
- 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/trigger/pikku-trigger-types.gen.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +2 -2
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts.map +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +2 -2
- package/dist/.pikku/variables/pikku-variable-types.gen.js.map +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.ts +2 -2
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +11 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts.map +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +13 -3
- package/dist/.pikku/variables/pikku-variables.gen.js.map +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.ts +16 -3
- package/dist/.pikku/workflow/personas.gen.json +1 -0
- package/dist/.pikku/workflow/pikku-personas.gen.d.ts +16 -0
- package/dist/.pikku/workflow/pikku-personas.gen.d.ts.map +1 -0
- package/dist/.pikku/workflow/pikku-personas.gen.js +18 -0
- package/dist/.pikku/workflow/pikku-personas.gen.js.map +1 -0
- package/dist/.pikku/workflow/pikku-personas.gen.ts +38 -0
- package/dist/.pikku/workflow/pikku-scenario-step-map.gen.d.ts +18 -0
- package/dist/.pikku/workflow/pikku-workflow-map.gen.d.ts +9 -5
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +289 -31
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +66 -18
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.ts +494 -61
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js.map +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +3 -3
- 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/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -1
- package/dist/src/functions/events/send.function.d.ts +2 -2
- package/dist/src/functions/events/send.function.d.ts.map +1 -1
- package/dist/src/meta-conversions.secret.js +2 -2
- package/dist/src/meta-conversions.secret.js.map +1 -1
- package/dist/src/services.d.ts.map +1 -1
- package/dist/src/services.js +1 -1
- package/dist/src/services.js.map +1 -1
- package/package.json +7 -6
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts +0 -2
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.d.ts.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +0 -7
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.json +0 -3
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.ts +0 -7
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +0 -5
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +0 -5
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js.map +0 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.ts +0 -3
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* This file was generated by @pikku/cli@0.12.
|
|
2
|
+
* This file was generated by @pikku/cli@0.12.96
|
|
3
3
|
*/
|
|
4
4
|
/**
|
|
5
5
|
* Core function, middleware, and permission types for all wirings
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import type { CorePikkuMiddleware, CorePermissionGroup, ListInput, ListOutput, PikkuWire, PickRequired, SecretlessServices, SecretService } from '@pikku/core'
|
|
9
|
+
import type { CorePikkuFunctionConfig, CorePikkuAuth, CorePikkuAuthConfig, CorePikkuPermission } from '@pikku/core/function'
|
|
10
|
+
import { pikkuAuth as pikkuAuthCore } from '@pikku/core/function'
|
|
11
|
+
import {
|
|
12
|
+
addTagMiddleware as addTagMiddlewareCore,
|
|
13
|
+
addGlobalMiddleware as addGlobalMiddlewareCore,
|
|
14
|
+
addGlobalPermission as addGlobalPermissionCore,
|
|
15
|
+
} from '@pikku/core/middleware'
|
|
9
16
|
import { pikkuState as __pikkuState, CreateWireServices } from '@pikku/core/internal'
|
|
10
|
-
import { pikkuAuth as pikkuAuthCore } from '@pikku/core'
|
|
11
|
-
import { PikkuError } from '@pikku/core/errors'
|
|
12
17
|
import type { NodeType } from '@pikku/core/node'
|
|
18
|
+
import type { ScopeId } from '../scopes/pikku-scopes.gen.js'
|
|
13
19
|
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
|
14
20
|
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
15
21
|
|
|
@@ -19,13 +25,37 @@ import type { Services } from '../../types/application-types.d.js'
|
|
|
19
25
|
import type { Config } from '../../types/application-types.d.js'
|
|
20
26
|
import type { TypedPikkuRPC, FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
|
|
21
27
|
import type { RequiredSingletonServices, RequiredWireServices } from '../pikku-services.gen.js'
|
|
22
|
-
import type { TypedWorkflow } from '../workflow/pikku-workflow-types.gen.js'
|
|
28
|
+
import type { TypedWorkflow, TypedScenario, TypedPersonas } from '../workflow/pikku-workflow-types.gen.js'
|
|
23
29
|
|
|
24
30
|
export type { SingletonServices as SingletonServices }
|
|
25
31
|
export type { Services as Services }
|
|
26
32
|
export type Session = UserSession
|
|
27
33
|
|
|
28
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The services a wired function actually receives. The inspector records which
|
|
37
|
+
* services each wired `func`, `permissions` and `middleware` destructures and
|
|
38
|
+
* emits them as `RequiredSingletonServices`; intersecting that here makes those
|
|
39
|
+
* services **non-optional** at every call site. A service is optional only when
|
|
40
|
+
* nothing destructures it — in which case it is never created either. This is
|
|
41
|
+
* why an `if (!service)` guard inside a function body is always dead code.
|
|
42
|
+
*/
|
|
43
|
+
export type WiredSingletonServices = RequiredSingletonServices & SingletonServices
|
|
44
|
+
export type WiredServices = SecretlessServices<RequiredSingletonServices & Services>
|
|
45
|
+
|
|
46
|
+
/** `WiredSingletonServices` without `secrets`, for auth gates. */
|
|
47
|
+
export type WiredAuthServices = SecretlessServices<WiredSingletonServices>
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* `WiredServices` with `secrets` restored, for the console's secret-admin
|
|
51
|
+
* functions. Reached by declaring `secretBroker: true` on a `pikkuFunc` config.
|
|
52
|
+
*
|
|
53
|
+
* Declaring it does not grant the service. The runner hands out the real
|
|
54
|
+
* `SecretService` only to the functions the inspector marks as secret brokers;
|
|
55
|
+
* every other function still receives the throwing accessor.
|
|
56
|
+
*/
|
|
57
|
+
export type WiredSecretBrokerServices = WiredServices & { secrets: SecretService }
|
|
58
|
+
|
|
29
59
|
/**
|
|
30
60
|
* Inline node configuration for function definitions.
|
|
31
61
|
*/
|
|
@@ -43,7 +73,7 @@ export type NodeConfig = {
|
|
|
43
73
|
* @template In - The input type that the permission check will receive
|
|
44
74
|
* @template RequiredServices - The services required for this permission check
|
|
45
75
|
*/
|
|
46
|
-
export type PikkuPermission<In = unknown, RequiredServices extends Services =
|
|
76
|
+
export type PikkuPermission<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = CorePikkuPermission<In, RequiredServices, PikkuWire<In, never, false, Session>>
|
|
47
77
|
|
|
48
78
|
/**
|
|
49
79
|
* Type-safe middleware definition that can access your application's services and session.
|
|
@@ -51,12 +81,12 @@ export type PikkuPermission<In = unknown, RequiredServices extends Services = Se
|
|
|
51
81
|
*
|
|
52
82
|
* @template RequiredServices - The services required for this middleware
|
|
53
83
|
*/
|
|
54
|
-
export type PikkuMiddleware<RequiredServices extends SingletonServices =
|
|
84
|
+
export type PikkuMiddleware<RequiredServices extends SingletonServices = WiredSingletonServices> = CorePikkuMiddleware<RequiredServices>
|
|
55
85
|
|
|
56
86
|
/**
|
|
57
87
|
* Configuration object for creating a permission with metadata
|
|
58
88
|
*/
|
|
59
|
-
export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services =
|
|
89
|
+
export type PikkuPermissionConfig<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = {
|
|
60
90
|
/** The permission function */
|
|
61
91
|
func: PikkuPermission<In, RequiredServices>
|
|
62
92
|
/** Optional human-readable name for the permission */
|
|
@@ -101,12 +131,12 @@ export const pikkuPermission = <In>(
|
|
|
101
131
|
*
|
|
102
132
|
* @template RequiredServices - The services required for this auth check
|
|
103
133
|
*/
|
|
104
|
-
export type PikkuAuth<RequiredServices extends SingletonServices =
|
|
134
|
+
export type PikkuAuth<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuth<RequiredServices, Session>
|
|
105
135
|
|
|
106
136
|
/**
|
|
107
137
|
* Configuration object for creating an auth permission with metadata
|
|
108
138
|
*/
|
|
109
|
-
export type PikkuAuthConfig<RequiredServices extends SingletonServices =
|
|
139
|
+
export type PikkuAuthConfig<RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices> = CorePikkuAuthConfig<RequiredServices, Session>
|
|
110
140
|
|
|
111
141
|
/**
|
|
112
142
|
* Factory function for creating auth-only permissions with tree-shaking support.
|
|
@@ -128,7 +158,7 @@ export type PikkuAuthConfig<RequiredServices extends SingletonServices = Singlet
|
|
|
128
158
|
* })
|
|
129
159
|
* \`\`\`
|
|
130
160
|
*/
|
|
131
|
-
export const pikkuAuth = <RequiredServices extends SingletonServices =
|
|
161
|
+
export const pikkuAuth = <RequiredServices extends SecretlessServices<SingletonServices> = WiredAuthServices>(
|
|
132
162
|
auth: PikkuAuth<RequiredServices> | PikkuAuthConfig<RequiredServices>
|
|
133
163
|
): PikkuPermission<any, any> => {
|
|
134
164
|
return pikkuAuthCore(auth as any) as any
|
|
@@ -137,7 +167,7 @@ export const pikkuAuth = <RequiredServices extends SingletonServices = Singleton
|
|
|
137
167
|
/**
|
|
138
168
|
* Configuration object for creating middleware with metadata
|
|
139
169
|
*/
|
|
140
|
-
export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices =
|
|
170
|
+
export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = WiredSingletonServices> = {
|
|
141
171
|
/** The middleware function */
|
|
142
172
|
func: PikkuMiddleware<RequiredServices>
|
|
143
173
|
/** Optional human-readable name for the middleware */
|
|
@@ -169,7 +199,7 @@ export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = S
|
|
|
169
199
|
* })
|
|
170
200
|
* ```
|
|
171
201
|
*/
|
|
172
|
-
export const pikkuMiddleware = <RequiredServices extends SingletonServices =
|
|
202
|
+
export const pikkuMiddleware = <RequiredServices extends SingletonServices = WiredSingletonServices>(
|
|
173
203
|
middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>
|
|
174
204
|
): PikkuMiddleware<RequiredServices> => {
|
|
175
205
|
return typeof middleware === 'function' ? middleware : middleware.func
|
|
@@ -230,7 +260,7 @@ export const pikkuPermissionFactory = <In = any>(
|
|
|
230
260
|
* @template In - The input type (same as the function it describes)
|
|
231
261
|
* @template RequiredServices - The services required for this description function
|
|
232
262
|
*/
|
|
233
|
-
export type PikkuApprovalDescription<In = unknown, RequiredServices extends Services =
|
|
263
|
+
export type PikkuApprovalDescription<In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices> = (
|
|
234
264
|
services: RequiredServices,
|
|
235
265
|
data: In
|
|
236
266
|
) => Promise<string>
|
|
@@ -248,7 +278,7 @@ export type PikkuApprovalDescription<In = unknown, RequiredServices extends Serv
|
|
|
248
278
|
* )
|
|
249
279
|
* ```
|
|
250
280
|
*/
|
|
251
|
-
export const pikkuApprovalDescription = <In = unknown, RequiredServices extends Services =
|
|
281
|
+
export const pikkuApprovalDescription = <In = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
|
|
252
282
|
fn: PikkuApprovalDescription<In, RequiredServices>
|
|
253
283
|
): PikkuApprovalDescription<In, RequiredServices> => {
|
|
254
284
|
return fn
|
|
@@ -266,13 +296,13 @@ export type PikkuFunctionSessionless<
|
|
|
266
296
|
In = unknown,
|
|
267
297
|
Out = never,
|
|
268
298
|
RequiredWires extends keyof PikkuWire = never,
|
|
269
|
-
RequiredServices extends Services =
|
|
299
|
+
RequiredServices extends SecretlessServices<Services> = WiredServices
|
|
270
300
|
> = CorePikkuFunctionSessionless<
|
|
271
301
|
In,
|
|
272
302
|
Out,
|
|
273
303
|
RequiredServices,
|
|
274
304
|
Session,
|
|
275
|
-
PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
|
305
|
+
PickRequired<PikkuWire<In, Out, false, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
|
|
276
306
|
>
|
|
277
307
|
|
|
278
308
|
/**
|
|
@@ -287,13 +317,13 @@ export type PikkuFunction<
|
|
|
287
317
|
In = unknown,
|
|
288
318
|
Out = never,
|
|
289
319
|
RequiredWires extends keyof PikkuWire = 'session',
|
|
290
|
-
RequiredServices extends Services =
|
|
320
|
+
RequiredServices extends SecretlessServices<Services> = WiredServices
|
|
291
321
|
> = CorePikkuFunction<
|
|
292
322
|
In,
|
|
293
323
|
Out,
|
|
294
324
|
RequiredServices,
|
|
295
325
|
Session,
|
|
296
|
-
PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow>, RequiredWires>
|
|
326
|
+
PickRequired<PikkuWire<In, Out, true, Session, TypedPikkuRPC, null, any, TypedWorkflow, unknown, TypedScenario, TypedPersonas>, RequiredWires>
|
|
297
327
|
>
|
|
298
328
|
|
|
299
329
|
/**
|
|
@@ -313,70 +343,66 @@ export type PikkuFunctionConfig<
|
|
|
313
343
|
In = unknown,
|
|
314
344
|
Out = unknown,
|
|
315
345
|
RequiredWires extends keyof PikkuWire = never,
|
|
316
|
-
PikkuFunc extends PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
|
|
346
|
+
PikkuFunc extends PikkuFunction<In, Out, RequiredWires, any> | PikkuFunctionSessionless<In, Out, RequiredWires, any> = PikkuFunction<In, Out, RequiredWires> | PikkuFunctionSessionless<In, Out, RequiredWires>,
|
|
317
347
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
318
348
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
319
|
-
> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema>
|
|
349
|
+
> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware, InputSchema, OutputSchema, ScopeId>
|
|
320
350
|
|
|
321
351
|
/**
|
|
322
352
|
* Configuration object for Pikku functions with Zod schema validation.
|
|
323
353
|
* Use this when you want to define input/output schemas using Zod.
|
|
324
354
|
* Types are automatically inferred from the schemas.
|
|
325
355
|
*/
|
|
356
|
+
type SchemaInferred<S, Fallback = unknown> = S extends StandardSchemaV1
|
|
357
|
+
? InferSchemaOutput<S>
|
|
358
|
+
: Fallback
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Schema-overload variant for pikkuFunc. Derived from CorePikkuFunctionConfig
|
|
362
|
+
* so adding a field on the core type automatically propagates here.
|
|
363
|
+
*/
|
|
326
364
|
export type PikkuFunctionConfigWithSchema<
|
|
327
365
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
328
366
|
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
329
|
-
RequiredWires extends keyof PikkuWire = never
|
|
330
|
-
> =
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
RequiredWires
|
|
346
|
-
>
|
|
347
|
-
auth?: boolean
|
|
348
|
-
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
|
349
|
-
middleware?: PikkuMiddleware[]
|
|
367
|
+
RequiredWires extends keyof PikkuWire = never,
|
|
368
|
+
RequiredServices extends SecretlessServices<Services> = WiredServices
|
|
369
|
+
> = Omit<
|
|
370
|
+
CorePikkuFunctionConfig<
|
|
371
|
+
| PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
|
|
372
|
+
| PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>,
|
|
373
|
+
CorePikkuPermission<any>,
|
|
374
|
+
PikkuMiddleware,
|
|
375
|
+
undefined,
|
|
376
|
+
undefined,
|
|
377
|
+
ScopeId
|
|
378
|
+
>,
|
|
379
|
+
'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
|
|
380
|
+
> & {
|
|
381
|
+
func:
|
|
382
|
+
| PikkuFunction<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
|
|
383
|
+
| PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
|
|
350
384
|
input?: InputSchema
|
|
351
385
|
output?: OutputSchema
|
|
352
|
-
|
|
353
|
-
|
|
386
|
+
permissions?: InputSchema extends StandardSchemaV1
|
|
387
|
+
? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
388
|
+
: undefined
|
|
389
|
+
approvalDescription?: InputSchema extends StandardSchemaV1
|
|
390
|
+
? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
391
|
+
: never
|
|
354
392
|
}
|
|
355
393
|
|
|
356
394
|
/**
|
|
357
395
|
* Creates a Pikku function that can be either session-aware or sessionless.
|
|
358
396
|
* This is the main function wrapper for creating API endpoints.
|
|
359
397
|
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
* 2. Zod schemas: `pikkuFunc({ input: z.object(...), output: z.object(...), func: ... })`
|
|
398
|
+
* Define the input and output with Zod schemas — the function's types are
|
|
399
|
+
* inferred from them, and the schemas double as runtime validation.
|
|
363
400
|
*
|
|
364
|
-
* @
|
|
365
|
-
* @template Out - Output type for the function (inferred from schema if provided)
|
|
366
|
-
* @param func - Function definition, either direct function or configuration object
|
|
401
|
+
* @param config - Function definition with `input`/`output` Zod schemas and `func`.
|
|
367
402
|
* @returns The normalized configuration object
|
|
368
403
|
*
|
|
369
404
|
* @example
|
|
370
405
|
* ```typescript
|
|
371
|
-
* // Pattern 1: Using generic types
|
|
372
|
-
* const createUser = pikkuFunc<{name: string, email: string}, {id: number}>({
|
|
373
|
-
* func: async ({db}, input) => {
|
|
374
|
-
* const user = await db.users.create(input)
|
|
375
|
-
* return { id: user.id }
|
|
376
|
-
* }
|
|
377
|
-
* })
|
|
378
|
-
*
|
|
379
|
-
* // Pattern 2: Using Zod schemas (types inferred automatically)
|
|
380
406
|
* const createUserInput = z.object({ name: z.string(), email: z.string() })
|
|
381
407
|
* const createUserOutput = z.object({ id: z.number() })
|
|
382
408
|
*
|
|
@@ -391,6 +417,12 @@ export type PikkuFunctionConfigWithSchema<
|
|
|
391
417
|
* })
|
|
392
418
|
* ```
|
|
393
419
|
*/
|
|
420
|
+
export function pikkuFunc<
|
|
421
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
422
|
+
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
423
|
+
>(
|
|
424
|
+
config: PikkuFunctionConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', WiredSecretBrokerServices> & { secretBroker: true }
|
|
425
|
+
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
|
394
426
|
export function pikkuFunc<
|
|
395
427
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
396
428
|
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
@@ -406,60 +438,78 @@ export function pikkuFunc(func: any) {
|
|
|
406
438
|
return typeof func === 'function' ? { func } : func
|
|
407
439
|
}
|
|
408
440
|
|
|
441
|
+
export type PikkuListFunction<
|
|
442
|
+
F extends Record<string, unknown> = {},
|
|
443
|
+
Row = unknown,
|
|
444
|
+
S extends string = never
|
|
445
|
+
> =
|
|
446
|
+
| PikkuFunction<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'>
|
|
447
|
+
| PikkuFunctionSessionless<
|
|
448
|
+
ListInput<F, S>,
|
|
449
|
+
ListOutput<Row>,
|
|
450
|
+
'session' | 'rpc'
|
|
451
|
+
>
|
|
452
|
+
|
|
453
|
+
export const pikkuListFunc = <
|
|
454
|
+
F extends Record<string, unknown> = {},
|
|
455
|
+
Row = unknown,
|
|
456
|
+
S extends string = never
|
|
457
|
+
>(
|
|
458
|
+
config: PikkuFunctionConfig<
|
|
459
|
+
ListInput<F, S>,
|
|
460
|
+
ListOutput<Row>,
|
|
461
|
+
'session' | 'rpc'
|
|
462
|
+
>
|
|
463
|
+
): PikkuFunctionConfig<ListInput<F, S>, ListOutput<Row>, 'session' | 'rpc'> => {
|
|
464
|
+
return pikkuFunc(config)
|
|
465
|
+
}
|
|
466
|
+
|
|
409
467
|
/**
|
|
410
468
|
* Configuration object for sessionless Pikku functions with Zod schema validation.
|
|
411
469
|
*/
|
|
470
|
+
/**
|
|
471
|
+
* Schema-overload variant for pikkuSessionlessFunc. Derived from
|
|
472
|
+
* CorePikkuFunctionConfig to stay in sync with the generic-typed config.
|
|
473
|
+
*/
|
|
412
474
|
export type PikkuFunctionSessionlessConfigWithSchema<
|
|
413
475
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
414
476
|
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
415
|
-
RequiredWires extends keyof PikkuWire = never
|
|
416
|
-
> =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
remote?: boolean
|
|
424
|
-
approvalRequired?: boolean
|
|
425
|
-
approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
|
|
477
|
+
RequiredWires extends keyof PikkuWire = never,
|
|
478
|
+
RequiredServices extends SecretlessServices<Services> = WiredServices
|
|
479
|
+
> = Omit<
|
|
480
|
+
CorePikkuFunctionConfig<
|
|
481
|
+
PikkuFunctionSessionless<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, RequiredWires, RequiredServices>
|
|
482
|
+
>,
|
|
483
|
+
'func' | 'input' | 'output' | 'permissions' | 'approvalDescription'
|
|
484
|
+
> & {
|
|
426
485
|
func: PikkuFunctionSessionless<
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
RequiredWires
|
|
486
|
+
SchemaInferred<InputSchema>,
|
|
487
|
+
SchemaInferred<OutputSchema>,
|
|
488
|
+
RequiredWires,
|
|
489
|
+
RequiredServices
|
|
430
490
|
>
|
|
431
|
-
auth?: boolean
|
|
432
|
-
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
|
433
|
-
middleware?: PikkuMiddleware[]
|
|
434
491
|
input?: InputSchema
|
|
435
492
|
output?: OutputSchema
|
|
436
|
-
|
|
437
|
-
|
|
493
|
+
permissions?: InputSchema extends StandardSchemaV1
|
|
494
|
+
? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>>
|
|
495
|
+
: undefined
|
|
496
|
+
approvalDescription?: InputSchema extends StandardSchemaV1
|
|
497
|
+
? PikkuApprovalDescription<InferSchemaOutput<InputSchema>>
|
|
498
|
+
: never
|
|
438
499
|
}
|
|
439
500
|
|
|
440
501
|
/**
|
|
441
502
|
* Creates a sessionless Pikku function that doesn't require user authentication.
|
|
442
503
|
* Use this for public endpoints, webhooks, or background tasks.
|
|
443
504
|
*
|
|
444
|
-
*
|
|
445
|
-
*
|
|
446
|
-
* 2. Zod schemas: `pikkuSessionlessFunc({ input: z.object(...), func: ... })`
|
|
505
|
+
* Define the input and output with Zod schemas — the function's types are
|
|
506
|
+
* inferred from them, and the schemas double as runtime validation.
|
|
447
507
|
*
|
|
448
|
-
* @
|
|
449
|
-
* @template Out - Output type for the function (inferred from schema if provided)
|
|
450
|
-
* @param func - Function definition, either direct function or configuration object
|
|
508
|
+
* @param config - Function definition with `input`/`output` Zod schemas and `func`.
|
|
451
509
|
* @returns The normalized configuration object
|
|
452
510
|
*
|
|
453
511
|
* @example
|
|
454
512
|
* ```typescript
|
|
455
|
-
* // Pattern 1: Using generic types
|
|
456
|
-
* const healthCheck = pikkuSessionlessFunc<void, {status: string}>({
|
|
457
|
-
* func: async ({logger}) => {
|
|
458
|
-
* return { status: 'healthy' }
|
|
459
|
-
* }
|
|
460
|
-
* })
|
|
461
|
-
*
|
|
462
|
-
* // Pattern 2: Using Zod schemas
|
|
463
513
|
* const greetInput = z.object({ name: z.string() })
|
|
464
514
|
* const greetOutput = z.object({ message: z.string() })
|
|
465
515
|
*
|
|
@@ -474,14 +524,15 @@ export type PikkuFunctionSessionlessConfigWithSchema<
|
|
|
474
524
|
*/
|
|
475
525
|
export function pikkuSessionlessFunc<
|
|
476
526
|
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
477
|
-
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
527
|
+
OutputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
528
|
+
RequiredServices extends SecretlessServices<Services> = WiredServices
|
|
478
529
|
>(
|
|
479
|
-
config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>
|
|
530
|
+
config: PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc', RequiredServices>
|
|
480
531
|
): PikkuFunctionConfig<InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown, OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown, 'session' | 'rpc'>
|
|
481
|
-
export function pikkuSessionlessFunc<In, Out = unknown>(
|
|
532
|
+
export function pikkuSessionlessFunc<In, Out = unknown, RequiredServices extends SecretlessServices<Services> = WiredServices>(
|
|
482
533
|
func:
|
|
483
|
-
| PikkuFunctionSessionless<In, Out, 'session' | 'rpc'>
|
|
484
|
-
| PikkuFunctionConfig<In, Out, 'session' | 'rpc'
|
|
534
|
+
| PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>
|
|
535
|
+
| PikkuFunctionConfig<In, Out, 'session' | 'rpc', PikkuFunctionSessionless<In, Out, 'session' | 'rpc', RequiredServices>>
|
|
485
536
|
): PikkuFunctionConfig<In, Out, 'session' | 'rpc'>
|
|
486
537
|
export function pikkuSessionlessFunc(func: any) {
|
|
487
538
|
return typeof func === 'function' ? { func } : func
|
|
@@ -512,27 +563,23 @@ export const pikkuVoidFunc = (
|
|
|
512
563
|
}
|
|
513
564
|
|
|
514
565
|
/**
|
|
515
|
-
*
|
|
516
|
-
*
|
|
517
|
-
* without type compatibility issues.
|
|
566
|
+
* References a registered function by name for use in any wiring.
|
|
567
|
+
* Works for both local and addon functions — resolves via RPC at runtime.
|
|
518
568
|
*
|
|
519
|
-
* @template Name - The
|
|
520
|
-
* @param rpcName - The name of the
|
|
521
|
-
* @returns A Pikku function that proxies calls
|
|
569
|
+
* @template Name - The function name (must be a key in FlattenedRPCMap)
|
|
570
|
+
* @param rpcName - The name of the function to reference
|
|
571
|
+
* @returns A Pikku function config that proxies calls via RPC
|
|
522
572
|
*
|
|
523
573
|
* @example
|
|
524
574
|
* ```typescript
|
|
525
|
-
* //
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
*
|
|
529
|
-
*
|
|
530
|
-
* func: addon('ext:hello'),
|
|
531
|
-
* tags: ['addon'],
|
|
532
|
-
* })
|
|
575
|
+
* // Use in agent tools
|
|
576
|
+
* tools: [ref('todos:listTodos'), ref('myLocalFunc')]
|
|
577
|
+
*
|
|
578
|
+
* // Use in HTTP wiring
|
|
579
|
+
* wireHTTP({ route: '/greet', method: 'post', func: ref('greet') })
|
|
533
580
|
* ```
|
|
534
581
|
*/
|
|
535
|
-
export const
|
|
582
|
+
export const ref = <Name extends keyof FlattenedRPCMap>(
|
|
536
583
|
rpcName: Name
|
|
537
584
|
): PikkuFunctionConfig<
|
|
538
585
|
FlattenedRPCMap[Name]['input'],
|
|
@@ -550,6 +597,43 @@ export const addon = <Name extends keyof FlattenedRPCMap>(
|
|
|
550
597
|
>
|
|
551
598
|
}
|
|
552
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Declares a capability the connected client answers, reachable from any
|
|
602
|
+
* `wireChannel` function as `channel.remote(name, input)`.
|
|
603
|
+
*
|
|
604
|
+
* There is no `func`: this side owns the contract, the client owns the body.
|
|
605
|
+
* The `description` is what a person is shown when asked to approve the call,
|
|
606
|
+
* so write it for them rather than for the caller.
|
|
607
|
+
*
|
|
608
|
+
* @example
|
|
609
|
+
* ```typescript
|
|
610
|
+
* export const localCheckoutOutput = z.object({ sha: z.string(), branch: z.string() })
|
|
611
|
+
*
|
|
612
|
+
* export const localCheckout = pikkuRemoteChannelFunc({
|
|
613
|
+
* description: 'Read the current commit and branch of your working tree',
|
|
614
|
+
* output: localCheckoutOutput,
|
|
615
|
+
* })
|
|
616
|
+
* ```
|
|
617
|
+
*/
|
|
618
|
+
export function pikkuRemoteChannelFunc<
|
|
619
|
+
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
|
620
|
+
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
|
621
|
+
>(
|
|
622
|
+
config: Omit<
|
|
623
|
+
PikkuFunctionSessionlessConfigWithSchema<InputSchema, OutputSchema, 'session' | 'rpc'>,
|
|
624
|
+
'func'
|
|
625
|
+
>
|
|
626
|
+
): PikkuFunctionConfig<SchemaInferred<InputSchema>, SchemaInferred<OutputSchema>, 'session' | 'rpc'> {
|
|
627
|
+
return {
|
|
628
|
+
...config,
|
|
629
|
+
func: async (_services: any, _data: any, _wire: any) => {
|
|
630
|
+
throw new Error(
|
|
631
|
+
`${config.title ?? 'This'} is a remote channel capability and has no local implementation — reach it with channel.remote() on the channel whose client exposes it.`
|
|
632
|
+
)
|
|
633
|
+
},
|
|
634
|
+
} as any
|
|
635
|
+
}
|
|
636
|
+
|
|
553
637
|
/**
|
|
554
638
|
* Creates a Pikku config factory.
|
|
555
639
|
* Use this to define your application's configuration factory.
|
|
@@ -591,12 +675,27 @@ export const pikkuConfig = (
|
|
|
591
675
|
* ```
|
|
592
676
|
*/
|
|
593
677
|
export const pikkuServices = (
|
|
594
|
-
func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<RequiredSingletonServices
|
|
678
|
+
func: (config: Config, existingServices: Partial<SingletonServices>) => Promise<Partial<Omit<RequiredSingletonServices, 'auth'>>>
|
|
595
679
|
) => {
|
|
596
680
|
return async (config: Config, existingServices: Partial<SingletonServices> = {}) => {
|
|
597
|
-
const
|
|
598
|
-
|
|
599
|
-
|
|
681
|
+
const createdServices = await func(config, existingServices)
|
|
682
|
+
const services = { ...existingServices, ...createdServices }
|
|
683
|
+
const authFactory = __pikkuState(null, 'package', 'authFactory')
|
|
684
|
+
if (authFactory) {
|
|
685
|
+
let authInstance: Promise<unknown> | undefined
|
|
686
|
+
;(services as any).auth = () => {
|
|
687
|
+
authInstance ??= Promise.resolve()
|
|
688
|
+
.then(() => authFactory(services as any))
|
|
689
|
+
.catch((error) => {
|
|
690
|
+
authInstance = undefined
|
|
691
|
+
throw error
|
|
692
|
+
})
|
|
693
|
+
return authInstance
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
const resolved = services as RequiredSingletonServices
|
|
697
|
+
__pikkuState(null, 'package', 'singletonServices', resolved as any)
|
|
698
|
+
return resolved
|
|
600
699
|
}
|
|
601
700
|
}
|
|
602
701
|
|
|
@@ -629,58 +728,70 @@ export const pikkuWireServices = (
|
|
|
629
728
|
}
|
|
630
729
|
|
|
631
730
|
/**
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
* This function allows you to register middleware that will be applied to
|
|
635
|
-
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
636
|
-
*
|
|
637
|
-
* @param tag - The tag that the middleware should apply to.
|
|
638
|
-
* @param middleware - The middleware array to apply for the specified tag.
|
|
639
|
-
*
|
|
640
|
-
* @throws Error if middleware for the tag already exists.
|
|
731
|
+
* Tag-scoped middleware. Applies to any wiring that carries the matching tag.
|
|
641
732
|
*
|
|
642
733
|
* @example
|
|
643
|
-
*
|
|
644
|
-
* // Add admin middleware for admin endpoints
|
|
645
|
-
* addMiddleware('admin', [adminMiddleware])
|
|
646
|
-
*
|
|
647
|
-
* // Add authentication middleware for auth endpoints
|
|
648
|
-
* addMiddleware('auth', [authMiddleware])
|
|
649
|
-
*
|
|
650
|
-
* // Add logging middleware for all API endpoints
|
|
651
|
-
* addMiddleware('api', [loggingMiddleware])
|
|
652
|
-
* ```
|
|
734
|
+
* addTagMiddleware('admin', [adminMiddleware])
|
|
653
735
|
*/
|
|
654
|
-
export const
|
|
655
|
-
|
|
736
|
+
export const addTagMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
|
|
737
|
+
addTagMiddlewareCore(tag, middleware as any, '@pikku/addon-meta-conversions')
|
|
656
738
|
}
|
|
657
739
|
|
|
658
740
|
/**
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
* This function allows you to register permissions that will be applied to
|
|
662
|
-
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
741
|
+
* Wire-agnostic global middleware. Runs at the top of every wiring's
|
|
742
|
+
* middleware chain — before wire-, tag-, and function-level entries.
|
|
663
743
|
*
|
|
664
|
-
*
|
|
665
|
-
* @param permissions - The permissions array or object to apply for the specified tag.
|
|
666
|
-
*
|
|
667
|
-
* @throws Error if permissions for the tag already exist.
|
|
744
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
668
745
|
*
|
|
669
746
|
* @example
|
|
670
|
-
*
|
|
671
|
-
|
|
672
|
-
|
|
747
|
+
* addGlobalMiddleware([telemetryMiddleware])
|
|
748
|
+
*/
|
|
749
|
+
export const addGlobalMiddleware = (middleware: PikkuMiddleware[]) => {
|
|
750
|
+
addGlobalMiddlewareCore(middleware as any, '@pikku/addon-meta-conversions')
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
/**
|
|
754
|
+
* Wire-agnostic global permissions. Runs at the top of every wiring's
|
|
755
|
+
* permission resolution — before wire-, tag-, and function-level entries.
|
|
673
756
|
*
|
|
674
|
-
*
|
|
675
|
-
* addPermission('auth', [authPermission])
|
|
757
|
+
* Resolution order: global -> wire -> tag -> function.
|
|
676
758
|
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
|
|
759
|
+
* @example
|
|
760
|
+
* addGlobalPermission([signedInUser])
|
|
761
|
+
*/
|
|
762
|
+
export const addGlobalPermission = <In = unknown>(permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
|
|
763
|
+
addGlobalPermissionCore(permissions as any, '@pikku/addon-meta-conversions')
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
export { wireAddon, wireRemoteAddon } from '@pikku/core/rpc'
|
|
767
|
+
export type { WireAddonConfig, WireRemoteAddonConfig, RemoteAddonAuth } from '@pikku/core/rpc'
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
/**
|
|
771
|
+
* Addon contract references. Generated from each wired addon's published
|
|
772
|
+
* contract metadata — no addon source is imported. Functions are proxied via
|
|
773
|
+
* ref() (RPC) exactly like ref('namespace:fn').
|
|
680
774
|
*/
|
|
681
|
-
|
|
682
|
-
|
|
775
|
+
const __addonHttp = {} as const
|
|
776
|
+
const __addonChannel = {} as const
|
|
777
|
+
const __addonCli = {} as const
|
|
778
|
+
|
|
779
|
+
export const refHTTP = <Name extends keyof typeof __addonHttp>(
|
|
780
|
+
name: Name,
|
|
781
|
+
options?: { basePath?: string }
|
|
782
|
+
): (typeof __addonHttp)[Name] => {
|
|
783
|
+
const contract = __addonHttp[name] as any
|
|
784
|
+
return (
|
|
785
|
+
options?.basePath !== undefined
|
|
786
|
+
? { ...contract, basePath: options.basePath }
|
|
787
|
+
: contract
|
|
788
|
+
) as (typeof __addonHttp)[Name]
|
|
683
789
|
}
|
|
684
790
|
|
|
685
|
-
export
|
|
686
|
-
|
|
791
|
+
export const refChannel = <Name extends keyof typeof __addonChannel>(
|
|
792
|
+
name: Name
|
|
793
|
+
): (typeof __addonChannel)[Name] => __addonChannel[name]
|
|
794
|
+
|
|
795
|
+
export const refCLI = <Name extends keyof typeof __addonCli>(
|
|
796
|
+
name: Name
|
|
797
|
+
): (typeof __addonCli)[Name] => __addonCli[name]
|