@upstash/workflow 0.2.1 → 0.2.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/astro.d.mts +2 -2
- package/astro.d.ts +2 -2
- package/astro.js +121 -75
- package/astro.mjs +5 -5
- package/{chunk-ADOBNR4O.mjs → chunk-Z7WS5XIR.mjs} +96 -221
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +121 -75
- package/cloudflare.mjs +5 -5
- package/express.d.mts +1 -1
- package/express.d.ts +1 -1
- package/express.js +133 -80
- package/express.mjs +17 -10
- package/h3.d.mts +2 -2
- package/h3.d.ts +2 -2
- package/h3.js +121 -75
- package/h3.mjs +5 -5
- package/hono.d.mts +4 -2
- package/hono.d.ts +4 -2
- package/hono.js +121 -75
- package/hono.mjs +5 -5
- package/index.d.mts +3 -3
- package/index.d.ts +3 -3
- package/index.js +125 -73
- package/index.mjs +189 -3
- package/nextjs.d.mts +3 -3
- package/nextjs.d.ts +3 -3
- package/nextjs.js +122 -76
- package/nextjs.mjs +6 -6
- package/package.json +1 -1
- package/solidjs.d.mts +2 -2
- package/solidjs.d.ts +2 -2
- package/solidjs.js +121 -75
- package/solidjs.mjs +5 -5
- package/svelte.d.mts +3 -3
- package/svelte.d.ts +3 -3
- package/svelte.js +124 -75
- package/svelte.mjs +8 -5
- package/{types-Be4hC1mu.d.mts → types-APRap-aV.d.mts} +10 -2
- package/{types-Be4hC1mu.d.ts → types-APRap-aV.d.ts} +10 -2
package/nextjs.js
CHANGED
|
@@ -20,53 +20,13 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// platforms/nextjs.ts
|
|
21
21
|
var nextjs_exports = {};
|
|
22
22
|
__export(nextjs_exports, {
|
|
23
|
-
serve: () =>
|
|
23
|
+
serve: () => serve,
|
|
24
24
|
servePagesRouter: () => servePagesRouter
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(nextjs_exports);
|
|
27
27
|
|
|
28
|
-
// src/error.ts
|
|
29
|
-
var import_qstash = require("@upstash/qstash");
|
|
30
|
-
var WorkflowError = class extends import_qstash.QstashError {
|
|
31
|
-
constructor(message) {
|
|
32
|
-
super(message);
|
|
33
|
-
this.name = "WorkflowError";
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var WorkflowAbort = class extends Error {
|
|
37
|
-
stepInfo;
|
|
38
|
-
stepName;
|
|
39
|
-
/**
|
|
40
|
-
* whether workflow is to be canceled on abort
|
|
41
|
-
*/
|
|
42
|
-
cancelWorkflow;
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param stepName name of the aborting step
|
|
46
|
-
* @param stepInfo step information
|
|
47
|
-
* @param cancelWorkflow
|
|
48
|
-
*/
|
|
49
|
-
constructor(stepName, stepInfo, cancelWorkflow = false) {
|
|
50
|
-
super(
|
|
51
|
-
`This is an Upstash Workflow error thrown after a step executes. It is expected to be raised. Make sure that you await for each step. Also, if you are using try/catch blocks, you should not wrap context.run/sleep/sleepUntil/call methods with try/catch. Aborting workflow after executing step '${stepName}'.`
|
|
52
|
-
);
|
|
53
|
-
this.name = "WorkflowAbort";
|
|
54
|
-
this.stepName = stepName;
|
|
55
|
-
this.stepInfo = stepInfo;
|
|
56
|
-
this.cancelWorkflow = cancelWorkflow;
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var formatWorkflowError = (error) => {
|
|
60
|
-
return error instanceof Error ? {
|
|
61
|
-
error: error.name,
|
|
62
|
-
message: error.message
|
|
63
|
-
} : {
|
|
64
|
-
error: "Error",
|
|
65
|
-
message: "An error occured while executing workflow."
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
28
|
// src/client/utils.ts
|
|
29
|
+
var import_qstash = require("@upstash/qstash");
|
|
70
30
|
var makeNotifyRequest = async (requester, eventId, eventData) => {
|
|
71
31
|
const result = await requester.request({
|
|
72
32
|
path: ["v2", "notify", eventId],
|
|
@@ -93,26 +53,71 @@ var getSteps = async (requester, workflowRunId, messageId, debug) => {
|
|
|
93
53
|
await debug?.log("INFO", "ENDPOINT_START", {
|
|
94
54
|
message: `Pulled ${steps.length} steps from QStashand returned them without filtering with messageId.`
|
|
95
55
|
});
|
|
96
|
-
return steps;
|
|
56
|
+
return { steps, workflowRunEnded: false };
|
|
97
57
|
} else {
|
|
98
58
|
const index = steps.findIndex((item) => item.messageId === messageId);
|
|
99
59
|
if (index === -1) {
|
|
100
|
-
return [];
|
|
60
|
+
return { steps: [], workflowRunEnded: false };
|
|
101
61
|
}
|
|
102
62
|
const filteredSteps = steps.slice(0, index + 1);
|
|
103
63
|
await debug?.log("INFO", "ENDPOINT_START", {
|
|
104
64
|
message: `Pulled ${steps.length} steps from QStash and filtered them to ${filteredSteps.length} using messageId.`
|
|
105
65
|
});
|
|
106
|
-
return filteredSteps;
|
|
66
|
+
return { steps: filteredSteps, workflowRunEnded: false };
|
|
107
67
|
}
|
|
108
68
|
} catch (error) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
69
|
+
if (error instanceof import_qstash.QstashError && error.status === 404) {
|
|
70
|
+
await debug?.log("WARN", "ENDPOINT_START", {
|
|
71
|
+
message: "Couldn't fetch workflow run steps. This can happen if the workflow run succesfully ends before some callback is executed.",
|
|
72
|
+
error
|
|
73
|
+
});
|
|
74
|
+
return { steps: void 0, workflowRunEnded: true };
|
|
75
|
+
} else {
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/error.ts
|
|
82
|
+
var import_qstash2 = require("@upstash/qstash");
|
|
83
|
+
var WorkflowError = class extends import_qstash2.QstashError {
|
|
84
|
+
constructor(message) {
|
|
85
|
+
super(message);
|
|
86
|
+
this.name = "WorkflowError";
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var WorkflowAbort = class extends Error {
|
|
90
|
+
stepInfo;
|
|
91
|
+
stepName;
|
|
92
|
+
/**
|
|
93
|
+
* whether workflow is to be canceled on abort
|
|
94
|
+
*/
|
|
95
|
+
cancelWorkflow;
|
|
96
|
+
/**
|
|
97
|
+
*
|
|
98
|
+
* @param stepName name of the aborting step
|
|
99
|
+
* @param stepInfo step information
|
|
100
|
+
* @param cancelWorkflow
|
|
101
|
+
*/
|
|
102
|
+
constructor(stepName, stepInfo, cancelWorkflow = false) {
|
|
103
|
+
super(
|
|
104
|
+
`This is an Upstash Workflow error thrown after a step executes. It is expected to be raised. Make sure that you await for each step. Also, if you are using try/catch blocks, you should not wrap context.run/sleep/sleepUntil/call methods with try/catch. Aborting workflow after executing step '${stepName}'.`
|
|
105
|
+
);
|
|
106
|
+
this.name = "WorkflowAbort";
|
|
107
|
+
this.stepName = stepName;
|
|
108
|
+
this.stepInfo = stepInfo;
|
|
109
|
+
this.cancelWorkflow = cancelWorkflow;
|
|
114
110
|
}
|
|
115
111
|
};
|
|
112
|
+
var formatWorkflowError = (error) => {
|
|
113
|
+
return error instanceof Error ? {
|
|
114
|
+
error: error.name,
|
|
115
|
+
message: error.message
|
|
116
|
+
} : {
|
|
117
|
+
error: "Error",
|
|
118
|
+
message: "An error occured while executing workflow."
|
|
119
|
+
};
|
|
120
|
+
};
|
|
116
121
|
|
|
117
122
|
// src/context/steps.ts
|
|
118
123
|
var BaseLazyStep = class {
|
|
@@ -734,8 +739,8 @@ var StepTypes = [
|
|
|
734
739
|
];
|
|
735
740
|
|
|
736
741
|
// src/workflow-requests.ts
|
|
737
|
-
var
|
|
738
|
-
var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
742
|
+
var import_qstash3 = require("@upstash/qstash");
|
|
743
|
+
var triggerFirstInvocation = async (workflowContext, retries, useJSONContent, debug) => {
|
|
739
744
|
const { headers } = getHeaders(
|
|
740
745
|
"true",
|
|
741
746
|
workflowContext.workflowRunId,
|
|
@@ -745,6 +750,9 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
745
750
|
workflowContext.failureUrl,
|
|
746
751
|
retries
|
|
747
752
|
);
|
|
753
|
+
if (useJSONContent) {
|
|
754
|
+
headers["content-type"] = "application/json";
|
|
755
|
+
}
|
|
748
756
|
try {
|
|
749
757
|
const body = typeof workflowContext.requestPayload === "string" ? workflowContext.requestPayload : JSON.stringify(workflowContext.requestPayload);
|
|
750
758
|
const result = await workflowContext.qstashClient.publish({
|
|
@@ -788,7 +796,7 @@ var triggerRouteFunction = async ({
|
|
|
788
796
|
return ok("workflow-finished");
|
|
789
797
|
} catch (error) {
|
|
790
798
|
const error_ = error;
|
|
791
|
-
if (error instanceof
|
|
799
|
+
if (error instanceof import_qstash3.QstashError && error.status === 400) {
|
|
792
800
|
await debug?.log("WARN", "RESPONSE_WORKFLOW", {
|
|
793
801
|
message: `tried to append to a cancelled workflow. exiting without publishing.`,
|
|
794
802
|
name: error.name,
|
|
@@ -822,7 +830,7 @@ var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
|
|
|
822
830
|
);
|
|
823
831
|
return { deleted: true };
|
|
824
832
|
} catch (error) {
|
|
825
|
-
if (error instanceof
|
|
833
|
+
if (error instanceof import_qstash3.QstashError && error.status === 404) {
|
|
826
834
|
await debug?.log("WARN", "SUBMIT_CLEANUP", {
|
|
827
835
|
message: `Failed to remove workflow run ${workflowContext.workflowRunId} as it doesn't exist.`,
|
|
828
836
|
name: error.name,
|
|
@@ -859,11 +867,19 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
|
|
|
859
867
|
if (!workflowRunId2)
|
|
860
868
|
throw new WorkflowError("workflow run id missing in context.call lazy fetch.");
|
|
861
869
|
if (!messageId) throw new WorkflowError("message id missing in context.call lazy fetch.");
|
|
862
|
-
const steps = await getSteps(
|
|
870
|
+
const { steps, workflowRunEnded } = await getSteps(
|
|
871
|
+
client.http,
|
|
872
|
+
workflowRunId2,
|
|
873
|
+
messageId,
|
|
874
|
+
debug
|
|
875
|
+
);
|
|
876
|
+
if (workflowRunEnded) {
|
|
877
|
+
return ok("workflow-ended");
|
|
878
|
+
}
|
|
863
879
|
const failingStep = steps.find((step) => step.messageId === messageId);
|
|
864
880
|
if (!failingStep)
|
|
865
881
|
throw new WorkflowError(
|
|
866
|
-
"Failed to submit the context.call." + (steps.length === 0 ? "No steps found." : `No step was found with matching messageId ${messageId} out of ${steps.length} steps.`)
|
|
882
|
+
"Failed to submit the context.call. " + (steps.length === 0 ? "No steps found." : `No step was found with matching messageId ${messageId} out of ${steps.length} steps.`)
|
|
867
883
|
);
|
|
868
884
|
callbackPayload = atob(failingStep.body);
|
|
869
885
|
}
|
|
@@ -1902,7 +1918,7 @@ function decodeBase64(base64) {
|
|
|
1902
1918
|
}
|
|
1903
1919
|
|
|
1904
1920
|
// src/serve/authorization.ts
|
|
1905
|
-
var
|
|
1921
|
+
var import_qstash4 = require("@upstash/qstash");
|
|
1906
1922
|
var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowContext {
|
|
1907
1923
|
static disabledMessage = "disabled-qstash-worklfow-run";
|
|
1908
1924
|
/**
|
|
@@ -1933,7 +1949,7 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
1933
1949
|
*/
|
|
1934
1950
|
static async tryAuthentication(routeFunction, context) {
|
|
1935
1951
|
const disabledContext = new _DisabledWorkflowContext({
|
|
1936
|
-
qstashClient: new
|
|
1952
|
+
qstashClient: new import_qstash4.Client({
|
|
1937
1953
|
baseUrl: "disabled-client",
|
|
1938
1954
|
token: "disabled-client"
|
|
1939
1955
|
}),
|
|
@@ -2057,7 +2073,8 @@ var parseRequest = async (requestPayload, isFirstInvocation, workflowRunId, requ
|
|
|
2057
2073
|
return {
|
|
2058
2074
|
rawInitialPayload: requestPayload ?? "",
|
|
2059
2075
|
steps: [],
|
|
2060
|
-
isLastDuplicate: false
|
|
2076
|
+
isLastDuplicate: false,
|
|
2077
|
+
workflowRunEnded: false
|
|
2061
2078
|
};
|
|
2062
2079
|
} else {
|
|
2063
2080
|
let rawSteps;
|
|
@@ -2067,7 +2084,21 @@ var parseRequest = async (requestPayload, isFirstInvocation, workflowRunId, requ
|
|
|
2067
2084
|
"ENDPOINT_START",
|
|
2068
2085
|
"request payload is empty, steps will be fetched from QStash."
|
|
2069
2086
|
);
|
|
2070
|
-
|
|
2087
|
+
const { steps: fetchedSteps, workflowRunEnded } = await getSteps(
|
|
2088
|
+
requester,
|
|
2089
|
+
workflowRunId,
|
|
2090
|
+
messageId,
|
|
2091
|
+
debug
|
|
2092
|
+
);
|
|
2093
|
+
if (workflowRunEnded) {
|
|
2094
|
+
return {
|
|
2095
|
+
rawInitialPayload: void 0,
|
|
2096
|
+
steps: void 0,
|
|
2097
|
+
isLastDuplicate: void 0,
|
|
2098
|
+
workflowRunEnded: true
|
|
2099
|
+
};
|
|
2100
|
+
}
|
|
2101
|
+
rawSteps = fetchedSteps;
|
|
2071
2102
|
} else {
|
|
2072
2103
|
rawSteps = JSON.parse(requestPayload);
|
|
2073
2104
|
}
|
|
@@ -2077,7 +2108,8 @@ var parseRequest = async (requestPayload, isFirstInvocation, workflowRunId, requ
|
|
|
2077
2108
|
return {
|
|
2078
2109
|
rawInitialPayload,
|
|
2079
2110
|
steps: deduplicatedSteps,
|
|
2080
|
-
isLastDuplicate
|
|
2111
|
+
isLastDuplicate,
|
|
2112
|
+
workflowRunEnded: false
|
|
2081
2113
|
};
|
|
2082
2114
|
}
|
|
2083
2115
|
};
|
|
@@ -2131,15 +2163,15 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
2131
2163
|
};
|
|
2132
2164
|
|
|
2133
2165
|
// src/serve/options.ts
|
|
2134
|
-
var import_qstash4 = require("@upstash/qstash");
|
|
2135
2166
|
var import_qstash5 = require("@upstash/qstash");
|
|
2167
|
+
var import_qstash6 = require("@upstash/qstash");
|
|
2136
2168
|
var processOptions = (options) => {
|
|
2137
2169
|
const environment = options?.env ?? (typeof process === "undefined" ? {} : process.env);
|
|
2138
2170
|
const receiverEnvironmentVariablesSet = Boolean(
|
|
2139
2171
|
environment.QSTASH_CURRENT_SIGNING_KEY && environment.QSTASH_NEXT_SIGNING_KEY
|
|
2140
2172
|
);
|
|
2141
2173
|
return {
|
|
2142
|
-
qstashClient: new
|
|
2174
|
+
qstashClient: new import_qstash6.Client({
|
|
2143
2175
|
baseUrl: environment.QSTASH_URL,
|
|
2144
2176
|
token: environment.QSTASH_TOKEN
|
|
2145
2177
|
}),
|
|
@@ -2173,13 +2205,14 @@ var processOptions = (options) => {
|
|
|
2173
2205
|
throw error;
|
|
2174
2206
|
}
|
|
2175
2207
|
},
|
|
2176
|
-
receiver: receiverEnvironmentVariablesSet ? new
|
|
2208
|
+
receiver: receiverEnvironmentVariablesSet ? new import_qstash5.Receiver({
|
|
2177
2209
|
currentSigningKey: environment.QSTASH_CURRENT_SIGNING_KEY,
|
|
2178
2210
|
nextSigningKey: environment.QSTASH_NEXT_SIGNING_KEY
|
|
2179
2211
|
}) : void 0,
|
|
2180
2212
|
baseUrl: environment.UPSTASH_WORKFLOW_URL,
|
|
2181
2213
|
env: environment,
|
|
2182
2214
|
retries: DEFAULT_RETRIES,
|
|
2215
|
+
useJSONContent: false,
|
|
2183
2216
|
...options
|
|
2184
2217
|
};
|
|
2185
2218
|
};
|
|
@@ -2196,6 +2229,16 @@ var determineUrls = async (request, url, baseUrl, failureFunction, failureUrl, d
|
|
|
2196
2229
|
});
|
|
2197
2230
|
}
|
|
2198
2231
|
const workflowFailureUrl = failureFunction ? workflowUrl : failureUrl;
|
|
2232
|
+
if (workflowUrl.includes("localhost")) {
|
|
2233
|
+
await debug?.log("WARN", "ENDPOINT_START", {
|
|
2234
|
+
message: `Workflow URL contains localhost. This can happen in local development, but shouldn't happen in production unless you have a route which contains localhost. Received: ${workflowUrl}`
|
|
2235
|
+
});
|
|
2236
|
+
}
|
|
2237
|
+
if (!(workflowUrl.startsWith("http://") || workflowUrl.startsWith("https://"))) {
|
|
2238
|
+
throw new WorkflowError(
|
|
2239
|
+
`Workflow URL should start with 'http://' or 'https://'. Recevied is '${workflowUrl}'`
|
|
2240
|
+
);
|
|
2241
|
+
}
|
|
2199
2242
|
return {
|
|
2200
2243
|
workflowUrl,
|
|
2201
2244
|
workflowFailureUrl
|
|
@@ -2204,7 +2247,7 @@ var determineUrls = async (request, url, baseUrl, failureFunction, failureUrl, d
|
|
|
2204
2247
|
var AUTH_FAIL_MESSAGE = `Failed to authenticate Workflow request. If this is unexpected, see the caveat https://upstash.com/docs/workflow/basics/caveats#avoid-non-deterministic-code-outside-context-run`;
|
|
2205
2248
|
|
|
2206
2249
|
// src/serve/index.ts
|
|
2207
|
-
var
|
|
2250
|
+
var serveBase = (routeFunction, options) => {
|
|
2208
2251
|
const {
|
|
2209
2252
|
qstashClient,
|
|
2210
2253
|
onStepFinish,
|
|
@@ -2216,7 +2259,8 @@ var serve = (routeFunction, options) => {
|
|
|
2216
2259
|
failureFunction,
|
|
2217
2260
|
baseUrl,
|
|
2218
2261
|
env,
|
|
2219
|
-
retries
|
|
2262
|
+
retries,
|
|
2263
|
+
useJSONContent
|
|
2220
2264
|
} = processOptions(options);
|
|
2221
2265
|
const debug = WorkflowLogger.getLogger(verbose);
|
|
2222
2266
|
const handler = async (request) => {
|
|
@@ -2233,7 +2277,7 @@ var serve = (routeFunction, options) => {
|
|
|
2233
2277
|
await verifyRequest(requestPayload, request.headers.get("upstash-signature"), receiver);
|
|
2234
2278
|
const { isFirstInvocation, workflowRunId } = validateRequest(request);
|
|
2235
2279
|
debug?.setWorkflowRunId(workflowRunId);
|
|
2236
|
-
const { rawInitialPayload, steps, isLastDuplicate } = await parseRequest(
|
|
2280
|
+
const { rawInitialPayload, steps, isLastDuplicate, workflowRunEnded } = await parseRequest(
|
|
2237
2281
|
requestPayload,
|
|
2238
2282
|
isFirstInvocation,
|
|
2239
2283
|
workflowRunId,
|
|
@@ -2241,8 +2285,11 @@ var serve = (routeFunction, options) => {
|
|
|
2241
2285
|
request.headers.get("upstash-message-id"),
|
|
2242
2286
|
debug
|
|
2243
2287
|
);
|
|
2288
|
+
if (workflowRunEnded) {
|
|
2289
|
+
return onStepFinish(workflowRunId, "workflow-already-ended");
|
|
2290
|
+
}
|
|
2244
2291
|
if (isLastDuplicate) {
|
|
2245
|
-
return onStepFinish(
|
|
2292
|
+
return onStepFinish(workflowRunId, "duplicate-step");
|
|
2246
2293
|
}
|
|
2247
2294
|
const failureCheck = await handleFailure(
|
|
2248
2295
|
request,
|
|
@@ -2256,7 +2303,7 @@ var serve = (routeFunction, options) => {
|
|
|
2256
2303
|
throw failureCheck.error;
|
|
2257
2304
|
} else if (failureCheck.value === "is-failure-callback") {
|
|
2258
2305
|
await debug?.log("WARN", "RESPONSE_DEFAULT", "failureFunction executed");
|
|
2259
|
-
return onStepFinish(
|
|
2306
|
+
return onStepFinish(workflowRunId, "failure-callback");
|
|
2260
2307
|
}
|
|
2261
2308
|
const workflowContext = new WorkflowContext({
|
|
2262
2309
|
qstashClient,
|
|
@@ -2299,7 +2346,7 @@ var serve = (routeFunction, options) => {
|
|
|
2299
2346
|
});
|
|
2300
2347
|
throw callReturnCheck.error;
|
|
2301
2348
|
} else if (callReturnCheck.value === "continue-workflow") {
|
|
2302
|
-
const result = isFirstInvocation ? await triggerFirstInvocation(workflowContext, retries, debug) : await triggerRouteFunction({
|
|
2349
|
+
const result = isFirstInvocation ? await triggerFirstInvocation(workflowContext, retries, useJSONContent, debug) : await triggerRouteFunction({
|
|
2303
2350
|
onStep: async () => routeFunction(workflowContext),
|
|
2304
2351
|
onCleanup: async () => {
|
|
2305
2352
|
await triggerWorkflowDelete(workflowContext, debug);
|
|
@@ -2315,6 +2362,8 @@ var serve = (routeFunction, options) => {
|
|
|
2315
2362
|
}
|
|
2316
2363
|
await debug?.log("INFO", "RESPONSE_WORKFLOW");
|
|
2317
2364
|
return onStepFinish(workflowContext.workflowRunId, "success");
|
|
2365
|
+
} else if (callReturnCheck.value === "workflow-ended") {
|
|
2366
|
+
return onStepFinish(workflowContext.workflowRunId, "workflow-already-ended");
|
|
2318
2367
|
}
|
|
2319
2368
|
await debug?.log("INFO", "RESPONSE_DEFAULT");
|
|
2320
2369
|
return onStepFinish("no-workflow-id", "fromCallback");
|
|
@@ -2332,12 +2381,9 @@ var serve = (routeFunction, options) => {
|
|
|
2332
2381
|
return { handler: safeHandler };
|
|
2333
2382
|
};
|
|
2334
2383
|
|
|
2335
|
-
// src/client/index.ts
|
|
2336
|
-
var import_qstash6 = require("@upstash/qstash");
|
|
2337
|
-
|
|
2338
2384
|
// platforms/nextjs.ts
|
|
2339
|
-
var
|
|
2340
|
-
const { handler: serveHandler } =
|
|
2385
|
+
var serve = (routeFunction, options) => {
|
|
2386
|
+
const { handler: serveHandler } = serveBase(
|
|
2341
2387
|
routeFunction,
|
|
2342
2388
|
options
|
|
2343
2389
|
);
|
|
@@ -2348,7 +2394,7 @@ var serve2 = (routeFunction, options) => {
|
|
|
2348
2394
|
};
|
|
2349
2395
|
};
|
|
2350
2396
|
var servePagesRouter = (routeFunction, options) => {
|
|
2351
|
-
const { handler: serveHandler } =
|
|
2397
|
+
const { handler: serveHandler } = serveBase(routeFunction, options);
|
|
2352
2398
|
const handler = async (request_, res) => {
|
|
2353
2399
|
if (request_.method?.toUpperCase() !== "POST") {
|
|
2354
2400
|
res.status(405).json("Only POST requests are allowed in worklfows");
|
package/nextjs.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
serveBase
|
|
3
|
+
} from "./chunk-Z7WS5XIR.mjs";
|
|
4
4
|
|
|
5
5
|
// platforms/nextjs.ts
|
|
6
|
-
var
|
|
7
|
-
const { handler: serveHandler } =
|
|
6
|
+
var serve = (routeFunction, options) => {
|
|
7
|
+
const { handler: serveHandler } = serveBase(
|
|
8
8
|
routeFunction,
|
|
9
9
|
options
|
|
10
10
|
);
|
|
@@ -15,7 +15,7 @@ var serve2 = (routeFunction, options) => {
|
|
|
15
15
|
};
|
|
16
16
|
};
|
|
17
17
|
var servePagesRouter = (routeFunction, options) => {
|
|
18
|
-
const { handler: serveHandler } =
|
|
18
|
+
const { handler: serveHandler } = serveBase(routeFunction, options);
|
|
19
19
|
const handler = async (request_, res) => {
|
|
20
20
|
if (request_.method?.toUpperCase() !== "POST") {
|
|
21
21
|
res.status(405).json("Only POST requests are allowed in worklfows");
|
|
@@ -37,6 +37,6 @@ var servePagesRouter = (routeFunction, options) => {
|
|
|
37
37
|
return { handler };
|
|
38
38
|
};
|
|
39
39
|
export {
|
|
40
|
-
|
|
40
|
+
serve,
|
|
41
41
|
servePagesRouter
|
|
42
42
|
};
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/workflow","version":"v0.2.
|
|
1
|
+
{"name":"@upstash/workflow","version":"v0.2.2","description":"Durable, Reliable and Performant Serverless Functions","main":"./index.js","module":"./index.mjs","types":"./index.d.ts","files":["./*"],"exports":{".":{"import":"./index.mjs","require":"./index.js"},"./dist/nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./nextjs":{"import":"./nextjs.mjs","require":"./nextjs.js"},"./h3":{"import":"./h3.mjs","require":"./h3.js"},"./svelte":{"import":"./svelte.mjs","require":"./svelte.js"},"./solidjs":{"import":"./solidjs.mjs","require":"./solidjs.js"},"./workflow":{"import":"./workflow.mjs","require":"./workflow.js"},"./hono":{"import":"./hono.mjs","require":"./hono.js"},"./cloudflare":{"import":"./cloudflare.mjs","require":"./cloudflare.js"},"./astro":{"import":"./astro.mjs","require":"./astro.js"},"./express":{"import":"./express.mjs","require":"./express.js"}},"scripts":{"build":"tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/","test":"bun test src","fmt":"prettier --write .","lint":"tsc && eslint \"{src,platforms}/**/*.{js,ts,tsx}\" --quiet --fix","check-exports":"bun run build && cd dist && attw -P"},"repository":{"type":"git","url":"git+https://github.com/upstash/workflow-ts.git"},"keywords":["upstash","qstash","workflow","serverless"],"author":"Cahid Arda Oz","license":"MIT","bugs":{"url":"https://github.com/upstash/workflow-ts/issues"},"homepage":"https://github.com/upstash/workflow-ts#readme","devDependencies":{"@commitlint/cli":"^19.5.0","@commitlint/config-conventional":"^19.5.0","@eslint/js":"^9.11.1","@solidjs/start":"^1.0.8","@sveltejs/kit":"^2.6.1","@types/bun":"^1.1.10","@types/express":"^5.0.0","astro":"^4.16.7","eslint":"^9.11.1","eslint-plugin-unicorn":"^55.0.0","express":"^4.21.1","globals":"^15.10.0","h3":"^1.12.0","hono":"^4.6.3","husky":"^9.1.6","next":"^14.2.14","prettier":"3.3.3","tsc":"^2.0.4","tsup":"^8.3.0","typescript":"^5.6.3","typescript-eslint":"^8.8.0"},"dependencies":{"@upstash/qstash":"^2.7.17"},"directories":{"example":"examples"}}
|
package/solidjs.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction,
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-APRap-aV.mjs';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ import '@upstash/qstash';
|
|
|
11
11
|
* @param options workflow options
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?:
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
15
15
|
POST: (event: APIEvent) => Promise<Response>;
|
|
16
16
|
};
|
|
17
17
|
|
package/solidjs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIEvent } from '@solidjs/start/server';
|
|
2
|
-
import { R as RouteFunction,
|
|
2
|
+
import { R as RouteFunction, j as PublicServeOptions } from './types-APRap-aV.js';
|
|
3
3
|
import '@upstash/qstash';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -11,7 +11,7 @@ import '@upstash/qstash';
|
|
|
11
11
|
* @param options workflow options
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
|
-
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?:
|
|
14
|
+
declare const serve: <TInitialPayload = unknown>(routeFunction: RouteFunction<TInitialPayload>, options?: PublicServeOptions<TInitialPayload>) => {
|
|
15
15
|
POST: (event: APIEvent) => Promise<Response>;
|
|
16
16
|
};
|
|
17
17
|
|