@medusajs/framework 0.0.2-snapshot-20240821132459 → 0.0.2-snapshot-20240821152538

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. package/dist/config/__fixtures__/medusa-config-2.d.ts +3 -0
  2. package/dist/config/__fixtures__/medusa-config-2.d.ts.map +1 -0
  3. package/dist/config/__fixtures__/medusa-config-2.js +8 -0
  4. package/dist/config/__fixtures__/medusa-config.d.ts +3 -0
  5. package/dist/config/__fixtures__/medusa-config.d.ts.map +1 -0
  6. package/dist/config/__fixtures__/medusa-config.js +4 -0
  7. package/dist/config/__tests__/index.spec.d.ts +2 -0
  8. package/dist/config/__tests__/index.spec.d.ts.map +1 -0
  9. package/dist/config/__tests__/index.spec.js +28 -0
  10. package/dist/config/types.d.ts +120 -58
  11. package/dist/config/types.d.ts.map +1 -1
  12. package/dist/feature-flags/__tests__/feature-flags.spec.d.ts +2 -0
  13. package/dist/feature-flags/__tests__/feature-flags.spec.d.ts.map +1 -0
  14. package/dist/feature-flags/__tests__/feature-flags.spec.js +82 -0
  15. package/dist/http/__fixtures__/mocks/index.d.ts +7 -0
  16. package/dist/http/__fixtures__/mocks/index.d.ts.map +1 -0
  17. package/dist/http/__fixtures__/mocks/index.js +20 -0
  18. package/dist/http/__fixtures__/routers/_private/route.d.ts +3 -0
  19. package/dist/http/__fixtures__/routers/_private/route.d.ts.map +1 -0
  20. package/dist/http/__fixtures__/routers/_private/route.js +7 -0
  21. package/dist/http/__fixtures__/routers/admin/orders/[id]/route.d.ts +4 -0
  22. package/dist/http/__fixtures__/routers/admin/orders/[id]/route.d.ts.map +1 -0
  23. package/dist/http/__fixtures__/routers/admin/orders/[id]/route.js +21 -0
  24. package/dist/http/__fixtures__/routers/admin/orders/route.d.ts +3 -0
  25. package/dist/http/__fixtures__/routers/admin/orders/route.d.ts.map +1 -0
  26. package/dist/http/__fixtures__/routers/admin/orders/route.js +7 -0
  27. package/dist/http/__fixtures__/routers/admin/products/[id]/route.d.ts +3 -0
  28. package/dist/http/__fixtures__/routers/admin/products/[id]/route.d.ts.map +1 -0
  29. package/dist/http/__fixtures__/routers/admin/products/[id]/route.js +7 -0
  30. package/dist/http/__fixtures__/routers/admin/products/route.d.ts +9 -0
  31. package/dist/http/__fixtures__/routers/admin/products/route.d.ts.map +1 -0
  32. package/dist/http/__fixtures__/routers/admin/products/route.js +31 -0
  33. package/dist/http/__fixtures__/routers/admin/route.d.ts +4 -0
  34. package/dist/http/__fixtures__/routers/admin/route.d.ts.map +1 -0
  35. package/dist/http/__fixtures__/routers/admin/route.js +11 -0
  36. package/dist/http/__fixtures__/routers/customers/[customer_id]/orders/[order_id]/route.d.ts +3 -0
  37. package/dist/http/__fixtures__/routers/customers/[customer_id]/orders/[order_id]/route.d.ts.map +1 -0
  38. package/dist/http/__fixtures__/routers/customers/[customer_id]/orders/[order_id]/route.js +9 -0
  39. package/dist/http/__fixtures__/routers/customers/route.d.ts +3 -0
  40. package/dist/http/__fixtures__/routers/customers/route.d.ts.map +1 -0
  41. package/dist/http/__fixtures__/routers/customers/route.js +7 -0
  42. package/dist/http/__fixtures__/routers-duplicate-parameter/admin/customers/[id]/orders/[id]/route.d.ts +4 -0
  43. package/dist/http/__fixtures__/routers-duplicate-parameter/admin/customers/[id]/orders/[id]/route.d.ts.map +1 -0
  44. package/dist/http/__fixtures__/routers-duplicate-parameter/admin/customers/[id]/orders/[id]/route.js +11 -0
  45. package/dist/http/__fixtures__/routers-error-handler/middlewares.d.ts +3 -0
  46. package/dist/http/__fixtures__/routers-error-handler/middlewares.d.ts.map +1 -0
  47. package/dist/http/__fixtures__/routers-error-handler/middlewares.js +39 -0
  48. package/dist/http/__fixtures__/routers-error-handler/store/route.d.ts +5 -0
  49. package/dist/http/__fixtures__/routers-error-handler/store/route.d.ts.map +1 -0
  50. package/dist/http/__fixtures__/routers-error-handler/store/route.js +31 -0
  51. package/dist/http/__fixtures__/routers-middleware/admin/protected/route.d.ts +3 -0
  52. package/dist/http/__fixtures__/routers-middleware/admin/protected/route.d.ts.map +1 -0
  53. package/dist/http/__fixtures__/routers-middleware/admin/protected/route.js +7 -0
  54. package/dist/http/__fixtures__/routers-middleware/admin/unprotected/route.d.ts +4 -0
  55. package/dist/http/__fixtures__/routers-middleware/admin/unprotected/route.d.ts.map +1 -0
  56. package/dist/http/__fixtures__/routers-middleware/admin/unprotected/route.js +8 -0
  57. package/dist/http/__fixtures__/routers-middleware/customers/error/route.d.ts +3 -0
  58. package/dist/http/__fixtures__/routers-middleware/customers/error/route.d.ts.map +1 -0
  59. package/dist/http/__fixtures__/routers-middleware/customers/error/route.js +8 -0
  60. package/dist/http/__fixtures__/routers-middleware/customers/route.d.ts +4 -0
  61. package/dist/http/__fixtures__/routers-middleware/customers/route.d.ts.map +1 -0
  62. package/dist/http/__fixtures__/routers-middleware/customers/route.js +11 -0
  63. package/dist/http/__fixtures__/routers-middleware/middlewares.d.ts +3 -0
  64. package/dist/http/__fixtures__/routers-middleware/middlewares.d.ts.map +1 -0
  65. package/dist/http/__fixtures__/routers-middleware/middlewares.js +38 -0
  66. package/dist/http/__fixtures__/routers-middleware/store/customers/me/protected/route.d.ts +3 -0
  67. package/dist/http/__fixtures__/routers-middleware/store/customers/me/protected/route.d.ts.map +1 -0
  68. package/dist/http/__fixtures__/routers-middleware/store/customers/me/protected/route.js +7 -0
  69. package/dist/http/__fixtures__/routers-middleware/store/customers/me/unprotected/route.d.ts +4 -0
  70. package/dist/http/__fixtures__/routers-middleware/store/customers/me/unprotected/route.d.ts.map +1 -0
  71. package/dist/http/__fixtures__/routers-middleware/store/customers/me/unprotected/route.js +8 -0
  72. package/dist/http/__fixtures__/routers-middleware/store/products/[id]/sync/route.d.ts +3 -0
  73. package/dist/http/__fixtures__/routers-middleware/store/products/[id]/sync/route.d.ts.map +1 -0
  74. package/dist/http/__fixtures__/routers-middleware/store/products/[id]/sync/route.js +7 -0
  75. package/dist/http/__fixtures__/routers-middleware/webhooks/payment/route.d.ts +3 -0
  76. package/dist/http/__fixtures__/routers-middleware/webhooks/payment/route.d.ts.map +1 -0
  77. package/dist/http/__fixtures__/routers-middleware/webhooks/payment/route.js +10 -0
  78. package/dist/http/__fixtures__/server/index.d.ts +9 -0
  79. package/dist/http/__fixtures__/server/index.d.ts.map +1 -0
  80. package/dist/http/__fixtures__/server/index.js +142 -0
  81. package/dist/http/__tests__/index.spec.d.ts +2 -0
  82. package/dist/http/__tests__/index.spec.d.ts.map +1 -0
  83. package/dist/http/__tests__/index.spec.js +182 -0
  84. package/dist/jobs/__fixtures__/mock-scheduler-storage.d.ts +9 -0
  85. package/dist/jobs/__fixtures__/mock-scheduler-storage.d.ts.map +1 -0
  86. package/dist/jobs/__fixtures__/mock-scheduler-storage.js +15 -0
  87. package/dist/jobs/__fixtures__/plugin/jobs/order-summary.d.ts +8 -0
  88. package/dist/jobs/__fixtures__/plugin/jobs/order-summary.d.ts.map +1 -0
  89. package/dist/jobs/__fixtures__/plugin/jobs/order-summary.js +12 -0
  90. package/dist/jobs/__tests__/register-jobs.spec.d.ts +2 -0
  91. package/dist/jobs/__tests__/register-jobs.spec.d.ts.map +1 -0
  92. package/dist/jobs/__tests__/register-jobs.spec.js +22 -0
  93. package/dist/links/__fixtures__/links/link.d.ts +2 -0
  94. package/dist/links/__fixtures__/links/link.d.ts.map +1 -0
  95. package/dist/links/__fixtures__/links/link.js +19 -0
  96. package/dist/links/__fixtures__/links/sub-links/link.d.ts +2 -0
  97. package/dist/links/__fixtures__/links/sub-links/link.d.ts.map +1 -0
  98. package/dist/links/__fixtures__/links/sub-links/link.js +19 -0
  99. package/dist/links/__tests__/index.spec.d.ts +2 -0
  100. package/dist/links/__tests__/index.spec.d.ts.map +1 -0
  101. package/dist/links/__tests__/index.spec.js +15 -0
  102. package/dist/subscribers/__fixtures__/subscribers/order-notifier.d.ts +4 -0
  103. package/dist/subscribers/__fixtures__/subscribers/order-notifier.d.ts.map +1 -0
  104. package/dist/subscribers/__fixtures__/subscribers/order-notifier.js +11 -0
  105. package/dist/subscribers/__fixtures__/subscribers/product-updater.d.ts +4 -0
  106. package/dist/subscribers/__fixtures__/subscribers/product-updater.d.ts.map +1 -0
  107. package/dist/subscribers/__fixtures__/subscribers/product-updater.js +13 -0
  108. package/dist/subscribers/__fixtures__/subscribers/variant-created.d.ts +4 -0
  109. package/dist/subscribers/__fixtures__/subscribers/variant-created.d.ts.map +1 -0
  110. package/dist/subscribers/__fixtures__/subscribers/variant-created.js +10 -0
  111. package/dist/subscribers/__mocks__/index.d.ts +5 -0
  112. package/dist/subscribers/__mocks__/index.d.ts.map +1 -0
  113. package/dist/subscribers/__mocks__/index.js +8 -0
  114. package/dist/subscribers/__tests__/index.spec.d.ts +2 -0
  115. package/dist/subscribers/__tests__/index.spec.d.ts.map +1 -0
  116. package/dist/subscribers/__tests__/index.spec.js +81 -0
  117. package/dist/workflows/__fixtures__/workflows/deep-workflows/product-updater.d.ts +3 -0
  118. package/dist/workflows/__fixtures__/workflows/deep-workflows/product-updater.d.ts.map +1 -0
  119. package/dist/workflows/__fixtures__/workflows/deep-workflows/product-updater.js +12 -0
  120. package/dist/workflows/__fixtures__/workflows/order-notifier.d.ts +3 -0
  121. package/dist/workflows/__fixtures__/workflows/order-notifier.d.ts.map +1 -0
  122. package/dist/workflows/__fixtures__/workflows/order-notifier.js +12 -0
  123. package/dist/workflows/__tests__/index.spec.d.ts +2 -0
  124. package/dist/workflows/__tests__/index.spec.d.ts.map +1 -0
  125. package/dist/workflows/__tests__/index.spec.js +19 -0
  126. package/package.json +10 -10
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const __mocks__1 = require("../__mocks__");
5
+ const subscriber_loader_1 = require("../subscriber-loader");
6
+ const container_1 = require("../../container");
7
+ const utils_1 = require("@medusajs/utils");
8
+ const awilix_1 = require("awilix");
9
+ describe("SubscriberLoader", () => {
10
+ const rootDir = (0, path_1.join)(__dirname, "../__fixtures__", "subscribers");
11
+ const pluginOptions = {
12
+ important_data: {
13
+ enabled: true,
14
+ },
15
+ };
16
+ let registeredPaths = [];
17
+ beforeAll(async () => {
18
+ container_1.container.register(utils_1.ModuleRegistrationName.EVENT_BUS, (0, awilix_1.asValue)(__mocks__1.eventBusServiceMock));
19
+ const paths = await new subscriber_loader_1.SubscriberLoader(rootDir, pluginOptions).load();
20
+ if (paths) {
21
+ registeredPaths = [...registeredPaths, ...paths];
22
+ }
23
+ });
24
+ it("should register each subscriber in the '/subscribers' folder", async () => {
25
+ // As '/subscribers' contains 3 subscribers, we expect the number of registered paths to be 3
26
+ expect(registeredPaths.length).toEqual(3);
27
+ });
28
+ it("should have registered subscribers for 5 events", async () => {
29
+ /**
30
+ * The 'product-updater.ts' subscriber is registered for the following events:
31
+ * - "product.created"
32
+ * The 'order-updater.ts' subscriber is registered for the following events:
33
+ * - "order.placed"
34
+ * - "order.canceled"
35
+ * - "order.completed"
36
+ * The 'variant-created.ts' subscriber is registered for the following events:
37
+ * - "variant.created"
38
+ *
39
+ * This means that we expect the eventBusServiceMock.subscribe method to have
40
+ * been called times, once for 'product-updater.ts', once for 'variant-created.ts',
41
+ * and 3 times for 'order-updater.ts'.
42
+ */
43
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledTimes(5);
44
+ });
45
+ it("should have registered subscribers with the correct props", async () => {
46
+ /**
47
+ * The 'product-updater.ts' subscriber is registered
48
+ * with a explicit subscriberId of "product-updater".
49
+ */
50
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledWith("product.updated", expect.any(Function), {
51
+ subscriberId: "product-updater",
52
+ });
53
+ /**
54
+ * The 'order-updater.ts' subscriber is registered
55
+ * without an explicit subscriberId, which means that
56
+ * the loader tries to infer one from either the handler
57
+ * functions name or the file name. In this case, the
58
+ * handler function is named 'orderUpdater' and is used
59
+ * to infer the subscriberId.
60
+ */
61
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledWith("order.placed", expect.any(Function), {
62
+ subscriberId: "order-notifier",
63
+ });
64
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledWith("order.canceled", expect.any(Function), {
65
+ subscriberId: "order-notifier",
66
+ });
67
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledWith("order.completed", expect.any(Function), {
68
+ subscriberId: "order-notifier",
69
+ });
70
+ /**
71
+ * The 'variant-created.ts' subscriber is registered
72
+ * without an explicit subscriberId, and with an anonymous
73
+ * handler function. This means that the loader tries to
74
+ * infer the subscriberId from the file name, which in this
75
+ * case is 'variant-created.ts'.
76
+ */
77
+ expect(__mocks__1.eventBusServiceMock.subscribe).toHaveBeenCalledWith("variant.created", expect.any(Function), {
78
+ subscriberId: "variant-created",
79
+ });
80
+ });
81
+ });
@@ -0,0 +1,3 @@
1
+ export declare const productWorkflowId = "product-notifier-workflow";
2
+ export declare const productUpdatedWorkflow: import("@medusajs/workflows-sdk").ReturnWorkflow<unknown, undefined, []>;
3
+ //# sourceMappingURL=product-updater.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-updater.d.ts","sourceRoot":"","sources":["../../../../../src/workflows/__fixtures__/workflows/deep-workflows/product-updater.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,iBAAiB,8BAA8B,CAAA;AAM5D,eAAO,MAAM,sBAAsB,0EAGjC,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.productUpdatedWorkflow = exports.productWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ exports.productWorkflowId = "product-notifier-workflow";
6
+ const step = (0, workflows_sdk_1.createStep)("product-step", () => {
7
+ return {};
8
+ });
9
+ exports.productUpdatedWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.productWorkflowId, () => {
10
+ step();
11
+ return new workflows_sdk_1.WorkflowResponse(void 0);
12
+ });
@@ -0,0 +1,3 @@
1
+ export declare const orderWorkflowId = "order-notifier-workflow";
2
+ export declare const orderNotifierWorkflow: import("@medusajs/workflows-sdk").ReturnWorkflow<unknown, undefined, []>;
3
+ //# sourceMappingURL=order-notifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"order-notifier.d.ts","sourceRoot":"","sources":["../../../../src/workflows/__fixtures__/workflows/order-notifier.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,eAAe,4BAA4B,CAAA;AAMxD,eAAO,MAAM,qBAAqB,0EAGhC,CAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.orderNotifierWorkflow = exports.orderWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/workflows-sdk");
5
+ exports.orderWorkflowId = "order-notifier-workflow";
6
+ const step = (0, workflows_sdk_1.createStep)("order-step", () => {
7
+ return {};
8
+ });
9
+ exports.orderNotifierWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.orderWorkflowId, () => {
10
+ step();
11
+ return new workflows_sdk_1.WorkflowResponse(void 0);
12
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.spec.d.ts","sourceRoot":"","sources":["../../../src/workflows/__tests__/index.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const path_1 = require("path");
4
+ const workflow_loader_1 = require("../workflow-loader");
5
+ const orchestration_1 = require("@medusajs/orchestration");
6
+ const order_notifier_1 = require("../__fixtures__/workflows/order-notifier");
7
+ const product_updater_1 = require("../__fixtures__/workflows/deep-workflows/product-updater");
8
+ describe("WorkflowLoader", () => {
9
+ const rootDir = (0, path_1.join)(__dirname, "../__fixtures__", "workflows");
10
+ beforeAll(async () => {
11
+ await new workflow_loader_1.WorkflowLoader(rootDir).load();
12
+ });
13
+ it("should register each workflow in the '/workflows' folder and sub folder", async () => {
14
+ const registeredWorkflows = orchestration_1.WorkflowManager.getWorkflows();
15
+ expect(registeredWorkflows.size).toBe(2);
16
+ expect(registeredWorkflows.has(order_notifier_1.orderWorkflowId)).toBe(true);
17
+ expect(registeredWorkflows.has(product_updater_1.productWorkflowId)).toBe(true);
18
+ });
19
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medusajs/framework",
3
- "version": "0.0.2-snapshot-20240821132459",
3
+ "version": "0.0.2-snapshot-20240821152538",
4
4
  "description": "Framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -33,13 +33,13 @@
33
33
  "scripts": {
34
34
  "watch": "tsc --watch -p ./tsconfig.build.json",
35
35
  "watch:test": "tsc --build tsconfig.spec.json --watch",
36
- "prepublishOnly": "cross-env NODE_ENV=production tsc -p ./tsconfig.build.json",
37
- "build": "rimraf dist && tsc --noEmit && tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
36
+ "prepublishOnly": "cross-env NODE_ENV=production tsc --build --verbose && tsc -p tsconfig.build.json",
37
+ "build": "rimraf dist && tsc --build && tsc -p ./tsconfig.build.json",
38
38
  "test": "jest --runInBand --bail --passWithNoTests --forceExit -- src",
39
39
  "test:integration": "jest --forceExit -- integration-tests/**/__tests__/**/*.ts"
40
40
  },
41
41
  "devDependencies": {
42
- "@medusajs/types": "1.12.0-snapshot-20240821132459",
42
+ "@medusajs/types": "1.12.0-snapshot-20240821152538",
43
43
  "@types/express": "^4.17.17",
44
44
  "@types/jsonwebtoken": "^8.5.9",
45
45
  "cross-env": "^7.0.3",
@@ -50,11 +50,11 @@
50
50
  "vite": "^5.2.11"
51
51
  },
52
52
  "dependencies": {
53
- "@medusajs/medusa-cli": "1.3.23-snapshot-20240821132459",
54
- "@medusajs/modules-sdk": "1.13.0-snapshot-20240821132459",
55
- "@medusajs/orchestration": "0.5.8-snapshot-20240821132459",
56
- "@medusajs/utils": "1.12.0-snapshot-20240821132459",
57
- "@medusajs/workflows-sdk": "0.1.7-snapshot-20240821132459",
53
+ "@medusajs/medusa-cli": "1.3.23-snapshot-20240821152538",
54
+ "@medusajs/modules-sdk": "1.13.0-snapshot-20240821152538",
55
+ "@medusajs/orchestration": "0.5.8-snapshot-20240821152538",
56
+ "@medusajs/utils": "1.12.0-snapshot-20240821152538",
57
+ "@medusajs/workflows-sdk": "0.1.7-snapshot-20240821152538",
58
58
  "awilix": "^8.0.0",
59
59
  "connect-redis": "^5.0.0",
60
60
  "cookie-parser": "^1.4.6",
@@ -64,7 +64,7 @@
64
64
  "ioredis": "^5.4.1",
65
65
  "ioredis-mock": "8.4.0",
66
66
  "jsonwebtoken": "^9.0.2",
67
- "medusa-telemetry": "0.0.18-snapshot-20240821132459",
67
+ "medusa-telemetry": "0.0.18-snapshot-20240821152538",
68
68
  "morgan": "^1.9.1",
69
69
  "zod": "3.22.4"
70
70
  }