@ai0x0/utils 0.0.10 → 0.0.12

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,3 +1,4 @@
1
+ import { TypedNextResponse } from "next-rest-framework";
1
2
  import { BaseTable } from "../types";
2
3
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
3
4
  import { NextRequest } from "next/server";
@@ -5,6 +6,7 @@ export interface DeleteOperationOptions<TTable extends BaseTable> {
5
6
  table: TTable;
6
7
  summary?: string;
7
8
  onSuccess?: () => Promise<void>;
9
+ onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
8
10
  byCreator?: boolean;
9
11
  }
10
12
  export declare const createDeleteOperation: ({ db, getSession, }: {
@@ -12,4 +14,4 @@ export declare const createDeleteOperation: ({ db, getSession, }: {
12
14
  getSession: (req: NextRequest) => Promise<{
13
15
  userId?: string;
14
16
  } | undefined>;
15
- }) => <TTable extends BaseTable>({ table, summary, onSuccess, byCreator, }: DeleteOperationOptions<TTable>) => any;
17
+ }) => <TTable extends BaseTable>({ table, summary, onSuccess, onError, byCreator, }: DeleteOperationOptions<TTable>) => any;
@@ -13,6 +13,7 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
13
13
  var table = _ref2.table,
14
14
  summary = _ref2.summary,
15
15
  onSuccess = _ref2.onSuccess,
16
+ onError = _ref2.onError,
16
17
  _ref2$byCreator = _ref2.byCreator,
17
18
  byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
18
19
  return routeOperation({
@@ -28,50 +29,65 @@ export var createDeleteOperation = function createDeleteOperation(_ref) {
28
29
  contentType: "application/json"
29
30
  }).handler( /*#__PURE__*/function () {
30
31
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
31
- var body, _ref4, userId, data;
32
+ var body, _ref4, userId, data, response;
32
33
  return _regeneratorRuntime().wrap(function _callee$(_context) {
33
34
  while (1) switch (_context.prev = _context.next) {
34
35
  case 0:
35
- _context.next = 2;
36
+ _context.prev = 0;
37
+ _context.next = 3;
36
38
  return req.json();
37
- case 2:
39
+ case 3:
38
40
  body = _context.sent;
39
41
  if (!byCreator) {
40
- _context.next = 12;
42
+ _context.next = 13;
41
43
  break;
42
44
  }
43
- _context.next = 6;
45
+ _context.next = 7;
44
46
  return getSession(req);
45
- case 6:
47
+ case 7:
46
48
  _context.t0 = _context.sent;
47
49
  if (_context.t0) {
48
- _context.next = 9;
50
+ _context.next = 10;
49
51
  break;
50
52
  }
51
53
  _context.t0 = {};
52
- case 9:
54
+ case 10:
53
55
  _ref4 = _context.t0;
54
56
  userId = _ref4.userId;
55
57
  body.creatorId = userId;
56
- case 12:
57
- _context.next = 14;
58
+ case 13:
59
+ _context.next = 15;
58
60
  return createDeleteAction({
59
61
  table: table,
60
62
  db: db
61
63
  })(body);
62
- case 14:
64
+ case 15:
63
65
  data = _context.sent;
64
- _context.next = 17;
66
+ _context.next = 18;
65
67
  return onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
66
- case 17:
68
+ case 18:
67
69
  return _context.abrupt("return", TypedNextResponse.json(data, {
68
70
  status: 200
69
71
  }));
70
- case 18:
72
+ case 21:
73
+ _context.prev = 21;
74
+ _context.t1 = _context["catch"](0);
75
+ _context.next = 25;
76
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t1);
77
+ case 25:
78
+ response = _context.sent;
79
+ if (!response) {
80
+ _context.next = 30;
81
+ break;
82
+ }
83
+ return _context.abrupt("return", response);
84
+ case 30:
85
+ throw _context.t1;
86
+ case 31:
71
87
  case "end":
72
88
  return _context.stop();
73
89
  }
74
- }, _callee);
90
+ }, _callee, null, [[0, 21]]);
75
91
  }));
76
92
  return function (_x) {
77
93
  return _ref3.apply(this, arguments);
@@ -1,5 +1,6 @@
1
1
  import { z, ZodSchema } from "zod";
2
2
  import { NextRequest } from "next/server";
3
+ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
3
4
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
5
  import { BaseTable, GetListRelations } from "../types";
5
6
  export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
@@ -7,7 +8,7 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
7
8
  jsonArrayFields?: string[];
8
9
  querySchema: Q;
9
10
  relations?: GetListRelations;
10
- setParams?: (req: NextRequest) => Promise<Record<string, unknown>>;
11
+ setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, unknown>>;
11
12
  byCreator?: boolean;
12
13
  summary?: string;
13
14
  table: TTable;
@@ -18,10 +19,11 @@ export interface GetListOperationOptions<T extends ZodSchema, Q extends ZodSchem
18
19
  data: z.infer<T>[];
19
20
  total: number;
20
21
  }>;
22
+ onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
21
23
  }
22
24
  export declare const createGetListOperation: ({ db, getSession, }: {
23
25
  db: NodePgDatabase<any>;
24
26
  getSession: (req: NextRequest) => Promise<{
25
27
  userId?: string;
26
28
  } | undefined>;
27
- }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, jsonArrayFields, setParams, onSuccess, byCreator, }: GetListOperationOptions<T, Q, TTable>) => any;
29
+ }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, jsonArrayFields, setParams, onSuccess, onError, byCreator, }: GetListOperationOptions<T, Q, TTable>) => any;
@@ -18,6 +18,7 @@ export var createGetListOperation = function createGetListOperation(_ref) {
18
18
  jsonArrayFields = _ref2.jsonArrayFields,
19
19
  setParams = _ref2.setParams,
20
20
  onSuccess = _ref2.onSuccess,
21
+ onError = _ref2.onError,
21
22
  _ref2$byCreator = _ref2.byCreator,
22
23
  byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
23
24
  return routeOperation({
@@ -34,40 +35,41 @@ export var createGetListOperation = function createGetListOperation(_ref) {
34
35
  status: 200
35
36
  }]).handler( /*#__PURE__*/function () {
36
37
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
37
- var params, _ref4, userId, result;
38
+ var params, _ref4, userId, result, response;
38
39
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
40
  while (1) switch (_context.prev = _context.next) {
40
41
  case 0:
41
- _context.next = 2;
42
+ _context.prev = 0;
43
+ _context.next = 3;
42
44
  return setParams === null || setParams === void 0 ? void 0 : setParams(req);
43
- case 2:
45
+ case 3:
44
46
  _context.t0 = _context.sent;
45
47
  if (_context.t0) {
46
- _context.next = 5;
48
+ _context.next = 6;
47
49
  break;
48
50
  }
49
51
  _context.t0 = {};
50
- case 5:
52
+ case 6:
51
53
  params = _context.t0;
52
54
  if (!byCreator) {
53
- _context.next = 15;
55
+ _context.next = 16;
54
56
  break;
55
57
  }
56
- _context.next = 9;
58
+ _context.next = 10;
57
59
  return getSession(req);
58
- case 9:
60
+ case 10:
59
61
  _context.t1 = _context.sent;
60
62
  if (_context.t1) {
61
- _context.next = 12;
63
+ _context.next = 13;
62
64
  break;
63
65
  }
64
66
  _context.t1 = {};
65
- case 12:
67
+ case 13:
66
68
  _ref4 = _context.t1;
67
69
  userId = _ref4.userId;
68
70
  params.creatorId = userId;
69
- case 15:
70
- _context.next = 17;
71
+ case 16:
72
+ _context.next = 18;
71
73
  return createGetListAction({
72
74
  bodySchema: bodySchema,
73
75
  db: db,
@@ -75,25 +77,39 @@ export var createGetListOperation = function createGetListOperation(_ref) {
75
77
  relations: relations,
76
78
  table: table
77
79
  })(Object.assign(Object.fromEntries(new URL(req.url).searchParams), params));
78
- case 17:
80
+ case 18:
79
81
  result = _context.sent;
80
82
  if (!onSuccess) {
81
- _context.next = 22;
83
+ _context.next = 23;
82
84
  break;
83
85
  }
84
- _context.next = 21;
86
+ _context.next = 22;
85
87
  return onSuccess(result);
86
- case 21:
87
- result = _context.sent;
88
88
  case 22:
89
+ result = _context.sent;
90
+ case 23:
89
91
  return _context.abrupt("return", TypedNextResponse.json(result, {
90
92
  status: 200
91
93
  }));
92
- case 23:
94
+ case 26:
95
+ _context.prev = 26;
96
+ _context.t2 = _context["catch"](0);
97
+ _context.next = 30;
98
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t2);
99
+ case 30:
100
+ response = _context.sent;
101
+ if (!response) {
102
+ _context.next = 35;
103
+ break;
104
+ }
105
+ return _context.abrupt("return", response);
106
+ case 35:
107
+ throw _context.t2;
108
+ case 36:
93
109
  case "end":
94
110
  return _context.stop();
95
111
  }
96
- }, _callee);
112
+ }, _callee, null, [[0, 26]]);
97
113
  }));
98
114
  return function (_x) {
99
115
  return _ref3.apply(this, arguments);
@@ -1,5 +1,6 @@
1
1
  import { z, ZodSchema } from "zod";
2
2
  import { NextRequest } from "next/server";
3
+ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
3
4
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
5
  import { BaseTable, GetListRelations } from "../types";
5
6
  export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, TTable extends BaseTable> {
@@ -7,8 +8,9 @@ export interface GetOperationOptions<T extends ZodSchema, Q extends ZodSchema, T
7
8
  jsonArrayFields?: string[];
8
9
  querySchema: Q;
9
10
  relations?: GetListRelations;
10
- setParams?: (req: NextRequest) => Promise<Record<string, any>>;
11
+ setParams?: (req: TypedNextRequest<"GET", "application/json", unknown, z.infer<Q>>) => Promise<Record<string, any>>;
11
12
  onSuccess?: (data: z.infer<T>) => Promise<z.infer<T>>;
13
+ onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
12
14
  summary?: string;
13
15
  table: TTable;
14
16
  byCreator?: boolean;
@@ -18,4 +20,4 @@ export declare const createGetOperation: ({ getSession, db, }: {
18
20
  getSession: (req: NextRequest) => Promise<{
19
21
  userId?: string;
20
22
  } | undefined>;
21
- }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, setParams, jsonArrayFields, onSuccess, byCreator, }: GetOperationOptions<T, Q, TTable>) => any;
23
+ }) => <T extends z.ZodType<any, z.ZodTypeDef, any>, Q extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ querySchema, bodySchema, table, summary, relations, setParams, jsonArrayFields, onSuccess, onError, byCreator, }: GetOperationOptions<T, Q, TTable>) => any;
@@ -17,6 +17,7 @@ export var createGetOperation = function createGetOperation(_ref) {
17
17
  setParams = _ref2.setParams,
18
18
  jsonArrayFields = _ref2.jsonArrayFields,
19
19
  onSuccess = _ref2.onSuccess,
20
+ onError = _ref2.onError,
20
21
  _ref2$byCreator = _ref2.byCreator,
21
22
  byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
22
23
  return routeOperation({
@@ -33,40 +34,41 @@ export var createGetOperation = function createGetOperation(_ref) {
33
34
  status: 200
34
35
  }]).handler( /*#__PURE__*/function () {
35
36
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
36
- var params, _ref4, userId, result;
37
+ var params, _ref4, userId, result, response;
37
38
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
39
  while (1) switch (_context.prev = _context.next) {
39
40
  case 0:
40
- _context.next = 2;
41
+ _context.prev = 0;
42
+ _context.next = 3;
41
43
  return setParams === null || setParams === void 0 ? void 0 : setParams(req);
42
- case 2:
44
+ case 3:
43
45
  _context.t0 = _context.sent;
44
46
  if (_context.t0) {
45
- _context.next = 5;
47
+ _context.next = 6;
46
48
  break;
47
49
  }
48
50
  _context.t0 = {};
49
- case 5:
51
+ case 6:
50
52
  params = _context.t0;
51
53
  if (!byCreator) {
52
- _context.next = 15;
54
+ _context.next = 16;
53
55
  break;
54
56
  }
55
- _context.next = 9;
57
+ _context.next = 10;
56
58
  return getSession(req);
57
- case 9:
59
+ case 10:
58
60
  _context.t1 = _context.sent;
59
61
  if (_context.t1) {
60
- _context.next = 12;
62
+ _context.next = 13;
61
63
  break;
62
64
  }
63
65
  _context.t1 = {};
64
- case 12:
66
+ case 13:
65
67
  _ref4 = _context.t1;
66
68
  userId = _ref4.userId;
67
69
  params.creatorId = userId;
68
- case 15:
69
- _context.next = 17;
70
+ case 16:
71
+ _context.next = 18;
70
72
  return createGetAction({
71
73
  bodySchema: bodySchema,
72
74
  db: db,
@@ -74,32 +76,46 @@ export var createGetOperation = function createGetOperation(_ref) {
74
76
  relations: relations,
75
77
  table: table
76
78
  })(Object.assign(Object.fromEntries(new URL(req.url).searchParams), params));
77
- case 17:
79
+ case 18:
78
80
  _context.t2 = _context.sent;
79
81
  if (_context.t2) {
80
- _context.next = 20;
82
+ _context.next = 21;
81
83
  break;
82
84
  }
83
85
  _context.t2 = {};
84
- case 20:
86
+ case 21:
85
87
  result = _context.t2;
86
88
  if (!onSuccess) {
87
- _context.next = 25;
89
+ _context.next = 26;
88
90
  break;
89
91
  }
90
- _context.next = 24;
92
+ _context.next = 25;
91
93
  return onSuccess(result);
92
- case 24:
93
- result = _context.sent;
94
94
  case 25:
95
+ result = _context.sent;
96
+ case 26:
95
97
  return _context.abrupt("return", TypedNextResponse.json(result, {
96
98
  status: 200
97
99
  }));
98
- case 26:
100
+ case 29:
101
+ _context.prev = 29;
102
+ _context.t3 = _context["catch"](0);
103
+ _context.next = 33;
104
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t3);
105
+ case 33:
106
+ response = _context.sent;
107
+ if (!response) {
108
+ _context.next = 38;
109
+ break;
110
+ }
111
+ return _context.abrupt("return", response);
112
+ case 38:
113
+ throw _context.t3;
114
+ case 39:
99
115
  case "end":
100
116
  return _context.stop();
101
117
  }
102
- }, _callee);
118
+ }, _callee, null, [[0, 29]]);
103
119
  }));
104
120
  return function (_x) {
105
121
  return _ref3.apply(this, arguments);
@@ -1,12 +1,12 @@
1
1
  import { z, ZodSchema } from "zod";
2
2
  import { PgTable } from "drizzle-orm/pg-core";
3
3
  import { NextRequest } from "next/server";
4
- import { TypedNextResponse } from "next-rest-framework";
4
+ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
5
5
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
6
6
  export interface PostOperationOptions<IB extends ZodSchema, OB extends ZodSchema, TTable extends PgTable> {
7
7
  bodySchema: IB;
8
8
  outputBodySchema?: IB;
9
- setBody?: (req: NextRequest) => Promise<Partial<z.infer<IB>>>;
9
+ setBody?: (req: TypedNextRequest<"POST", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
10
10
  summary?: string;
11
11
  onSuccess?: (data: z.infer<OB>) => Promise<z.infer<OB>>;
12
12
  onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
@@ -84,9 +84,9 @@ export var createPostOperation = function createPostOperation(_ref) {
84
84
  bodySchema: bodySchema,
85
85
  db: db,
86
86
  table: table
87
- })(_objectSpread(_objectSpread({}, body), {}, {
87
+ })(_objectSpread({
88
88
  creatorId: userId
89
- }));
89
+ }, body));
90
90
  case 21:
91
91
  _yield$createPostActi = _context.sent;
92
92
  _yield$createPostActi2 = _slicedToArray(_yield$createPostActi, 1);
@@ -1,5 +1,6 @@
1
1
  import { z, ZodSchema } from "zod";
2
2
  import { PgTable } from "drizzle-orm/pg-core";
3
+ import { TypedNextRequest, TypedNextResponse } from "next-rest-framework";
3
4
  import { NodePgDatabase } from "drizzle-orm/node-postgres";
4
5
  import { NextRequest } from "next/server";
5
6
  import { BaseTable } from "../types";
@@ -8,8 +9,9 @@ export interface PutOperationOptions<IB extends ZodSchema, OB extends ZodSchema,
8
9
  outputBodySchema?: OB;
9
10
  table: TTable;
10
11
  summary?: string;
11
- setBody?: (req: NextRequest) => Promise<Partial<z.infer<IB>>>;
12
+ setBody?: (req: TypedNextRequest<"PUT", "application/json", z.infer<IB>>) => Promise<Partial<z.infer<IB>>>;
12
13
  onSuccess?: (data: z.infer<OB>) => Promise<z.infer<OB>>;
14
+ onError?: (error: Error) => Promise<ReturnType<(typeof TypedNextResponse)["json"]> | undefined>;
13
15
  byCreator?: boolean;
14
16
  }
15
17
  export declare const createPutOperation: ({ getSession, db, }: {
@@ -17,4 +19,4 @@ export declare const createPutOperation: ({ getSession, db, }: {
17
19
  userId?: string;
18
20
  } | undefined>;
19
21
  db: NodePgDatabase<any>;
20
- }) => <IB extends z.ZodType<any, z.ZodTypeDef, any>, OB extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ bodySchema, outputBodySchema, table, summary, setBody, onSuccess, byCreator, }: PutOperationOptions<IB, OB, TTable>) => any;
22
+ }) => <IB extends z.ZodType<any, z.ZodTypeDef, any>, OB extends z.ZodType<any, z.ZodTypeDef, any>, TTable extends BaseTable>({ bodySchema, outputBodySchema, table, summary, setBody, onSuccess, byCreator, onError, }: PutOperationOptions<IB, OB, TTable>) => any;
@@ -22,7 +22,8 @@ export var createPutOperation = function createPutOperation(_ref) {
22
22
  setBody = _ref2.setBody,
23
23
  onSuccess = _ref2.onSuccess,
24
24
  _ref2$byCreator = _ref2.byCreator,
25
- byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator;
25
+ byCreator = _ref2$byCreator === void 0 ? true : _ref2$byCreator,
26
+ onError = _ref2.onError;
26
27
  return routeOperation({
27
28
  method: "PUT",
28
29
  openApiOperation: {
@@ -38,68 +39,83 @@ export var createPutOperation = function createPutOperation(_ref) {
38
39
  contentType: "application/json"
39
40
  }]).handler( /*#__PURE__*/function () {
40
41
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(req) {
41
- var _ref4, userId, body, data;
42
+ var _ref4, userId, body, _data, response;
42
43
  return _regeneratorRuntime().wrap(function _callee$(_context) {
43
44
  while (1) switch (_context.prev = _context.next) {
44
45
  case 0:
45
- _context.next = 2;
46
+ _context.prev = 0;
47
+ _context.next = 3;
46
48
  return getSession(req);
47
- case 2:
49
+ case 3:
48
50
  _context.t0 = _context.sent;
49
51
  if (_context.t0) {
50
- _context.next = 5;
52
+ _context.next = 6;
51
53
  break;
52
54
  }
53
55
  _context.t0 = {};
54
- case 5:
56
+ case 6:
55
57
  _ref4 = _context.t0;
56
58
  userId = _ref4.userId;
57
59
  _context.t1 = Object;
58
- _context.next = 10;
60
+ _context.next = 11;
59
61
  return req.json();
60
- case 10:
62
+ case 11:
61
63
  _context.t2 = _context.sent;
62
- _context.next = 13;
64
+ _context.next = 14;
63
65
  return setBody === null || setBody === void 0 ? void 0 : setBody(req);
64
- case 13:
66
+ case 14:
65
67
  _context.t3 = _context.sent;
66
68
  if (_context.t3) {
67
- _context.next = 16;
69
+ _context.next = 17;
68
70
  break;
69
71
  }
70
72
  _context.t3 = {};
71
- case 16:
73
+ case 17:
72
74
  _context.t4 = _context.t3;
73
75
  body = _context.t1.assign.call(_context.t1, _context.t2, _context.t4);
74
- _context.next = 20;
76
+ _context.next = 21;
75
77
  return createPutAction({
76
78
  bodySchema: bodySchema,
77
79
  table: table,
78
80
  db: db
79
- })(_objectSpread(_objectSpread({}, body), {}, {
81
+ })(_objectSpread({
80
82
  editorId: userId
81
- }), {
83
+ }, body), {
82
84
  byCreator: byCreator
83
85
  });
84
- case 20:
85
- data = _context.sent;
86
+ case 21:
87
+ _data = _context.sent;
86
88
  if (!onSuccess) {
87
- _context.next = 25;
89
+ _context.next = 26;
88
90
  break;
89
91
  }
90
- _context.next = 24;
91
- return onSuccess(data);
92
- case 24:
93
- data = _context.sent;
92
+ _context.next = 25;
93
+ return onSuccess(_data);
94
94
  case 25:
95
- return _context.abrupt("return", TypedNextResponse.json(data, {
95
+ _data = _context.sent;
96
+ case 26:
97
+ return _context.abrupt("return", TypedNextResponse.json(_data, {
96
98
  status: 200
97
99
  }));
98
- case 26:
100
+ case 29:
101
+ _context.prev = 29;
102
+ _context.t5 = _context["catch"](0);
103
+ _context.next = 33;
104
+ return onError === null || onError === void 0 ? void 0 : onError(_context.t5);
105
+ case 33:
106
+ response = _context.sent;
107
+ if (!response) {
108
+ _context.next = 38;
109
+ break;
110
+ }
111
+ return _context.abrupt("return", response);
112
+ case 38:
113
+ throw _context.t5;
114
+ case 39:
99
115
  case "end":
100
116
  return _context.stop();
101
117
  }
102
- }, _callee);
118
+ }, _callee, null, [[0, 29]]);
103
119
  }));
104
120
  return function (_x) {
105
121
  return _ref3.apply(this, arguments);