@8medusa/framework 2.7.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.
Files changed (274) hide show
  1. package/README.md +0 -0
  2. package/dist/build-tools/compiler.d.ts +64 -0
  3. package/dist/build-tools/compiler.d.ts.map +1 -0
  4. package/dist/build-tools/compiler.js +419 -0
  5. package/dist/build-tools/compiler.js.map +1 -0
  6. package/dist/build-tools/index.d.ts +2 -0
  7. package/dist/build-tools/index.d.ts.map +1 -0
  8. package/dist/build-tools/index.js +18 -0
  9. package/dist/build-tools/index.js.map +1 -0
  10. package/dist/config/config.d.ts +34 -0
  11. package/dist/config/config.d.ts.map +1 -0
  12. package/dist/config/config.js +134 -0
  13. package/dist/config/config.js.map +1 -0
  14. package/dist/config/index.d.ts +5 -0
  15. package/dist/config/index.d.ts.map +1 -0
  16. package/dist/config/index.js +21 -0
  17. package/dist/config/index.js.map +1 -0
  18. package/dist/config/loader.d.ts +11 -0
  19. package/dist/config/loader.d.ts.map +1 -0
  20. package/dist/config/loader.js +35 -0
  21. package/dist/config/loader.js.map +1 -0
  22. package/dist/config/types.d.ts +2 -0
  23. package/dist/config/types.d.ts.map +1 -0
  24. package/dist/config/types.js +3 -0
  25. package/dist/config/types.js.map +1 -0
  26. package/dist/container.d.ts +3 -0
  27. package/dist/container.d.ts.map +1 -0
  28. package/dist/container.js +21 -0
  29. package/dist/container.js.map +1 -0
  30. package/dist/database/index.d.ts +3 -0
  31. package/dist/database/index.d.ts.map +1 -0
  32. package/dist/database/index.js +19 -0
  33. package/dist/database/index.js.map +1 -0
  34. package/dist/database/pg-connection-loader.d.ts +6 -0
  35. package/dist/database/pg-connection-loader.d.ts.map +1 -0
  36. package/dist/database/pg-connection-loader.js +43 -0
  37. package/dist/database/pg-connection-loader.js.map +1 -0
  38. package/dist/feature-flags/feature-flag-loader.d.ts +8 -0
  39. package/dist/feature-flags/feature-flag-loader.d.ts.map +1 -0
  40. package/dist/feature-flags/feature-flag-loader.js +81 -0
  41. package/dist/feature-flags/feature-flag-loader.js.map +1 -0
  42. package/dist/feature-flags/flag-router.d.ts +32 -0
  43. package/dist/feature-flags/flag-router.d.ts.map +1 -0
  44. package/dist/feature-flags/flag-router.js +67 -0
  45. package/dist/feature-flags/flag-router.js.map +1 -0
  46. package/dist/feature-flags/index.d.ts +5 -0
  47. package/dist/feature-flags/index.d.ts.map +1 -0
  48. package/dist/feature-flags/index.js +21 -0
  49. package/dist/feature-flags/index.js.map +1 -0
  50. package/dist/feature-flags/types.d.ts +31 -0
  51. package/dist/feature-flags/types.d.ts.map +1 -0
  52. package/dist/feature-flags/types.js +3 -0
  53. package/dist/feature-flags/types.js.map +1 -0
  54. package/dist/http/express-loader.d.ts +8 -0
  55. package/dist/http/express-loader.d.ts.map +1 -0
  56. package/dist/http/express-loader.js +128 -0
  57. package/dist/http/express-loader.js.map +1 -0
  58. package/dist/http/index.d.ts +15 -0
  59. package/dist/http/index.d.ts.map +1 -0
  60. package/dist/http/index.js +31 -0
  61. package/dist/http/index.js.map +1 -0
  62. package/dist/http/middleware-file-loader.d.ts +33 -0
  63. package/dist/http/middleware-file-loader.d.ts.map +1 -0
  64. package/dist/http/middleware-file-loader.js +173 -0
  65. package/dist/http/middleware-file-loader.js.map +1 -0
  66. package/dist/http/middlewares/apply-default-filters.d.ts +3 -0
  67. package/dist/http/middlewares/apply-default-filters.d.ts.map +1 -0
  68. package/dist/http/middlewares/apply-default-filters.js +32 -0
  69. package/dist/http/middlewares/apply-default-filters.js.map +1 -0
  70. package/dist/http/middlewares/apply-params-as-filters.d.ts +5 -0
  71. package/dist/http/middlewares/apply-params-as-filters.d.ts.map +1 -0
  72. package/dist/http/middlewares/apply-params-as-filters.js +14 -0
  73. package/dist/http/middlewares/apply-params-as-filters.js.map +1 -0
  74. package/dist/http/middlewares/authenticate-middleware.d.ts +13 -0
  75. package/dist/http/middlewares/authenticate-middleware.d.ts.map +1 -0
  76. package/dist/http/middlewares/authenticate-middleware.js +136 -0
  77. package/dist/http/middlewares/authenticate-middleware.js.map +1 -0
  78. package/dist/http/middlewares/bodyparser.d.ts +13 -0
  79. package/dist/http/middlewares/bodyparser.d.ts.map +1 -0
  80. package/dist/http/middlewares/bodyparser.js +62 -0
  81. package/dist/http/middlewares/bodyparser.js.map +1 -0
  82. package/dist/http/middlewares/clear-filters-by-key.d.ts +3 -0
  83. package/dist/http/middlewares/clear-filters-by-key.d.ts.map +1 -0
  84. package/dist/http/middlewares/clear-filters-by-key.js +12 -0
  85. package/dist/http/middlewares/clear-filters-by-key.js.map +1 -0
  86. package/dist/http/middlewares/ensure-publishable-api-key.d.ts +3 -0
  87. package/dist/http/middlewares/ensure-publishable-api-key.d.ts.map +1 -0
  88. package/dist/http/middlewares/ensure-publishable-api-key.js +45 -0
  89. package/dist/http/middlewares/ensure-publishable-api-key.js.map +1 -0
  90. package/dist/http/middlewares/error-handler.d.ts +21 -0
  91. package/dist/http/middlewares/error-handler.d.ts.map +1 -0
  92. package/dist/http/middlewares/error-handler.js +85 -0
  93. package/dist/http/middlewares/error-handler.js.map +1 -0
  94. package/dist/http/middlewares/exception-formatter.d.ts +9 -0
  95. package/dist/http/middlewares/exception-formatter.d.ts.map +1 -0
  96. package/dist/http/middlewares/exception-formatter.js +36 -0
  97. package/dist/http/middlewares/exception-formatter.js.map +1 -0
  98. package/dist/http/middlewares/index.d.ts +8 -0
  99. package/dist/http/middlewares/index.d.ts.map +1 -0
  100. package/dist/http/middlewares/index.js +24 -0
  101. package/dist/http/middlewares/index.js.map +1 -0
  102. package/dist/http/middlewares/set-context.d.ts +3 -0
  103. package/dist/http/middlewares/set-context.d.ts.map +1 -0
  104. package/dist/http/middlewares/set-context.js +18 -0
  105. package/dist/http/middlewares/set-context.js.map +1 -0
  106. package/dist/http/router.d.ts +28 -0
  107. package/dist/http/router.d.ts.map +1 -0
  108. package/dist/http/router.js +252 -0
  109. package/dist/http/router.js.map +1 -0
  110. package/dist/http/routes-finder.d.ts +22 -0
  111. package/dist/http/routes-finder.d.ts.map +1 -0
  112. package/dist/http/routes-finder.js +62 -0
  113. package/dist/http/routes-finder.js.map +1 -0
  114. package/dist/http/routes-loader.d.ts +30 -0
  115. package/dist/http/routes-loader.d.ts.map +1 -0
  116. package/dist/http/routes-loader.js +203 -0
  117. package/dist/http/routes-loader.js.map +1 -0
  118. package/dist/http/routes-sorter.d.ts +105 -0
  119. package/dist/http/routes-sorter.d.ts.map +1 -0
  120. package/dist/http/routes-sorter.js +146 -0
  121. package/dist/http/routes-sorter.js.map +1 -0
  122. package/dist/http/types.d.ts +164 -0
  123. package/dist/http/types.d.ts.map +1 -0
  124. package/dist/http/types.js +16 -0
  125. package/dist/http/types.js.map +1 -0
  126. package/dist/http/utils/define-middlewares.d.ts +22 -0
  127. package/dist/http/utils/define-middlewares.d.ts.map +1 -0
  128. package/dist/http/utils/define-middlewares.js +27 -0
  129. package/dist/http/utils/define-middlewares.js.map +1 -0
  130. package/dist/http/utils/get-query-config.d.ts +42 -0
  131. package/dist/http/utils/get-query-config.d.ts.map +1 -0
  132. package/dist/http/utils/get-query-config.js +183 -0
  133. package/dist/http/utils/get-query-config.js.map +1 -0
  134. package/dist/http/utils/http-compression.d.ts +5 -0
  135. package/dist/http/utils/http-compression.d.ts.map +1 -0
  136. package/dist/http/utils/http-compression.js +33 -0
  137. package/dist/http/utils/http-compression.js.map +1 -0
  138. package/dist/http/utils/maybe-apply-link-filter.d.ts +8 -0
  139. package/dist/http/utils/maybe-apply-link-filter.d.ts.map +1 -0
  140. package/dist/http/utils/maybe-apply-link-filter.js +68 -0
  141. package/dist/http/utils/maybe-apply-link-filter.js.map +1 -0
  142. package/dist/http/utils/refetch-entities.d.ts +5 -0
  143. package/dist/http/utils/refetch-entities.d.ts.map +1 -0
  144. package/dist/http/utils/refetch-entities.js +29 -0
  145. package/dist/http/utils/refetch-entities.js.map +1 -0
  146. package/dist/http/utils/restricted-fields.d.ts +6 -0
  147. package/dist/http/utils/restricted-fields.d.ts.map +1 -0
  148. package/dist/http/utils/restricted-fields.js +30 -0
  149. package/dist/http/utils/restricted-fields.js.map +1 -0
  150. package/dist/http/utils/unless-path.d.ts +9 -0
  151. package/dist/http/utils/unless-path.d.ts.map +1 -0
  152. package/dist/http/utils/unless-path.js +19 -0
  153. package/dist/http/utils/unless-path.js.map +1 -0
  154. package/dist/http/utils/validate-body.d.ts +5 -0
  155. package/dist/http/utils/validate-body.d.ts.map +1 -0
  156. package/dist/http/utils/validate-body.js +23 -0
  157. package/dist/http/utils/validate-body.js.map +1 -0
  158. package/dist/http/utils/validate-query.d.ts +6 -0
  159. package/dist/http/utils/validate-query.d.ts.map +1 -0
  160. package/dist/http/utils/validate-query.js +79 -0
  161. package/dist/http/utils/validate-query.js.map +1 -0
  162. package/dist/http/utils/wrap-handler.d.ts +3 -0
  163. package/dist/http/utils/wrap-handler.d.ts.map +1 -0
  164. package/dist/http/utils/wrap-handler.js +26 -0
  165. package/dist/http/utils/wrap-handler.js.map +1 -0
  166. package/dist/index.d.ts +17 -0
  167. package/dist/index.d.ts.map +1 -0
  168. package/dist/index.js +35 -0
  169. package/dist/index.js.map +1 -0
  170. package/dist/jobs/index.d.ts +2 -0
  171. package/dist/jobs/index.d.ts.map +1 -0
  172. package/dist/jobs/index.js +18 -0
  173. package/dist/jobs/index.js.map +1 -0
  174. package/dist/jobs/job-loader.d.ts +42 -0
  175. package/dist/jobs/job-loader.d.ts.map +1 -0
  176. package/dist/jobs/job-loader.js +78 -0
  177. package/dist/jobs/job-loader.js.map +1 -0
  178. package/dist/links/index.d.ts +2 -0
  179. package/dist/links/index.d.ts.map +1 -0
  180. package/dist/links/index.js +18 -0
  181. package/dist/links/index.js.map +1 -0
  182. package/dist/links/link-loader.d.ts +10 -0
  183. package/dist/links/link-loader.d.ts.map +1 -0
  184. package/dist/links/link-loader.js +74 -0
  185. package/dist/links/link-loader.js.map +1 -0
  186. package/dist/logger/index.d.ts +3 -0
  187. package/dist/logger/index.d.ts.map +1 -0
  188. package/dist/logger/index.js +9 -0
  189. package/dist/logger/index.js.map +1 -0
  190. package/dist/medusa-app-loader.d.ts +51 -0
  191. package/dist/medusa-app-loader.d.ts.map +1 -0
  192. package/dist/medusa-app-loader.js +189 -0
  193. package/dist/medusa-app-loader.js.map +1 -0
  194. package/dist/migrations/index.d.ts +3 -0
  195. package/dist/migrations/index.d.ts.map +1 -0
  196. package/dist/migrations/index.js +19 -0
  197. package/dist/migrations/index.js.map +1 -0
  198. package/dist/migrations/migrator.d.ts +38 -0
  199. package/dist/migrations/migrator.d.ts.map +1 -0
  200. package/dist/migrations/migrator.js +129 -0
  201. package/dist/migrations/migrator.js.map +1 -0
  202. package/dist/migrations/run-migration-scripts.d.ts +17 -0
  203. package/dist/migrations/run-migration-scripts.d.ts.map +1 -0
  204. package/dist/migrations/run-migration-scripts.js +94 -0
  205. package/dist/migrations/run-migration-scripts.js.map +1 -0
  206. package/dist/mikro-orm-cli/bin.d.ts +14 -0
  207. package/dist/mikro-orm-cli/bin.d.ts.map +1 -0
  208. package/dist/mikro-orm-cli/bin.js +54 -0
  209. package/dist/mikro-orm-cli/bin.js.map +1 -0
  210. package/dist/modules-sdk/index.d.ts +2 -0
  211. package/dist/modules-sdk/index.d.ts.map +1 -0
  212. package/dist/modules-sdk/index.js +18 -0
  213. package/dist/modules-sdk/index.js.map +1 -0
  214. package/dist/orchestration/index.d.ts +2 -0
  215. package/dist/orchestration/index.d.ts.map +1 -0
  216. package/dist/orchestration/index.js +18 -0
  217. package/dist/orchestration/index.js.map +1 -0
  218. package/dist/subscribers/index.d.ts +3 -0
  219. package/dist/subscribers/index.d.ts.map +1 -0
  220. package/dist/subscribers/index.js +19 -0
  221. package/dist/subscribers/index.js.map +1 -0
  222. package/dist/subscribers/subscriber-loader.d.ts +12 -0
  223. package/dist/subscribers/subscriber-loader.d.ts.map +1 -0
  224. package/dist/subscribers/subscriber-loader.js +147 -0
  225. package/dist/subscribers/subscriber-loader.js.map +1 -0
  226. package/dist/subscribers/types.d.ts +15 -0
  227. package/dist/subscribers/types.d.ts.map +1 -0
  228. package/dist/subscribers/types.js +3 -0
  229. package/dist/subscribers/types.js.map +1 -0
  230. package/dist/telemetry/index.d.ts +50 -0
  231. package/dist/telemetry/index.d.ts.map +1 -0
  232. package/dist/telemetry/index.js +81 -0
  233. package/dist/telemetry/index.js.map +1 -0
  234. package/dist/types/container.d.ts +62 -0
  235. package/dist/types/container.d.ts.map +1 -0
  236. package/dist/types/container.js +3 -0
  237. package/dist/types/container.js.map +1 -0
  238. package/dist/types/index.d.ts +2 -0
  239. package/dist/types/index.d.ts.map +1 -0
  240. package/dist/types/index.js +18 -0
  241. package/dist/types/index.js.map +1 -0
  242. package/dist/utils/index.d.ts +3 -0
  243. package/dist/utils/index.d.ts.map +1 -0
  244. package/dist/utils/index.js +19 -0
  245. package/dist/utils/index.js.map +1 -0
  246. package/dist/utils/resource-loader.d.ts +26 -0
  247. package/dist/utils/resource-loader.d.ts.map +1 -0
  248. package/dist/utils/resource-loader.js +78 -0
  249. package/dist/utils/resource-loader.js.map +1 -0
  250. package/dist/workflows/index.d.ts +3 -0
  251. package/dist/workflows/index.d.ts.map +1 -0
  252. package/dist/workflows/index.js +19 -0
  253. package/dist/workflows/index.js.map +1 -0
  254. package/dist/workflows/workflow-loader.d.ts +12 -0
  255. package/dist/workflows/workflow-loader.d.ts.map +1 -0
  256. package/dist/workflows/workflow-loader.js +24 -0
  257. package/dist/workflows/workflow-loader.js.map +1 -0
  258. package/dist/workflows-sdk/composer.d.ts +2 -0
  259. package/dist/workflows-sdk/composer.d.ts.map +1 -0
  260. package/dist/workflows-sdk/composer.js +18 -0
  261. package/dist/workflows-sdk/composer.js.map +1 -0
  262. package/dist/workflows-sdk/index.d.ts +3 -0
  263. package/dist/workflows-sdk/index.d.ts.map +1 -0
  264. package/dist/workflows-sdk/index.js +19 -0
  265. package/dist/workflows-sdk/index.js.map +1 -0
  266. package/dist/zod/index.d.ts +2 -0
  267. package/dist/zod/index.d.ts.map +1 -0
  268. package/dist/zod/index.js +18 -0
  269. package/dist/zod/index.js.map +1 -0
  270. package/dist/zod/zod-helpers.d.ts +3 -0
  271. package/dist/zod/zod-helpers.d.ts.map +1 -0
  272. package/dist/zod/zod-helpers.js +95 -0
  273. package/dist/zod/zod-helpers.js.map +1 -0
  274. package/package.json +133 -0
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pickByConfig = pickByConfig;
4
+ exports.prepareListQuery = prepareListQuery;
5
+ exports.prepareRetrieveQuery = prepareRetrieveQuery;
6
+ const utils_1 = require("@8medusa/utils");
7
+ const lodash_1 = require("lodash");
8
+ function pickByConfig(obj, config) {
9
+ const fields = [...(config.select ?? []), ...(config.relations ?? [])];
10
+ if (fields.length) {
11
+ if (Array.isArray(obj)) {
12
+ return obj.map((o) => (0, lodash_1.pick)(o, fields));
13
+ }
14
+ else {
15
+ return (0, lodash_1.pick)(obj, fields);
16
+ }
17
+ }
18
+ return obj;
19
+ }
20
+ function checkRestrictedFields({ fields, restricted, }) {
21
+ const notAllowedFields = [];
22
+ fields.forEach((field) => {
23
+ const fieldSegments = field.split(".");
24
+ const hasRestrictedField = restricted.some((restrictedField) => fieldSegments.includes(restrictedField));
25
+ if (hasRestrictedField) {
26
+ notAllowedFields.push(field);
27
+ return;
28
+ }
29
+ return;
30
+ });
31
+ return notAllowedFields;
32
+ }
33
+ function checkAllowedFields({ fields, allowed, starFields, }) {
34
+ const notAllowedFields = [];
35
+ fields.forEach((field) => {
36
+ const hasAllowedField = allowed.includes(field);
37
+ if (hasAllowedField) {
38
+ return;
39
+ }
40
+ // Select full relation in that case it must match an allowed field fully
41
+ // e.g product.variants in that case we must have a product.variants in the allowedFields
42
+ if (starFields.has(field)) {
43
+ if (hasAllowedField) {
44
+ return;
45
+ }
46
+ notAllowedFields.push(field);
47
+ return;
48
+ }
49
+ const fieldStartsWithAllowedField = allowed.some((allowedField) => field.startsWith(allowedField));
50
+ if (!fieldStartsWithAllowedField) {
51
+ notAllowedFields.push(field);
52
+ return;
53
+ }
54
+ });
55
+ return notAllowedFields;
56
+ }
57
+ function prepareListQuery(validated, queryConfig = {}) {
58
+ let { allowed = [], restricted = [], defaults = [], defaultLimit = 50, isList, } = queryConfig;
59
+ const { order, fields, limit = defaultLimit, offset = 0 } = validated;
60
+ // e.g *product.variants meaning that we want all fields from the product.variants
61
+ // in that case it wont be part of the select but it will be part of the relations.
62
+ // For the remote query we will have to add the fields to the fields array as product.variants.*
63
+ const starFields = new Set();
64
+ let allFields = new Set(defaults);
65
+ if ((0, utils_1.isDefined)(fields)) {
66
+ const customFields = fields.split(",").filter(Boolean);
67
+ const shouldReplaceDefaultFields = !customFields.length ||
68
+ customFields.some((field) => {
69
+ return !(field.startsWith("-") ||
70
+ field.startsWith("+") ||
71
+ field.startsWith(" ") ||
72
+ field.startsWith("*") ||
73
+ field.endsWith(".*"));
74
+ });
75
+ if (shouldReplaceDefaultFields) {
76
+ allFields = new Set(customFields.map((f) => f.replace(/^[+ -]/, "")));
77
+ }
78
+ else {
79
+ customFields.forEach((field) => {
80
+ if (field.startsWith("+") || field.startsWith(" ")) {
81
+ allFields.add(field.trim().replace(/^\+/, ""));
82
+ }
83
+ else if (field.startsWith("-")) {
84
+ const fieldName = field.replace(/^-/, "");
85
+ for (const reqField of allFields) {
86
+ const reqFieldName = reqField.replace(/^\*/, "");
87
+ if (reqFieldName === fieldName ||
88
+ reqFieldName.startsWith(fieldName + ".")) {
89
+ allFields.delete(reqField);
90
+ }
91
+ }
92
+ }
93
+ else {
94
+ allFields.add(field);
95
+ }
96
+ });
97
+ }
98
+ allFields.add("id");
99
+ }
100
+ allFields.forEach((field) => {
101
+ if (field.startsWith("*") || field.endsWith(".*")) {
102
+ starFields.add(field.replace(/(^\*|\.\*$)/, ""));
103
+ allFields.delete(field);
104
+ }
105
+ });
106
+ let notAllowedFields = [];
107
+ if (allowed.length || restricted.length) {
108
+ const fieldsToCheck = [...allFields, ...Array.from(starFields)];
109
+ if (allowed.length) {
110
+ notAllowedFields = checkAllowedFields({
111
+ fields: fieldsToCheck,
112
+ starFields,
113
+ allowed,
114
+ });
115
+ }
116
+ else if (restricted.length) {
117
+ notAllowedFields = checkRestrictedFields({
118
+ fields: fieldsToCheck,
119
+ restricted,
120
+ });
121
+ }
122
+ }
123
+ if (notAllowedFields.length) {
124
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Requested fields [${Array.from(notAllowedFields).join(", ")}] are not valid`);
125
+ }
126
+ // TODO: maintain backward compatibility, remove in the future
127
+ const { select, relations } = (0, utils_1.stringToSelectRelationObject)(Array.from(allFields));
128
+ let allRelations = new Set([...relations, ...Array.from(starFields)]);
129
+ // End of expand compatibility
130
+ let orderBy = {};
131
+ if ((0, utils_1.isDefined)(order)) {
132
+ let orderField = order;
133
+ if (order.startsWith("-")) {
134
+ const [, field] = order.split("-");
135
+ orderField = field;
136
+ orderBy = { [field]: "DESC" };
137
+ }
138
+ else {
139
+ orderBy = { [order]: "ASC" };
140
+ }
141
+ if (allowed.length && !allowed.includes(orderField)) {
142
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_DATA, `Order field ${orderField} is not valid`);
143
+ }
144
+ }
145
+ const finalOrder = (0, utils_1.isPresent)(orderBy) ? orderBy : undefined;
146
+ return {
147
+ listConfig: {
148
+ select: select.length ? select : undefined,
149
+ relations: Array.from(allRelations),
150
+ skip: offset,
151
+ take: limit,
152
+ order: finalOrder,
153
+ },
154
+ remoteQueryConfig: {
155
+ // Add starFields that are relations only on which we want all properties with a dedicated format to the remote query
156
+ fields: [
157
+ ...Array.from(allFields),
158
+ ...Array.from(starFields).map((f) => `${f}.*`),
159
+ ],
160
+ pagination: isList
161
+ ? {
162
+ skip: offset,
163
+ take: limit,
164
+ order: finalOrder,
165
+ }
166
+ : {},
167
+ },
168
+ };
169
+ }
170
+ function prepareRetrieveQuery(validated, queryConfig) {
171
+ const { listConfig, remoteQueryConfig } = prepareListQuery(validated, queryConfig);
172
+ return {
173
+ retrieveConfig: {
174
+ select: listConfig.select,
175
+ relations: listConfig.relations,
176
+ },
177
+ remoteQueryConfig: {
178
+ fields: remoteQueryConfig.fields,
179
+ pagination: {},
180
+ },
181
+ };
182
+ }
183
+ //# sourceMappingURL=get-query-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-query-config.js","sourceRoot":"","sources":["../../../src/http/utils/get-query-config.ts"],"names":[],"mappings":";;AASA,oCAcC;AAoED,4CAmJC;AAED,oDAmBC;AAlQD,0CAKuB;AACvB,mCAA6B;AAE7B,SAAgB,YAAY,CAC1B,GAAsB,EACtB,MAA0B;IAE1B,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,CAAA;IAEtE,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAClB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YACvB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,aAAI,EAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAA;QACxC,CAAC;aAAM,CAAC;YACN,OAAO,IAAA,aAAI,EAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,SAAS,qBAAqB,CAAC,EAC7B,MAAM,EACN,UAAU,GAIX;IACC,MAAM,gBAAgB,GAAa,EAAE,CAAA;IAErC,MAAM,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACtC,MAAM,kBAAkB,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,EAAE,CAC7D,aAAa,CAAC,Q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,iBAAiB,EAAE;YACjB,MAAM,EAAE,iBAAiB,CAAC,MAAM;YAChC,UAAU,EAAE,EAAE;SACf;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { HttpCompressionOptions, ProjectConfigOptions } from "../../config";
2
+ import type { MedusaRequest, MedusaResponse } from "../types";
3
+ export declare function shouldCompressResponse(req: MedusaRequest, res: MedusaResponse): boolean;
4
+ export declare function compressionOptions(config: ProjectConfigOptions): HttpCompressionOptions;
5
+ //# sourceMappingURL=http-compression.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-compression.d.ts","sourceRoot":"","sources":["../../../src/http/utils/http-compression.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAE7D,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,cAAc,WAkBpB;AAED,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,oBAAoB,GAC3B,sBAAsB,CAWxB"}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.shouldCompressResponse = shouldCompressResponse;
7
+ exports.compressionOptions = compressionOptions;
8
+ const compression_1 = __importDefault(require("compression"));
9
+ const utils_1 = require("@8medusa/utils");
10
+ function shouldCompressResponse(req, res) {
11
+ const { projectConfig } = req.scope.resolve(utils_1.ContainerRegistrationKeys.CONFIG_MODULE);
12
+ const { enabled } = compressionOptions(projectConfig);
13
+ if (!enabled) {
14
+ return false;
15
+ }
16
+ if (req.headers["x-no-compression"]) {
17
+ // don't compress responses with this request header
18
+ return false;
19
+ }
20
+ // fallback to standard filter function
21
+ return compression_1.default.filter(req, res);
22
+ }
23
+ function compressionOptions(config) {
24
+ const responseCompressionOptions = config.http.compression ?? {};
25
+ responseCompressionOptions.enabled =
26
+ responseCompressionOptions.enabled ?? false;
27
+ responseCompressionOptions.level = responseCompressionOptions.level ?? 6;
28
+ responseCompressionOptions.memLevel = responseCompressionOptions.memLevel ?? 8;
29
+ responseCompressionOptions.threshold =
30
+ responseCompressionOptions.threshold ?? 1024;
31
+ return responseCompressionOptions;
32
+ }
33
+ //# sourceMappingURL=http-compression.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-compression.js","sourceRoot":"","sources":["../../../src/http/utils/http-compression.ts"],"names":[],"mappings":";;;;;AAOA,wDAoBC;AAED,gDAaC;AA1CD,8DAAqC;AAErC,0CAA0D;AAK1D,SAAgB,sBAAsB,CACpC,GAAkB,EAClB,GAAmB;IAEnB,MAAM,EAAE,aAAa,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CACzC,iCAAyB,CAAC,aAAa,CACxC,CAAA;IACD,MAAM,EAAE,OAAO,EAAE,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAA;IAErD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,GAAG,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACpC,oDAAoD;QACpD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,uCAAuC;IACvC,OAAO,qBAAW,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;AACrC,CAAC;AAED,SAAgB,kBAAkB,CAChC,MAA4B;IAE5B,MAAM,0BAA0B,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAA;IAEhE,0BAA0B,CAAC,OAAO;QAChC,0BAA0B,CAAC,OAAO,IAAI,KAAK,CAAA;IAC7C,0BAA0B,CAAC,KAAK,GAAG,0BAA0B,CAAC,KAAK,IAAI,CAAC,CAAA;IACxE,0BAA0B,CAAC,QAAQ,GAAG,0BAA0B,CAAC,QAAQ,IAAI,CAAC,CAAA;IAC9E,0BAA0B,CAAC,SAAS;QAClC,0BAA0B,CAAC,SAAS,IAAI,IAAI,CAAA;IAE9C,OAAO,0BAA0B,CAAA;AACnC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { MedusaNextFunction, MedusaRequest, MedusaResponse } from "../types";
2
+ export declare function maybeApplyLinkFilter({ entryPoint, resourceId, filterableField, filterByField, }: {
3
+ entryPoint: any;
4
+ resourceId: any;
5
+ filterableField: any;
6
+ filterByField?: string | undefined;
7
+ }): (req: MedusaRequest, _: MedusaResponse, next: MedusaNextFunction) => Promise<void>;
8
+ //# sourceMappingURL=maybe-apply-link-filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe-apply-link-filter.d.ts","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,cAAc,EACf,MAAM,UAAU,CAAA;AAEjB,wBAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAoB,GACrB;;;;;CAAA,SAEQ,aAAa,KACf,cAAc,QACX,kBAAkB,mBA2C3B"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.maybeApplyLinkFilter = maybeApplyLinkFilter;
4
+ const utils_1 = require("@8medusa/utils");
5
+ function maybeApplyLinkFilter({ entryPoint, resourceId, filterableField, filterByField = "id", }) {
6
+ return async function linkFilter(req, _, next) {
7
+ const filterableFields = req.filterableFields;
8
+ if (!filterableFields?.[filterableField]) {
9
+ return next();
10
+ }
11
+ const filterFields = filterableFields[filterableField];
12
+ const idsToFilterBy = Array.isArray(filterFields)
13
+ ? filterFields
14
+ : [filterFields];
15
+ delete filterableFields[filterableField];
16
+ let existingFilters = filterableFields[filterByField];
17
+ const query = req.scope.resolve(utils_1.ContainerRegistrationKeys.QUERY);
18
+ const filters = {
19
+ [filterableField]: idsToFilterBy,
20
+ };
21
+ if (existingFilters) {
22
+ filters[resourceId] = existingFilters;
23
+ }
24
+ const { data: resources } = await query.graph({
25
+ entity: entryPoint,
26
+ fields: [resourceId],
27
+ filters,
28
+ });
29
+ filterableFields[filterByField] = resources.map((p) => p[resourceId]);
30
+ req.filterableFields = transformFilterableFields(filterableFields);
31
+ return next();
32
+ };
33
+ }
34
+ /*
35
+ Transforms an object key string into nested objects
36
+ before = {
37
+ "test.something.another": []
38
+ }
39
+
40
+ after = {
41
+ test: {
42
+ something: {
43
+ another: []
44
+ }
45
+ }
46
+ }
47
+ */
48
+ function transformFilterableFields(filterableFields) {
49
+ const result = {};
50
+ for (const key of Object.keys(filterableFields)) {
51
+ const value = filterableFields[key];
52
+ const keys = key.split(".");
53
+ let current = result;
54
+ // Iterate over the keys, creating nested objects as needed
55
+ for (let i = 0; i < keys.length; i++) {
56
+ const part = keys[i];
57
+ current[part] ??= {};
58
+ if (i === keys.length - 1) {
59
+ // If its the last key, assign the value
60
+ current[part] = value;
61
+ break;
62
+ }
63
+ current = current[part];
64
+ }
65
+ }
66
+ return result;
67
+ }
68
+ //# sourceMappingURL=maybe-apply-link-filter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"maybe-apply-link-filter.js","sourceRoot":"","sources":["../../../src/http/utils/maybe-apply-link-filter.ts"],"names":[],"mappings":";;AAOA,oDAoDC;AA3DD,0CAA0D;AAO1D,SAAgB,oBAAoB,CAAC,EACnC,UAAU,EACV,UAAU,EACV,eAAe,EACf,aAAa,GAAG,IAAI,GACrB;IACC,OAAO,KAAK,UAAU,UAAU,CAC9B,GAAkB,EAClB,CAAiB,EACjB,IAAwB;QAExB,MAAM,gBAAgB,GAAG,GAAG,CAAC,gBAAgB,CAAA;QAE7C,IAAI,CAAC,gBAAgB,EAAE,CAAC,eAAe,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,EAAE,CAAA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GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QAC3B,IAAI,OAAO,GAAG,MAAM,CAAA;QAEpB,2DAA2D;QAC3D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;YACpB,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,CAAA;YAEpB,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC1B,wCAAwC;gBACxC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAA;gBACrB,MAAK;YACP,CAAC;YAED,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;QACzB,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { MedusaContainer } from "@8medusa/types";
2
+ import { MedusaRequest } from "../types";
3
+ export declare const refetchEntities: (entryPoint: string, idOrFilter: string | object, scope: MedusaContainer, fields: string[], pagination?: MedusaRequest["queryConfig"]["pagination"]) => Promise<any>;
4
+ export declare const refetchEntity: (entryPoint: string, idOrFilter: string | object, scope: MedusaContainer, fields: string[]) => Promise<any>;
5
+ //# sourceMappingURL=refetch-entities.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refetch-entities.d.ts","sourceRoot":"","sources":["../../../src/http/utils/refetch-entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAMhD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,eAAO,MAAM,eAAe,eACd,MAAM,cACN,MAAM,GAAG,MAAM,SACpB,eAAe,UACd,MAAM,EAAE,eACH,aAAa,CAAC,aAAa,CAAC,CAAC,YAAY,CAAC,iBAuBxD,CAAA;AAED,eAAO,MAAM,aAAa,eACZ,MAAM,cACN,MAAM,GAAG,MAAM,SACpB,eAAe,UACd,MAAM,EAAE,iBAKjB,CAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refetchEntity = exports.refetchEntities = void 0;
4
+ const utils_1 = require("@8medusa/utils");
5
+ const refetchEntities = async (entryPoint, idOrFilter, scope, fields, pagination) => {
6
+ const remoteQuery = scope.resolve(utils_1.ContainerRegistrationKeys.REMOTE_QUERY);
7
+ const filters = (0, utils_1.isString)(idOrFilter) ? { id: idOrFilter } : idOrFilter;
8
+ let context = {};
9
+ if ("context" in filters) {
10
+ if (filters.context) {
11
+ context = filters.context;
12
+ }
13
+ delete filters.context;
14
+ }
15
+ const variables = { filters, ...context, ...pagination };
16
+ const queryObject = (0, utils_1.remoteQueryObjectFromString)({
17
+ entryPoint,
18
+ variables,
19
+ fields,
20
+ });
21
+ return await remoteQuery(queryObject);
22
+ };
23
+ exports.refetchEntities = refetchEntities;
24
+ const refetchEntity = async (entryPoint, idOrFilter, scope, fields) => {
25
+ const [entity] = await (0, exports.refetchEntities)(entryPoint, idOrFilter, scope, fields);
26
+ return entity;
27
+ };
28
+ exports.refetchEntity = refetchEntity;
29
+ //# sourceMappingURL=refetch-entities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refetch-entities.js","sourceRoot":"","sources":["../../../src/http/utils/refetch-entities.ts"],"names":[],"mappings":";;;AACA,0CAIuB;AAGhB,MAAM,eAAe,GAAG,KAAK,EAClC,UAAkB,EAClB,UAA2B,EAC3B,KAAsB,EACtB,MAAgB,EAChB,UAAuD,EACvD,EAAE;IACF,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,iCAAyB,CAAC,YAAY,CAAC,CAAA;IACzE,MAAM,OAAO,GAAG,IAAA,gBAAQ,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,UAAU,CAAA;IACtE,IAAI,OAAO,GAAW,EAAE,CAAA;IAExB,IAAI,SAAS,IAAI,OAAO,EAAE,CAAC;QACzB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,GAAG,OAAO,CAAC,OAAQ,CAAA;QAC5B,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC;IAED,MAAM,SAAS,GAAG,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,UAAU,EAAE,CAAA;IAExD,MAAM,WAAW,GAAG,IAAA,mCAA2B,EAAC;QAC9C,UAAU;QACV,SAAS;QACT,MAAM;KACP,CAAC,CAAA;IAEF,OAAO,MAAM,WAAW,CAAC,WAAW,CAAC,CAAA;AACvC,CAAC,CAAA;AA5BY,QAAA,eAAe,mBA4B3B;AAEM,MAAM,aAAa,GAAG,KAAK,EAChC,UAAkB,EAClB,UAA2B,EAC3B,KAAsB,EACtB,MAAgB,EAChB,EAAE;IACF,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,IAAA,uBAAe,EAAC,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;IAE7E,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AATY,QAAA,aAAa,iBASzB"}
@@ -0,0 +1,6 @@
1
+ export declare class RestrictedFields {
2
+ #private;
3
+ list(): string[];
4
+ add(fields: string[]): void;
5
+ }
6
+ //# sourceMappingURL=restricted-fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restricted-fields.d.ts","sourceRoot":"","sources":["../../../src/http/utils/restricted-fields.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAgB;;IAU3B,IAAI;IAIJ,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE;CAGrB"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _RestrictedFields_restrictedFields;
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.RestrictedFields = void 0;
10
+ class RestrictedFields {
11
+ constructor() {
12
+ /**
13
+ * Fields that are restricted from being selected in the response.
14
+ * Those fields can be allowed if specified in the allowed configuration of the query config of an end point.
15
+ *
16
+ * @type {string[]}
17
+ * @private
18
+ */
19
+ _RestrictedFields_restrictedFields.set(this, new Set());
20
+ }
21
+ list() {
22
+ return Array.from(__classPrivateFieldGet(this, _RestrictedFields_restrictedFields, "f"));
23
+ }
24
+ add(fields) {
25
+ fields.map((field) => __classPrivateFieldGet(this, _RestrictedFields_restrictedFields, "f").add(field));
26
+ }
27
+ }
28
+ exports.RestrictedFields = RestrictedFields;
29
+ _RestrictedFields_restrictedFields = new WeakMap();
30
+ //# sourceMappingURL=restricted-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"restricted-fields.js","sourceRoot":"","sources":["../../../src/http/utils/restricted-fields.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAa,gBAAgB;IAA7B;QACE;;;;;;WAMG;QACH,6CAAiC,IAAI,GAAG,EAAE,EAAA;IAS5C,CAAC;IAPC,IAAI;QACF,OAAO,KAAK,CAAC,IAAI,CAAC,uBAAA,IAAI,0CAAkB,CAAC,CAAA;IAC3C,CAAC;IAED,GAAG,CAAC,MAAgB;QAClB,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,uBAAA,IAAI,0CAAkB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IAC1D,CAAC;CACF;AAjBD,4CAiBC"}
@@ -0,0 +1,9 @@
1
+ import { MedusaNextFunction, MedusaRequest, MedusaResponse, MiddlewareFunction } from "../types";
2
+ /**
3
+ * Due to how our route loader works, where we load all middlewares before routes, ambiguous routes * end up having all middlewares on different routes executed before the route handler is.
4
+ */
5
+ /**
6
+ * This function allows us to skip middlewares for particular routes, so we can temporarily solve * * this without completely breaking the route loader for everyone.
7
+ */
8
+ export declare const unlessPath: (onPath: RegExp, middleware: MiddlewareFunction) => (req: MedusaRequest, res: MedusaResponse, next: MedusaNextFunction) => any;
9
+ //# sourceMappingURL=unless-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unless-path.d.ts","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAEjB;;GAEG;AACH;;GAEG;AACH,eAAO,MAAM,UAAU,WACZ,MAAM,cAAc,kBAAkB,WACzC,aAAa,OAAO,cAAc,QAAQ,kBAAkB,QAMjE,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unlessPath = void 0;
4
+ /**
5
+ * Due to how our route loader works, where we load all middlewares before routes, ambiguous routes * end up having all middlewares on different routes executed before the route handler is.
6
+ */
7
+ /**
8
+ * This function allows us to skip middlewares for particular routes, so we can temporarily solve * * this without completely breaking the route loader for everyone.
9
+ */
10
+ const unlessPath = (onPath, middleware) => (req, res, next) => {
11
+ if (onPath.test(req.path)) {
12
+ return next();
13
+ }
14
+ else {
15
+ return middleware(req, res, next);
16
+ }
17
+ };
18
+ exports.unlessPath = unlessPath;
19
+ //# sourceMappingURL=unless-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unless-path.js","sourceRoot":"","sources":["../../../src/http/utils/unless-path.ts"],"names":[],"mappings":";;;AAOA;;GAEG;AACH;;GAEG;AACI,MAAM,UAAU,GACrB,CAAC,MAAc,EAAE,UAA8B,EAAE,EAAE,CACnD,CAAC,GAAkB,EAAE,GAAmB,EAAE,IAAwB,EAAE,EAAE;IACpE,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1B,OAAO,IAAI,EAAE,CAAA;IACf,CAAC;SAAM,CAAC;QACN,OAAO,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IACnC,CAAC;AACH,CAAC,CAAA;AARU,QAAA,UAAU,cAQpB"}
@@ -0,0 +1,5 @@
1
+ import { z } from "zod";
2
+ import { NextFunction } from "express";
3
+ import { MedusaRequest, MedusaResponse } from "../types";
4
+ export declare function validateAndTransformBody(zodSchema: z.ZodObject<any, any> | ((customSchema?: z.ZodOptional<z.ZodNullable<z.ZodObject<any, any>>>) => z.ZodObject<any, any> | z.ZodEffects<any, any>)): (req: MedusaRequest, res: MedusaResponse, next: NextFunction) => Promise<void>;
5
+ //# sourceMappingURL=validate-body.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-body.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGxD,wBAAgB,wBAAwB,CACtC,SAAS,EACL,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GACrB,CAAC,CACC,YAAY,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,KAC/D,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GACvD,CACD,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,IAAI,CAAC,CAoBjB"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAndTransformBody = validateAndTransformBody;
4
+ const zod_helpers_1 = require("../../zod/zod-helpers");
5
+ function validateAndTransformBody(zodSchema) {
6
+ return async function validateBody(req, _, next) {
7
+ try {
8
+ let schema;
9
+ if (typeof zodSchema === "function") {
10
+ schema = zodSchema(req.additionalDataValidator);
11
+ }
12
+ else {
13
+ schema = zodSchema;
14
+ }
15
+ req.validatedBody = await (0, zod_helpers_1.zodValidator)(schema, req.body);
16
+ next();
17
+ }
18
+ catch (e) {
19
+ next(e);
20
+ }
21
+ };
22
+ }
23
+ //# sourceMappingURL=validate-body.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-body.js","sourceRoot":"","sources":["../../../src/http/utils/validate-body.ts"],"names":[],"mappings":";;AAKA,4DA8BC;AAhCD,uDAAoD;AAEpD,SAAgB,wBAAwB,CACtC,SAIwD;IAMxD,OAAO,KAAK,UAAU,YAAY,CAChC,GAAkB,EAClB,CAAiB,EACjB,IAAkB;QAElB,IAAI,CAAC;YACH,IAAI,MAAsD,CAAA;YAC1D,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;gBACpC,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAA;YACjD,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,SAAS,CAAA;YACpB,CAAC;YAED,GAAG,CAAC,aAAa,GAAG,MAAM,IAAA,0BAAY,EAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YACxD,IAAI,EAAE,CAAA;QACR,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,CAAC,CAAA;QACT,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { BaseEntity, QueryConfig } from "@8medusa/types";
2
+ import { NextFunction } from "express";
3
+ import { z } from "zod";
4
+ import { MedusaRequest, MedusaResponse } from "../types";
5
+ export declare function validateAndTransformQuery<TEntity extends BaseEntity>(zodSchema: z.ZodObject<any, any> | z.ZodEffects<any, any>, queryConfig: QueryConfig<TEntity>): (req: MedusaRequest, res: MedusaResponse, next: NextFunction) => Promise<void>;
6
+ //# sourceMappingURL=validate-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-query.d.ts","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAsB,MAAM,gBAAgB,CAAA;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAEtC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAiDxD,wBAAgB,yBAAyB,CAAC,OAAO,SAAS,UAAU,EAClE,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,EACzD,WAAW,EAAE,WAAW,CAAC,OAAO,CAAC,GAChC,CACD,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,cAAc,EACnB,IAAI,EAAE,YAAY,KACf,OAAO,CAAC,IAAI,CAAC,CAuCjB"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateAndTransformQuery = validateAndTransformQuery;
4
+ const utils_1 = require("@8medusa/utils");
5
+ const lodash_1 = require("lodash");
6
+ const zod_helpers_1 = require("../../zod/zod-helpers");
7
+ const get_query_config_1 = require("./get-query-config");
8
+ /**
9
+ * Normalize an input query, especially from array like query params to an array type
10
+ * e.g: /admin/orders/?fields[]=id,status,cart_id becomes { fields: ["id", "status", "cart_id"] }
11
+ *
12
+ * We only support up to 2 levels of depth for query params in order to have a somewhat readable query param, and limit possible performance issues
13
+ */
14
+ const normalizeQuery = (req) => {
15
+ return Object.entries(req.query).reduce((acc, [key, val]) => {
16
+ let normalizedValue = val;
17
+ if (Array.isArray(val) && val.length === 1 && typeof val[0] === "string") {
18
+ normalizedValue = val[0].split(",");
19
+ }
20
+ if (key.includes(".")) {
21
+ const [parent, child, ...others] = key.split(".");
22
+ if (others.length > 0) {
23
+ throw new utils_1.MedusaError(utils_1.MedusaError.Types.INVALID_ARGUMENT, `Key accessor more than 2 levels deep: ${key}`);
24
+ }
25
+ if (!acc[parent]) {
26
+ acc[parent] = {};
27
+ }
28
+ acc[parent] = {
29
+ ...acc[parent],
30
+ [child]: normalizedValue,
31
+ };
32
+ }
33
+ else {
34
+ acc[key] = normalizedValue;
35
+ }
36
+ return acc;
37
+ }, {});
38
+ };
39
+ /**
40
+ * Omit the non filterable config from the validated object
41
+ * @param obj
42
+ */
43
+ const getFilterableFields = (obj) => {
44
+ const result = (0, lodash_1.omit)(obj, ["limit", "offset", "fields", "order"]);
45
+ return (0, utils_1.removeUndefinedProperties)(result);
46
+ };
47
+ function validateAndTransformQuery(zodSchema, queryConfig) {
48
+ return async function validateQuery(req, _, next) {
49
+ try {
50
+ const restricted = req.restrictedFields?.list();
51
+ const allowed = queryConfig.allowed ?? [];
52
+ // If any custom allowed fields are set, we add them to the allowed list along side the one configured in the query config if any
53
+ if (req.allowed?.length) {
54
+ allowed.push(...req.allowed);
55
+ }
56
+ delete req.allowed;
57
+ const query = normalizeQuery(req);
58
+ const validated = await (0, zod_helpers_1.zodValidator)(zodSchema, query);
59
+ const cnf = queryConfig.isList
60
+ ? (0, get_query_config_1.prepareListQuery)(validated, { ...queryConfig, allowed, restricted })
61
+ : (0, get_query_config_1.prepareRetrieveQuery)(validated, {
62
+ ...queryConfig,
63
+ allowed,
64
+ restricted,
65
+ });
66
+ req.validatedQuery = validated;
67
+ req.filterableFields = getFilterableFields(req.validatedQuery);
68
+ req.queryConfig = cnf.remoteQueryConfig;
69
+ req.remoteQueryConfig = req.queryConfig;
70
+ req.listConfig = cnf.listConfig;
71
+ req.retrieveConfig = cnf.retrieveConfig;
72
+ next();
73
+ }
74
+ catch (e) {
75
+ next(e);
76
+ }
77
+ };
78
+ }
79
+ //# sourceMappingURL=validate-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-query.js","sourceRoot":"","sources":["../../../src/http/utils/validate-query.ts"],"names":[],"mappings":";;AAwDA,8DA8CC;AArGD,0CAAuE;AAEvE,mCAA6B;AAG7B,uDAAoD;AAEpD,yDAA2E;AAE3E;;;;;GAKG;AACH,MAAM,cAAc,GAAG,CAAC,GAAkB,EAAE,EAAE;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE;QAC1D,IAAI,eAAe,GAAG,GAAG,CAAA;QACzB,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE,CAAC;YACzE,eAAe,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACrC,CAAC;QAED,IAAI,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACjD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACtB,MAAM,IAAI,mBAAW,CACnB,mBAAW,CAAC,KAAK,CAAC,gBAAgB,EAClC,yCAAyC,GAAG,EAAE,CAC/C,CAAA;YACH,CAAC;YAED,IAAI,CAAC,GAAG,CAAC,MA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,CAAC,MAAM;gBAC5B,CAAC,CAAC,IAAA,mCAAgB,EAAC,SAAS,EAAE,EAAE,GAAG,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;gBACtE,CAAC,CAAC,IAAA,uCAAoB,EAAC,SAAS,EAAE;oBAC9B,GAAG,WAAW;oBACd,OAAO;oBACP,UAAU;iBACX,CAAC,CAAA;YAEN,GAAG,CAAC,cAAc,GAAG,SAAS,CAAA;YAC9B,GAAG,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;YAC9D,GAAG,CAAC,WAAW,GAAG,GAAG,CAAC,iBAAwB,CAAA;YAC9C,GAAG,CAAC,iBAAiB,GAAG,GAAG,CAAC,WAAW,CAAA;YACvC,GAAG,CAAC,UAAU,GAAI,GAAW,CAAC,UAAU,CAAA;YACxC,GAAG,CAAC,cAAc,GAAI,GAAW,CAAC,cAAc,CAAA;YAEhD,IAAI,EAAE,CAAA;QACR,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,CAAC,CAAC,CAAA;QACT,CAAC;IACH,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { MiddlewareFunction, RouteHandler } from "../types";
2
+ export declare const wrapHandler: <T extends RouteHandler | MiddlewareFunction>(fn: T) => T;
3
+ //# sourceMappingURL=wrap-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-handler.d.ts","sourceRoot":"","sources":["../../../src/http/utils/wrap-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,kBAAkB,EAClB,YAAY,EACb,MAAM,UAAU,CAAA;AAEjB,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,YAAY,GAAG,kBAAkB,MACjE,CAAC,KA0BoB,CAC1B,CAAA"}