@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,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@8medusa/modules-sdk"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules-sdk/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC"}
@@ -0,0 +1,2 @@
1
+ export * from "@8medusa/orchestration";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@8medusa/orchestration"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/orchestration/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yDAAsC"}
@@ -0,0 +1,3 @@
1
+ export * from "./subscriber-loader";
2
+ export * from "./types";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/subscribers/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./subscriber-loader"), exports);
18
+ __exportStar(require("./types"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/subscribers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC;AACnC,0CAAuB"}
@@ -0,0 +1,12 @@
1
+ import { ResourceLoader } from "../utils/resource-loader";
2
+ export declare class SubscriberLoader extends ResourceLoader {
3
+ #private;
4
+ protected resourceName: string;
5
+ constructor(sourceDir: string | string[], options?: Record<string, unknown>);
6
+ protected onFileLoaded(path: string, fileExports: Record<string, unknown>): Promise<void>;
7
+ private validateSubscriber;
8
+ private inferIdentifier;
9
+ private createSubscriber;
10
+ load(): Promise<string[]>;
11
+ }
12
+ //# sourceMappingURL=subscriber-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber-loader.d.ts","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AASzD,qBAAa,gBAAiB,SAAQ,cAAc;;IAClD,SAAS,CAAC,YAAY,SAAe;gBAenC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;cAMvB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAgBtC,OAAO,CAAC,kBAAkB;IA4D1B,OAAO,CAAC,eAAe;IA4BvB,OAAO,CAAC,gBAAgB;IAmClB,IAAI;CAsBX"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _SubscriberLoader_pluginOptions, _SubscriberLoader_subscriberDescriptors;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SubscriberLoader = void 0;
16
+ const utils_1 = require("@8medusa/utils");
17
+ const path_1 = require("path");
18
+ const config_1 = require("../config");
19
+ const container_1 = require("../container");
20
+ const logger_1 = require("../logger");
21
+ const resource_loader_1 = require("../utils/resource-loader");
22
+ class SubscriberLoader extends resource_loader_1.ResourceLoader {
23
+ constructor(sourceDir, options = {}) {
24
+ super(sourceDir);
25
+ this.resourceName = "subscriber";
26
+ /**
27
+ * The options of the plugin from which the subscribers are being loaded
28
+ * @private
29
+ */
30
+ _SubscriberLoader_pluginOptions.set(this, void 0);
31
+ /**
32
+ * Map of subscribers descriptors to consume in the loader
33
+ * @private
34
+ */
35
+ _SubscriberLoader_subscriberDescriptors.set(this, new Map());
36
+ __classPrivateFieldSet(this, _SubscriberLoader_pluginOptions, options, "f");
37
+ }
38
+ async onFileLoaded(path, fileExports) {
39
+ const isValid = this.validateSubscriber(fileExports, path);
40
+ logger_1.logger.debug(`Registering subscribers from ${path}.`);
41
+ if (!isValid) {
42
+ return;
43
+ }
44
+ __classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").set(path, {
45
+ config: fileExports.config,
46
+ handler: fileExports.default,
47
+ });
48
+ }
49
+ validateSubscriber(subscriber, path) {
50
+ const handler = subscriber.default;
51
+ if (!handler || typeof handler !== "function") {
52
+ /**
53
+ * If the handler is not a function, we can't use it
54
+ */
55
+ logger_1.logger.warn(`The subscriber in ${path} is not a function. skipped.`);
56
+ return false;
57
+ }
58
+ const config = subscriber.config;
59
+ if (!config) {
60
+ /**
61
+ * If the subscriber is missing a config, we can't use it
62
+ */
63
+ logger_1.logger.warn(`The subscriber in ${path} is missing a config. skipped.`);
64
+ return false;
65
+ }
66
+ if (!config.event) {
67
+ /**
68
+ * If the subscriber is missing an event, we can't use it.
69
+ * In production we throw an error, else we log a warning
70
+ */
71
+ if (config_1.configManager.isProduction) {
72
+ throw new Error(`The subscriber in ${path} is missing an event in the config.`);
73
+ }
74
+ else {
75
+ logger_1.logger.warn(`The subscriber in ${path} is missing an event in the config. skipped.`);
76
+ }
77
+ return false;
78
+ }
79
+ const events = Array.isArray(config.event) ? config.event : [config.event];
80
+ if (events.some((e) => !(typeof e === "string"))) {
81
+ /**
82
+ * If the subscribers event is not a string or an array of strings, we can't use it
83
+ */
84
+ logger_1.logger.warn(`The subscriber in ${path} has an invalid event config. The event must be a string or an array of strings. skipped.`);
85
+ return false;
86
+ }
87
+ return true;
88
+ }
89
+ inferIdentifier(fileName, { context }, handler) {
90
+ /**
91
+ * If subscriberId is provided, use that
92
+ */
93
+ if (context?.subscriberId) {
94
+ return context.subscriberId;
95
+ }
96
+ const handlerName = handler.name;
97
+ /**
98
+ * If the handler is not anonymous, use the name
99
+ */
100
+ if (handlerName && !handlerName.startsWith("_default")) {
101
+ return (0, utils_1.kebabCase)(handlerName);
102
+ }
103
+ /**
104
+ * If the handler is anonymous, use the file name
105
+ */
106
+ const idFromFile = (0, path_1.parse)(fileName).name;
107
+ return (0, utils_1.kebabCase)(idFromFile);
108
+ }
109
+ createSubscriber({ fileName, config, handler, }) {
110
+ const eventBusService = container_1.container.resolve(utils_1.Modules.EVENT_BUS);
111
+ const { event } = config;
112
+ const events = Array.isArray(event) ? event : [event];
113
+ const subscriberId = this.inferIdentifier(fileName, config, handler);
114
+ for (const e of events) {
115
+ const subscriber = async (data) => {
116
+ return await handler({
117
+ event: { name: e, ...data },
118
+ container: container_1.container,
119
+ pluginOptions: __classPrivateFieldGet(this, _SubscriberLoader_pluginOptions, "f"),
120
+ });
121
+ };
122
+ eventBusService.subscribe(e, subscriber, {
123
+ ...config.context,
124
+ subscriberId,
125
+ });
126
+ }
127
+ }
128
+ async load() {
129
+ await super.discoverResources();
130
+ for (const [fileName, { config, handler },] of __classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").entries()) {
131
+ this.createSubscriber({
132
+ fileName,
133
+ config,
134
+ handler,
135
+ });
136
+ }
137
+ logger_1.logger.debug(`Subscribers registered.`);
138
+ /**
139
+ * Return the file paths of the registered subscribers, to prevent the
140
+ * backwards compatible loader from trying to register them.
141
+ */
142
+ return [...__classPrivateFieldGet(this, _SubscriberLoader_subscriberDescriptors, "f").keys()];
143
+ }
144
+ }
145
+ exports.SubscriberLoader = SubscriberLoader;
146
+ _SubscriberLoader_pluginOptions = new WeakMap(), _SubscriberLoader_subscriberDescriptors = new WeakMap();
147
+ //# sourceMappingURL=subscriber-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber-loader.js","sourceRoot":"","sources":["../../src/subscribers/subscriber-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,0CAAmD;AACnD,+BAA4B;AAE5B,sCAAyC;AACzC,4CAAwC;AACxC,sCAAkC;AAElC,8DAAyD;AASzD,MAAa,gBAAiB,SAAQ,gCAAc;IAelD,YACE,SAA4B,EAC5B,UAAmC,EAAE;QAErC,KAAK,CAAC,SAAS,CAAC,CAAA;QAlBR,iBAAY,GAAG,YAAY,CAAA;QAErC;;;WAGG;QACH,kDAAuC;QAEvC;;;WAGG;QACH,kDAA6D,IAAI,GAAG,EAAE,EAAA;QAOpE,uBAAA,IAAI,mCAAkB,OAAO,MAAA,CAAA;IAC/B,CAAC;IAES,KAAK,CAAC,Y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,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;QAEpE,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,UAAU,GAAG,KAAK,EAAE,IAAO,EAAE,EAAE;gBACnC,OAAO,MAAM,OAAO,CAAC;oBACnB,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAyB;oBAClD,SAAS,EAAT,qBAAS;oBACT,aAAa,EAAE,uBAAA,IAAI,uCAAe;iBACnC,CAAC,CAAA;YACJ,CAAC,CAAA;YAED,eAAe,CAAC,SAAS,CAAC,CAAC,EAAE,UAAwB,EAAE;gBACrD,GAAG,MAAM,CAAC,OAAO;gBACjB,YAAY;aACb,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAE/B,KAAK,MAAM,CACT,QAAQ,EACR,EAAE,MAAM,EAAE,OAAO,EAAE,EACpB,IAAI,uBAAA,IAAI,+CAAuB,CAAC,OAAO,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,gBAAgB,CAAC;gBACpB,QAAQ;gBACR,MAAM;gBACN,OAAO;aACR,CAAC,CAAA;QACJ,CAAC;QAED,eAAM,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAA;QAEvC;;;WAGG;QACH,OAAO,CAAC,GAAG,uBAAA,IAAI,+CAAuB,CAAC,IAAI,EAAE,CAAC,CAAA;IAChD,CAAC;CACF;AA1LD,4CA0LC"}
@@ -0,0 +1,15 @@
1
+ import { Event, MedusaContainer } from "@8medusa/types";
2
+ interface SubscriberContext extends Record<string, unknown> {
3
+ subscriberId?: string;
4
+ }
5
+ export type SubscriberConfig = {
6
+ event: string | string[];
7
+ context?: SubscriberContext;
8
+ };
9
+ export type SubscriberArgs<T = unknown> = {
10
+ event: Event<T>;
11
+ container: MedusaContainer;
12
+ pluginOptions: Record<string, unknown>;
13
+ };
14
+ export {};
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/subscribers/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAEvD,UAAU,iBAAkB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACzD,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;IACxB,OAAO,CAAC,EAAE,iBAAiB,CAAA;CAC5B,CAAA;AAED,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACf,SAAS,EAAE,eAAe,CAAA;IAC1B,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvC,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/subscribers/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { Tracer as OTTracer, Span } from "@opentelemetry/api";
2
+ /**
3
+ * Tracer creates an instrumentation scope within the application
4
+ * code. For example: You might create a tracer for the API
5
+ * requests, another one for the modules, one for workflows
6
+ * and so on.
7
+ *
8
+ * There is no need to create a Tracer instance per HTTP
9
+ * call.
10
+ */
11
+ export declare class Tracer {
12
+ #private;
13
+ name: string;
14
+ version?: string | undefined;
15
+ constructor(name: string, version?: string | undefined);
16
+ /**
17
+ * Returns the underlying tracer from open telemetry that
18
+ * could be used directly for certain advanced use-cases
19
+ */
20
+ getOTTracer(): OTTracer;
21
+ /**
22
+ * Trace a function call. Using this method will create a
23
+ * child scope for the invocations within the callback.
24
+ */
25
+ trace<F extends (span: Span) => unknown>(name: string, callback: F): ReturnType<F>;
26
+ /**
27
+ * Returns the active context
28
+ */
29
+ getActiveContext(): import("@opentelemetry/api").Context;
30
+ /**
31
+ * Returns the propagation state from the current active
32
+ * context
33
+ */
34
+ getPropagationState(): {
35
+ traceparent: string;
36
+ tracestate?: string;
37
+ };
38
+ /**
39
+ * Use the existing propogation state and trace an action. This
40
+ * will allow the newly traced action to be part of some
41
+ * existing trace
42
+ */
43
+ withPropagationState(state: {
44
+ traceparent: string;
45
+ tracestate?: string;
46
+ }): {
47
+ trace: <F extends (span: Span) => unknown>(name: string, callback: F) => ReturnType<F>;
48
+ };
49
+ }
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,IAAI,QAAQ,EAClB,IAAI,EAIL,MAAM,oBAAoB,CAAA;AAE3B;;;;;;;;GAQG;AACH,qBAAa,MAAM;;IAKE,IAAI,EAAE,MAAM;IAAS,OAAO,CAAC,EAAE,MAAM;gBAArC,IAAI,EAAE,MAAM,EAAS,OAAO,CAAC,EAAE,MAAM,YAAA;IAIxD;;;OAGG;IACH,WAAW;IAIX;;;OAGG;IACH,KAAK,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,EACrC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,GACV,UAAU,CAAC,CAAC,CAAC;IAIhB;;OAEG;IACH,gBAAgB;IAIhB;;;OAGG;IACH,mBAAmB,IAGA;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAG/D;;;;OAIG;IACH,oBAAoB,CAAC,KAAK,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;gBAE5D,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,QACjC,MAAM,YACF,CAAC,KACV,UAAU,CAAC,CAAC,CAAC;;CAMrB"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ 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");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var _Tracer_otTracer;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Tracer = void 0;
16
+ const api_1 = require("@opentelemetry/api");
17
+ /**
18
+ * Tracer creates an instrumentation scope within the application
19
+ * code. For example: You might create a tracer for the API
20
+ * requests, another one for the modules, one for workflows
21
+ * and so on.
22
+ *
23
+ * There is no need to create a Tracer instance per HTTP
24
+ * call.
25
+ */
26
+ class Tracer {
27
+ constructor(name, version) {
28
+ this.name = name;
29
+ this.version = version;
30
+ /**
31
+ * Reference to the underlying OpenTelemetry tracer
32
+ */
33
+ _Tracer_otTracer.set(this, void 0);
34
+ __classPrivateFieldSet(this, _Tracer_otTracer, api_1.trace.getTracer(name, version), "f");
35
+ }
36
+ /**
37
+ * Returns the underlying tracer from open telemetry that
38
+ * could be used directly for certain advanced use-cases
39
+ */
40
+ getOTTracer() {
41
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f");
42
+ }
43
+ /**
44
+ * Trace a function call. Using this method will create a
45
+ * child scope for the invocations within the callback.
46
+ */
47
+ trace(name, callback) {
48
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f").startActiveSpan(name, callback);
49
+ }
50
+ /**
51
+ * Returns the active context
52
+ */
53
+ getActiveContext() {
54
+ return api_1.context.active();
55
+ }
56
+ /**
57
+ * Returns the propagation state from the current active
58
+ * context
59
+ */
60
+ getPropagationState() {
61
+ let output = {};
62
+ api_1.propagation.inject(api_1.context.active(), output);
63
+ return output;
64
+ }
65
+ /**
66
+ * Use the existing propogation state and trace an action. This
67
+ * will allow the newly traced action to be part of some
68
+ * existing trace
69
+ */
70
+ withPropagationState(state) {
71
+ return {
72
+ trace: (name, callback) => {
73
+ const activeContext = api_1.propagation.extract(api_1.context.active(), state);
74
+ return __classPrivateFieldGet(this, _Tracer_otTracer, "f").startActiveSpan(name, {}, activeContext, callback);
75
+ },
76
+ };
77
+ }
78
+ }
79
+ exports.Tracer = Tracer;
80
+ _Tracer_otTracer = new WeakMap();
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/telemetry/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,4CAM2B;AAE3B;;;;;;;;GAQG;AACH,MAAa,MAAM;IAKjB,YAAmB,IAAY,EAAS,OAAgB;QAArC,SAAI,GAAJ,IAAI,CAAQ;QAAS,YAAO,GAAP,OAAO,CAAS;QAJxD;;WAEG;QACH,mCAAmB;QAEjB,uBAAA,IAAI,oBAAa,WAAK,CAAC,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,MAAA,CAAA;IACjD,CAAC;IAED;;;OAGG;IACH,WAAW;QACT,OAAO,uBAAA,IAAI,wBAAU,CAAA;IACvB,CAAC;IAED;;;OAGG;IACH,KAAK,CACH,IAAY,EACZ,QAAW;QAEX,OAAO,uBAAA,IAAI,wBAAU,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;IACvD,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,aAAO,CAAC,MAAM,EAAE,CAAA;IACzB,CAAC;IAED;;;OAGG;IACH,mBAAmB;QACjB,IAAI,MAAM,GAAG,EAAE,CAAA;QACf,iBAAW,CAAC,MAAM,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,MAAM,CAAC,CAAA;QAC5C,OAAO,MAAsD,CAAA;IAC/D,CAAC;IAED;;;;OAIG;IACH,oBAAoB,CAAC,KAAmD;QACtE,OAAO;YACL,KAAK,EAAE,CACL,IAAY,EACZ,QAAW,EACI,EAAE;gBACjB,MAAM,aAAa,GAAG,iBAAW,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,CAAA;gBAClE,OAAO,uBAAA,IAAI,wBAAU,CAAC,eAAe,CAAC,IAAI,EAAE,EAAE,EAAE,aAAa,EAAE,QAAQ,CAAC,CAAA;YAC1E,CAAC;SACF,CAAA;IACH,CAAC;CACF;AA7DD,wBA6DC"}
@@ -0,0 +1,62 @@
1
+ import { Link } from "@8medusa/modules-sdk";
2
+ import { ConfigModule, IApiKeyModuleService, IAuthModuleService, ICacheService, ICartModuleService, ICurrencyModuleService, ICustomerModuleService, IEventBusModuleService, IFileModuleService, IFulfillmentModuleService, IInventoryService, ILockingModule, INotificationModuleService, IOrderModuleService, IPaymentModuleService, IPricingModuleService, IProductModuleService, IPromotionModuleService, IRegionModuleService, ISalesChannelModuleService, IStockLocationService, IStoreModuleService, ITaxModuleService, IUserModuleService, IWorkflowEngineService, Logger, ModuleImplementations, RemoteQueryFunction } from "@8medusa/types";
3
+ import { ContainerRegistrationKeys, Modules } from "@8medusa/utils";
4
+ import { Knex } from "@mikro-orm/knex";
5
+ import { AwilixContainer, ResolveOptions } from "awilix";
6
+ declare module "@8medusa/types" {
7
+ interface ModuleImplementations {
8
+ /**
9
+ * @deprecated use {@link ContainerRegistrationKeys.LINK} instead.
10
+ */
11
+ [ContainerRegistrationKeys.REMOTE_LINK]: Link;
12
+ /**
13
+ * @version 2.2.0
14
+ */
15
+ [ContainerRegistrationKeys.LINK]: Link;
16
+ [ContainerRegistrationKeys.CONFIG_MODULE]: ConfigModule;
17
+ [ContainerRegistrationKeys.PG_CONNECTION]: Knex<any>;
18
+ [ContainerRegistrationKeys.REMOTE_QUERY]: RemoteQueryFunction;
19
+ [ContainerRegistrationKeys.QUERY]: Omit<RemoteQueryFunction, symbol>;
20
+ [ContainerRegistrationKeys.LOGGER]: Logger;
21
+ [Modules.AUTH]: IAuthModuleService;
22
+ [Modules.CACHE]: ICacheService;
23
+ [Modules.CART]: ICartModuleService;
24
+ [Modules.CUSTOMER]: ICustomerModuleService;
25
+ [Modules.EVENT_BUS]: IEventBusModuleService;
26
+ [Modules.INVENTORY]: IInventoryService;
27
+ [Modules.PAYMENT]: IPaymentModuleService;
28
+ [Modules.PRICING]: IPricingModuleService;
29
+ [Modules.PRODUCT]: IProductModuleService;
30
+ [Modules.PROMOTION]: IPromotionModuleService;
31
+ [Modules.SALES_CHANNEL]: ISalesChannelModuleService;
32
+ [Modules.TAX]: ITaxModuleService;
33
+ [Modules.FULFILLMENT]: IFulfillmentModuleService;
34
+ [Modules.STOCK_LOCATION]: IStockLocationService;
35
+ [Modules.USER]: IUserModuleService;
36
+ [Modules.WORKFLOW_ENGINE]: IWorkflowEngineService;
37
+ [Modules.REGION]: IRegionModuleService;
38
+ [Modules.ORDER]: IOrderModuleService;
39
+ [Modules.API_KEY]: IApiKeyModuleService;
40
+ [Modules.STORE]: IStoreModuleService;
41
+ [Modules.CURRENCY]: ICurrencyModuleService;
42
+ [Modules.FILE]: IFileModuleService;
43
+ [Modules.NOTIFICATION]: INotificationModuleService;
44
+ [Modules.LOCKING]: ILockingModule;
45
+ }
46
+ }
47
+ export type MedusaContainer<Cradle extends object = ModuleImplementations> = Omit<AwilixContainer, "resolve"> & {
48
+ resolve<K extends keyof Cradle>(key: K, resolveOptions?: ResolveOptions): Cradle[K];
49
+ resolve<T>(key: string, resolveOptions?: ResolveOptions): T;
50
+ /**
51
+ * @ignore
52
+ */
53
+ registerAdd: <T>(name: string, registration: T) => MedusaContainer;
54
+ /**
55
+ * @ignore
56
+ */
57
+ createScope: () => MedusaContainer;
58
+ };
59
+ export type ContainerLike = {
60
+ resolve<T = unknown>(key: string): T;
61
+ };
62
+ //# sourceMappingURL=container.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,kBAAkB,EAClB,aAAa,EACb,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,cAAc,EACd,0BAA0B,EAC1B,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,EACN,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,yBAAyB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAA;AAExD,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,UAAiB,qBAAqB;QACpC;;WAEG;QACH,CAAC,yBAAyB,CAAC,WAAW,CAAC,EAAE,IAAI,CAAA;QAC7C;;WAEG;QACH,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,IAAI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"version":3,"file":"container.js","sourceRoot":"","sources":["../../src/types/container.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "@8medusa/types";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("@8medusa/types"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
@@ -0,0 +1,3 @@
1
+ import "../types/container";
2
+ export * from "@8medusa/utils";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAA;AAE3B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ require("../types/container");
18
+ __exportStar(require("@8medusa/utils"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8BAA2B;AAE3B,iDAA8B"}
@@ -0,0 +1,26 @@
1
+ import { Dirent } from "fs";
2
+ export declare abstract class ResourceLoader {
3
+ #private;
4
+ /**
5
+ * The name of the resource (e.g job, subscriber, workflow)
6
+ */
7
+ protected abstract resourceName: string;
8
+ constructor(sourceDir: string | string[]);
9
+ /**
10
+ * Discover resources from the source directory
11
+ * @param exclude - custom exclusion regexes
12
+ * @param customFiltering - custom filtering function
13
+ * @returns The resources discovered
14
+ */
15
+ protected discoverResources({ exclude, customFiltering, }?: {
16
+ exclude?: RegExp[];
17
+ customFiltering?: (entry: Dirent) => boolean;
18
+ }): Promise<Record<string, unknown>[]>;
19
+ /**
20
+ * Called when a file is imported
21
+ * @param path - The path of the file
22
+ * @param fileExports - The exports of the file
23
+ */
24
+ protected abstract onFileLoaded(path: string, fileExports: Record<string, unknown>): Promise<void> | never;
25
+ }
26
+ //# sourceMappingURL=resource-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource-loader.d.ts","sourceRoot":"","sources":["../../src/utils/resource-loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAA;AAK3B,8BAAsB,cAAc;;IAClC;;OAEG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;gBAc3B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE;IAIxC;;;;;OAKG;cACa,iBAAiB,CAAC,EAChC,OAAO,EACP,eAAe,GAChB,GAAE;QACD,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;QAClB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAA;KACxC,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC;IAmD3C;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,YAAY,CAC7B,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACnC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK;CACzB"}