@csbeker/medusa-product-attributes 2.2.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 (237) hide show
  1. package/.medusa/server/src/admin/index.js +9012 -0
  2. package/.medusa/server/src/admin/index.mjs +9010 -0
  3. package/.medusa/server/src/api/admin/middlewares.js +10 -0
  4. package/.medusa/server/src/api/admin/plugin/attribute-set/[id]/attributes/route.js +17 -0
  5. package/.medusa/server/src/api/admin/plugin/attribute-set/[id]/route.js +33 -0
  6. package/.medusa/server/src/api/admin/plugin/attribute-set/middlewares.js +44 -0
  7. package/.medusa/server/src/api/admin/plugin/attribute-set/query-config.js +22 -0
  8. package/.medusa/server/src/api/admin/plugin/attribute-set/route.js +25 -0
  9. package/.medusa/server/src/api/admin/plugin/attribute-set/validators.js +37 -0
  10. package/.medusa/server/src/api/admin/plugin/attributes/[id]/route.js +68 -0
  11. package/.medusa/server/src/api/admin/plugin/attributes/[id]/values/[valueId]/route.js +37 -0
  12. package/.medusa/server/src/api/admin/plugin/attributes/[id]/values/route.js +31 -0
  13. package/.medusa/server/src/api/admin/plugin/attributes/middlewares.js +103 -0
  14. package/.medusa/server/src/api/admin/plugin/attributes/query-config.js +41 -0
  15. package/.medusa/server/src/api/admin/plugin/attributes/route.js +28 -0
  16. package/.medusa/server/src/api/admin/plugin/attributes/validators.js +69 -0
  17. package/.medusa/server/src/api/admin/plugin/route.js +7 -0
  18. package/.medusa/server/src/api/middlewares.js +12 -0
  19. package/.medusa/server/src/api/store/middlewares.js +8 -0
  20. package/.medusa/server/src/api/store/plugin/attributes/middlewares.js +64 -0
  21. package/.medusa/server/src/api/store/plugin/attributes/products/middlewares.js +100 -0
  22. package/.medusa/server/src/api/store/plugin/attributes/products/query-config.js +20 -0
  23. package/.medusa/server/src/api/store/plugin/attributes/products/route.js +48 -0
  24. package/.medusa/server/src/api/store/plugin/attributes/products/validators.js +39 -0
  25. package/.medusa/server/src/api/store/plugin/attributes/query-config.js +21 -0
  26. package/.medusa/server/src/api/store/plugin/attributes/route.js +15 -0
  27. package/.medusa/server/src/api/store/plugin/attributes/validators.js +14 -0
  28. package/.medusa/server/src/api/store/plugin/route.js +7 -0
  29. package/.medusa/server/src/api/utils/common-validators.js +23 -0
  30. package/.medusa/server/src/api/utils/constants.js +6 -0
  31. package/.medusa/server/src/api/utils/middlewares.js +34 -0
  32. package/.medusa/server/src/links/attribute-product-category.js +16 -0
  33. package/.medusa/server/src/links/attribute-value-product.js +16 -0
  34. package/.medusa/server/src/modules/attribute/events/index.js +8 -0
  35. package/.medusa/server/src/modules/attribute/index.js +13 -0
  36. package/.medusa/server/src/modules/attribute/migrations/Migration20250319161229.js +24 -0
  37. package/.medusa/server/src/modules/attribute/migrations/Migration20250320182643.js +16 -0
  38. package/.medusa/server/src/modules/attribute/migrations/Migration20250321162638.js +14 -0
  39. package/.medusa/server/src/modules/attribute/migrations/Migration20250505144933.js +23 -0
  40. package/.medusa/server/src/modules/attribute/migrations/Migration20250505201747.js +21 -0
  41. package/.medusa/server/src/modules/attribute/migrations/Migration20250506162300.js +14 -0
  42. package/.medusa/server/src/modules/attribute/migrations/Migration20250611160552.js +14 -0
  43. package/.medusa/server/src/modules/attribute/migrations/Migration20250611173345.js +16 -0
  44. package/.medusa/server/src/modules/attribute/migrations/Migration20250612192857.js +16 -0
  45. package/.medusa/server/src/modules/attribute/models/attribute-possible-value.js +24 -0
  46. package/.medusa/server/src/modules/attribute/models/attribute-set.js +22 -0
  47. package/.medusa/server/src/modules/attribute/models/attribute-value.js +17 -0
  48. package/.medusa/server/src/modules/attribute/models/attribute.js +27 -0
  49. package/.medusa/server/src/modules/attribute/service.js +84 -0
  50. package/.medusa/server/src/modules/attribute/types/attribute/common.js +13 -0
  51. package/.medusa/server/src/modules/attribute/types/attribute/index.js +18 -0
  52. package/.medusa/server/src/modules/attribute/types/attribute-set/index.js +18 -0
  53. package/.medusa/server/src/modules/attribute/types/attribute-set/mutations.js +3 -0
  54. package/.medusa/server/src/modules/attribute/types/attribute-value/index.js +18 -0
  55. package/.medusa/server/src/modules/attribute/types/attribute-value/mutations.js +3 -0
  56. package/.medusa/server/src/modules/attribute/types/index.js +20 -0
  57. package/.medusa/server/src/types/attribute/common.js +3 -0
  58. package/.medusa/server/src/types/attribute/http/attribute/admin/index.js +3 -0
  59. package/.medusa/server/src/types/attribute/http/attribute/index.js +18 -0
  60. package/.medusa/server/src/types/attribute/http/attribute-set/index.js +3 -0
  61. package/.medusa/server/src/types/attribute/http/index.js +19 -0
  62. package/.medusa/server/src/types/attribute/index.js +19 -0
  63. package/.medusa/server/src/utils/index.js +18 -0
  64. package/.medusa/server/src/utils/products-created-handler.js +22 -0
  65. package/.medusa/server/src/utils/products-updated-handler.js +58 -0
  66. package/.medusa/server/src/utils/validate-attribute-values-to-link.js +43 -0
  67. package/.medusa/server/src/workflows/attribute/index.js +19 -0
  68. package/.medusa/server/src/workflows/attribute/steps/create-attribute-possible-values.js +18 -0
  69. package/.medusa/server/src/workflows/attribute/steps/create-attributes.js +27 -0
  70. package/.medusa/server/src/workflows/attribute/steps/delete-attribute.js +31 -0
  71. package/.medusa/server/src/workflows/attribute/steps/index.js +21 -0
  72. package/.medusa/server/src/workflows/attribute/steps/update-attributes.js +34 -0
  73. package/.medusa/server/src/workflows/attribute/workflows/create-attribute-possible-values.js +11 -0
  74. package/.medusa/server/src/workflows/attribute/workflows/create-attributes.js +46 -0
  75. package/.medusa/server/src/workflows/attribute/workflows/delete-attribute.js +10 -0
  76. package/.medusa/server/src/workflows/attribute/workflows/index.js +20 -0
  77. package/.medusa/server/src/workflows/attribute/workflows/update-attributes.js +73 -0
  78. package/.medusa/server/src/workflows/attribute-set/steps/batch-link-attribute-set-attributes.js +66 -0
  79. package/.medusa/server/src/workflows/attribute-set/steps/create-attribute-set.js +24 -0
  80. package/.medusa/server/src/workflows/attribute-set/steps/index.js +20 -0
  81. package/.medusa/server/src/workflows/attribute-set/steps/update-attribute-set.js +22 -0
  82. package/.medusa/server/src/workflows/attribute-set/workflows/batch-link-attribute-set-attributes.js +10 -0
  83. package/.medusa/server/src/workflows/attribute-set/workflows/create-attribute-set.js +11 -0
  84. package/.medusa/server/src/workflows/attribute-set/workflows/index.js +20 -0
  85. package/.medusa/server/src/workflows/attribute-set/workflows/update-attribute-set.js +10 -0
  86. package/.medusa/server/src/workflows/attribute-value/steps/create-attribute-value.js +18 -0
  87. package/.medusa/server/src/workflows/attribute-value/steps/delete-attribute-value.js +18 -0
  88. package/.medusa/server/src/workflows/attribute-value/steps/index.js +20 -0
  89. package/.medusa/server/src/workflows/attribute-value/steps/validate-attribute-value.js +53 -0
  90. package/.medusa/server/src/workflows/attribute-value/workflow/create-attribute-value.js +28 -0
  91. package/.medusa/server/src/workflows/attribute-value/workflow/delete-attribute-value.js +38 -0
  92. package/.medusa/server/src/workflows/attribute-value/workflow/index.js +19 -0
  93. package/.medusa/server/src/workflows/attribute_possible_value/index.js +19 -0
  94. package/.medusa/server/src/workflows/attribute_possible_value/steps/index.js +18 -0
  95. package/.medusa/server/src/workflows/attribute_possible_value/steps/update-attribute-possible-value.js +18 -0
  96. package/.medusa/server/src/workflows/attribute_possible_value/workflows/index.js +18 -0
  97. package/.medusa/server/src/workflows/attribute_possible_value/workflows/update-attribute-possible-value.js +11 -0
  98. package/.medusa/server/src/workflows/index.js +18 -0
  99. package/CHANGELOG.md +104 -0
  100. package/README.md +86 -0
  101. package/package.json +90 -0
  102. package/src/admin/README.md +31 -0
  103. package/src/admin/components/metadata-editor/index.tsx +101 -0
  104. package/src/admin/components/section-row.tsx +41 -0
  105. package/src/admin/hooks/api/attribute-set.ts +122 -0
  106. package/src/admin/hooks/api/attributes.ts +126 -0
  107. package/src/admin/hooks/table/columns/index.ts +1 -0
  108. package/src/admin/hooks/table/columns/use-attribute-table-columns.tsx +280 -0
  109. package/src/admin/layouts/single-column.tsx +11 -0
  110. package/src/admin/lib/config.ts +8 -0
  111. package/src/admin/lib/query-key-factory.ts +53 -0
  112. package/src/admin/routes/attributes/[id]/edit/page.tsx +133 -0
  113. package/src/admin/routes/attributes/[id]/edit-possible-value/page.tsx +174 -0
  114. package/src/admin/routes/attributes/[id]/page.tsx +127 -0
  115. package/src/admin/routes/attributes/components/AttributeForm.tsx +301 -0
  116. package/src/admin/routes/attributes/components/AttributeSetTable.tsx +108 -0
  117. package/src/admin/routes/attributes/components/category-selection-modal.tsx +82 -0
  118. package/src/admin/routes/attributes/components/possible-values-table.tsx +119 -0
  119. package/src/admin/routes/attributes/create/components/MultiSelectCategory.tsx +148 -0
  120. package/src/admin/routes/attributes/create/components/PossibleValuesList.tsx +151 -0
  121. package/src/admin/routes/attributes/create/page.tsx +123 -0
  122. package/src/admin/routes/attributes/create-set/page.tsx +110 -0
  123. package/src/admin/routes/attributes/page.tsx +346 -0
  124. package/src/admin/routes/attributes/set/[id]/attributes/page.tsx +35 -0
  125. package/src/admin/routes/attributes/set/[id]/components/AttributeSetAttributesSection.tsx +114 -0
  126. package/src/admin/routes/attributes/set/[id]/components/AttributeSetGeneralSection.tsx +42 -0
  127. package/src/admin/routes/attributes/set/[id]/components/attribute-set-attributes-form.tsx +143 -0
  128. package/src/admin/routes/attributes/set/[id]/components/index.ts +2 -0
  129. package/src/admin/routes/attributes/set/[id]/edit/page.tsx +119 -0
  130. package/src/admin/routes/attributes/set/[id]/page.tsx +45 -0
  131. package/src/admin/tsconfig.json +27 -0
  132. package/src/admin/types/global.d.ts +3 -0
  133. package/src/admin/vite-env.d.ts +1 -0
  134. package/src/api/README.md +133 -0
  135. package/src/api/admin/middlewares.ts +8 -0
  136. package/src/api/admin/plugin/attribute-set/[id]/attributes/route.ts +17 -0
  137. package/src/api/admin/plugin/attribute-set/[id]/route.ts +41 -0
  138. package/src/api/admin/plugin/attribute-set/middlewares.ts +42 -0
  139. package/src/api/admin/plugin/attribute-set/query-config.ts +20 -0
  140. package/src/api/admin/plugin/attribute-set/route.ts +34 -0
  141. package/src/api/admin/plugin/attribute-set/validators.ts +45 -0
  142. package/src/api/admin/plugin/attributes/[id]/route.ts +85 -0
  143. package/src/api/admin/plugin/attributes/[id]/values/[valueId]/route.ts +41 -0
  144. package/src/api/admin/plugin/attributes/[id]/values/route.ts +39 -0
  145. package/src/api/admin/plugin/attributes/middlewares.ts +91 -0
  146. package/src/api/admin/plugin/attributes/query-config.ts +42 -0
  147. package/src/api/admin/plugin/attributes/route.ts +33 -0
  148. package/src/api/admin/plugin/attributes/validators.ts +91 -0
  149. package/src/api/admin/plugin/route.ts +8 -0
  150. package/src/api/middlewares.ts +10 -0
  151. package/src/api/store/middlewares.ts +6 -0
  152. package/src/api/store/plugin/attributes/middlewares.ts +33 -0
  153. package/src/api/store/plugin/attributes/products/middlewares.ts +73 -0
  154. package/src/api/store/plugin/attributes/products/query-config.ts +19 -0
  155. package/src/api/store/plugin/attributes/products/route.ts +68 -0
  156. package/src/api/store/plugin/attributes/products/validators.ts +55 -0
  157. package/src/api/store/plugin/attributes/query-config.ts +19 -0
  158. package/src/api/store/plugin/attributes/route.ts +13 -0
  159. package/src/api/store/plugin/attributes/validators.ts +14 -0
  160. package/src/api/store/plugin/route.ts +8 -0
  161. package/src/api/utils/common-validators.ts +24 -0
  162. package/src/api/utils/constants.ts +2 -0
  163. package/src/api/utils/middlewares.ts +31 -0
  164. package/src/jobs/README.md +36 -0
  165. package/src/links/README.md +26 -0
  166. package/src/links/attribute-product-category.ts +14 -0
  167. package/src/links/attribute-value-product.ts +14 -0
  168. package/src/modules/README.md +116 -0
  169. package/src/modules/attribute/events/index.ts +4 -0
  170. package/src/modules/attribute/index.ts +8 -0
  171. package/src/modules/attribute/migrations/.snapshot-medusa-attribute.json +624 -0
  172. package/src/modules/attribute/migrations/Migration20250319161229.ts +27 -0
  173. package/src/modules/attribute/migrations/Migration20250320182643.ts +15 -0
  174. package/src/modules/attribute/migrations/Migration20250321162638.ts +13 -0
  175. package/src/modules/attribute/migrations/Migration20250505144933.ts +26 -0
  176. package/src/modules/attribute/migrations/Migration20250505201747.ts +23 -0
  177. package/src/modules/attribute/migrations/Migration20250506162300.ts +13 -0
  178. package/src/modules/attribute/migrations/Migration20250611160552.ts +13 -0
  179. package/src/modules/attribute/migrations/Migration20250611173345.ts +17 -0
  180. package/src/modules/attribute/migrations/Migration20250612192857.ts +17 -0
  181. package/src/modules/attribute/models/attribute-possible-value.ts +20 -0
  182. package/src/modules/attribute/models/attribute-set.ts +18 -0
  183. package/src/modules/attribute/models/attribute-value.ts +13 -0
  184. package/src/modules/attribute/models/attribute.ts +23 -0
  185. package/src/modules/attribute/service.ts +102 -0
  186. package/src/modules/attribute/types/attribute/common.ts +94 -0
  187. package/src/modules/attribute/types/attribute/index.ts +1 -0
  188. package/src/modules/attribute/types/attribute-set/index.ts +1 -0
  189. package/src/modules/attribute/types/attribute-set/mutations.ts +7 -0
  190. package/src/modules/attribute/types/attribute-value/index.ts +1 -0
  191. package/src/modules/attribute/types/attribute-value/mutations.ts +5 -0
  192. package/src/modules/attribute/types/index.ts +3 -0
  193. package/src/providers/README.md +30 -0
  194. package/src/subscribers/README.md +59 -0
  195. package/src/types/attribute/common.ts +173 -0
  196. package/src/types/attribute/http/attribute/admin/index.ts +0 -0
  197. package/src/types/attribute/http/attribute/index.ts +42 -0
  198. package/src/types/attribute/http/attribute-set/index.ts +10 -0
  199. package/src/types/attribute/http/index.ts +2 -0
  200. package/src/types/attribute/index.ts +2 -0
  201. package/src/utils/index.ts +1 -0
  202. package/src/utils/products-created-handler.ts +35 -0
  203. package/src/utils/products-updated-handler.ts +74 -0
  204. package/src/utils/validate-attribute-values-to-link.ts +67 -0
  205. package/src/workflows/README.md +79 -0
  206. package/src/workflows/attribute/index.ts +2 -0
  207. package/src/workflows/attribute/steps/create-attribute-possible-values.ts +29 -0
  208. package/src/workflows/attribute/steps/create-attributes.ts +35 -0
  209. package/src/workflows/attribute/steps/delete-attribute.ts +41 -0
  210. package/src/workflows/attribute/steps/index.ts +4 -0
  211. package/src/workflows/attribute/steps/update-attributes.ts +45 -0
  212. package/src/workflows/attribute/workflows/create-attribute-possible-values.ts +17 -0
  213. package/src/workflows/attribute/workflows/create-attributes.ts +56 -0
  214. package/src/workflows/attribute/workflows/delete-attribute.ts +15 -0
  215. package/src/workflows/attribute/workflows/index.ts +3 -0
  216. package/src/workflows/attribute/workflows/update-attributes.ts +103 -0
  217. package/src/workflows/attribute-set/steps/batch-link-attribute-set-attributes.ts +82 -0
  218. package/src/workflows/attribute-set/steps/create-attribute-set.ts +34 -0
  219. package/src/workflows/attribute-set/steps/index.ts +3 -0
  220. package/src/workflows/attribute-set/steps/update-attribute-set.ts +32 -0
  221. package/src/workflows/attribute-set/workflows/batch-link-attribute-set-attributes.ts +12 -0
  222. package/src/workflows/attribute-set/workflows/create-attribute-set.ts +17 -0
  223. package/src/workflows/attribute-set/workflows/index.ts +3 -0
  224. package/src/workflows/attribute-set/workflows/update-attribute-set.ts +14 -0
  225. package/src/workflows/attribute-value/steps/create-attribute-value.ts +26 -0
  226. package/src/workflows/attribute-value/steps/delete-attribute-value.ts +26 -0
  227. package/src/workflows/attribute-value/steps/index.ts +3 -0
  228. package/src/workflows/attribute-value/steps/validate-attribute-value.ts +95 -0
  229. package/src/workflows/attribute-value/workflow/create-attribute-value.ts +36 -0
  230. package/src/workflows/attribute-value/workflow/delete-attribute-value.ts +46 -0
  231. package/src/workflows/attribute-value/workflow/index.ts +2 -0
  232. package/src/workflows/attribute_possible_value/index.ts +2 -0
  233. package/src/workflows/attribute_possible_value/steps/index.ts +1 -0
  234. package/src/workflows/attribute_possible_value/steps/update-attribute-possible-value.ts +25 -0
  235. package/src/workflows/attribute_possible_value/workflows/index.ts +1 -0
  236. package/src/workflows/attribute_possible_value/workflows/update-attribute-possible-value.ts +15 -0
  237. package/src/workflows/index.ts +1 -0
@@ -0,0 +1,53 @@
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.validateAttributeValueStep = exports.validateAttributeValueStepId = void 0;
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
9
+ const attribute_value_product_1 = __importDefault(require("../../../links/attribute-value-product"));
10
+ exports.validateAttributeValueStepId = "validate-attribute-value";
11
+ exports.validateAttributeValueStep = (0, workflows_sdk_1.createStep)(exports.validateAttributeValueStepId, async (input, { container }) => {
12
+ const query = container.resolve(utils_1.ContainerRegistrationKeys.QUERY);
13
+ const { data: [attribute], } = await query.graph({
14
+ entity: "attribute",
15
+ fields: ["product_categories.id", "possible_values.value"],
16
+ filters: {
17
+ id: input.attribute_id,
18
+ },
19
+ });
20
+ const allowedValues = attribute.possible_values?.map((posVal) => posVal.value);
21
+ if (allowedValues?.length && !allowedValues.includes(input.value)) {
22
+ throw new utils_1.MedusaError(utils_1.MedusaErrorTypes.INVALID_DATA, `Attribute ${input.attribute_id} doesn't define ${input.value} as a possible_value`);
23
+ }
24
+ const attributeCategoryIds = attribute.product_categories.map((cat) => cat.id);
25
+ // If all attributes are global, we don't enforce for product.categories to include the attribute.product_categories, since there are none
26
+ if (attributeCategoryIds.length) {
27
+ const { data: [product], } = await query.graph({
28
+ entity: "product",
29
+ fields: ["categories.id"],
30
+ filters: {
31
+ id: input.product_id,
32
+ },
33
+ });
34
+ const productCategoryIds = product.categories?.map((cat) => cat.id);
35
+ if (!productCategoryIds?.some((prodCatId) => attributeCategoryIds.includes(prodCatId))) {
36
+ throw new utils_1.MedusaError(utils_1.MedusaErrorTypes.INVALID_DATA, `Product ${input.product_id} isn't linked to any category from the requested attributes.`);
37
+ }
38
+ }
39
+ const { data: attributeValuesProduct } = await query.graph({
40
+ entity: attribute_value_product_1.default.entryPoint,
41
+ fields: ["attribute_value.value", "attribute_value.attribute_id"],
42
+ filters: {
43
+ product_id: input.product_id,
44
+ },
45
+ });
46
+ const attributeValues = attributeValuesProduct.map((element) => element.attribute_value);
47
+ if (attributeValues.some((value) => value.attribute_id === input.attribute_id &&
48
+ value.value === input.value)) {
49
+ throw new utils_1.MedusaError(utils_1.MedusaErrorTypes.DUPLICATE_ERROR, `Attribute value ${input.value} for attribute ${input.attribute_id} already exists for product ${input.product_id}`);
50
+ }
51
+ return new workflows_sdk_1.StepResponse();
52
+ });
53
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdGUtYXR0cmlidXRlLXZhbHVlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL3dvcmtmbG93cy9hdHRyaWJ1dGUtdmFsdWUvc3RlcHMvdmFsaWRhdGUtYXR0cmlidXRlLXZhbHVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHFEQUltQztBQUNuQyxxRUFBNkU7QUFHN0UscUdBQStFO0FBRWxFLFFBQUEsNEJBQTRCLEdBQUcsMEJBQTBCLENBQUM7QUFFMUQsUUFBQSwwQkFBMEIsR0FBRyxJQUFBLDBCQUFVLEVBQ2xELG9DQUE0QixFQUM1QixLQUFLLEVBQUUsS0FBcUMsRUFBRSxFQUFFLFNBQVMsRUFBRSxFQUFFLEVBQUU7SUFDN0QsTUFBTSxLQUFLLEdBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQyxpQ0FBeUIsQ0FBQyxLQUFLLENBQUMsQ0FBQztJQUVqRSxNQUFNLEVBQ0osSUFBSSxFQUFFLENBQUMsU0FBUyxDQUFDLEdBQ2xCLEdBQUcsTUFBTSxLQUFLLENBQUMsS0FBSyxDQUFDO1FBQ3BCLE1BQU0sRUFBRSxXQUFXO1FBQ25CLE1BQU0sRUFBRSxDQUFDLHVCQUF1QixFQUFFLHVCQUF1QixDQUFDO1FBQzFELE9BQU8sRUFBRTtZQUNQLEVBQUUsRUFBRSxLQUFLLENBQUMsWUFBWTtTQUN2QjtLQUNGLENBQUMs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sQ0FBQztJQUNKLENBQUM7SUFFRCxPQUFPLElBQUksNEJBQVksRUFBRSxDQUFDO0FBQzVCLENBQUMsQ0FDRixDQUFDIn0=
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAttributeValueWorkflow = exports.createAttributeValueWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
5
+ const steps_1 = require("../steps");
6
+ const attribute_1 = require("../../../modules/attribute");
7
+ const utils_1 = require("@medusajs/framework/utils");
8
+ const core_flows_1 = require("@medusajs/medusa/core-flows");
9
+ exports.createAttributeValueWorkflowId = 'create-attribute-value';
10
+ exports.createAttributeValueWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.createAttributeValueWorkflowId, (input) => {
11
+ const attributeValueWithoutExternalRelations = (0, workflows_sdk_1.transform)({ input }, ({ input }) => {
12
+ const { product_id, ...attributeValue } = input;
13
+ return attributeValue;
14
+ });
15
+ (0, steps_1.validateAttributeValueStep)(input);
16
+ const attributeValue = (0, steps_1.createAttributeValueStep)(attributeValueWithoutExternalRelations);
17
+ const link = (0, workflows_sdk_1.transform)({ input, attributeValue }, ({ input, attributeValue }) => ([{
18
+ [attribute_1.ATTRIBUTE_MODULE]: {
19
+ attribute_value_id: attributeValue.id,
20
+ },
21
+ [utils_1.Modules.PRODUCT]: {
22
+ product_id: input.product_id
23
+ }
24
+ }]));
25
+ (0, core_flows_1.createRemoteLinkStep)(link);
26
+ return new workflows_sdk_1.WorkflowResponse(attributeValue);
27
+ });
28
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWF0dHJpYnV0ZS12YWx1ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvYXR0cmlidXRlLXZhbHVlL3dvcmtmbG93L2NyZWF0ZS1hdHRya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LENBQUMsQ0FBQTtJQUVKLElBQUEsaUNBQW9CLEVBQUMsSUFBSSxDQUFDLENBQUE7SUFFMUIsT0FBTyxJQUFJLGdDQUFnQixDQUFDLGNBQWMsQ0FBQyxDQUFBO0FBQy9DLENBQUMsQ0FDSixDQUFBIn0=
@@ -0,0 +1,38 @@
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.deleteAttributeValueWorkflow = exports.deleteAttributeValueWorkflowId = void 0;
7
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
8
+ const core_flows_1 = require("@medusajs/medusa/core-flows");
9
+ const attribute_1 = require("../../../modules/attribute");
10
+ const utils_1 = require("@medusajs/framework/utils");
11
+ const attribute_value_product_1 = __importDefault(require("../../../links/attribute-value-product"));
12
+ const steps_1 = require("../steps");
13
+ exports.deleteAttributeValueWorkflowId = 'delete-attribute-value';
14
+ exports.deleteAttributeValueWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.deleteAttributeValueWorkflowId, (input) => {
15
+ const normalizedInput = (0, workflows_sdk_1.transform)({ input }, ({ input }) => Array.isArray(input) ? input : [input]);
16
+ const attributeValueProductQuery = (0, core_flows_1.useQueryGraphStep)({
17
+ entity: attribute_value_product_1.default.entryPoint,
18
+ fields: ['product_id', 'attribute_value_id'],
19
+ filters: {
20
+ attribute_value_id: normalizedInput
21
+ }
22
+ });
23
+ const deleted = (0, steps_1.deleteAttributeValueStep)(normalizedInput);
24
+ const links = (0, workflows_sdk_1.transform)({ attributeValueProductQuery }, ({ attributeValueProductQuery }) => {
25
+ const { data } = attributeValueProductQuery;
26
+ return data.map(element => ({
27
+ [attribute_1.ATTRIBUTE_MODULE]: {
28
+ attribute_value_id: element.attribute_value_id,
29
+ },
30
+ [utils_1.Modules.PRODUCT]: {
31
+ product_id: element.product_id
32
+ }
33
+ }));
34
+ });
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FBZTtTQUN0QztLQUNKLENBQUMsQ0FBQTtJQUVGLE1BQU0sT0FBTyxHQUFHLElBQUEsZ0NBQXdCLEVBQUMsZUFBZSxDQUFDLENBQUE7SUFFekQsTUFBTSxLQUFLLEdBQUcsSUFBQSx5QkFBUyxFQUFDLEVBQUUsMEJBQTBCLEVBQUUsRUFBRSxDQUFDLEVBQUUsMEJBQTBCLEVBQUUsRUFBRSxFQUFFO1FBQ3ZGLE1BQU0sRUFBRSxJQUFJLEVBQUUsR0FBRywwQkFBMEIsQ0FBQztRQUM1QyxPQUFPLElBQUksQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLEVBQUUsQ0FBQyxDQUFDO1lBQ3hCLENBQUMsNEJBQWdCLENBQUMsRUFBRTtnQkFDaEIsa0JBQWtCLEVBQUUsT0FBTyxDQUFDLGtCQUFrQjthQUNqRDtZQUNELENBQUMsZUFBTyxDQUFDLE9BQU8sQ0FBQyxFQUFFO2dCQUNmLFVBQVUsRUFBRSxPQUFPLENBQUMsVUFBVTthQUNqQztTQUNKLENBQUMsQ0FBQyxDQUFBO0lBQ1AsQ0FBQyxDQUFDLENBQUE7SUFFRixJQUFBLGtDQUFxQixFQUFDLEtBQUssQ0FBQyxDQUFBO0lBRTVCLE9BQU8sSUFBSSxnQ0FBZ0IsQ0FBQyxPQUFPLENBQUMsQ0FBQTtBQUN4QyxDQUFDLENBQ0osQ0FBQSJ9
@@ -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("./create-attribute-value"), exports);
18
+ __exportStar(require("./delete-attribute-value"), exports);
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2F0dHJpYnV0ZS12YWx1ZS93b3JrZmxvdy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMkRBQXdDO0FBQ3hDLDJEQUF3QyJ9
@@ -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("./steps"), exports);
18
+ __exportStar(require("./workflows"), exports);
19
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2F0dHJpYnV0ZV9wb3NzaWJsZV92YWx1ZS9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsMENBQXVCO0FBQ3ZCLDhDQUEyQiJ9
@@ -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("./update-attribute-possible-value"), exports);
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2F0dHJpYnV0ZV9wb3NzaWJsZV92YWx1ZS9zdGVwcy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7O0FBQUEsb0VBQWlEIn0=
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAttributePossibleValueStep = exports.updateAttributePossibleValueStepId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
5
+ const attribute_1 = require("../../../modules/attribute");
6
+ exports.updateAttributePossibleValueStepId = 'update-attribute-possible-value';
7
+ exports.updateAttributePossibleValueStep = (0, workflows_sdk_1.createStep)(exports.updateAttributePossibleValueStepId, async (payload, { container }) => {
8
+ const attributeModuleService = container.resolve(attribute_1.ATTRIBUTE_MODULE);
9
+ const updated = await attributeModuleService.updateAttributePossibleValues(payload);
10
+ return new workflows_sdk_1.StepResponse(updated, payload.id);
11
+ }, async (id, { container }) => {
12
+ if (!id) {
13
+ return;
14
+ }
15
+ const attributeModuleService = container.resolve(attribute_1.ATTRIBUTE_MODULE);
16
+ await attributeModuleService.deleteAttributePossibleValues(id);
17
+ });
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBkYXRlLWF0dHJpYnV0ZS1wb3NzaWJsZS12YWx1ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvYXR0cmlidXRlX3Bvc3NpYmxlX3ZhbHVlL3N0ZXBzL3VwZGF0ZS1hdHRyaWJ1dGUtcG9zc2libGUtdmFsdWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7O0FBQUEscUVBQTRFO0FBRTVFLDBEQUE2RDtBQUdoRCxRQUFBLGtDQUFrQyxHQUFHLGlDQUFpQyxDQUFBO0FBSXRFLFFBQUEsZ0NBQWdDLEdBQUcsSUFBQSwwQkFBVSxFQUN0RCwwQ0FBa0MsRUFDbEMsS0FBSyxFQUFFLE9BQWtCLEVBQUUsRUFBRSxTQUFTLEVBQUUsRUFBRSxFQUFFO0lBQ3hDLE1BQU0sc0JBQXNCLEdBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQyw0QkFBZ0IsQ0FBMkIsQ0FBQTtJQUM1RixNQUFNLE9BQU8sR0FBRyxNQUFNLHNCQUFzQixDQUFDLDZCQUE2QixDQUFDLE9BQU8sQ0FBQyxDQUFBO0lBQ25GLE9BQU8sSUFBSSw0QkFBWSxDQUFDLE9BQU8sRUFBRSxPQUFPLENBQUMsRUFBRSxDQUFDLENBQUE7QUFDaEQsQ0FBQyxFQUNELEtBQUssRUFBRSxFQUFzQixFQUFFLEVBQUUsU0FBUyxFQUFFLEVBQUUsRUFBRTtJQUM1QyxJQUFJLENBQUMsRUFBRSxFQUFFLENBQUM7UUFDTixPQUFNO0lBQ1YsQ0FBQztJQUVELE1BQU0sc0JBQXNCLEdBQUcsU0FBUyxDQUFDLE9BQU8sQ0FBQyw0QkFBZ0IsQ0FBMkIsQ0FBQTtJQUM1RixNQUFNLHNCQUFzQixDQUFDLDZCQUE2QixDQUFDLEVBQUUsQ0FBQyxDQUFBO0FBQ2xFLENBQUMsQ0FDSixDQUFBIn0=
@@ -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("./update-attribute-possible-value"), exports);
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2F0dHJpYnV0ZV9wb3NzaWJsZV92YWx1ZS93b3JrZmxvd3MvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7OztBQUFBLG9FQUFpRCJ9
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateAttributePossibleValueWorkflow = exports.updateAttributePossibleValueWorkflowId = void 0;
4
+ const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
5
+ const steps_1 = require("../steps");
6
+ exports.updateAttributePossibleValueWorkflowId = 'update-attribute-possible-value';
7
+ exports.updateAttributePossibleValueWorkflow = (0, workflows_sdk_1.createWorkflow)(exports.updateAttributePossibleValueWorkflowId, (input) => {
8
+ const updated = (0, steps_1.updateAttributePossibleValueStep)(input);
9
+ return new workflows_sdk_1.WorkflowResponse(updated);
10
+ });
11
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXBkYXRlLWF0dHJpYnV0ZS1wb3NzaWJsZS12YWx1ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy93b3JrZmxvd3MvYXR0cmlidXRlX3Bvc3NpYmxlX3ZhbHVlL3dvcmtmbG93cy91cGRhdGUtYXR0cmlidXRlLXBvc3NpYmxlLXZhbHVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLHFFQUFvRjtBQUVwRixvQ0FBMkQ7QUFFOUMsUUFBQSxzQ0FBc0MsR0FBRyxpQ0FBaUMsQ0FBQTtBQUkxRSxRQUFBLG9DQUFvQyxHQUFHLElBQUEsOEJBQWMsRUFDOUQsOENBQXNDLEVBQ3RDLENBQUMsS0FBb0IsRUFBRSxFQUFFO0lBQ3JCLE1BQU0sT0FBTyxHQUFHLElBQUEsd0NBQWdDLEVBQUMsS0FBSyxDQUFDLENBQUE7SUFDdkQsT0FBTyxJQUFJLGdDQUFnQixDQUFDLE9BQU8sQ0FBQyxDQUFBO0FBQ3hDLENBQUMsQ0FDSixDQUFBIn0=
@@ -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("./attribute"), exports);
18
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvd29ya2Zsb3dzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQSw4Q0FBMkIifQ==
package/CHANGELOG.md ADDED
@@ -0,0 +1,104 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## Unreleased
9
+
10
+ ## 2.2.0 - 2026-01-01
11
+
12
+ ## 2.1.2 - 2025-10-19
13
+ ### Added
14
+ - Improved attributes list and detail page UI, allowing to update certain fields directly from the list page, more information in detail page
15
+
16
+ ### Fixed
17
+ - Build error in attributes products route
18
+
19
+ ## 2.1.1 - 2025-06-13
20
+ ### Added
21
+ - Updated Medusa from 2.6.1 to 2.7.0
22
+
23
+ ### Fixed
24
+ - Included missing admin extensions export in package.json
25
+
26
+ ## 2.1.0 - 2025-06-13
27
+ ### Added
28
+ - UI Routes in admin panel to manage attributes, attribute sets and possible values
29
+ - Added ui_component to attribute schema, to allow admin widgets in product to understand how they should ask for the value input
30
+ - API Routes and workflows to facilitate interacting with the UI components
31
+
32
+ ## 2.0.2 - 2025-06-10
33
+ ### Fixed
34
+ - Updating an attribute value, with same value as other existing ones, causes deletion of the other values, due to a bug in the `productsUpdatedHookHandler`
35
+
36
+ ## 2.0.1 - 2025-05-29
37
+ ### Fixed
38
+ - Updating one product attribute values, deletes other product attribute values
39
+
40
+ ## 2.0.0 - 2025-05-06
41
+ ### Added
42
+ - New AttributePossibleValue entity, to optionally restrict the possible values for an attribute. These possible values will be used as a blueprint when actually linkng an attribute value to a product.
43
+
44
+ ### Changed
45
+ - We no longer link a Product to an already existing AttributeValue, but rather, specify the 'value' property and an AttributeValue is created on the fly. This allows for more flexibility, since a Product can now be linked to an AttributeValue, for an Attribute that has potentially inifinite possibilities. Otherwise, you would need to create in advance all of these values
46
+ - Updated utility hook handlers for product created and updated hooks, to attain for the new schema
47
+ - /admin/plugin/attributes/[id]/values routes now point to AttributePossibleValue entity, not AttributeValue. AttributeValue entries now are linked directly to a Product and an Attribute, so it doesn't make much sense to interact with them directly. For this, you will almost certain be interacting through the Product, to get the linked AttributeValues and update them.
48
+
49
+ ## 1.3.0 - 2025-05-05
50
+ ### Added
51
+ - New AttributeSet entity and API route to create a set and link Attributes to it. This is useful for example, to create an AttributeSet 'Measurements' and link individual values like "Chest", "Sleeve", etc to create a group of related attributes.
52
+
53
+ ## 1.2.1 - 2025-04-01
54
+ ### Removed
55
+ - updateProductsWorkflow hook handler
56
+
57
+ ## 1.2.0 - 2025-04-01
58
+ ### Added
59
+ - New `productsUpdatedHookHandler` utility function, to include in your own `updatedProducstWorkflow.productsUpdated` hook, to be able to pass attribute values when updating a product
60
+
61
+ ## 1.1.0 - 2025-03-25
62
+ ### Added
63
+ - `addGlobalAttributesIfNecessary` middleware to allow returning global attributes when requesting attributes linked to a category, by specifying `include_globals` query param. Defaults to true if not specified
64
+
65
+ ## 1.0.0 - 2025-03-25
66
+ ### Added
67
+ - Added utility function `productsCreatedHookHandler` to incorporate in your own productCreated hook handler
68
+
69
+ ### Removed
70
+ - productsCreated hook handler. This is a breaking change and i decided to do this because of [this issue](https://github.com/medusajs/medusa/issues/11968). See README section 3.
71
+
72
+ ## 0.3.0 - 2025-03-23
73
+ ### Added
74
+ - ability to query products passing `attribute_value_id` filter, to filter by linked attribute values. Recreating the core /store/products route in
75
+ /store/plugin/attributes/products route, until i get a response from Medusa regarding [this issue](https://github.com/medusajs/medusa/issues/11938).
76
+ Since there are also limitations on complef filtering for linked tables, the values passed for `attribute_value_id` are applied with OR
77
+
78
+ ## 0.2.0 - 2025-03-21
79
+ ### Added
80
+ - /store/plugin/attributes route to list attributes from storefront and apply query params filters
81
+ - applyCategoryFilterIfNecessary middleware to support filtering by product category link, passing "categories" array
82
+ as query param. Doesn't handle categories inside $and or $or params yet
83
+
84
+ ### Changed
85
+ - Unique constraint on attribute_value table (attribute_id, rank), since when updating values for an attribute and swapping the "rank"
86
+ values, the constraint made it throw. Until i find a way to do this, you could have duplicated attribute_id, rank
87
+
88
+ ## 0.1.1 - 2025-03-21
89
+ ### Added
90
+ - Manual update to changelog, due to problems when first trying the Github release workflow
91
+
92
+ ## 0.1.0 - 2024-03-21
93
+ ### Added
94
+ - Changelog
95
+ - Link attribute values to products including additional_data.values on /admin/products
96
+
97
+ ## 0.0.1 - 2024-03-20
98
+ ### Added
99
+ - Create, retrieve and list attributes
100
+ - Link \ unlink attributes to categories
101
+ - Create values for said attributes
102
+ - Update, delete, insert new values for existent attributes
103
+ - Values can initially be created on POST /admin/plugin/attributes endpoint
104
+ - For existent attributes, values can be created, updated, deleted depending on what is passed to POST /admin/plugin/attributes/attrId endpoint and what is currently stored in the DB
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ # @nicogorga/medusa-product-attributes
2
+
3
+ Create global (category specific) product attributes on your Medusa commerce application
4
+
5
+ > [!WARNING]
6
+ > This plugin is a WIP and I am working on it in my spare time between projects and work. Feel free to make contributions by making pull requests and proposing ideas / new flows to implement via [Discussions](https://github.com/NicolasGorga/medusa-product-attributes/discussions)
7
+ > If this helps you, you can buy me a :coffee: or reach out to me if you need help with your MedusaJS projects :wink:
8
+
9
+ ## Compatibility
10
+
11
+ This plugin is compatible with versions >= 2.6.1 of `@medusajs/medusa`.
12
+
13
+ ## Progress
14
+
15
+ All the progress is recorded in CHANGELOG.md and so far, it is solely focused on backend (you can use the functionallities via API calls)
16
+
17
+ ## Roadmap
18
+
19
+ - Create Admin panel widgets link attribute values to products
20
+
21
+ ## Prerequisites
22
+
23
+ - [Node.js v20 or greater](https://nodejs.org/en)
24
+ - [A Medusa backend](https://docs.medusajs.com/learn/installation)
25
+
26
+ ## How to Install
27
+
28
+ 1\. Run the following command in the directory of the Medusa backend using your package manager (for example for npm):
29
+
30
+ ```bash
31
+ npm install @nicogorga/medusa-product-attributes
32
+ ```
33
+
34
+ 2\. In `medusa-config.ts` add the following to the `plugins` array in your project config:
35
+
36
+ ```js
37
+ module.exports = defineConfig({
38
+ projectConfig: {
39
+ // ...
40
+ },
41
+ plugins: [
42
+ {
43
+ resolve: `@nicogorga/medusa-product-attributes`,
44
+ options: {}
45
+ }
46
+ ]
47
+ })
48
+ ```
49
+
50
+ 3\. In your already existent or new createProductsWorkflow.productsCreated hook handler, import `productsCreatedHookHandler` and call it like following. This is important as it's what links new products to the requested attribute values (if any):
51
+
52
+ ```js
53
+ import { createProductsWorkflow } from "@medusajs/medusa/core-flows";
54
+ import { productsCreatedHookHandler } from "@nicogorga/medusa-product-attributes/utils/products-created-handler"
55
+
56
+ createProductsWorkflow.hooks.productsCreated(
57
+ async ({ products, additional_data }, { container }) => {
58
+ const links = await productsCreatedHookHandler({ products, additional_data, container })
59
+
60
+ // Your own logic (if any). You can return 'links' to your compensation function, to dismiss the links if an error occurs
61
+ }
62
+ )
63
+ ```
64
+
65
+ 4\. In your already existent or new updateProductsWorkflow.productsUpdated hook handler, import `productUpdatedHookHandler` and call it like following. This is important as it's what updated the porduct attributes, with the requested attribute values (if any):
66
+
67
+ ```js
68
+ import { updateProductsWorkflow } from "@medusajs/medusa/core-flows";
69
+ import { productsUpdatedHookHandler } from "@nicogorga/medusa-product-attributes/utils/products-updated-handler"
70
+
71
+ updateProductsWorkflow.hooks.productsUpdated(
72
+ async ({ products, additional_data }, { container }) => {
73
+ const links = await productsUpdatedHookHandler({ products, additional_data, container })
74
+
75
+ // Your own logic (if any). You can return 'links' to your compensation function, to dismiss the links if an error occurs
76
+ }
77
+ )
78
+ ```
79
+
80
+ ## Additional Resources
81
+
82
+ - [medusa-custom-attributes v1](https://github.com/vholik/medusa-custom-attributes)
83
+ Props to [Viktor Holik](https://github.com/vholik), the creator, for his work as it is a great reference and has proved to be open to help
84
+ - Github Discussions
85
+ - [Global / Category Based Product Options](https://github.com/medusajs/medusa/discussions/11910)
86
+ - [Global variant options and variant generator](https://github.com/medusajs/medusa/discussions/5119)
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@csbeker/medusa-product-attributes",
3
+ "version": "2.2.0",
4
+ "description": "A plugin for adding attributes support to MedusaJS products",
5
+ "author": "Cronopia Web (https://github.com/cronopia-web)",
6
+ "license": "MIT",
7
+ "files": [
8
+ ".medusa/server"
9
+ ],
10
+ "exports": {
11
+ "./package.json": "./package.json",
12
+ "./workflows": "./.medusa/server/src/workflows/index.js",
13
+ "./.medusa/server/src/modules/*": "./.medusa/server/src/modules/*/index.js",
14
+ "./modules/*": "./.medusa/server/src/modules/*/index.js",
15
+ "./providers/*": "./.medusa/server/src/providers/*/index.js",
16
+ "./admin": {
17
+ "import": "./.medusa/server/src/admin/index.mjs",
18
+ "require": "./.medusa/server/src/admin/index.js",
19
+ "default": "./.medusa/server/src/admin/index.js"
20
+ },
21
+ "./*": "./.medusa/server/src/*.js"
22
+ },
23
+ "keywords": [
24
+ "medusa",
25
+ "plugin",
26
+ "medusa-plugin-other",
27
+ "medusa-plugin",
28
+ "medusa-v2",
29
+ "product-attributes",
30
+ "medusa-product"
31
+ ],
32
+ "scripts": {
33
+ "build": "medusa plugin:build",
34
+ "dev": "medusa plugin:develop",
35
+ "prepublishOnly": "medusa plugin:build"
36
+ },
37
+ "devDependencies": {
38
+ "@dnd-kit/core": "^6.1.0",
39
+ "@dnd-kit/sortable": "^8.0.0",
40
+ "@dnd-kit/utilities": "^3.2.2",
41
+ "@medusajs/admin-sdk": "2.10.3",
42
+ "@medusajs/cli": "2.10.3",
43
+ "@medusajs/framework": "2.10.3",
44
+ "@medusajs/medusa": "2.10.3",
45
+ "@medusajs/js-sdk": "2.10.3",
46
+ "@medusajs/test-utils": "2.10.3",
47
+ "@medusajs/ui": "4.0.4",
48
+ "@medusajs/icons": "2.10.3",
49
+ "@mikro-orm/cli": "6.4.3",
50
+ "@mikro-orm/core": "6.4.3",
51
+ "@mikro-orm/knex": "6.4.3",
52
+ "@mikro-orm/migrations": "6.4.3",
53
+ "@mikro-orm/postgresql": "6.4.3",
54
+ "@swc/core": "1.5.7",
55
+ "@tanstack/react-query": "5.64.2",
56
+ "@types/node": "^20.0.0",
57
+ "@types/react": "^18.3.2",
58
+ "@types/react-dom": "^18.2.25",
59
+ "awilix": "^8.0.1",
60
+ "pg": "^8.13.0",
61
+ "prop-types": "^15.8.1",
62
+ "react": "^18.2.0",
63
+ "react-dom": "^18.2.0",
64
+ "ts-node": "^10.9.2",
65
+ "typescript": "^5.6.2",
66
+ "vite": "^5.2.11",
67
+ "yalc": "^1.0.0-pre.53"
68
+ },
69
+ "peerDependencies": {
70
+ "@medusajs/admin-sdk": "2.10.3",
71
+ "@medusajs/cli": "2.10.3",
72
+ "@medusajs/framework": "2.10.3",
73
+ "@medusajs/test-utils": "2.10.3",
74
+ "@medusajs/medusa": "2.10.3",
75
+ "@medusajs/js-sdk": "2.10.3",
76
+ "@medusajs/ui": "4.0.23",
77
+ "@medusajs/icons": "2.10.3",
78
+ "@mikro-orm/cli": "6.4.3",
79
+ "@mikro-orm/core": "6.4.3",
80
+ "@mikro-orm/knex": "6.4.3",
81
+ "@mikro-orm/migrations": "6.4.3",
82
+ "@mikro-orm/postgresql": "6.4.3",
83
+ "awilix": "^8.0.1",
84
+ "pg": "^8.13.0"
85
+ },
86
+ "engines": {
87
+ "node": ">=20"
88
+ },
89
+ "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
90
+ }
@@ -0,0 +1,31 @@
1
+ # Admin Customizations
2
+
3
+ You can extend the Medusa Admin to add widgets and new pages. Your customizations interact with API routes to provide merchants with custom functionalities.
4
+
5
+ ## Example: Create a Widget
6
+
7
+ A widget is a React component that can be injected into an existing page in the admin dashboard.
8
+
9
+ For example, create the file `src/admin/widgets/product-widget.tsx` with the following content:
10
+
11
+ ```tsx title="src/admin/widgets/product-widget.tsx"
12
+ import { defineWidgetConfig } from "@medusajs/admin-sdk"
13
+
14
+ // The widget
15
+ const ProductWidget = () => {
16
+ return (
17
+ <div>
18
+ <h2>Product Widget</h2>
19
+ </div>
20
+ )
21
+ }
22
+
23
+ // The widget's configurations
24
+ export const config = defineWidgetConfig({
25
+ zone: "product.details.after",
26
+ })
27
+
28
+ export default ProductWidget
29
+ ```
30
+
31
+ This inserts a widget with the text “Product Widget” at the end of a product’s details page.