@pyck/sdk
v0.2.0
Published
TypeScript contract and types for building remote pyck components.
Keywords
Readme
@pyck/sdk
TypeScript contract and types for building remote pyck components.
Installation
npm install @pyck/sdkUsage
import type { PyckComponent } from '@pyck/sdk'
interface Input {
productId: string
}
interface Output {
quantity: number
}
const MyComponent: PyckComponent<Input, Output> = ({ input, outputSchema, onComplete, context }) => {
const handleSubmit = async () => {
const error = await onComplete({ quantity: 1 })
if (error) {
// handle error
}
}
return <button onClick={handleSubmit}>Submit</button>
}
export default MyComponentExports
@pyck/sdk
PyckComponent— Component type alias (ComponentType<PyckComponentProps>)PyckComponentProps— Props received by a remote componentPyckWorkflowContext— Workflow execution contextJSONSchema— JSON Schema type
Props
| Prop | Type | Description |
|------|------|-------------|
| onComplete | (output?) => Promise<undefined \| Error> | Call to signal activity completion |
| outputSchema | JSONSchema | JSON Schema describing the expected output |
| inputSchema | JSONSchema (optional) | JSON Schema describing the input |
| input | TInput (optional) | Input data for the component |
| context | PyckWorkflowContext | Workflow execution context |
Context
| Field | Type | Description |
|-------|------|-------------|
| workflowId | string | ID of the workflow |
| runId | string | ID of the current run |
| activityIndex | number | Index of the current activity |
| activityCount | number | Total number of activities |
| tenantId | string | Tenant ID |
| deviceId | string \| null | Device ID |
| locationId | string \| null | Location ID |
