@hotmeshio/hotmesh 0.27.0 → 0.27.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -101,6 +101,16 @@ declare class ExporterService {
101
101
  * ```
102
102
  */
103
103
  export(jobId: string, options?: ExportOptions): Promise<DurableJobExport>;
104
+ /**
105
+ * Read the workflow input arguments without a full export. Resolves the
106
+ * `trigger/output/data/arguments` symbol and reads that single field from
107
+ * the job hash, so the cost is one symbol lookup (cached) plus a one-field
108
+ * `hmget` rather than a whole-hash read.
109
+ *
110
+ * @param jobId - the workflow ID
111
+ * @returns the input arguments array, or undefined if unavailable
112
+ */
113
+ getInput(jobId: string): Promise<any>;
104
114
  /**
105
115
  * Export a workflow execution as a structured event history ({@link WorkflowExecution}).
106
116
  *
@@ -220,6 +220,26 @@ class ExporterService {
220
220
  const jobExport = this.inflate(jobData, options);
221
221
  return jobExport;
222
222
  }
223
+ /**
224
+ * Read the workflow input arguments without a full export. Resolves the
225
+ * `trigger/output/data/arguments` symbol and reads that single field from
226
+ * the job hash, so the cost is one symbol lookup (cached) plus a one-field
227
+ * `hmget` rather than a whole-hash read.
228
+ *
229
+ * @param jobId - the workflow ID
230
+ * @returns the input arguments array, or undefined if unavailable
231
+ */
232
+ async getInput(jobId) {
233
+ if (!this.store.getJobArguments) {
234
+ return undefined;
235
+ }
236
+ const symbolSets = await this.store.getSymbolKeys(['trigger']);
237
+ const field = this.resolveSymbolField(symbolSets, 'trigger', 'trigger/output/data/arguments');
238
+ if (!field) {
239
+ return undefined;
240
+ }
241
+ return this.store.getJobArguments(jobId, field);
242
+ }
223
243
  /**
224
244
  * Export a workflow execution as a structured event history ({@link WorkflowExecution}).
225
245
  *
@@ -119,6 +119,36 @@ export declare class WorkflowHandleService {
119
119
  * @param fields - The field names to retrieve.
120
120
  */
121
121
  queryState(fields: string[]): Promise<Record<string, any>>;
122
+ /**
123
+ * Returns the input arguments the workflow was started with, exactly as
124
+ * passed to `client.workflow.start({ args })`. Reads a single field from
125
+ * the job hash (no full export), so it stays cheap on large jobs and is
126
+ * available for the life of the job — while running or after completion.
127
+ *
128
+ * @template T - The tuple type of the workflow's arguments.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const [orderId, region] = await handle.input<[string, string]>();
133
+ * ```
134
+ */
135
+ input<T = any[]>(): Promise<T>;
136
+ /**
137
+ * Returns the workflow's response if it has completed, or `undefined`
138
+ * while it is still running. Unlike {@link result}, this never blocks —
139
+ * it reads the current state and returns immediately.
140
+ *
141
+ * @template T - The workflow's return type.
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const value = await handle.output<{ ok: boolean }>();
146
+ * if (value === undefined) {
147
+ * // still running
148
+ * }
149
+ * ```
150
+ */
151
+ output<T = any>(): Promise<T | undefined>;
122
152
  /**
123
153
  * Returns the workflow's numeric status code: `0` = completed,
124
154
  * positive = still running, negative = interrupted/errored.
@@ -147,6 +147,44 @@ class WorkflowHandleService {
147
147
  async queryState(fields) {
148
148
  return await this.hotMesh.getQueryState(this.workflowId, fields);
149
149
  }
150
+ /**
151
+ * Returns the input arguments the workflow was started with, exactly as
152
+ * passed to `client.workflow.start({ args })`. Reads a single field from
153
+ * the job hash (no full export), so it stays cheap on large jobs and is
154
+ * available for the life of the job — while running or after completion.
155
+ *
156
+ * @template T - The tuple type of the workflow's arguments.
157
+ *
158
+ * @example
159
+ * ```typescript
160
+ * const [orderId, region] = await handle.input<[string, string]>();
161
+ * ```
162
+ */
163
+ async input() {
164
+ return (await this.exporter.getInput(this.workflowId));
165
+ }
166
+ /**
167
+ * Returns the workflow's response if it has completed, or `undefined`
168
+ * while it is still running. Unlike {@link result}, this never blocks —
169
+ * it reads the current state and returns immediately.
170
+ *
171
+ * @template T - The workflow's return type.
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const value = await handle.output<{ ok: boolean }>();
176
+ * if (value === undefined) {
177
+ * // still running
178
+ * }
179
+ * ```
180
+ */
181
+ async output() {
182
+ const state = await this.hotMesh.getState(`${this.hotMesh.appId}.execute`, this.workflowId);
183
+ if (!state.data && state.metadata?.err) {
184
+ throw new Error(JSON.parse(state.metadata.err));
185
+ }
186
+ return state.data?.response;
187
+ }
150
188
  /**
151
189
  * Returns the workflow's numeric status code: `0` = completed,
152
190
  * positive = still running, negative = interrupted/errored.
@@ -135,6 +135,16 @@ declare abstract class StoreService<Provider extends ProviderClient, Transaction
135
135
  * @returns Map of child_workflow_id -> parsed input arguments
136
136
  */
137
137
  getChildWorkflowInputs?(childJobKeys: string[], symbolField: string): Promise<Map<string, any>>;
138
+ /**
139
+ * Fetch and decode a single compressed-symbol field from a job's HASH.
140
+ * Reads one field with `hmget` rather than the whole hash, so it is the
141
+ * cheap path for narrow getters like the workflow input arguments.
142
+ *
143
+ * @param jobId - The job ID
144
+ * @param symbolField - The compressed symbol field (symbol + dimension)
145
+ * @returns The decoded value, or undefined if the field is absent
146
+ */
147
+ getJobArguments?(jobId: string, symbolField: string): Promise<any>;
138
148
  /**
139
149
  * Fetch stream message history for a job from worker_streams.
140
150
  * Returns raw activity input/output data from soft-deleted messages.
@@ -202,6 +202,13 @@ declare class PostgresStoreService extends StoreService<ProviderClient, Provider
202
202
  * Deploy time-aware notification triggers and functions
203
203
  */
204
204
  private deployTimeNotificationTriggers;
205
+ /**
206
+ * Fetch and decode a single compressed-symbol field from a job's HASH.
207
+ * Reads one field with `hmget` (no full-hash scan), then decodes it with
208
+ * the same rules the serializer uses on write. Powers narrow getters such
209
+ * as the workflow input arguments without a full export.
210
+ */
211
+ getJobArguments(jobId: string, symbolField: string): Promise<any>;
205
212
  /**
206
213
  * Fetch activity inputs for a workflow. Used by the exporter to enrich
207
214
  * timeline events with activity arguments.
@@ -1314,6 +1314,20 @@ class PostgresStoreService extends __1.StoreService {
1314
1314
  }
1315
1315
  }
1316
1316
  // ── Exporter queries ───────────────────────────────────────────────────────
1317
+ /**
1318
+ * Fetch and decode a single compressed-symbol field from a job's HASH.
1319
+ * Reads one field with `hmget` (no full-hash scan), then decodes it with
1320
+ * the same rules the serializer uses on write. Powers narrow getters such
1321
+ * as the workflow input arguments without a full export.
1322
+ */
1323
+ async getJobArguments(jobId, symbolField) {
1324
+ const key = this.mintKey(key_1.KeyType.JOB_STATE, { appId: this.appId, jobId });
1325
+ const [raw] = await this.kvsql().hmget(key, [symbolField]);
1326
+ if (raw === undefined || raw === null) {
1327
+ return undefined;
1328
+ }
1329
+ return this.parseHmshValue(raw);
1330
+ }
1317
1331
  /**
1318
1332
  * Fetch activity inputs for a workflow. Used by the exporter to enrich
1319
1333
  * timeline events with activity arguments.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hotmeshio/hotmesh",
3
- "version": "0.27.0",
3
+ "version": "0.27.1",
4
4
  "description": "Durable Workflow",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",