@medusajs/medusa 1.1.47-alpha.0 → 1.1.47

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/CHANGELOG.md CHANGED
@@ -3,6 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.47](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.46...@medusajs/medusa@1.1.47) (2021-10-23)
7
+
8
+ ### Bug Fixes
9
+
10
+ - pull missing fields ([b82b43b](https://github.com/medusajs/medusa/commit/b82b43b4c64dc5bc705a439a214f9d1dc9976e21))
11
+
6
12
  ## [1.1.46](https://github.com/medusajs/medusa/compare/@medusajs/medusa@1.1.45...@medusajs/medusa@1.1.46) (2021-10-19)
7
13
 
8
14
  ### Bug Fixes
@@ -59,56 +59,46 @@ var _default = /*#__PURE__*/function () {
59
59
  throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error.details);
60
60
 
61
61
  case 4:
62
- _context.prev = 4;
63
62
  customerService = req.scope.resolve("customerService");
64
- _context.next = 8;
65
- return customerService.retrieveByEmail(value.email);
63
+ _context.next = 7;
64
+ return customerService.retrieveByEmail(value.email, {
65
+ select: ["id", "password_hash"]
66
+ });
66
67
 
67
- case 8:
68
+ case 7:
68
69
  customer = _context.sent;
69
- _context.next = 11;
70
- return _jsonwebtoken["default"].verify(value.token, customer.password_hash);
71
-
72
- case 11:
73
- decodedToken = _context.sent;
70
+ decodedToken = _jsonwebtoken["default"].verify(value.token, customer.password_hash);
74
71
 
75
72
  if (!(!decodedToken || customer.id !== decodedToken.customer_id)) {
76
- _context.next = 15;
73
+ _context.next = 12;
77
74
  break;
78
75
  }
79
76
 
80
77
  res.status(401).send("Invalid or expired password reset token");
81
78
  return _context.abrupt("return");
82
79
 
83
- case 15:
84
- _context.next = 17;
80
+ case 12:
81
+ _context.next = 14;
85
82
  return customerService.update(customer.id, {
86
83
  password: value.password
87
84
  });
88
85
 
89
- case 17:
90
- _context.next = 19;
86
+ case 14:
87
+ _context.next = 16;
91
88
  return customerService.retrieve(customer.id);
92
89
 
93
- case 19:
90
+ case 16:
94
91
  customer = _context.sent;
95
92
  res.status(200).json({
96
93
  customer: customer
97
94
  });
98
- _context.next = 26;
99
- break;
100
-
101
- case 23:
102
- _context.prev = 23;
103
- _context.t0 = _context["catch"](4);
104
- throw _context.t0;
105
95
 
106
- case 26:
96
+ case 18:
107
97
  case "end":
108
98
  return _context.stop();
109
99
  }
110
100
  }
111
- }, _callee, null, [[4, 23]]);
101
+ }, _callee);
112
102
  }));
113
103
 
114
104
  return function (_x, _x2) {
@@ -152,7 +152,9 @@ var CustomerService = /*#__PURE__*/function (_BaseService) {
152
152
  switch (_context.prev = _context.next) {
153
153
  case 0:
154
154
  _context.next = 2;
155
- return this.retrieve(customerId);
155
+ return this.retrieve(customerId, {
156
+ select: ["id", "has_account", "password_hash", "email", "first_name", "last_name"]
157
+ });
156
158
 
157
159
  case 2:
158
160
  customer = _context.sent;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/medusa",
3
- "version": "1.1.47-alpha.0+71e1ee80",
3
+ "version": "1.1.47",
4
4
  "description": "E-commerce for JAMstack",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -87,5 +87,5 @@
87
87
  "uuid": "^8.3.1",
88
88
  "winston": "^3.2.1"
89
89
  },
90
- "gitHead": "71e1ee808b0c30f308821ec9cba298d267134fef"
90
+ "gitHead": "81847456f1b2229d58f0e4e46a7fc079277e4b2b"
91
91
  }
@@ -1,116 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _medusaCoreUtils = require("medusa-core-utils");
15
-
16
- var _ = require("./");
17
-
18
- /**
19
- * @oas [post] /claim-reasons
20
- * operationId: "PostClaimReasons"
21
- * summary: "Create a Claim Reason"
22
- * description: "Creates a Claim Reason"
23
- * requestBody:
24
- * content:
25
- * application/json:
26
- * schema:
27
- * properties:
28
- * label:
29
- * description: "The label to display to the Customer."
30
- * type: string
31
- * value:
32
- * description: "The value that the Claim Reason will be identified by. Must be unique."
33
- * type: string
34
- * description:
35
- * description: "An optional description to for the Reason."
36
- * type: string
37
- * metadata:
38
- * description: An optional set of key-value pairs with additional information.
39
- * type: object
40
- * tags:
41
- * - Claim Reason
42
- * responses:
43
- * 200:
44
- * description: OK
45
- * content:
46
- * application/json:
47
- * schema:
48
- * properties:
49
- * claim_reason:
50
- * $ref: "#/components/schemas/claim_reason"
51
- */
52
- var _default = /*#__PURE__*/function () {
53
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(req, res) {
54
- var schema, _schema$validate, value, error, claimReasonService, result, reason;
55
-
56
- return _regenerator["default"].wrap(function _callee$(_context) {
57
- while (1) {
58
- switch (_context.prev = _context.next) {
59
- case 0:
60
- schema = _medusaCoreUtils.Validator.object().keys({
61
- value: _medusaCoreUtils.Validator.string().required(),
62
- label: _medusaCoreUtils.Validator.string().required(),
63
- parent_claim_reason_id: _medusaCoreUtils.Validator.string().optional(),
64
- description: _medusaCoreUtils.Validator.string().optional().allow(""),
65
- metadata: _medusaCoreUtils.Validator.object().optional()
66
- });
67
- _schema$validate = schema.validate(req.body), value = _schema$validate.value, error = _schema$validate.error;
68
-
69
- if (!error) {
70
- _context.next = 4;
71
- break;
72
- }
73
-
74
- throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error.details);
75
-
76
- case 4:
77
- _context.prev = 4;
78
- claimReasonService = req.scope.resolve("claimReasonService");
79
- _context.next = 8;
80
- return claimReasonService.create(value);
81
-
82
- case 8:
83
- result = _context.sent;
84
- _context.next = 11;
85
- return claimReasonService.retrieve(result.id, {
86
- select: _.defaultFields,
87
- relations: _.defaultRelations
88
- });
89
-
90
- case 11:
91
- reason = _context.sent;
92
- res.status(200).json({
93
- claim_reason: reason
94
- });
95
- _context.next = 18;
96
- break;
97
-
98
- case 15:
99
- _context.prev = 15;
100
- _context.t0 = _context["catch"](4);
101
- throw _context.t0;
102
-
103
- case 18:
104
- case "end":
105
- return _context.stop();
106
- }
107
- }
108
- }, _callee, null, [[4, 15]]);
109
- }));
110
-
111
- return function (_x, _x2) {
112
- return _ref.apply(this, arguments);
113
- };
114
- }();
115
-
116
- exports["default"] = _default;
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- /**
15
- * @oas [delete] /claim-reason/{id}
16
- * operationId: "DeleteClaimReason"
17
- * summary: "Delete a claim reason"
18
- * description: "Deletes a claim reason."
19
- * parameters:
20
- * - (path) id=* {string} The id of the claim reason
21
- * tags:
22
- * - Claim Reason
23
- * responses:
24
- * 200:
25
- * description: OK
26
- * content:
27
- * application/json:
28
- * schema:
29
- * properties:
30
- * id:
31
- * type: string
32
- * description: The id of the deleted claim reason
33
- * object:
34
- * type: string
35
- * description: The type of the object that was deleted.
36
- * deleted:
37
- * type: boolean
38
- */
39
- var _default = /*#__PURE__*/function () {
40
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(req, res) {
41
- var id, claimReasonService;
42
- return _regenerator["default"].wrap(function _callee$(_context) {
43
- while (1) {
44
- switch (_context.prev = _context.next) {
45
- case 0:
46
- id = req.params.id;
47
- _context.prev = 1;
48
- claimReasonService = req.scope.resolve("claimReasonService");
49
- _context.next = 5;
50
- return claimReasonService["delete"](id);
51
-
52
- case 5:
53
- res.json({
54
- id: id,
55
- object: "claim_reason",
56
- deleted: true
57
- });
58
- _context.next = 11;
59
- break;
60
-
61
- case 8:
62
- _context.prev = 8;
63
- _context.t0 = _context["catch"](1);
64
- throw _context.t0;
65
-
66
- case 11:
67
- case "end":
68
- return _context.stop();
69
- }
70
- }
71
- }, _callee, null, [[1, 8]]);
72
- }));
73
-
74
- return function (_x, _x2) {
75
- return _ref.apply(this, arguments);
76
- };
77
- }();
78
-
79
- exports["default"] = _default;
@@ -1,79 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _medusaCoreUtils = require("medusa-core-utils");
15
-
16
- var _ = require("./");
17
-
18
- /**
19
- * @oas [get] /claim-reasons/{id}
20
- * operationId: "GetClaimReasonsReason"
21
- * summary: "Retrieve a Claim Reason"
22
- * description: "Retrieves a Claim Reason."
23
- * parameters:
24
- * - (path) id=* {string} The id of the Claim Reason.
25
- * tags:
26
- * - Claim Reason
27
- * responses:
28
- * 200:
29
- * description: OK
30
- * content:
31
- * application/json:
32
- * schema:
33
- * properties:
34
- * claim_reason:
35
- * $ref: "#/components/schemas/claim_reason"
36
- */
37
- var _default = /*#__PURE__*/function () {
38
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(req, res) {
39
- var id, claimReasonService, data;
40
- return _regenerator["default"].wrap(function _callee$(_context) {
41
- while (1) {
42
- switch (_context.prev = _context.next) {
43
- case 0:
44
- id = req.params.id;
45
- _context.prev = 1;
46
- claimReasonService = req.scope.resolve("claimReasonService");
47
- _context.next = 5;
48
- return claimReasonService.retrieve(id, {
49
- select: _.defaultFields,
50
- relations: _.defaultRelations
51
- });
52
-
53
- case 5:
54
- data = _context.sent;
55
- res.status(200).json({
56
- claim_reason: data
57
- });
58
- _context.next = 12;
59
- break;
60
-
61
- case 9:
62
- _context.prev = 9;
63
- _context.t0 = _context["catch"](1);
64
- throw _context.t0;
65
-
66
- case 12:
67
- case "end":
68
- return _context.stop();
69
- }
70
- }
71
- }, _callee, null, [[1, 9]]);
72
- }));
73
-
74
- return function (_x, _x2) {
75
- return _ref.apply(this, arguments);
76
- };
77
- }();
78
-
79
- exports["default"] = _default;
@@ -1,50 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.defaultRelations = exports.defaultFields = exports["default"] = void 0;
9
-
10
- var _express = require("express");
11
-
12
- var _middlewares = _interopRequireDefault(require("../../../middlewares"));
13
-
14
- var route = (0, _express.Router)();
15
-
16
- var _default = function _default(app) {
17
- app.use("/claim-reasons", route);
18
- /**
19
- * List reasons
20
- */
21
-
22
- route.get("/", _middlewares["default"].wrap(require("./list-reasons")["default"]));
23
- /**
24
- * Retrieve reason
25
- */
26
-
27
- route.get("/:id", _middlewares["default"].wrap(require("./get-reason")["default"]));
28
- /**
29
- * Create a reason
30
- */
31
-
32
- route.post("/", _middlewares["default"].wrap(require("./create-reason")["default"]));
33
- /**
34
- * Update a reason
35
- */
36
-
37
- route.post("/:id", _middlewares["default"].wrap(require("./update-reason")["default"]));
38
- /**
39
- * Delete a reason
40
- */
41
-
42
- route["delete"]("/:id", _middlewares["default"].wrap(require("./delete-reason")["default"]));
43
- return app;
44
- };
45
-
46
- exports["default"] = _default;
47
- var defaultFields = ["id", "value", "label", "parent_claim_reason_id", "description", "created_at", "updated_at", "deleted_at"];
48
- exports.defaultFields = defaultFields;
49
- var defaultRelations = ["parent_claim_reason", "claim_reason_children"];
50
- exports.defaultRelations = defaultRelations;
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _medusaCoreUtils = require("medusa-core-utils");
15
-
16
- var _ = require("./");
17
-
18
- /**
19
- * @oas [get] /claim-reasons
20
- * operationId: "GetClaimReasons"
21
- * summary: "List Claim Reasons"
22
- * description: "Retrieves a list of Claim Reasons."
23
- * tags:
24
- * - Claim Reason
25
- * responses:
26
- * 200:
27
- * description: OK
28
- * content:
29
- * application/json:
30
- * schema:
31
- * properties:
32
- * claim_reasons:
33
- * type: array
34
- * items:
35
- * $ref: "#/components/schemas/claim_reason"
36
- */
37
- var _default = /*#__PURE__*/function () {
38
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(req, res) {
39
- var claimReasonService, query, data;
40
- return _regenerator["default"].wrap(function _callee$(_context) {
41
- while (1) {
42
- switch (_context.prev = _context.next) {
43
- case 0:
44
- _context.prev = 0;
45
- claimReasonService = req.scope.resolve("claimReasonService");
46
- query = {
47
- parent_claim_reason_id: null
48
- };
49
- _context.next = 5;
50
- return claimReasonService.list(query, {
51
- select: _.defaultFields,
52
- relations: _.defaultRelations
53
- });
54
-
55
- case 5:
56
- data = _context.sent;
57
- res.status(200).json({
58
- claim_reasons: data
59
- });
60
- _context.next = 12;
61
- break;
62
-
63
- case 9:
64
- _context.prev = 9;
65
- _context.t0 = _context["catch"](0);
66
- throw _context.t0;
67
-
68
- case 12:
69
- case "end":
70
- return _context.stop();
71
- }
72
- }
73
- }, _callee, null, [[0, 9]]);
74
- }));
75
-
76
- return function (_x, _x2) {
77
- return _ref.apply(this, arguments);
78
- };
79
- }();
80
-
81
- exports["default"] = _default;
@@ -1,117 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _medusaCoreUtils = require("medusa-core-utils");
15
-
16
- var _ = require("./");
17
-
18
- /**
19
- * @oas [post] /claim-reasons/{id}
20
- * operationId: "PostClaimReasonsReason"
21
- * summary: "Update a Claim Reason"
22
- * description: "Updates a Claim Reason"
23
- * parameters:
24
- * - (path) id=* {string} The id of the Claim Reason.
25
- * requestBody:
26
- * content:
27
- * application/json:
28
- * schema:
29
- * properties:
30
- * label:
31
- * description: "The label to display to the Customer."
32
- * type: string
33
- * value:
34
- * description: "The value that the Claim Reason will be identified by. Must be unique."
35
- * type: string
36
- * description:
37
- * description: "An optional description to for the Reason."
38
- * type: string
39
- * metadata:
40
- * description: An optional set of key-value pairs with additional information.
41
- * type: object
42
- * tags:
43
- * - Claim Reason
44
- * responses:
45
- * 200:
46
- * description: OK
47
- * content:
48
- * application/json:
49
- * schema:
50
- * properties:
51
- * claim_reason:
52
- * $ref: "#/components/schemas/claim_reason"
53
- */
54
- var _default = /*#__PURE__*/function () {
55
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(req, res) {
56
- var id, schema, _schema$validate, value, error, claimReasonService, reason;
57
-
58
- return _regenerator["default"].wrap(function _callee$(_context) {
59
- while (1) {
60
- switch (_context.prev = _context.next) {
61
- case 0:
62
- id = req.params.id;
63
- schema = _medusaCoreUtils.Validator.object().keys({
64
- label: _medusaCoreUtils.Validator.string().optional(),
65
- parent_claim_reason_id: _medusaCoreUtils.Validator.string().optional(),
66
- description: _medusaCoreUtils.Validator.string().optional().allow(""),
67
- metadata: _medusaCoreUtils.Validator.object().optional()
68
- });
69
- _schema$validate = schema.validate(req.body), value = _schema$validate.value, error = _schema$validate.error;
70
-
71
- if (!error) {
72
- _context.next = 5;
73
- break;
74
- }
75
-
76
- throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, error.details);
77
-
78
- case 5:
79
- _context.prev = 5;
80
- claimReasonService = req.scope.resolve("claimReasonService");
81
- _context.next = 9;
82
- return claimReasonService.update(id, value);
83
-
84
- case 9:
85
- _context.next = 11;
86
- return claimReasonService.retrieve(id, {
87
- select: _.defaultFields,
88
- relations: _.defaultRelations
89
- });
90
-
91
- case 11:
92
- reason = _context.sent;
93
- res.status(200).json({
94
- claim_reason: reason
95
- });
96
- _context.next = 18;
97
- break;
98
-
99
- case 15:
100
- _context.prev = 15;
101
- _context.t0 = _context["catch"](5);
102
- throw _context.t0;
103
-
104
- case 18:
105
- case "end":
106
- return _context.stop();
107
- }
108
- }
109
- }, _callee, null, [[5, 15]]);
110
- }));
111
-
112
- return function (_x, _x2) {
113
- return _ref.apply(this, arguments);
114
- };
115
- }();
116
-
117
- exports["default"] = _default;
@@ -1,173 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ClaimReason = void 0;
9
-
10
- var _initializerDefineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerDefineProperty"));
11
-
12
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
-
14
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
-
16
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
17
-
18
- var _applyDecoratedDescriptor2 = _interopRequireDefault(require("@babel/runtime/helpers/applyDecoratedDescriptor"));
19
-
20
- var _initializerWarningHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/initializerWarningHelper"));
21
-
22
- var _typeorm = require("typeorm");
23
-
24
- var _ulid = require("ulid");
25
-
26
- var _dbAwareColumn = require("../utils/db-aware-column");
27
-
28
- var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _dec11, _dec12, _dec13, _dec14, _dec15, _dec16, _dec17, _dec18, _dec19, _dec20, _dec21, _dec22, _dec23, _dec24, _dec25, _dec26, _dec27, _dec28, _class, _class2, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11;
29
-
30
- var ClaimReason = (_dec = (0, _typeorm.Entity)(), _dec2 = (0, _typeorm.PrimaryColumn)(), _dec3 = Reflect.metadata("design:type", String), _dec4 = (0, _typeorm.Index)({
31
- unique: true
32
- }), _dec5 = (0, _typeorm.Column)(), _dec6 = Reflect.metadata("design:type", String), _dec7 = (0, _typeorm.Column)(), _dec8 = Reflect.metadata("design:type", String), _dec9 = (0, _typeorm.Column)({
33
- nullable: true
34
- }), _dec10 = Reflect.metadata("design:type", String), _dec11 = (0, _typeorm.Column)({
35
- nullable: true
36
- }), _dec12 = Reflect.metadata("design:type", String), _dec13 = (0, _typeorm.ManyToOne)(function () {
37
- return ClaimReason;
38
- }, {
39
- cascade: ['soft-remove']
40
- }), _dec14 = (0, _typeorm.JoinColumn)({
41
- name: "parent_claim_reason_id"
42
- }), _dec15 = Reflect.metadata("design:type", Object), _dec16 = (0, _typeorm.OneToMany)(function () {
43
- return ClaimReason;
44
- }, function (claim_reason) {
45
- return claim_reason.parent_claim_reason;
46
- }, {
47
- cascade: ["insert", 'soft-remove']
48
- }), _dec17 = Reflect.metadata("design:type", Array), _dec18 = (0, _typeorm.CreateDateColumn)({
49
- type: (0, _dbAwareColumn.resolveDbType)("timestamptz")
50
- }), _dec19 = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec20 = (0, _typeorm.UpdateDateColumn)({
51
- type: (0, _dbAwareColumn.resolveDbType)("timestamptz")
52
- }), _dec21 = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec22 = (0, _typeorm.DeleteDateColumn)({
53
- type: (0, _dbAwareColumn.resolveDbType)("timestamptz")
54
- }), _dec23 = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec24 = (0, _dbAwareColumn.DbAwareColumn)({
55
- type: "jsonb",
56
- nullable: true
57
- }), _dec25 = Reflect.metadata("design:type", Object), _dec26 = (0, _typeorm.BeforeInsert)(), _dec27 = Reflect.metadata("design:type", Function), _dec28 = Reflect.metadata("design:paramtypes", []), _dec(_class = (_class2 = /*#__PURE__*/function () {
58
- function ClaimReason() {
59
- (0, _classCallCheck2["default"])(this, ClaimReason);
60
- (0, _initializerDefineProperty2["default"])(this, "id", _descriptor, this);
61
- (0, _initializerDefineProperty2["default"])(this, "value", _descriptor2, this);
62
- (0, _initializerDefineProperty2["default"])(this, "label", _descriptor3, this);
63
- (0, _initializerDefineProperty2["default"])(this, "description", _descriptor4, this);
64
- (0, _initializerDefineProperty2["default"])(this, "parent_claim_reason_id", _descriptor5, this);
65
- (0, _initializerDefineProperty2["default"])(this, "parent_claim_reason", _descriptor6, this);
66
- (0, _initializerDefineProperty2["default"])(this, "claim_reason_children", _descriptor7, this);
67
- (0, _initializerDefineProperty2["default"])(this, "created_at", _descriptor8, this);
68
- (0, _initializerDefineProperty2["default"])(this, "updated_at", _descriptor9, this);
69
- (0, _initializerDefineProperty2["default"])(this, "deleted_at", _descriptor10, this);
70
- (0, _initializerDefineProperty2["default"])(this, "metadata", _descriptor11, this);
71
- }
72
-
73
- (0, _createClass2["default"])(ClaimReason, [{
74
- key: "beforeInsert",
75
- value: function beforeInsert() {
76
- if (this.id) return;
77
- var id = (0, _ulid.ulid)();
78
- this.id = "cr_".concat(id);
79
- }
80
- }]);
81
- return ClaimReason;
82
- }(), (_descriptor = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "id", [_dec2, _dec3], {
83
- configurable: true,
84
- enumerable: true,
85
- writable: true,
86
- initializer: null
87
- }), _descriptor2 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "value", [_dec4, _dec5, _dec6], {
88
- configurable: true,
89
- enumerable: true,
90
- writable: true,
91
- initializer: null
92
- }), _descriptor3 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "label", [_dec7, _dec8], {
93
- configurable: true,
94
- enumerable: true,
95
- writable: true,
96
- initializer: null
97
- }), _descriptor4 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "description", [_dec9, _dec10], {
98
- configurable: true,
99
- enumerable: true,
100
- writable: true,
101
- initializer: null
102
- }), _descriptor5 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "parent_claim_reason_id", [_dec11, _dec12], {
103
- configurable: true,
104
- enumerable: true,
105
- writable: true,
106
- initializer: null
107
- }), _descriptor6 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "parent_claim_reason", [_dec13, _dec14, _dec15], {
108
- configurable: true,
109
- enumerable: true,
110
- writable: true,
111
- initializer: null
112
- }), _descriptor7 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "claim_reason_children", [_dec16, _dec17], {
113
- configurable: true,
114
- enumerable: true,
115
- writable: true,
116
- initializer: null
117
- }), _descriptor8 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "created_at", [_dec18, _dec19], {
118
- configurable: true,
119
- enumerable: true,
120
- writable: true,
121
- initializer: null
122
- }), _descriptor9 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "updated_at", [_dec20, _dec21], {
123
- configurable: true,
124
- enumerable: true,
125
- writable: true,
126
- initializer: null
127
- }), _descriptor10 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "deleted_at", [_dec22, _dec23], {
128
- configurable: true,
129
- enumerable: true,
130
- writable: true,
131
- initializer: null
132
- }), _descriptor11 = (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "metadata", [_dec24, _dec25], {
133
- configurable: true,
134
- enumerable: true,
135
- writable: true,
136
- initializer: null
137
- }), (0, _applyDecoratedDescriptor2["default"])(_class2.prototype, "beforeInsert", [_dec26, _dec27, _dec28], Object.getOwnPropertyDescriptor(_class2.prototype, "beforeInsert"), _class2.prototype)), _class2)) || _class);
138
- /**
139
- * @schema claim_reason
140
- * title: "Claim Reason"
141
- * description: "A Reason for why a claim was made. A Claim Reason can be used on Claim Items in order to indicate why a Line Item was claimed."
142
- * x-resourceId: claim_reason
143
- * properties:
144
- * id:
145
- * description: "The id of the Claim Reason will start with `cr_`."
146
- * type: string
147
- * description:
148
- * description: "A description of the Claim Reason."
149
- * type: string
150
- * label:
151
- * description: "A text that can be displayed to the Customer as a reason."
152
- * type: string
153
- * value:
154
- * description: "The value to identify the reason by."
155
- * type: string
156
- * created_at:
157
- * description: "The date with timezone at which the resource was created."
158
- * type: string
159
- * format: date-time
160
- * updated_at:
161
- * description: "The date with timezone at which the resource was last updated."
162
- * type: string
163
- * format: date-time
164
- * deleted_at:
165
- * description: "The date with timezone at which the resource was deleted."
166
- * type: string
167
- * format: date-time
168
- * metadata:
169
- * description: "An optional key-value map with additional information."
170
- * type: object
171
- */
172
-
173
- exports.ClaimReason = ClaimReason;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.ClaimReasonRepository = void 0;
9
-
10
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
-
14
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
15
-
16
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
17
-
18
- var _typeorm = require("typeorm");
19
-
20
- var _claimReason = require("../models/claim-reason");
21
-
22
- var _dec, _class;
23
-
24
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
25
-
26
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
27
-
28
- var ClaimReasonRepository = (_dec = (0, _typeorm.EntityRepository)(_claimReason.ClaimReason), _dec(_class = /*#__PURE__*/function (_Repository) {
29
- (0, _inherits2["default"])(ClaimReasonRepository, _Repository);
30
-
31
- var _super = _createSuper(ClaimReasonRepository);
32
-
33
- function ClaimReasonRepository() {
34
- (0, _classCallCheck2["default"])(this, ClaimReasonRepository);
35
- return _super.apply(this, arguments);
36
- }
37
-
38
- return ClaimReasonRepository;
39
- }(_typeorm.Repository)) || _class);
40
- exports.ClaimReasonRepository = ClaimReasonRepository;
@@ -1,343 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
-
10
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
-
16
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
-
18
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
19
-
20
- var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
-
22
- var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
23
-
24
- var _medusaCoreUtils = require("medusa-core-utils");
25
-
26
- var _medusaInterfaces = require("medusa-interfaces");
27
-
28
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
29
-
30
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
31
-
32
- var ClaimReasonService = /*#__PURE__*/function (_BaseService) {
33
- (0, _inherits2["default"])(ClaimReasonService, _BaseService);
34
-
35
- var _super = _createSuper(ClaimReasonService);
36
-
37
- function ClaimReasonService(_ref) {
38
- var _this;
39
-
40
- var manager = _ref.manager,
41
- claimReasonRepository = _ref.claimReasonRepository;
42
- (0, _classCallCheck2["default"])(this, ClaimReasonService);
43
- _this = _super.call(this);
44
- /** @private @constant {EntityManager} */
45
-
46
- _this.manager_ = manager;
47
- /** @private @constant {ClaimReasonRepository} */
48
-
49
- _this.claimReasonRepo_ = claimReasonRepository;
50
- return _this;
51
- }
52
-
53
- (0, _createClass2["default"])(ClaimReasonService, [{
54
- key: "withTransaction",
55
- value: function withTransaction(manager) {
56
- if (!manager) {
57
- return this;
58
- }
59
-
60
- var cloned = new ClaimReasonService({
61
- manager: manager,
62
- claimReasonRepository: this.claimReasonRepo_
63
- });
64
- cloned.transactionManager_ = manager;
65
- return cloned;
66
- }
67
- }, {
68
- key: "create",
69
- value: function create(data) {
70
- var _this2 = this;
71
-
72
- return this.atomicPhase_( /*#__PURE__*/function () {
73
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(manager) {
74
- var crRepo, parentReason, created, result;
75
- return _regenerator["default"].wrap(function _callee$(_context) {
76
- while (1) {
77
- switch (_context.prev = _context.next) {
78
- case 0:
79
- crRepo = manager.getCustomRepository(_this2.claimReasonRepo_);
80
-
81
- if (!(data.parent_claim_reason_id && data.parent_claim_reason_id !== "")) {
82
- _context.next = 7;
83
- break;
84
- }
85
-
86
- _context.next = 4;
87
- return _this2.retrieve(data.parent_claim_reason_id);
88
-
89
- case 4:
90
- parentReason = _context.sent;
91
-
92
- if (!parentReason.parent_claim_reason_id) {
93
- _context.next = 7;
94
- break;
95
- }
96
-
97
- throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.INVALID_DATA, "Doubly nested claim reasons is not supported");
98
-
99
- case 7:
100
- created = crRepo.create(data);
101
- _context.next = 10;
102
- return crRepo.save(created);
103
-
104
- case 10:
105
- result = _context.sent;
106
- return _context.abrupt("return", result);
107
-
108
- case 12:
109
- case "end":
110
- return _context.stop();
111
- }
112
- }
113
- }, _callee);
114
- }));
115
-
116
- return function (_x) {
117
- return _ref2.apply(this, arguments);
118
- };
119
- }());
120
- }
121
- }, {
122
- key: "update",
123
- value: function update(id, data) {
124
- var _this3 = this;
125
-
126
- return this.atomicPhase_( /*#__PURE__*/function () {
127
- var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(manager) {
128
- var crRepo, reason, description, label, parent_claim_reason_id;
129
- return _regenerator["default"].wrap(function _callee2$(_context2) {
130
- while (1) {
131
- switch (_context2.prev = _context2.next) {
132
- case 0:
133
- crRepo = manager.getCustomRepository(_this3.claimReasonRepo_);
134
- _context2.next = 3;
135
- return _this3.retrieve(id);
136
-
137
- case 3:
138
- reason = _context2.sent;
139
- description = data.description, label = data.label, parent_claim_reason_id = data.parent_claim_reason_id;
140
-
141
- if (description) {
142
- reason.description = data.description;
143
- }
144
-
145
- if (label) {
146
- reason.label = data.label;
147
- }
148
-
149
- if (parent_claim_reason_id) {
150
- reason.parent_claim_reason_id = parent_claim_reason_id;
151
- }
152
-
153
- _context2.next = 10;
154
- return crRepo.save(reason);
155
-
156
- case 10:
157
- return _context2.abrupt("return", reason);
158
-
159
- case 11:
160
- case "end":
161
- return _context2.stop();
162
- }
163
- }
164
- }, _callee2);
165
- }));
166
-
167
- return function (_x2) {
168
- return _ref3.apply(this, arguments);
169
- };
170
- }());
171
- }
172
- /**
173
- * @param {Object} selector - the query object for find
174
- * @return {Promise} the result of the find operation
175
- */
176
-
177
- }, {
178
- key: "list",
179
- value: function () {
180
- var _list = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(selector) {
181
- var config,
182
- crRepo,
183
- query,
184
- _args3 = arguments;
185
- return _regenerator["default"].wrap(function _callee3$(_context3) {
186
- while (1) {
187
- switch (_context3.prev = _context3.next) {
188
- case 0:
189
- config = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {
190
- skip: 0,
191
- take: 50,
192
- order: {
193
- created_at: "DESC"
194
- }
195
- };
196
- crRepo = this.manager_.getCustomRepository(this.claimReasonRepo_);
197
- query = this.buildQuery_(selector, config);
198
- return _context3.abrupt("return", crRepo.find(query));
199
-
200
- case 4:
201
- case "end":
202
- return _context3.stop();
203
- }
204
- }
205
- }, _callee3, this);
206
- }));
207
-
208
- function list(_x3) {
209
- return _list.apply(this, arguments);
210
- }
211
-
212
- return list;
213
- }()
214
- /**
215
- * Gets an order by id.
216
- * @param {string} orderId - id of order to retrieve
217
- * @return {Promise<Order>} the order document
218
- */
219
-
220
- }, {
221
- key: "retrieve",
222
- value: function () {
223
- var _retrieve = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(id) {
224
- var config,
225
- crRepo,
226
- validatedId,
227
- query,
228
- item,
229
- _args4 = arguments;
230
- return _regenerator["default"].wrap(function _callee4$(_context4) {
231
- while (1) {
232
- switch (_context4.prev = _context4.next) {
233
- case 0:
234
- config = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
235
- crRepo = this.manager_.getCustomRepository(this.claimReasonRepo_);
236
- validatedId = this.validateId_(id);
237
- query = this.buildQuery_({
238
- id: validatedId
239
- }, config);
240
- _context4.next = 6;
241
- return crRepo.findOne(query);
242
-
243
- case 6:
244
- item = _context4.sent;
245
-
246
- if (item) {
247
- _context4.next = 9;
248
- break;
249
- }
250
-
251
- throw new _medusaCoreUtils.MedusaError(_medusaCoreUtils.MedusaError.Types.NOT_FOUND, "Claim Reason with id: ".concat(id, " was not found."));
252
-
253
- case 9:
254
- return _context4.abrupt("return", item);
255
-
256
- case 10:
257
- case "end":
258
- return _context4.stop();
259
- }
260
- }
261
- }, _callee4, this);
262
- }));
263
-
264
- function retrieve(_x4) {
265
- return _retrieve.apply(this, arguments);
266
- }
267
-
268
- return retrieve;
269
- }()
270
- }, {
271
- key: "delete",
272
- value: function () {
273
- var _delete2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(claimReasonId) {
274
- var _this4 = this;
275
-
276
- return _regenerator["default"].wrap(function _callee6$(_context6) {
277
- while (1) {
278
- switch (_context6.prev = _context6.next) {
279
- case 0:
280
- return _context6.abrupt("return", this.atomicPhase_( /*#__PURE__*/function () {
281
- var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(manager) {
282
- var crRepo, reason;
283
- return _regenerator["default"].wrap(function _callee5$(_context5) {
284
- while (1) {
285
- switch (_context5.prev = _context5.next) {
286
- case 0:
287
- crRepo = manager.getCustomRepository(_this4.claimReasonRepo_); // We include the relation 'claim_reason_children' to enable cascading deletes of claim reasons if a parent is removed
288
-
289
- _context5.next = 3;
290
- return _this4.retrieve(claimReasonId, {
291
- relations: ["claim_reason_children"]
292
- });
293
-
294
- case 3:
295
- reason = _context5.sent;
296
-
297
- if (reason) {
298
- _context5.next = 6;
299
- break;
300
- }
301
-
302
- return _context5.abrupt("return", Promise.resolve());
303
-
304
- case 6:
305
- _context5.next = 8;
306
- return crRepo.softRemove(reason);
307
-
308
- case 8:
309
- return _context5.abrupt("return", Promise.resolve());
310
-
311
- case 9:
312
- case "end":
313
- return _context5.stop();
314
- }
315
- }
316
- }, _callee5);
317
- }));
318
-
319
- return function (_x6) {
320
- return _ref4.apply(this, arguments);
321
- };
322
- }()));
323
-
324
- case 1:
325
- case "end":
326
- return _context6.stop();
327
- }
328
- }
329
- }, _callee6, this);
330
- }));
331
-
332
- function _delete(_x5) {
333
- return _delete2.apply(this, arguments);
334
- }
335
-
336
- return _delete;
337
- }()
338
- }]);
339
- return ClaimReasonService;
340
- }(_medusaInterfaces.BaseService);
341
-
342
- var _default = ClaimReasonService;
343
- exports["default"] = _default;