@nightfuel-ai/app-sdk 0.1.1 → 0.1.2
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/README.md +17 -0
- package/index.d.ts +8 -1
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -49,6 +49,23 @@ for await (const event of nightfuel.workflows.stream('notify-low-stock', run.run
|
|
|
49
49
|
}
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
## Workflow input
|
|
53
|
+
|
|
54
|
+
`workflows.run(bindingId, input, { idempotencyKey, customFields })` sends the
|
|
55
|
+
same run input as `workflow_run` in the Nightfuel SDK. `input` is a JSON object
|
|
56
|
+
that reaches the bound workflow's entry node:
|
|
57
|
+
|
|
58
|
+
- a **Webhook** entry receives it as its request body (`payload.payload.body`),
|
|
59
|
+
checked against the entry's JSON Schema;
|
|
60
|
+
- a **Request Harness** entry receives it as its input: an App sends `text`
|
|
61
|
+
only, and `customFields` fills the custom fields the entry declares.
|
|
62
|
+
|
|
63
|
+
Input that does not match the entry is refused with `400` before the run is
|
|
64
|
+
accepted (`WEBHOOK_BODY_SCHEMA_MISMATCH`, `HARNESS_CUSTOM_FIELDS_INVALID`,
|
|
65
|
+
`WORKFLOW_INPUT_INVALID`). A run accepted with `202` that cannot start (no
|
|
66
|
+
credits, or a workflow that runs with its own published identity) ends its
|
|
67
|
+
stream with `run.failed` and `payload.errorCode`.
|
|
68
|
+
|
|
52
69
|
## Runtime environment
|
|
53
70
|
|
|
54
71
|
A Cloud App receives these variables from the platform; the SDK reads them
|
package/index.d.ts
CHANGED
|
@@ -161,10 +161,17 @@ export interface NightfuelDatabaseMutationInput {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
export interface NightfuelWorkflowClient {
|
|
164
|
+
/**
|
|
165
|
+
* Starts the bound workflow. `input` reaches its entry node: a Request
|
|
166
|
+
* Harness entry reads it as its input (an App sends `text` only), a Webhook
|
|
167
|
+
* entry as its request body, checked against the entry's JSON Schema.
|
|
168
|
+
* `customFields` fills the Request Harness entry's declared custom fields.
|
|
169
|
+
* Input outside that contract is refused with 400 before the run starts.
|
|
170
|
+
*/
|
|
164
171
|
run(
|
|
165
172
|
bindingId: string,
|
|
166
173
|
input: Record<string, unknown>,
|
|
167
|
-
options: { idempotencyKey: string }
|
|
174
|
+
options: { idempotencyKey: string; customFields?: Record<string, unknown> }
|
|
168
175
|
): Promise<WorkflowRunAccepted>;
|
|
169
176
|
stream<T = NightfuelKnownWorkflowEventData | NightfuelWorkflowEventData>(
|
|
170
177
|
bindingId: string,
|
package/index.js
CHANGED
|
@@ -207,7 +207,7 @@ function createNightfuelAppSdk(options = {}) {
|
|
|
207
207
|
const key = idempotencyKey(options.idempotencyKey);
|
|
208
208
|
return postJson(
|
|
209
209
|
`/internal/hosting/apps/${appId}/workflows/${encodeURIComponent(resolvedBindingId)}/runs`,
|
|
210
|
-
{ input },
|
|
210
|
+
{ input, ...(options.customFields === undefined ? {} : { customFields: options.customFields }) },
|
|
211
211
|
{ 'Idempotency-Key': key }
|
|
212
212
|
);
|
|
213
213
|
},
|