@upstash/workflow 0.1.1-canary → 0.1.1-canary-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/h3.js CHANGED
@@ -783,7 +783,6 @@ var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
783
783
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
784
784
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
785
785
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
786
- var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
787
786
  var WORKFLOW_PROTOCOL_VERSION = "1";
788
787
  var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
789
788
  var DEFAULT_CONTENT_TYPE = "application/json";
@@ -869,13 +868,13 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
869
868
  try {
870
869
  if (request.headers.get("Upstash-Workflow-Callback")) {
871
870
  const callbackMessage = JSON.parse(requestPayload);
872
- if (!(callbackMessage.status >= 200 && callbackMessage.status < 300) && callbackMessage.maxRetries && callbackMessage.retried !== callbackMessage.maxRetries) {
871
+ if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
873
872
  await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
874
873
  status: callbackMessage.status,
875
874
  body: atob(callbackMessage.body)
876
875
  });
877
876
  console.warn(
878
- `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (retried ${callbackMessage.retried ?? 0} out of ${callbackMessage.maxRetries} times). Error Message:
877
+ `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (if there are retries remaining). Error Message:
879
878
  ${atob(callbackMessage.body)}`
880
879
  );
881
880
  return ok("call-will-retry");
@@ -912,11 +911,7 @@ ${atob(callbackMessage.body)}`
912
911
  stepId: Number(stepIdString),
913
912
  stepName,
914
913
  stepType,
915
- out: {
916
- status: callbackMessage.status,
917
- body: atob(callbackMessage.body),
918
- header: callbackMessage.header
919
- },
914
+ out: atob(callbackMessage.body),
920
915
  concurrent: Number(concurrentString)
921
916
  };
922
917
  await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
@@ -951,24 +946,15 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
951
946
  [WORKFLOW_INIT_HEADER]: initHeaderValue,
952
947
  [WORKFLOW_ID_HEADER]: workflowRunId,
953
948
  [WORKFLOW_URL_HEADER]: workflowUrl,
954
- [WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
955
- [`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
956
- };
957
- if (failureUrl) {
958
- if (!step?.callUrl) {
959
- baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
960
- }
961
- baseHeaders["Upstash-Failure-Callback"] = failureUrl;
962
- }
963
- if (step?.callUrl) {
964
- baseHeaders["Upstash-Retries"] = "0";
965
- if (retries) {
966
- baseHeaders["Upstash-Callback-Retries"] = retries.toString();
967
- baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
949
+ [`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION,
950
+ ...failureUrl ? {
951
+ [`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`]: "true",
952
+ "Upstash-Failure-Callback": failureUrl
953
+ } : {},
954
+ ...retries === void 0 ? {} : {
955
+ "Upstash-Retries": retries.toString()
968
956
  }
969
- } else if (retries !== void 0) {
970
- baseHeaders["Upstash-Retries"] = retries.toString();
971
- }
957
+ };
972
958
  if (userHeaders) {
973
959
  for (const header of userHeaders.keys()) {
974
960
  if (step?.callHeaders) {
@@ -1433,6 +1419,16 @@ var sortSteps = (steps) => {
1433
1419
  return steps.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther));
1434
1420
  };
1435
1421
 
1422
+ // src/client/utils.ts
1423
+ var makeNotifyRequest = async (requester, eventId, eventData) => {
1424
+ const result = await requester.request({
1425
+ path: ["v2", "notify", eventId],
1426
+ method: "POST",
1427
+ body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
1428
+ });
1429
+ return result;
1430
+ };
1431
+
1436
1432
  // src/context/steps.ts
1437
1433
  var BaseLazyStep = class {
1438
1434
  stepName;
@@ -1591,6 +1587,19 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
1591
1587
  });
1592
1588
  }
1593
1589
  };
1590
+ var LazyNotifyStep = class extends LazyFunctionStep {
1591
+ stepType = "Notify";
1592
+ constructor(stepName, eventId, eventData, requester) {
1593
+ super(stepName, async () => {
1594
+ const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
1595
+ return {
1596
+ eventId,
1597
+ eventData,
1598
+ notifyResponse
1599
+ };
1600
+ });
1601
+ }
1602
+ };
1594
1603
 
1595
1604
  // src/context/context.ts
1596
1605
  var WorkflowContext = class {
@@ -1827,13 +1836,48 @@ var WorkflowContext = class {
1827
1836
  * @returns call result (parsed as JSON if possible)
1828
1837
  */
1829
1838
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1830
- async call(stepName, callSettings) {
1831
- const { url, method = "GET", body, headers = {} } = callSettings;
1839
+ async call(stepName, url, method, body, headers) {
1832
1840
  const result = await this.addStep(
1833
- new LazyCallStep(stepName, url, method, body, headers)
1841
+ new LazyCallStep(stepName, url, method, body, headers ?? {})
1834
1842
  );
1835
- return result;
1843
+ try {
1844
+ return JSON.parse(result);
1845
+ } catch {
1846
+ return result;
1847
+ }
1836
1848
  }
1849
+ /**
1850
+ * Makes the workflow run wait until a notify request is sent or until the
1851
+ * timeout ends
1852
+ *
1853
+ * ```ts
1854
+ * const { eventData, timeout } = await context.waitForEvent(
1855
+ * "wait for event step",
1856
+ * "my-event-id",
1857
+ * 100 // timeout after 100 seconds
1858
+ * );
1859
+ * ```
1860
+ *
1861
+ * To notify a waiting workflow run, you can use the notify method:
1862
+ *
1863
+ * ```ts
1864
+ * import { Client } from "@upstash/workflow";
1865
+ *
1866
+ * const client = new Client({ token: });
1867
+ *
1868
+ * await client.notify({
1869
+ * eventId: "my-event-id",
1870
+ * eventData: "eventData"
1871
+ * })
1872
+ * ```
1873
+ *
1874
+ * @param stepName
1875
+ * @param eventId event id to wake up the waiting workflow run
1876
+ * @param timeout timeout duration in seconds
1877
+ * @returns wait response as `{ timeout: boolean, eventData: unknown }`.
1878
+ * timeout is true if the wait times out, if notified it is false. eventData
1879
+ * is the value passed to `client.notify`.
1880
+ */
1837
1881
  async waitForEvent(stepName, eventId, timeout) {
1838
1882
  const result = await this.addStep(
1839
1883
  new LazyWaitForEventStep(
@@ -1842,7 +1886,27 @@ var WorkflowContext = class {
1842
1886
  typeof timeout === "string" ? timeout : `${timeout}s`
1843
1887
  )
1844
1888
  );
1845
- return result;
1889
+ try {
1890
+ return {
1891
+ ...result,
1892
+ eventData: JSON.parse(result.eventData)
1893
+ };
1894
+ } catch {
1895
+ return result;
1896
+ }
1897
+ }
1898
+ async notify(stepName, eventId, eventData) {
1899
+ const result = await this.addStep(
1900
+ new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
1901
+ );
1902
+ try {
1903
+ return {
1904
+ ...result,
1905
+ eventData: JSON.parse(result.eventData)
1906
+ };
1907
+ } catch {
1908
+ return result;
1909
+ }
1846
1910
  }
1847
1911
  /**
1848
1912
  * Adds steps to the executor. Needed so that it can be overwritten in
@@ -1943,7 +2007,7 @@ var parsePayload = (rawPayload) => {
1943
2007
  const step = JSON.parse(decodeBase64(rawStep.body));
1944
2008
  if (step.waitEventId) {
1945
2009
  const newOut = {
1946
- notifyBody: step.out,
2010
+ eventData: step.out,
1947
2011
  timeout: step.waitTimeout ?? false
1948
2012
  };
1949
2013
  step.out = newOut;
@@ -2200,7 +2264,6 @@ var serve = (routeFunction, options) => {
2200
2264
  } = processOptions(options);
2201
2265
  const debug = WorkflowLogger.getLogger(verbose);
2202
2266
  const handler = async (request) => {
2203
- await debug?.log("INFO", "ENDPOINT_START");
2204
2267
  const { workflowUrl, workflowFailureUrl } = await determineUrls(
2205
2268
  request,
2206
2269
  url,
@@ -2244,8 +2307,7 @@ var serve = (routeFunction, options) => {
2244
2307
  url: workflowUrl,
2245
2308
  failureUrl: workflowFailureUrl,
2246
2309
  debug,
2247
- env,
2248
- retries
2310
+ env
2249
2311
  });
2250
2312
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
2251
2313
  routeFunction,
@@ -2288,7 +2350,7 @@ var serve = (routeFunction, options) => {
2288
2350
  await debug?.log("INFO", "RESPONSE_DEFAULT");
2289
2351
  return onStepFinish("no-workflow-id", "fromCallback");
2290
2352
  };
2291
- const safeHandler = async (request) => {
2353
+ return async (request) => {
2292
2354
  try {
2293
2355
  return await handler(request);
2294
2356
  } catch (error) {
@@ -2298,7 +2360,6 @@ var serve = (routeFunction, options) => {
2298
2360
  });
2299
2361
  }
2300
2362
  };
2301
- return { handler: safeHandler };
2302
2363
  };
2303
2364
 
2304
2365
  // src/client/index.ts
@@ -2331,10 +2392,10 @@ var serve2 = (routeFunction, options) => {
2331
2392
  body: await readRawBody(event),
2332
2393
  method: "POST"
2333
2394
  });
2334
- const { handler: serveHandler } = serve(routeFunction, options);
2395
+ const serveHandler = serve(routeFunction, options);
2335
2396
  return await serveHandler(request);
2336
2397
  });
2337
- return { handler };
2398
+ return handler;
2338
2399
  };
2339
2400
  // Annotate the CommonJS export names for ESM import in node:
2340
2401
  0 && (module.exports = {
package/h3.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-YW5KUHA2.mjs";
3
+ } from "./chunk-BPN5JBNG.mjs";
4
4
 
5
5
  // node_modules/defu/dist/defu.mjs
6
6
  function isPlainObject(value) {
@@ -338,10 +338,10 @@ var serve2 = (routeFunction, options) => {
338
338
  body: await readRawBody(event),
339
339
  method: "POST"
340
340
  });
341
- const { handler: serveHandler } = serve(routeFunction, options);
341
+ const serveHandler = serve(routeFunction, options);
342
342
  return await serveHandler(request);
343
343
  });
344
- return { handler };
344
+ return handler;
345
345
  };
346
346
  export {
347
347
  serve2 as serve
package/hono.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Context } from 'hono';
2
- import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.mjs';
2
+ import { R as RouteFunction, W as WorkflowServeOptions } from './types-CoXaNrxX.mjs';
3
3
  import '@upstash/qstash';
4
4
 
5
5
  type WorkflowBindings = {
package/hono.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Context } from 'hono';
2
- import { R as RouteFunction, W as WorkflowServeOptions } from './types-D8FBKkto.js';
2
+ import { R as RouteFunction, W as WorkflowServeOptions } from './types-CoXaNrxX.js';
3
3
  import '@upstash/qstash';
4
4
 
5
5
  type WorkflowBindings = {
package/hono.js CHANGED
@@ -474,7 +474,6 @@ var WORKFLOW_ID_HEADER = "Upstash-Workflow-RunId";
474
474
  var WORKFLOW_INIT_HEADER = "Upstash-Workflow-Init";
475
475
  var WORKFLOW_URL_HEADER = "Upstash-Workflow-Url";
476
476
  var WORKFLOW_FAILURE_HEADER = "Upstash-Workflow-Is-Failure";
477
- var WORKFLOW_FEATURE_HEADER = "Upstash-Feature-Set";
478
477
  var WORKFLOW_PROTOCOL_VERSION = "1";
479
478
  var WORKFLOW_PROTOCOL_VERSION_HEADER = "Upstash-Workflow-Sdk-Version";
480
479
  var DEFAULT_CONTENT_TYPE = "application/json";
@@ -560,13 +559,13 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
560
559
  try {
561
560
  if (request.headers.get("Upstash-Workflow-Callback")) {
562
561
  const callbackMessage = JSON.parse(requestPayload);
563
- if (!(callbackMessage.status >= 200 && callbackMessage.status < 300) && callbackMessage.maxRetries && callbackMessage.retried !== callbackMessage.maxRetries) {
562
+ if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
564
563
  await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
565
564
  status: callbackMessage.status,
566
565
  body: atob(callbackMessage.body)
567
566
  });
568
567
  console.warn(
569
- `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (retried ${callbackMessage.retried ?? 0} out of ${callbackMessage.maxRetries} times). Error Message:
568
+ `Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (if there are retries remaining). Error Message:
570
569
  ${atob(callbackMessage.body)}`
571
570
  );
572
571
  return ok("call-will-retry");
@@ -603,11 +602,7 @@ ${atob(callbackMessage.body)}`
603
602
  stepId: Number(stepIdString),
604
603
  stepName,
605
604
  stepType,
606
- out: {
607
- status: callbackMessage.status,
608
- body: atob(callbackMessage.body),
609
- header: callbackMessage.header
610
- },
605
+ out: atob(callbackMessage.body),
611
606
  concurrent: Number(concurrentString)
612
607
  };
613
608
  await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
@@ -642,24 +637,15 @@ var getHeaders = (initHeaderValue, workflowRunId, workflowUrl, userHeaders, step
642
637
  [WORKFLOW_INIT_HEADER]: initHeaderValue,
643
638
  [WORKFLOW_ID_HEADER]: workflowRunId,
644
639
  [WORKFLOW_URL_HEADER]: workflowUrl,
645
- [WORKFLOW_FEATURE_HEADER]: "WF_NoDelete",
646
- [`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION
647
- };
648
- if (failureUrl) {
649
- if (!step?.callUrl) {
650
- baseHeaders[`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`] = "true";
651
- }
652
- baseHeaders["Upstash-Failure-Callback"] = failureUrl;
653
- }
654
- if (step?.callUrl) {
655
- baseHeaders["Upstash-Retries"] = "0";
656
- if (retries) {
657
- baseHeaders["Upstash-Callback-Retries"] = retries.toString();
658
- baseHeaders["Upstash-Failure-Callback-Retries"] = retries.toString();
640
+ [`Upstash-Forward-${WORKFLOW_PROTOCOL_VERSION_HEADER}`]: WORKFLOW_PROTOCOL_VERSION,
641
+ ...failureUrl ? {
642
+ [`Upstash-Failure-Callback-Forward-${WORKFLOW_FAILURE_HEADER}`]: "true",
643
+ "Upstash-Failure-Callback": failureUrl
644
+ } : {},
645
+ ...retries === void 0 ? {} : {
646
+ "Upstash-Retries": retries.toString()
659
647
  }
660
- } else if (retries !== void 0) {
661
- baseHeaders["Upstash-Retries"] = retries.toString();
662
- }
648
+ };
663
649
  if (userHeaders) {
664
650
  for (const header of userHeaders.keys()) {
665
651
  if (step?.callHeaders) {
@@ -1124,6 +1110,16 @@ var sortSteps = (steps) => {
1124
1110
  return steps.toSorted((step, stepOther) => getStepId(step) - getStepId(stepOther));
1125
1111
  };
1126
1112
 
1113
+ // src/client/utils.ts
1114
+ var makeNotifyRequest = async (requester, eventId, eventData) => {
1115
+ const result = await requester.request({
1116
+ path: ["v2", "notify", eventId],
1117
+ method: "POST",
1118
+ body: typeof eventData === "string" ? eventData : JSON.stringify(eventData)
1119
+ });
1120
+ return result;
1121
+ };
1122
+
1127
1123
  // src/context/steps.ts
1128
1124
  var BaseLazyStep = class {
1129
1125
  stepName;
@@ -1282,6 +1278,19 @@ var LazyWaitForEventStep = class extends BaseLazyStep {
1282
1278
  });
1283
1279
  }
1284
1280
  };
1281
+ var LazyNotifyStep = class extends LazyFunctionStep {
1282
+ stepType = "Notify";
1283
+ constructor(stepName, eventId, eventData, requester) {
1284
+ super(stepName, async () => {
1285
+ const notifyResponse = await makeNotifyRequest(requester, eventId, eventData);
1286
+ return {
1287
+ eventId,
1288
+ eventData,
1289
+ notifyResponse
1290
+ };
1291
+ });
1292
+ }
1293
+ };
1285
1294
 
1286
1295
  // src/context/context.ts
1287
1296
  var WorkflowContext = class {
@@ -1518,13 +1527,48 @@ var WorkflowContext = class {
1518
1527
  * @returns call result (parsed as JSON if possible)
1519
1528
  */
1520
1529
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1521
- async call(stepName, callSettings) {
1522
- const { url, method = "GET", body, headers = {} } = callSettings;
1530
+ async call(stepName, url, method, body, headers) {
1523
1531
  const result = await this.addStep(
1524
- new LazyCallStep(stepName, url, method, body, headers)
1532
+ new LazyCallStep(stepName, url, method, body, headers ?? {})
1525
1533
  );
1526
- return result;
1534
+ try {
1535
+ return JSON.parse(result);
1536
+ } catch {
1537
+ return result;
1538
+ }
1527
1539
  }
1540
+ /**
1541
+ * Makes the workflow run wait until a notify request is sent or until the
1542
+ * timeout ends
1543
+ *
1544
+ * ```ts
1545
+ * const { eventData, timeout } = await context.waitForEvent(
1546
+ * "wait for event step",
1547
+ * "my-event-id",
1548
+ * 100 // timeout after 100 seconds
1549
+ * );
1550
+ * ```
1551
+ *
1552
+ * To notify a waiting workflow run, you can use the notify method:
1553
+ *
1554
+ * ```ts
1555
+ * import { Client } from "@upstash/workflow";
1556
+ *
1557
+ * const client = new Client({ token: });
1558
+ *
1559
+ * await client.notify({
1560
+ * eventId: "my-event-id",
1561
+ * eventData: "eventData"
1562
+ * })
1563
+ * ```
1564
+ *
1565
+ * @param stepName
1566
+ * @param eventId event id to wake up the waiting workflow run
1567
+ * @param timeout timeout duration in seconds
1568
+ * @returns wait response as `{ timeout: boolean, eventData: unknown }`.
1569
+ * timeout is true if the wait times out, if notified it is false. eventData
1570
+ * is the value passed to `client.notify`.
1571
+ */
1528
1572
  async waitForEvent(stepName, eventId, timeout) {
1529
1573
  const result = await this.addStep(
1530
1574
  new LazyWaitForEventStep(
@@ -1533,7 +1577,27 @@ var WorkflowContext = class {
1533
1577
  typeof timeout === "string" ? timeout : `${timeout}s`
1534
1578
  )
1535
1579
  );
1536
- return result;
1580
+ try {
1581
+ return {
1582
+ ...result,
1583
+ eventData: JSON.parse(result.eventData)
1584
+ };
1585
+ } catch {
1586
+ return result;
1587
+ }
1588
+ }
1589
+ async notify(stepName, eventId, eventData) {
1590
+ const result = await this.addStep(
1591
+ new LazyNotifyStep(stepName, eventId, eventData, this.qstashClient.http)
1592
+ );
1593
+ try {
1594
+ return {
1595
+ ...result,
1596
+ eventData: JSON.parse(result.eventData)
1597
+ };
1598
+ } catch {
1599
+ return result;
1600
+ }
1537
1601
  }
1538
1602
  /**
1539
1603
  * Adds steps to the executor. Needed so that it can be overwritten in
@@ -1634,7 +1698,7 @@ var parsePayload = (rawPayload) => {
1634
1698
  const step = JSON.parse(decodeBase64(rawStep.body));
1635
1699
  if (step.waitEventId) {
1636
1700
  const newOut = {
1637
- notifyBody: step.out,
1701
+ eventData: step.out,
1638
1702
  timeout: step.waitTimeout ?? false
1639
1703
  };
1640
1704
  step.out = newOut;
@@ -1891,7 +1955,6 @@ var serve = (routeFunction, options) => {
1891
1955
  } = processOptions(options);
1892
1956
  const debug = WorkflowLogger.getLogger(verbose);
1893
1957
  const handler = async (request) => {
1894
- await debug?.log("INFO", "ENDPOINT_START");
1895
1958
  const { workflowUrl, workflowFailureUrl } = await determineUrls(
1896
1959
  request,
1897
1960
  url,
@@ -1935,8 +1998,7 @@ var serve = (routeFunction, options) => {
1935
1998
  url: workflowUrl,
1936
1999
  failureUrl: workflowFailureUrl,
1937
2000
  debug,
1938
- env,
1939
- retries
2001
+ env
1940
2002
  });
1941
2003
  const authCheck = await DisabledWorkflowContext.tryAuthentication(
1942
2004
  routeFunction,
@@ -1979,7 +2041,7 @@ var serve = (routeFunction, options) => {
1979
2041
  await debug?.log("INFO", "RESPONSE_DEFAULT");
1980
2042
  return onStepFinish("no-workflow-id", "fromCallback");
1981
2043
  };
1982
- const safeHandler = async (request) => {
2044
+ return async (request) => {
1983
2045
  try {
1984
2046
  return await handler(request);
1985
2047
  } catch (error) {
@@ -1989,7 +2051,6 @@ var serve = (routeFunction, options) => {
1989
2051
  });
1990
2052
  }
1991
2053
  };
1992
- return { handler: safeHandler };
1993
2054
  };
1994
2055
 
1995
2056
  // src/client/index.ts
@@ -2000,7 +2061,7 @@ var serve2 = (routeFunction, options) => {
2000
2061
  const handler = async (context) => {
2001
2062
  const environment = context.env;
2002
2063
  const request = context.req.raw;
2003
- const { handler: serveHandler } = serve(routeFunction, {
2064
+ const serveHandler = serve(routeFunction, {
2004
2065
  // when hono is used without cf workers, it sends a DebugHTTPServer
2005
2066
  // object in `context.env`. don't pass env if this is the case:
2006
2067
  env: "QSTASH_TOKEN" in environment ? environment : void 0,
package/hono.mjs CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  serve
3
- } from "./chunk-YW5KUHA2.mjs";
3
+ } from "./chunk-BPN5JBNG.mjs";
4
4
 
5
5
  // platforms/hono.ts
6
6
  var serve2 = (routeFunction, options) => {
7
7
  const handler = async (context) => {
8
8
  const environment = context.env;
9
9
  const request = context.req.raw;
10
- const { handler: serveHandler } = serve(routeFunction, {
10
+ const serveHandler = serve(routeFunction, {
11
11
  // when hono is used without cf workers, it sends a DebugHTTPServer
12
12
  // object in `context.env`. don't pass env if this is the case:
13
13
  env: "QSTASH_TOKEN" in environment ? environment : void 0,
package/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-D8FBKkto.mjs';
2
- export { A as AsyncStepFunction, C as CallResponse, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-D8FBKkto.mjs';
1
+ import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CoXaNrxX.mjs';
2
+ export { A as AsyncStepFunction, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CoXaNrxX.mjs';
3
3
  import { Client as Client$1, QstashError } from '@upstash/qstash';
4
4
 
5
5
  /**
@@ -10,9 +10,7 @@ import { Client as Client$1, QstashError } from '@upstash/qstash';
10
10
  * @param options - Options including the client, onFinish callback, and initialPayloadParser.
11
11
  * @returns An async method that consumes incoming requests and runs the workflow.
12
12
  */
13
- declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
14
- handler: (request: TRequest) => Promise<TResponse>;
15
- };
13
+ declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
16
14
 
17
15
  type ClientConfig = ConstructorParameters<typeof Client$1>[0];
18
16
  declare class Client {
@@ -33,12 +31,20 @@ declare class Client {
33
31
  * Notify a workflow run waiting for an event
34
32
  *
35
33
  * @param eventId event id to notify
36
- * @param notifyData data to provide to the workflow
34
+ * @param eventData data to provide to the workflow
37
35
  */
38
- notify({ eventId, notifyBody, }: {
36
+ notify({ eventId, eventData, }: {
39
37
  eventId: string;
40
- notifyBody?: string;
38
+ eventData?: unknown;
41
39
  }): Promise<NotifyResponse[]>;
40
+ /**
41
+ * Check waiters of an event
42
+ *
43
+ * @param eventId event id to check
44
+ */
45
+ getWaiters({ eventId }: {
46
+ eventId: string;
47
+ }): Promise<Waiter[]>;
42
48
  }
43
49
 
44
50
  /**
@@ -56,4 +62,4 @@ declare class QStashWorkflowAbort extends Error {
56
62
  constructor(stepName: string, stepInfo?: Step);
57
63
  }
58
64
 
59
- export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, WorkflowServeOptions, serve };
65
+ export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, Waiter, WorkflowServeOptions, serve };
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, S as Step } from './types-D8FBKkto.js';
2
- export { A as AsyncStepFunction, C as CallResponse, i as FailureFunctionPayload, F as FinishCondition, L as LogLevel, P as ParallelCallState, f as RawStep, j as RequiredExceptFields, h as StepFunction, e as StepType, d as StepTypes, g as SyncStepFunction, m as WaitRequest, k as WaitResult, n as WaitStepResponse, l as Waiter, b as WorkflowClient, a as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, c as WorkflowReceiver } from './types-D8FBKkto.js';
1
+ import { R as RouteFunction, W as WorkflowServeOptions, N as NotifyResponse, a as Waiter, S as Step } from './types-CoXaNrxX.js';
2
+ export { A as AsyncStepFunction, j as FailureFunctionPayload, F as FinishCondition, L as LogLevel, n as NotifyStepResponse, P as ParallelCallState, g as RawStep, k as RequiredExceptFields, i as StepFunction, f as StepType, e as StepTypes, h as SyncStepFunction, l as WaitRequest, m as WaitStepResponse, c as WorkflowClient, b as WorkflowContext, p as WorkflowLogger, o as WorkflowLoggerOptions, d as WorkflowReceiver } from './types-CoXaNrxX.js';
3
3
  import { Client as Client$1, QstashError } from '@upstash/qstash';
4
4
 
5
5
  /**
@@ -10,9 +10,7 @@ import { Client as Client$1, QstashError } from '@upstash/qstash';
10
10
  * @param options - Options including the client, onFinish callback, and initialPayloadParser.
11
11
  * @returns An async method that consumes incoming requests and runs the workflow.
12
12
  */
13
- declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => {
14
- handler: (request: TRequest) => Promise<TResponse>;
15
- };
13
+ declare const serve: <TInitialPayload = unknown, TRequest extends Request = Request, TResponse extends Response = Response>(routeFunction: RouteFunction<TInitialPayload>, options?: WorkflowServeOptions<TResponse, TInitialPayload>) => ((request: TRequest) => Promise<TResponse>);
16
14
 
17
15
  type ClientConfig = ConstructorParameters<typeof Client$1>[0];
18
16
  declare class Client {
@@ -33,12 +31,20 @@ declare class Client {
33
31
  * Notify a workflow run waiting for an event
34
32
  *
35
33
  * @param eventId event id to notify
36
- * @param notifyData data to provide to the workflow
34
+ * @param eventData data to provide to the workflow
37
35
  */
38
- notify({ eventId, notifyBody, }: {
36
+ notify({ eventId, eventData, }: {
39
37
  eventId: string;
40
- notifyBody?: string;
38
+ eventData?: unknown;
41
39
  }): Promise<NotifyResponse[]>;
40
+ /**
41
+ * Check waiters of an event
42
+ *
43
+ * @param eventId event id to check
44
+ */
45
+ getWaiters({ eventId }: {
46
+ eventId: string;
47
+ }): Promise<Waiter[]>;
42
48
  }
43
49
 
44
50
  /**
@@ -56,4 +62,4 @@ declare class QStashWorkflowAbort extends Error {
56
62
  constructor(stepName: string, stepInfo?: Step);
57
63
  }
58
64
 
59
- export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, WorkflowServeOptions, serve };
65
+ export { Client, NotifyResponse, QStashWorkflowAbort, QStashWorkflowError, RouteFunction, Step, Waiter, WorkflowServeOptions, serve };