chore: server-and-serverless template
This commit is contained in:
46
packages/functions/.pikku/workflow/pikku-workflow-map.gen.d.ts
vendored
Normal file
46
packages/functions/.pikku/workflow/pikku-workflow-map.gen.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.48
|
||||
*/
|
||||
/**
|
||||
* Workflow type map with input/output types for each workflow
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// Addon package Workflow maps
|
||||
import type { WorkflowMap as ConsoleWorkflowMap } from '@pikku/addon-console/.pikku/workflow/pikku-workflow-map.gen.d.js'
|
||||
|
||||
|
||||
interface WorkflowHandler<I, O> {
|
||||
input: I;
|
||||
output: O;
|
||||
}
|
||||
|
||||
interface GraphNodeHandler<I> {
|
||||
input: I;
|
||||
}
|
||||
|
||||
export type WorkflowMap = {
|
||||
};
|
||||
|
||||
export type GraphsMap = {
|
||||
};
|
||||
|
||||
type PrefixWorkflowKeys<T, Prefix extends string> = unknown extends T ? {} : {
|
||||
[K in keyof T as `${Prefix}:${string & K}`]: T[K]
|
||||
}
|
||||
|
||||
export type FlattenedWorkflowMap =
|
||||
WorkflowMap & PrefixWorkflowKeys<ConsoleWorkflowMap, 'console'>
|
||||
|
||||
|
||||
export type WorkflowClient<Name extends keyof FlattenedWorkflowMap> = {
|
||||
start: (input: FlattenedWorkflowMap[Name]['input']) => Promise<{ runId: string }>;
|
||||
getRun: <output extends keyof FlattenedWorkflowMap[Name]>(runId: string) => Promise<FlattenedWorkflowMap[Name][output]>;
|
||||
cancelRun: (runId: string) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export type TypedWorkflowClients = {
|
||||
[Name in keyof FlattenedWorkflowMap]: WorkflowClient<Name>;
|
||||
}
|
||||
167
packages/functions/.pikku/workflow/pikku-workflow-types.gen.ts
Normal file
167
packages/functions/.pikku/workflow/pikku-workflow-types.gen.ts
Normal file
@@ -0,0 +1,167 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.48
|
||||
*/
|
||||
import { WorkflowCancelledException } from '@pikku/core/workflow'
|
||||
import { template } from '@pikku/core/workflow'
|
||||
import {
|
||||
pikkuWorkflowGraph as corePikkuWorkflowGraph,
|
||||
type PikkuWorkflowGraphConfig,
|
||||
type PikkuWorkflowGraphResult,
|
||||
} from '@pikku/core/workflow'
|
||||
import type { PikkuWorkflowWire, WorkflowStepOptions } from '@pikku/core/workflow'
|
||||
|
||||
export { WorkflowCancelledException }
|
||||
import type { PikkuFunctionSessionless, PikkuFunctionConfig } from '../function/pikku-function-types.gen.js'
|
||||
import type { FlattenedRPCMap } from '../rpc/pikku-rpc-wirings-map.internal.gen.d.js'
|
||||
import type { FlattenedWorkflowMap } from './pikku-workflow-map.gen.d.js'
|
||||
|
||||
export { template }
|
||||
|
||||
export interface TypedWorkflow extends PikkuWorkflowWire {
|
||||
do<K extends keyof FlattenedRPCMap>(
|
||||
stepName: string,
|
||||
rpcName: K,
|
||||
data: FlattenedRPCMap[K]['input'],
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<FlattenedRPCMap[K]['output']>
|
||||
|
||||
do<K extends keyof FlattenedWorkflowMap>(
|
||||
stepName: string,
|
||||
workflowName: K,
|
||||
data: FlattenedWorkflowMap[K]['input'],
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<FlattenedWorkflowMap[K]['output']>
|
||||
|
||||
do<T>(
|
||||
stepName: string,
|
||||
fn: () => T | Promise<T>,
|
||||
options?: WorkflowStepOptions
|
||||
): Promise<T>
|
||||
}
|
||||
|
||||
import type { StandardSchemaV1 } from '@standard-schema/spec'
|
||||
import type { InferSchemaOutput, PikkuPermission, PikkuMiddleware, NodeConfig, PikkuApprovalDescription } from '../function/pikku-function-types.gen.js'
|
||||
import { PikkuError } from '@pikku/core/errors'
|
||||
import type { CorePermissionGroup } from '@pikku/core'
|
||||
|
||||
export type PikkuFunctionWorkflow<
|
||||
In = unknown,
|
||||
Out = never
|
||||
> = PikkuFunctionSessionless<In, Out, 'workflow'>
|
||||
|
||||
export type PikkuWorkflowConfigWithSchema<
|
||||
InputSchema extends StandardSchemaV1 | undefined = undefined,
|
||||
OutputSchema extends StandardSchemaV1 | undefined = undefined
|
||||
> = {
|
||||
title?: string
|
||||
description?: string
|
||||
tags?: string[]
|
||||
expose?: boolean
|
||||
internal?: boolean
|
||||
override?: string
|
||||
version?: number
|
||||
remote?: boolean
|
||||
mcp?: boolean
|
||||
readonly?: boolean
|
||||
approvalRequired?: boolean
|
||||
approvalDescription?: InputSchema extends StandardSchemaV1 ? PikkuApprovalDescription<InferSchemaOutput<InputSchema>> : never
|
||||
func: PikkuFunctionWorkflow<
|
||||
InputSchema extends StandardSchemaV1 ? InferSchemaOutput<InputSchema> : unknown,
|
||||
OutputSchema extends StandardSchemaV1 ? InferSchemaOutput<OutputSchema> : unknown
|
||||
>
|
||||
auth?: boolean
|
||||
permissions?: InputSchema extends StandardSchemaV1 ? CorePermissionGroup<PikkuPermission<InferSchemaOutput<InputSchema>>> : undefined
|
||||
middleware?: PikkuMiddleware[]
|
||||
input?: InputSchema
|
||||
output?: OutputSchema
|
||||
node?: NodeConfig
|
||||
errors?: Array<typeof PikkuError>
|
||||
inline?: boolean
|
||||
}
|
||||
|
||||
export function pikkuWorkflowFunc<
|
||||
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>
|
||||
export function pikkuWorkflowFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionWorkflow<In, Out>
|
||||
| PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>
|
||||
): PikkuFunctionConfig<In, Out, 'workflow'>
|
||||
export function pikkuWorkflowFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
export 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>
|
||||
export function pikkuWorkflowComplexFunc<In, Out = unknown>(
|
||||
func:
|
||||
| PikkuFunctionWorkflow<In, Out>
|
||||
| PikkuFunctionConfig<In, Out, 'workflow', PikkuFunctionWorkflow<In, Out>>
|
||||
): PikkuFunctionConfig<In, Out, 'workflow'>
|
||||
export function pikkuWorkflowComplexFunc(func: any) {
|
||||
return typeof func === 'function' ? { func } : func
|
||||
}
|
||||
|
||||
type TypedRef<T> = { $ref: string; path?: string } & { __phantomType?: T }
|
||||
|
||||
type TemplateString = {
|
||||
$template: {
|
||||
parts: string[]
|
||||
expressions: Array<{ $ref: string; path?: string }>
|
||||
}
|
||||
} & { __brand: 'TemplateString' }
|
||||
|
||||
type InputWithRefs<T> = {
|
||||
[K in keyof T]?: T[K] | TypedRef<T[K]> | TypedRef<unknown> | TemplateString
|
||||
}
|
||||
|
||||
type NodeInputType<FuncMap extends Record<string, string>, K extends keyof FuncMap> =
|
||||
FuncMap[K] extends keyof FlattenedRPCMap
|
||||
? InputWithRefs<FlattenedRPCMap[FuncMap[K]]['input']>
|
||||
: Record<string, unknown>
|
||||
|
||||
type NodeOutputKeys<FuncMap extends Record<string, string>, N extends string> =
|
||||
N extends keyof FuncMap
|
||||
? FuncMap[N] extends keyof FlattenedRPCMap
|
||||
? keyof FlattenedRPCMap[FuncMap[N]]['output'] & string
|
||||
: string
|
||||
: string
|
||||
|
||||
type RefFunction<FuncMap extends Record<string, string>> = {
|
||||
<N extends Extract<keyof FuncMap, string>>(
|
||||
nodeId: N,
|
||||
path: NodeOutputKeys<FuncMap, N>
|
||||
): TypedRef<unknown>
|
||||
(nodeId: 'trigger' | '$item', path?: string): TypedRef<unknown>
|
||||
}
|
||||
|
||||
type TemplateFunction = (templateStr: string, refs: TypedRef<unknown>[]) => TemplateString
|
||||
|
||||
type GraphNodeConfigMap<FuncMap extends Record<string, string>> = {
|
||||
[K in Extract<keyof FuncMap, string>]?: {
|
||||
next?: NextConfig<Extract<keyof FuncMap, string>>
|
||||
input?:
|
||||
| NodeInputType<FuncMap, K>
|
||||
| (() => NodeInputType<FuncMap, K>)
|
||||
| ((ref: RefFunction<FuncMap>, template: TemplateFunction) => NodeInputType<FuncMap, K>)
|
||||
onError?: Extract<keyof FuncMap, string> | Extract<keyof FuncMap, string>[]
|
||||
}
|
||||
}
|
||||
|
||||
type NextConfig<NodeIds extends string> = NodeIds | NodeIds[] | { if: string; then: NodeIds; else?: NodeIds }
|
||||
|
||||
export function pikkuWorkflowGraph<
|
||||
const FuncMap extends Record<string, keyof FlattenedRPCMap & string>
|
||||
>(
|
||||
config: PikkuWorkflowGraphConfig<FuncMap, GraphNodeConfigMap<FuncMap>>
|
||||
): PikkuWorkflowGraphResult {
|
||||
return corePikkuWorkflowGraph(config as any)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.48
|
||||
*/
|
||||
import { pikkuState } from '@pikku/core/internal'
|
||||
import type { SerializedWorkflowGraphs } from '@pikku/inspector/workflow-graph'
|
||||
|
||||
const workflowsMeta: SerializedWorkflowGraphs = {}
|
||||
|
||||
pikkuState(null, 'workflows', 'meta', workflowsMeta)
|
||||
@@ -0,0 +1,3 @@
|
||||
/**
|
||||
* This file was generated by @pikku/cli@0.12.48
|
||||
*/
|
||||
Reference in New Issue
Block a user