@lotics/app-sdk 0.29.0 → 0.30.0

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.
@@ -1,4 +1,4 @@
1
- import type { AppWorkflows, AppQueries } from "./types.js";
1
+ import type { AppWorkflows, AppWorkflowResults, AppQueries } from "./types.js";
2
2
  import type { ResolvedMember } from "./members.js";
3
3
  /** Fields shared by every query hook's return value. */
4
4
  interface QueryStateBase {
@@ -151,17 +151,21 @@ export interface PaginatedQueryOptions extends BaseQueryOptions {
151
151
  */
152
152
  export declare function useWorkflow<K extends keyof AppWorkflows & string>(alias: K): UseWorkflowFn<K>;
153
153
  export declare function useWorkflow(alias: string): (inputs?: Record<string, unknown>) => Promise<WorkflowResult>;
154
- type UseWorkflowFn<K extends keyof AppWorkflows & string> = AppWorkflows[K] extends Record<string, unknown> ? AppWorkflows[K] extends Record<string, never> ? (inputs?: Record<string, never>) => Promise<WorkflowResult> : (inputs: AppWorkflows[K]) => Promise<WorkflowResult> : (inputs?: Record<string, unknown>) => Promise<WorkflowResult>;
154
+ type ResultDataOf<K extends string> = K extends keyof AppWorkflowResults ? AppWorkflowResults[K] : unknown;
155
+ type UseWorkflowFn<K extends keyof AppWorkflows & string> = AppWorkflows[K] extends Record<string, unknown> ? AppWorkflows[K] extends Record<string, never> ? (inputs?: Record<string, never>) => Promise<WorkflowResult<ResultDataOf<K>>> : (inputs: AppWorkflows[K]) => Promise<WorkflowResult<ResultDataOf<K>>> : (inputs?: Record<string, unknown>) => Promise<WorkflowResult<ResultDataOf<K>>>;
155
156
  /**
156
157
  * Result of an app-workflow run — the execute endpoint's response. `files` holds
157
158
  * any document a workflow step generated (e.g. via a `generate_*_from_template`
158
159
  * tool), resolved for download: read `files[0].url` and pass it to `openExternal`.
159
- * A workflow that generates no file resolves with `files` absent.
160
+ * A workflow that generates no file resolves with `files` absent. `data` is the
161
+ * structured value the workflow returned via `return({ data })`, typed per the
162
+ * alias's declared `outputs` schema (`unknown` when none was declared).
160
163
  */
161
- export interface WorkflowResult {
164
+ export interface WorkflowResult<TData = unknown> {
162
165
  status: "success" | "error";
163
166
  message?: string;
164
167
  files?: UploadedFile[];
168
+ data?: TData;
165
169
  }
166
170
  type QueryArgs<K extends keyof AppQueries & string, O> = AppQueries[K] extends Record<string, never> ? [params?: Record<string, never>, opts?: O] : [params: AppQueries[K], opts?: O];
167
171
  /**
@@ -23,6 +23,27 @@
23
23
  */
24
24
  export interface AppWorkflows {
25
25
  }
26
+ /**
27
+ * App-specific workflow-RESULT augmentation point. Same pattern as AppWorkflows,
28
+ * but maps each alias to the type of the `data` its workflow returns via
29
+ * `return({ data })` — derived from the alias's declared `outputs` schema.
30
+ *
31
+ * The base SDK ships it empty, so `useWorkflow(alias)` resolves `result.data` as
32
+ * `unknown`. Per-app codegen augments it for aliases that declare `outputs`:
33
+ *
34
+ * ```ts
35
+ * // .lotics/app_workflows.d.ts (generated)
36
+ * declare module "@lotics/app-sdk" {
37
+ * interface AppWorkflowResults {
38
+ * "computeQuote": { total: number; lines: ReadonlyArray<{ name: string; amount: number }> };
39
+ * }
40
+ * }
41
+ * ```
42
+ *
43
+ * An alias absent from this map (no declared `outputs`) gets `result.data: unknown`.
44
+ */
45
+ export interface AppWorkflowResults {
46
+ }
26
47
  /**
27
48
  * App-specific named-query augmentation point. Same pattern as AppWorkflows.
28
49
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lotics/app-sdk",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Runtime SDK for Lotics custom-code apps — typed hooks, postMessage bridge, mount entry point",
5
5
  "type": "module",
6
6
  "exports": {