supercompat 2.27.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -378,8 +378,8 @@ var __toCommonJS = function(mod) {
378
378
  }), mod);
379
379
  };
380
380
  // src/index.ts
381
- var src_exports = {};
382
- __export(src_exports, {
381
+ var index_exports = {};
382
+ __export(index_exports, {
383
383
  anthropicClientAdapter: function() {
384
384
  return anthropicClientAdapter;
385
385
  },
@@ -420,7 +420,7 @@ __export(src_exports, {
420
420
  return togetherClientAdapter;
421
421
  }
422
422
  });
423
- module.exports = __toCommonJS(src_exports);
423
+ module.exports = __toCommonJS(index_exports);
424
424
  // src/supercompat.ts
425
425
  var import_openai = __toESM(require("openai"), 1);
426
426
  // src/supercompatFetch/requestHandlers.ts
@@ -3935,7 +3935,7 @@ var get10 = function(param) {
3935
3935
  var prisma = param.prisma;
3936
3936
  return /*#__PURE__*/ function() {
3937
3937
  var _ref = _async_to_generator(function(urlString) {
3938
- var _this, url, _url_pathname_match, threadId, _ref, limit, order, after, messages3, _id;
3938
+ var _this, url, _url_pathname_match, threadId, _ref, limit, order, after, pageSize, messagesPlusOne, messages3, _id;
3939
3939
  return _ts_generator(this, function(_state) {
3940
3940
  switch(_state.label){
3941
3941
  case 0:
@@ -3945,25 +3945,27 @@ var get10 = function(param) {
3945
3945
  limit: "20",
3946
3946
  order: "desc"
3947
3947
  }, Object.fromEntries(url.searchParams)), limit = _ref.limit, order = _ref.order, after = _ref.after;
3948
+ pageSize = parseInt(limit);
3948
3949
  return [
3949
3950
  4,
3950
3951
  prisma.message.findMany(_object_spread({
3951
3952
  where: {
3952
3953
  threadId: threadId
3953
3954
  },
3954
- take: parseInt(limit),
3955
+ take: pageSize + 1,
3955
3956
  orderBy: {
3956
3957
  createdAt: order
3957
3958
  }
3958
- }, after ? {
3959
+ }, after && {
3959
3960
  skip: 1,
3960
3961
  cursor: {
3961
3962
  id: after
3962
3963
  }
3963
- } : {}))
3964
+ }))
3964
3965
  ];
3965
3966
  case 1:
3966
- messages3 = _state.sent();
3967
+ messagesPlusOne = _state.sent();
3968
+ messages3 = messagesPlusOne.slice(0, pageSize);
3967
3969
  return [
3968
3970
  2,
3969
3971
  new Response(JSON.stringify({
@@ -3972,9 +3974,7 @@ var get10 = function(param) {
3972
3974
  message: message
3973
3975
  });
3974
3976
  }),
3975
- hasNextPage: function() {
3976
- return messages3.length === parseInt(limit);
3977
- },
3977
+ has_more: messagesPlusOne.length > pageSize,
3978
3978
  last_id: (_id = (_this = (0, import_radash7.last)(messages3)) === null || _this === void 0 ? void 0 : _this.id) !== null && _id !== void 0 ? _id : null
3979
3979
  }), {
3980
3980
  status: 200,
@@ -4047,7 +4047,7 @@ var get11 = function(param) {
4047
4047
  var prisma = param.prisma;
4048
4048
  return /*#__PURE__*/ function() {
4049
4049
  var _ref = _async_to_generator(function(urlString) {
4050
- var _this, url, _url_pathname_match, threadId, _ref, limit, order, after, runs2, _id;
4050
+ var _runs2_at, url, _url_pathname_match, threadId, _ref, limit, order, after, pageSize, runsPlusOne, runs2, _runs2_at_id;
4051
4051
  return _ts_generator(this, function(_state) {
4052
4052
  switch(_state.label){
4053
4053
  case 0:
@@ -4057,25 +4057,27 @@ var get11 = function(param) {
4057
4057
  limit: "20",
4058
4058
  order: "desc"
4059
4059
  }, Object.fromEntries(url.searchParams)), limit = _ref.limit, order = _ref.order, after = _ref.after;
4060
+ pageSize = parseInt(limit, 10);
4060
4061
  return [
4061
4062
  4,
4062
4063
  prisma.run.findMany(_object_spread({
4063
4064
  where: {
4064
4065
  threadId: threadId
4065
4066
  },
4066
- take: parseInt(limit),
4067
+ take: pageSize + 1,
4067
4068
  orderBy: {
4068
4069
  createdAt: order
4069
4070
  }
4070
- }, after ? {
4071
+ }, after && {
4071
4072
  skip: 1,
4072
4073
  cursor: {
4073
4074
  id: after
4074
4075
  }
4075
- } : {}))
4076
+ }))
4076
4077
  ];
4077
4078
  case 1:
4078
- runs2 = _state.sent();
4079
+ runsPlusOne = _state.sent();
4080
+ runs2 = runsPlusOne.slice(0, pageSize);
4079
4081
  return [
4080
4082
  2,
4081
4083
  new Response(JSON.stringify({
@@ -4084,11 +4086,8 @@ var get11 = function(param) {
4084
4086
  run: run2
4085
4087
  });
4086
4088
  }),
4087
- hasNextPage: function() {
4088
- return runs2.length === parseInt(limit);
4089
- },
4090
- // @ts-ignore-next-line
4091
- last_id: (_id = (_this = (0, import_radash8.last)(runs2)) === null || _this === void 0 ? void 0 : _this.id) !== null && _id !== void 0 ? _id : null
4089
+ has_more: runsPlusOne.length > pageSize,
4090
+ last_id: (_runs2_at_id = (_runs2_at = runs2.at(-1)) === null || _runs2_at === void 0 ? void 0 : _runs2_at.id) !== null && _runs2_at_id !== void 0 ? _runs2_at_id : null
4092
4091
  }), {
4093
4092
  status: 200,
4094
4093
  headers: {
@@ -4704,7 +4703,7 @@ var get13 = function(param) {
4704
4703
  var prisma = param.prisma;
4705
4704
  return /*#__PURE__*/ function() {
4706
4705
  var _ref = _async_to_generator(function(urlString) {
4707
- var _this, url, _url_pathname_match, threadId, runId, _ref, limit, order, after, runSteps, _id;
4706
+ var _runSteps_at, url, _url_pathname_match, threadId, runId, _ref, limit, order, after, pageSize, runStepsPlusOne, runSteps, _runSteps_at_id;
4708
4707
  return _ts_generator(this, function(_state) {
4709
4708
  switch(_state.label){
4710
4709
  case 0:
@@ -4714,6 +4713,7 @@ var get13 = function(param) {
4714
4713
  limit: "20",
4715
4714
  order: "desc"
4716
4715
  }, Object.fromEntries(url.searchParams)), limit = _ref.limit, order = _ref.order, after = _ref.after;
4716
+ pageSize = parseInt(limit, 10);
4717
4717
  return [
4718
4718
  4,
4719
4719
  prisma.runStep.findMany(_object_spread({
@@ -4721,19 +4721,20 @@ var get13 = function(param) {
4721
4721
  threadId: threadId,
4722
4722
  runId: runId
4723
4723
  },
4724
- take: parseInt(limit),
4724
+ take: pageSize + 1,
4725
4725
  orderBy: {
4726
4726
  createdAt: order
4727
4727
  }
4728
- }, after ? {
4728
+ }, after && {
4729
4729
  skip: 1,
4730
4730
  cursor: {
4731
4731
  id: after
4732
4732
  }
4733
- } : {}))
4733
+ }))
4734
4734
  ];
4735
4735
  case 1:
4736
- runSteps = _state.sent();
4736
+ runStepsPlusOne = _state.sent();
4737
+ runSteps = runStepsPlusOne.slice(0, pageSize);
4737
4738
  return [
4738
4739
  2,
4739
4740
  new Response(JSON.stringify({
@@ -4742,11 +4743,8 @@ var get13 = function(param) {
4742
4743
  runStep: runStep
4743
4744
  });
4744
4745
  }),
4745
- hasNextPage: function() {
4746
- return runSteps.length === parseInt(limit);
4747
- },
4748
- // @ts-ignore-next-line
4749
- last_id: (_id = (_this = (0, import_radash10.last)(runSteps)) === null || _this === void 0 ? void 0 : _this.id) !== null && _id !== void 0 ? _id : null
4746
+ has_more: runStepsPlusOne.length > pageSize,
4747
+ last_id: (_runSteps_at_id = (_runSteps_at = runSteps.at(-1)) === null || _runSteps_at === void 0 ? void 0 : _runSteps_at.id) !== null && _runSteps_at_id !== void 0 ? _runSteps_at_id : null
4750
4748
  }), {
4751
4749
  status: 200,
4752
4750
  headers: {