@upstash/qstash 2.7.11-canary-3 → 2.7.11
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/{chunk-E4S2C5HM.mjs → chunk-IYU467WN.mjs} +1 -1
- package/{chunk-KGI26PDH.mjs → chunk-Q6E5NF42.mjs} +36 -390
- package/{client-DkrYCqaq.d.mts → client-DEZq0-qk.d.mts} +18 -27
- package/{client-DkrYCqaq.d.ts → client-DEZq0-qk.d.ts} +18 -27
- package/cloudflare.d.mts +2 -2
- package/cloudflare.d.ts +2 -2
- package/cloudflare.js +32 -394
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +48 -410
- package/h3.mjs +2 -2
- package/hono.d.mts +2 -2
- package/hono.d.ts +2 -2
- package/hono.js +32 -394
- package/hono.mjs +1 -1
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +26 -378
- package/index.mjs +1 -1
- package/nextjs.d.mts +2 -2
- package/nextjs.d.ts +2 -2
- package/nextjs.js +32 -394
- package/nextjs.mjs +1 -1
- package/nuxt.js +24 -387
- package/nuxt.mjs +2 -2
- package/package.json +1 -1
- package/solidjs.d.mts +2 -2
- package/solidjs.d.ts +2 -2
- package/solidjs.js +32 -394
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +2 -2
- package/svelte.d.ts +2 -2
- package/svelte.js +32 -394
- package/svelte.mjs +1 -1
- package/workflow.d.mts +1 -1
- package/workflow.d.ts +1 -1
- package/workflow.js +32 -394
- package/workflow.mjs +1 -1
package/hono.js
CHANGED
|
@@ -205,7 +205,7 @@ var QStashWorkflowAbort = class extends Error {
|
|
|
205
205
|
stepName;
|
|
206
206
|
constructor(stepName, stepInfo) {
|
|
207
207
|
super(
|
|
208
|
-
`This is an
|
|
208
|
+
`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}'.`
|
|
209
209
|
);
|
|
210
210
|
this.name = "QStashWorkflowAbort";
|
|
211
211
|
this.stepName = stepName;
|
|
@@ -461,7 +461,7 @@ var Chat = class _Chat {
|
|
|
461
461
|
*/
|
|
462
462
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
463
463
|
createThirdParty = async (request) => {
|
|
464
|
-
const { baseUrl, token, owner } = request.provider;
|
|
464
|
+
const { baseUrl, token, owner, organization } = request.provider;
|
|
465
465
|
if (owner === "upstash")
|
|
466
466
|
throw new Error("Upstash is not 3rd party provider!");
|
|
467
467
|
delete request.provider;
|
|
@@ -475,6 +475,9 @@ var Chat = class _Chat {
|
|
|
475
475
|
const headers = {
|
|
476
476
|
"Content-Type": "application/json",
|
|
477
477
|
Authorization: `Bearer ${token}`,
|
|
478
|
+
...organization ? {
|
|
479
|
+
"OpenAI-Organization": organization
|
|
480
|
+
} : {},
|
|
478
481
|
...isStream ? {
|
|
479
482
|
Connection: "keep-alive",
|
|
480
483
|
Accept: "text/event-stream",
|
|
@@ -690,7 +693,7 @@ function decodeBase64(base64) {
|
|
|
690
693
|
return new TextDecoder().decode(intArray);
|
|
691
694
|
} catch (error) {
|
|
692
695
|
console.warn(
|
|
693
|
-
`Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead.
|
|
696
|
+
`Upstash Qstash: Failed while decoding base64 "${base64}". Decoding with atob and returning it instead. ${error}`
|
|
694
697
|
);
|
|
695
698
|
return atob(base64);
|
|
696
699
|
}
|
|
@@ -1197,377 +1200,11 @@ var DEFAULT_CONTENT_TYPE = "application/json";
|
|
|
1197
1200
|
var NO_CONCURRENCY = 1;
|
|
1198
1201
|
var DEFAULT_RETRIES = 3;
|
|
1199
1202
|
|
|
1200
|
-
//
|
|
1201
|
-
var
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
var
|
|
1205
|
-
const data = result.isOk() ? { type: "Ok", value: result.value } : { type: "Err", value: result.error };
|
|
1206
|
-
const maybeStack = config.withStackTrace ? new Error().stack : void 0;
|
|
1207
|
-
return {
|
|
1208
|
-
data,
|
|
1209
|
-
message,
|
|
1210
|
-
stack: maybeStack
|
|
1211
|
-
};
|
|
1212
|
-
};
|
|
1213
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1214
|
-
function adopt(value) {
|
|
1215
|
-
return value instanceof P ? value : new P(function(resolve) {
|
|
1216
|
-
resolve(value);
|
|
1217
|
-
});
|
|
1218
|
-
}
|
|
1219
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
1220
|
-
function fulfilled(value) {
|
|
1221
|
-
try {
|
|
1222
|
-
step(generator.next(value));
|
|
1223
|
-
} catch (e) {
|
|
1224
|
-
reject(e);
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
function rejected(value) {
|
|
1228
|
-
try {
|
|
1229
|
-
step(generator["throw"](value));
|
|
1230
|
-
} catch (e) {
|
|
1231
|
-
reject(e);
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
function step(result) {
|
|
1235
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1236
|
-
}
|
|
1237
|
-
step((generator = generator.apply(thisArg, [])).next());
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
function __values(o) {
|
|
1241
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
1242
|
-
if (m)
|
|
1243
|
-
return m.call(o);
|
|
1244
|
-
if (o && typeof o.length === "number")
|
|
1245
|
-
return {
|
|
1246
|
-
next: function() {
|
|
1247
|
-
if (o && i >= o.length)
|
|
1248
|
-
o = void 0;
|
|
1249
|
-
return { value: o && o[i++], done: !o };
|
|
1250
|
-
}
|
|
1251
|
-
};
|
|
1252
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
1253
|
-
}
|
|
1254
|
-
function __await(v) {
|
|
1255
|
-
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
1256
|
-
}
|
|
1257
|
-
function __asyncGenerator(thisArg, _arguments, generator) {
|
|
1258
|
-
if (!Symbol.asyncIterator)
|
|
1259
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1260
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
1261
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
1262
|
-
return this;
|
|
1263
|
-
}, i;
|
|
1264
|
-
function verb(n) {
|
|
1265
|
-
if (g[n])
|
|
1266
|
-
i[n] = function(v) {
|
|
1267
|
-
return new Promise(function(a, b) {
|
|
1268
|
-
q.push([n, v, a, b]) > 1 || resume(n, v);
|
|
1269
|
-
});
|
|
1270
|
-
};
|
|
1271
|
-
}
|
|
1272
|
-
function resume(n, v) {
|
|
1273
|
-
try {
|
|
1274
|
-
step(g[n](v));
|
|
1275
|
-
} catch (e) {
|
|
1276
|
-
settle(q[0][3], e);
|
|
1277
|
-
}
|
|
1278
|
-
}
|
|
1279
|
-
function step(r) {
|
|
1280
|
-
r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
|
|
1281
|
-
}
|
|
1282
|
-
function fulfill(value) {
|
|
1283
|
-
resume("next", value);
|
|
1284
|
-
}
|
|
1285
|
-
function reject(value) {
|
|
1286
|
-
resume("throw", value);
|
|
1287
|
-
}
|
|
1288
|
-
function settle(f, v) {
|
|
1289
|
-
if (f(v), q.shift(), q.length)
|
|
1290
|
-
resume(q[0][0], q[0][1]);
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
function __asyncDelegator(o) {
|
|
1294
|
-
var i, p;
|
|
1295
|
-
return i = {}, verb("next"), verb("throw", function(e) {
|
|
1296
|
-
throw e;
|
|
1297
|
-
}), verb("return"), i[Symbol.iterator] = function() {
|
|
1298
|
-
return this;
|
|
1299
|
-
}, i;
|
|
1300
|
-
function verb(n, f) {
|
|
1301
|
-
i[n] = o[n] ? function(v) {
|
|
1302
|
-
return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v;
|
|
1303
|
-
} : f;
|
|
1304
|
-
}
|
|
1305
|
-
}
|
|
1306
|
-
function __asyncValues(o) {
|
|
1307
|
-
if (!Symbol.asyncIterator)
|
|
1308
|
-
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1309
|
-
var m = o[Symbol.asyncIterator], i;
|
|
1310
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
|
|
1311
|
-
return this;
|
|
1312
|
-
}, i);
|
|
1313
|
-
function verb(n) {
|
|
1314
|
-
i[n] = o[n] && function(v) {
|
|
1315
|
-
return new Promise(function(resolve, reject) {
|
|
1316
|
-
v = o[n](v), settle(resolve, reject, v.done, v.value);
|
|
1317
|
-
});
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
function settle(resolve, reject, d, v) {
|
|
1321
|
-
Promise.resolve(v).then(function(v2) {
|
|
1322
|
-
resolve({ value: v2, done: d });
|
|
1323
|
-
}, reject);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
var ResultAsync = class _ResultAsync {
|
|
1327
|
-
constructor(res) {
|
|
1328
|
-
this._promise = res;
|
|
1329
|
-
}
|
|
1330
|
-
static fromSafePromise(promise) {
|
|
1331
|
-
const newPromise = promise.then((value) => new Ok(value));
|
|
1332
|
-
return new _ResultAsync(newPromise);
|
|
1333
|
-
}
|
|
1334
|
-
static fromPromise(promise, errorFn) {
|
|
1335
|
-
const newPromise = promise.then((value) => new Ok(value)).catch((e) => new Err(errorFn(e)));
|
|
1336
|
-
return new _ResultAsync(newPromise);
|
|
1337
|
-
}
|
|
1338
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1339
|
-
static fromThrowable(fn, errorFn) {
|
|
1340
|
-
return (...args) => {
|
|
1341
|
-
return new _ResultAsync((() => __awaiter(this, void 0, void 0, function* () {
|
|
1342
|
-
try {
|
|
1343
|
-
return new Ok(yield fn(...args));
|
|
1344
|
-
} catch (error) {
|
|
1345
|
-
return new Err(errorFn ? errorFn(error) : error);
|
|
1346
|
-
}
|
|
1347
|
-
}))());
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
static combine(asyncResultList) {
|
|
1351
|
-
return combineResultAsyncList(asyncResultList);
|
|
1352
|
-
}
|
|
1353
|
-
static combineWithAllErrors(asyncResultList) {
|
|
1354
|
-
return combineResultAsyncListWithAllErrors(asyncResultList);
|
|
1355
|
-
}
|
|
1356
|
-
map(f) {
|
|
1357
|
-
return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
1358
|
-
if (res.isErr()) {
|
|
1359
|
-
return new Err(res.error);
|
|
1360
|
-
}
|
|
1361
|
-
return new Ok(yield f(res.value));
|
|
1362
|
-
})));
|
|
1363
|
-
}
|
|
1364
|
-
mapErr(f) {
|
|
1365
|
-
return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
1366
|
-
if (res.isOk()) {
|
|
1367
|
-
return new Ok(res.value);
|
|
1368
|
-
}
|
|
1369
|
-
return new Err(yield f(res.error));
|
|
1370
|
-
})));
|
|
1371
|
-
}
|
|
1372
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1373
|
-
andThen(f) {
|
|
1374
|
-
return new _ResultAsync(this._promise.then((res) => {
|
|
1375
|
-
if (res.isErr()) {
|
|
1376
|
-
return new Err(res.error);
|
|
1377
|
-
}
|
|
1378
|
-
const newValue = f(res.value);
|
|
1379
|
-
return newValue instanceof _ResultAsync ? newValue._promise : newValue;
|
|
1380
|
-
}));
|
|
1381
|
-
}
|
|
1382
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1383
|
-
orElse(f) {
|
|
1384
|
-
return new _ResultAsync(this._promise.then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
1385
|
-
if (res.isErr()) {
|
|
1386
|
-
return f(res.error);
|
|
1387
|
-
}
|
|
1388
|
-
return new Ok(res.value);
|
|
1389
|
-
})));
|
|
1390
|
-
}
|
|
1391
|
-
match(ok2, _err) {
|
|
1392
|
-
return this._promise.then((res) => res.match(ok2, _err));
|
|
1393
|
-
}
|
|
1394
|
-
unwrapOr(t) {
|
|
1395
|
-
return this._promise.then((res) => res.unwrapOr(t));
|
|
1396
|
-
}
|
|
1397
|
-
/**
|
|
1398
|
-
* Emulates Rust's `?` operator in `safeTry`'s body. See also `safeTry`.
|
|
1399
|
-
*/
|
|
1400
|
-
safeUnwrap() {
|
|
1401
|
-
return __asyncGenerator(this, arguments, function* safeUnwrap_1() {
|
|
1402
|
-
return yield __await(yield __await(yield* __asyncDelegator(__asyncValues(yield __await(this._promise.then((res) => res.safeUnwrap()))))));
|
|
1403
|
-
});
|
|
1404
|
-
}
|
|
1405
|
-
// Makes ResultAsync implement PromiseLike<Result>
|
|
1406
|
-
then(successCallback, failureCallback) {
|
|
1407
|
-
return this._promise.then(successCallback, failureCallback);
|
|
1408
|
-
}
|
|
1409
|
-
};
|
|
1410
|
-
var errAsync = (err2) => new ResultAsync(Promise.resolve(new Err(err2)));
|
|
1411
|
-
var fromPromise = ResultAsync.fromPromise;
|
|
1412
|
-
var fromSafePromise = ResultAsync.fromSafePromise;
|
|
1413
|
-
var fromAsyncThrowable = ResultAsync.fromThrowable;
|
|
1414
|
-
var combineResultList = (resultList) => {
|
|
1415
|
-
let acc = ok([]);
|
|
1416
|
-
for (const result of resultList) {
|
|
1417
|
-
if (result.isErr()) {
|
|
1418
|
-
acc = err(result.error);
|
|
1419
|
-
break;
|
|
1420
|
-
} else {
|
|
1421
|
-
acc.map((list) => list.push(result.value));
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
return acc;
|
|
1425
|
-
};
|
|
1426
|
-
var combineResultAsyncList = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultList);
|
|
1427
|
-
var combineResultListWithAllErrors = (resultList) => {
|
|
1428
|
-
let acc = ok([]);
|
|
1429
|
-
for (const result of resultList) {
|
|
1430
|
-
if (result.isErr() && acc.isErr()) {
|
|
1431
|
-
acc.error.push(result.error);
|
|
1432
|
-
} else if (result.isErr() && acc.isOk()) {
|
|
1433
|
-
acc = err([result.error]);
|
|
1434
|
-
} else if (result.isOk() && acc.isOk()) {
|
|
1435
|
-
acc.value.push(result.value);
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
return acc;
|
|
1439
|
-
};
|
|
1440
|
-
var combineResultAsyncListWithAllErrors = (asyncResultList) => ResultAsync.fromSafePromise(Promise.all(asyncResultList)).andThen(combineResultListWithAllErrors);
|
|
1441
|
-
var Result;
|
|
1442
|
-
(function(Result2) {
|
|
1443
|
-
function fromThrowable2(fn, errorFn) {
|
|
1444
|
-
return (...args) => {
|
|
1445
|
-
try {
|
|
1446
|
-
const result = fn(...args);
|
|
1447
|
-
return ok(result);
|
|
1448
|
-
} catch (e) {
|
|
1449
|
-
return err(errorFn ? errorFn(e) : e);
|
|
1450
|
-
}
|
|
1451
|
-
};
|
|
1452
|
-
}
|
|
1453
|
-
Result2.fromThrowable = fromThrowable2;
|
|
1454
|
-
function combine(resultList) {
|
|
1455
|
-
return combineResultList(resultList);
|
|
1456
|
-
}
|
|
1457
|
-
Result2.combine = combine;
|
|
1458
|
-
function combineWithAllErrors(resultList) {
|
|
1459
|
-
return combineResultListWithAllErrors(resultList);
|
|
1460
|
-
}
|
|
1461
|
-
Result2.combineWithAllErrors = combineWithAllErrors;
|
|
1462
|
-
})(Result || (Result = {}));
|
|
1463
|
-
var ok = (value) => new Ok(value);
|
|
1464
|
-
var err = (err2) => new Err(err2);
|
|
1465
|
-
var Ok = class {
|
|
1466
|
-
constructor(value) {
|
|
1467
|
-
this.value = value;
|
|
1468
|
-
}
|
|
1469
|
-
isOk() {
|
|
1470
|
-
return true;
|
|
1471
|
-
}
|
|
1472
|
-
isErr() {
|
|
1473
|
-
return !this.isOk();
|
|
1474
|
-
}
|
|
1475
|
-
map(f) {
|
|
1476
|
-
return ok(f(this.value));
|
|
1477
|
-
}
|
|
1478
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1479
|
-
mapErr(_f) {
|
|
1480
|
-
return ok(this.value);
|
|
1481
|
-
}
|
|
1482
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1483
|
-
andThen(f) {
|
|
1484
|
-
return f(this.value);
|
|
1485
|
-
}
|
|
1486
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1487
|
-
orElse(_f) {
|
|
1488
|
-
return ok(this.value);
|
|
1489
|
-
}
|
|
1490
|
-
asyncAndThen(f) {
|
|
1491
|
-
return f(this.value);
|
|
1492
|
-
}
|
|
1493
|
-
asyncMap(f) {
|
|
1494
|
-
return ResultAsync.fromSafePromise(f(this.value));
|
|
1495
|
-
}
|
|
1496
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1497
|
-
unwrapOr(_v) {
|
|
1498
|
-
return this.value;
|
|
1499
|
-
}
|
|
1500
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1501
|
-
match(ok2, _err) {
|
|
1502
|
-
return ok2(this.value);
|
|
1503
|
-
}
|
|
1504
|
-
safeUnwrap() {
|
|
1505
|
-
const value = this.value;
|
|
1506
|
-
return function* () {
|
|
1507
|
-
return value;
|
|
1508
|
-
}();
|
|
1509
|
-
}
|
|
1510
|
-
_unsafeUnwrap(_) {
|
|
1511
|
-
return this.value;
|
|
1512
|
-
}
|
|
1513
|
-
_unsafeUnwrapErr(config) {
|
|
1514
|
-
throw createNeverThrowError("Called `_unsafeUnwrapErr` on an Ok", this, config);
|
|
1515
|
-
}
|
|
1516
|
-
};
|
|
1517
|
-
var Err = class {
|
|
1518
|
-
constructor(error) {
|
|
1519
|
-
this.error = error;
|
|
1520
|
-
}
|
|
1521
|
-
isOk() {
|
|
1522
|
-
return false;
|
|
1523
|
-
}
|
|
1524
|
-
isErr() {
|
|
1525
|
-
return !this.isOk();
|
|
1526
|
-
}
|
|
1527
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1528
|
-
map(_f) {
|
|
1529
|
-
return err(this.error);
|
|
1530
|
-
}
|
|
1531
|
-
mapErr(f) {
|
|
1532
|
-
return err(f(this.error));
|
|
1533
|
-
}
|
|
1534
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1535
|
-
andThen(_f) {
|
|
1536
|
-
return err(this.error);
|
|
1537
|
-
}
|
|
1538
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1539
|
-
orElse(f) {
|
|
1540
|
-
return f(this.error);
|
|
1541
|
-
}
|
|
1542
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1543
|
-
asyncAndThen(_f) {
|
|
1544
|
-
return errAsync(this.error);
|
|
1545
|
-
}
|
|
1546
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1547
|
-
asyncMap(_f) {
|
|
1548
|
-
return errAsync(this.error);
|
|
1549
|
-
}
|
|
1550
|
-
unwrapOr(v) {
|
|
1551
|
-
return v;
|
|
1552
|
-
}
|
|
1553
|
-
match(_ok, err2) {
|
|
1554
|
-
return err2(this.error);
|
|
1555
|
-
}
|
|
1556
|
-
safeUnwrap() {
|
|
1557
|
-
const error = this.error;
|
|
1558
|
-
return function* () {
|
|
1559
|
-
yield err(error);
|
|
1560
|
-
throw new Error("Do not use this generator out of `safeTry`");
|
|
1561
|
-
}();
|
|
1562
|
-
}
|
|
1563
|
-
_unsafeUnwrap(config) {
|
|
1564
|
-
throw createNeverThrowError("Called `_unsafeUnwrap` on an Err", this, config);
|
|
1565
|
-
}
|
|
1566
|
-
_unsafeUnwrapErr(_) {
|
|
1567
|
-
return this.error;
|
|
1568
|
-
}
|
|
1569
|
-
};
|
|
1570
|
-
var fromThrowable = Result.fromThrowable;
|
|
1203
|
+
// src/client/workflow/context.ts
|
|
1204
|
+
var import_neverthrow2 = require("neverthrow");
|
|
1205
|
+
|
|
1206
|
+
// src/client/workflow/workflow-requests.ts
|
|
1207
|
+
var import_neverthrow = require("neverthrow");
|
|
1571
1208
|
|
|
1572
1209
|
// src/client/workflow/types.ts
|
|
1573
1210
|
var StepTypes = ["Initial", "Run", "SleepFor", "SleepUntil", "Call"];
|
|
@@ -1595,10 +1232,10 @@ var triggerFirstInvocation = async (workflowContext, retries, debug) => {
|
|
|
1595
1232
|
body: workflowContext.requestPayload,
|
|
1596
1233
|
url: workflowContext.url
|
|
1597
1234
|
});
|
|
1598
|
-
return ok("success");
|
|
1235
|
+
return (0, import_neverthrow.ok)("success");
|
|
1599
1236
|
} catch (error) {
|
|
1600
1237
|
const error_ = error;
|
|
1601
|
-
return err(error_);
|
|
1238
|
+
return (0, import_neverthrow.err)(error_);
|
|
1602
1239
|
}
|
|
1603
1240
|
};
|
|
1604
1241
|
var triggerRouteFunction = async ({
|
|
@@ -1608,10 +1245,10 @@ var triggerRouteFunction = async ({
|
|
|
1608
1245
|
try {
|
|
1609
1246
|
await onStep();
|
|
1610
1247
|
await onCleanup();
|
|
1611
|
-
return ok("workflow-finished");
|
|
1248
|
+
return (0, import_neverthrow.ok)("workflow-finished");
|
|
1612
1249
|
} catch (error) {
|
|
1613
1250
|
const error_ = error;
|
|
1614
|
-
return error_ instanceof QStashWorkflowAbort ? ok("step-finished") : err(error_);
|
|
1251
|
+
return error_ instanceof QStashWorkflowAbort ? (0, import_neverthrow.ok)("step-finished") : (0, import_neverthrow.err)(error_);
|
|
1615
1252
|
}
|
|
1616
1253
|
};
|
|
1617
1254
|
var triggerWorkflowDelete = async (workflowContext, debug, cancel = false) => {
|
|
@@ -1643,13 +1280,13 @@ var handleThirdPartyCallResult = async (request, requestPayload, client, workflo
|
|
|
1643
1280
|
if (!(callbackMessage.status >= 200 && callbackMessage.status < 300)) {
|
|
1644
1281
|
await debug?.log("WARN", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
1645
1282
|
status: callbackMessage.status,
|
|
1646
|
-
body:
|
|
1283
|
+
body: atob(callbackMessage.body)
|
|
1647
1284
|
});
|
|
1648
1285
|
console.warn(
|
|
1649
1286
|
`Workflow Warning: "context.call" failed with status ${callbackMessage.status} and will retry (if there are retries remaining). Error Message:
|
|
1650
|
-
${
|
|
1287
|
+
${atob(callbackMessage.body)}`
|
|
1651
1288
|
);
|
|
1652
|
-
return ok("call-will-retry");
|
|
1289
|
+
return (0, import_neverthrow.ok)("call-will-retry");
|
|
1653
1290
|
}
|
|
1654
1291
|
const workflowRunId = request.headers.get(WORKFLOW_ID_HEADER);
|
|
1655
1292
|
const stepIdString = request.headers.get("Upstash-Workflow-StepId");
|
|
@@ -1683,7 +1320,7 @@ ${decodeBase64(callbackMessage.body)}`
|
|
|
1683
1320
|
stepId: Number(stepIdString),
|
|
1684
1321
|
stepName,
|
|
1685
1322
|
stepType,
|
|
1686
|
-
out:
|
|
1323
|
+
out: atob(callbackMessage.body),
|
|
1687
1324
|
concurrent: Number(concurrentString)
|
|
1688
1325
|
};
|
|
1689
1326
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
@@ -1700,13 +1337,13 @@ ${decodeBase64(callbackMessage.body)}`
|
|
|
1700
1337
|
await debug?.log("SUBMIT", "SUBMIT_THIRD_PARTY_RESULT", {
|
|
1701
1338
|
messageId: result.messageId
|
|
1702
1339
|
});
|
|
1703
|
-
return ok("is-call-return");
|
|
1340
|
+
return (0, import_neverthrow.ok)("is-call-return");
|
|
1704
1341
|
} else {
|
|
1705
|
-
return ok("continue-workflow");
|
|
1342
|
+
return (0, import_neverthrow.ok)("continue-workflow");
|
|
1706
1343
|
}
|
|
1707
1344
|
} catch (error) {
|
|
1708
1345
|
const isCallReturn = request.headers.get("Upstash-Workflow-Callback");
|
|
1709
|
-
return err(
|
|
1346
|
+
return (0, import_neverthrow.err)(
|
|
1710
1347
|
new QStashWorkflowError(
|
|
1711
1348
|
`Error when handling call return (isCallReturn=${isCallReturn}): ${error}`
|
|
1712
1349
|
)
|
|
@@ -2562,11 +2199,11 @@ var DisabledWorkflowContext = class _DisabledWorkflowContext extends WorkflowCon
|
|
|
2562
2199
|
await routeFunction(disabledContext);
|
|
2563
2200
|
} catch (error) {
|
|
2564
2201
|
if (error instanceof QStashWorkflowAbort && error.stepName === this.disabledMessage) {
|
|
2565
|
-
return ok("step-found");
|
|
2202
|
+
return (0, import_neverthrow2.ok)("step-found");
|
|
2566
2203
|
}
|
|
2567
|
-
return err(error);
|
|
2204
|
+
return (0, import_neverthrow2.err)(error);
|
|
2568
2205
|
}
|
|
2569
|
-
return ok("run-ended");
|
|
2206
|
+
return (0, import_neverthrow2.ok)("run-ended");
|
|
2570
2207
|
}
|
|
2571
2208
|
};
|
|
2572
2209
|
|
|
@@ -2619,6 +2256,7 @@ var WorkflowLogger = class _WorkflowLogger {
|
|
|
2619
2256
|
};
|
|
2620
2257
|
|
|
2621
2258
|
// src/client/workflow/workflow-parser.ts
|
|
2259
|
+
var import_neverthrow3 = require("neverthrow");
|
|
2622
2260
|
var getPayload = async (request) => {
|
|
2623
2261
|
try {
|
|
2624
2262
|
return await request.text();
|
|
@@ -2675,7 +2313,7 @@ var checkIfLastOneIsDuplicate = async (steps, debug) => {
|
|
|
2675
2313
|
for (let index = 0; index < steps.length - 1; index++) {
|
|
2676
2314
|
const step = steps[index];
|
|
2677
2315
|
if (step.stepId === lastStepId && step.targetStep === lastTargetStepId) {
|
|
2678
|
-
const message = `
|
|
2316
|
+
const message = `Upstash Workflow: The step '${step.stepName}' with id '${step.stepId}' has run twice during workflow execution. Rest of the workflow will continue running as usual.`;
|
|
2679
2317
|
await debug?.log("WARN", "RESPONSE_DEFAULT", message);
|
|
2680
2318
|
console.warn(message);
|
|
2681
2319
|
return true;
|
|
@@ -2723,10 +2361,10 @@ var parseRequest = async (requestPayload, isFirstInvocation, debug) => {
|
|
|
2723
2361
|
};
|
|
2724
2362
|
var handleFailure = async (request, requestPayload, qstashClient, initialPayloadParser, failureFunction, debug) => {
|
|
2725
2363
|
if (request.headers.get(WORKFLOW_FAILURE_HEADER) !== "true") {
|
|
2726
|
-
return ok("not-failure-callback");
|
|
2364
|
+
return (0, import_neverthrow3.ok)("not-failure-callback");
|
|
2727
2365
|
}
|
|
2728
2366
|
if (!failureFunction) {
|
|
2729
|
-
return err(
|
|
2367
|
+
return (0, import_neverthrow3.err)(
|
|
2730
2368
|
new QStashWorkflowError(
|
|
2731
2369
|
"Workflow endpoint is called to handle a failure, but a failureFunction is not provided in serve options. Either provide a failureUrl or a failureFunction."
|
|
2732
2370
|
)
|
|
@@ -2756,9 +2394,9 @@ var handleFailure = async (request, requestPayload, qstashClient, initialPayload
|
|
|
2756
2394
|
});
|
|
2757
2395
|
await failureFunction(workflowContext, status, errorPayload.message, header);
|
|
2758
2396
|
} catch (error) {
|
|
2759
|
-
return err(error);
|
|
2397
|
+
return (0, import_neverthrow3.err)(error);
|
|
2760
2398
|
}
|
|
2761
|
-
return ok("is-failure-callback");
|
|
2399
|
+
return (0, import_neverthrow3.ok)("is-failure-callback");
|
|
2762
2400
|
};
|
|
2763
2401
|
|
|
2764
2402
|
// src/client/workflow/serve.ts
|
|
@@ -2820,7 +2458,7 @@ var serve = (routeFunction, options) => {
|
|
|
2820
2458
|
}) : initialWorkflowUrl;
|
|
2821
2459
|
if (workflowUrl !== initialWorkflowUrl) {
|
|
2822
2460
|
await debug?.log("WARN", "ENDPOINT_START", {
|
|
2823
|
-
warning: `
|
|
2461
|
+
warning: `Upstash Workflow: replacing the base of the url with "${baseUrl}" and using it as workflow endpoint.`,
|
|
2824
2462
|
originalURL: initialWorkflowUrl,
|
|
2825
2463
|
updatedURL: workflowUrl
|
|
2826
2464
|
});
|
package/hono.mjs
CHANGED
package/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-
|
|
2
|
-
export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-
|
|
1
|
+
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-DEZq0-qk.mjs';
|
|
2
|
+
export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-DEZq0-qk.mjs';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
/**
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-
|
|
2
|
-
export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-
|
|
1
|
+
import { R as RateLimit, C as ChatRateLimit, S as Step, F as FailureFunctionPayload } from './client-DEZq0-qk.js';
|
|
2
|
+
export { A as AddEndpointsRequest, $ as AnalyticsConfig, a0 as AnalyticsSetup, B as BodyInit, y as Chat, D as ChatCompletion, I as ChatCompletionChunk, z as ChatCompletionMessage, T as ChatRequest, f as Client, n as CreateScheduleRequest, p as Endpoint, t as Event, u as EventPayload, E as EventsRequest, v as GetEventsPayload, G as GetEventsResponse, H as HTTPMethods, w as HeadersInit, M as Message, k as MessagePayload, l as Messages, O as OpenAIChatModel, N as PromptChatRequest, _ as ProviderReturnType, P as PublishBatchRequest, e as PublishJsonRequest, d as PublishRequest, j as PublishResponse, g as PublishToApiResponse, i as PublishToUrlGroupsResponse, h as PublishToUrlResponse, Q as QueueRequest, c as Receiver, a as ReceiverConfig, q as RemoveEndpointsRequest, x as RequestOptions, m as Schedule, o as Schedules, b as SignatureError, s as State, K as StreamDisabled, J as StreamEnabled, L as StreamParameter, U as UrlGroup, r as UrlGroups, V as VerifyRequest, W as WithCursor, X as custom, Y as openai, a1 as setupAnalytics, Z as upstash } from './client-DEZq0-qk.js';
|
|
3
3
|
import 'neverthrow';
|
|
4
4
|
|
|
5
5
|
/**
|