@lodashventure/medusa-brand 1.1.11 → 1.1.13

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 (56) hide show
  1. package/.medusa/server/api/admin/brands/[id]/image/route.js +119 -0
  2. package/.medusa/server/api/admin/brands/[id]/logo/route.js +119 -0
  3. package/.medusa/server/api/admin/brands/[id]/products/route.js +52 -0
  4. package/.medusa/server/api/admin/brands/[id]/route.js +112 -0
  5. package/.medusa/server/api/admin/brands/route.js +76 -0
  6. package/.medusa/server/api/admin/products/[id]/brand/route.js +117 -0
  7. package/{dist → .medusa/server}/api/middlewares/attach-brand-to-products.js +1 -0
  8. package/{dist → .medusa/server}/api/middlewares.js +1 -0
  9. package/.medusa/server/api/store/brands/route.js +53 -0
  10. package/{dist → .medusa/server}/index.js +1 -0
  11. package/{dist → .medusa/server}/modules/brand/index.js +1 -0
  12. package/{dist → .medusa/server}/modules/brand/migrations/Migration20251021070648.js +1 -0
  13. package/.medusa/server/modules/brand/models/brand.js +43 -0
  14. package/.medusa/server/modules/brand/service.js +11 -0
  15. package/.medusa/server/services/gcs-direct-upload.js +55 -0
  16. package/.medusa/server/src/admin/index.js +972 -0
  17. package/.medusa/server/src/admin/index.mjs +971 -0
  18. package/.medusa/server/workflows/upload-brand-image.js +57 -0
  19. package/package.json +14 -13
  20. package/dist/admin/components/brand-form.d.ts +0 -19
  21. package/dist/admin/components/brand-form.js +0 -182
  22. package/dist/admin/components/brand-image-uploader.d.ts +0 -14
  23. package/dist/admin/components/brand-image-uploader.js +0 -217
  24. package/dist/admin/lib/sdk.d.ts +0 -1
  25. package/dist/admin/lib/sdk.js +0 -14
  26. package/dist/admin/routes/brands/page.d.ts +0 -4
  27. package/dist/admin/routes/brands/page.js +0 -253
  28. package/dist/admin/widgets/product-brand-widget.d.ts +0 -8
  29. package/dist/admin/widgets/product-brand-widget.js +0 -207
  30. package/dist/api/admin/brands/[id]/image/route.js +0 -118
  31. package/dist/api/admin/brands/[id]/logo/route.js +0 -118
  32. package/dist/api/admin/brands/[id]/products/route.js +0 -51
  33. package/dist/api/admin/brands/[id]/route.js +0 -111
  34. package/dist/api/admin/brands/route.js +0 -75
  35. package/dist/api/admin/products/[id]/brand/route.js +0 -116
  36. package/dist/api/store/brands/route.js +0 -50
  37. package/dist/modules/brand/models/brand.js +0 -42
  38. package/dist/modules/brand/service.js +0 -10
  39. package/dist/services/gcs-direct-upload.js +0 -54
  40. package/dist/workflows/upload-brand-image.js +0 -56
  41. /package/{dist → .medusa/server}/api/admin/brands/[id]/image/route.d.ts +0 -0
  42. /package/{dist → .medusa/server}/api/admin/brands/[id]/logo/route.d.ts +0 -0
  43. /package/{dist → .medusa/server}/api/admin/brands/[id]/products/route.d.ts +0 -0
  44. /package/{dist → .medusa/server}/api/admin/brands/[id]/route.d.ts +0 -0
  45. /package/{dist → .medusa/server}/api/admin/brands/route.d.ts +0 -0
  46. /package/{dist → .medusa/server}/api/admin/products/[id]/brand/route.d.ts +0 -0
  47. /package/{dist → .medusa/server}/api/middlewares/attach-brand-to-products.d.ts +0 -0
  48. /package/{dist → .medusa/server}/api/middlewares.d.ts +0 -0
  49. /package/{dist → .medusa/server}/api/store/brands/route.d.ts +0 -0
  50. /package/{dist → .medusa/server}/index.d.ts +0 -0
  51. /package/{dist → .medusa/server}/modules/brand/index.d.ts +0 -0
  52. /package/{dist → .medusa/server}/modules/brand/migrations/Migration20251021070648.d.ts +0 -0
  53. /package/{dist → .medusa/server}/modules/brand/models/brand.d.ts +0 -0
  54. /package/{dist → .medusa/server}/modules/brand/service.d.ts +0 -0
  55. /package/{dist → .medusa/server}/services/gcs-direct-upload.d.ts +0 -0
  56. /package/{dist → .medusa/server}/workflows/upload-brand-image.d.ts +0 -0
@@ -1,56 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uploadBrandImageWorkflow = void 0;
4
- const workflows_sdk_1 = require("@medusajs/framework/workflows-sdk");
5
- const gcs_direct_upload_1 = require("../services/gcs-direct-upload");
6
- const uploadBrandImageStep = (0, workflows_sdk_1.createStep)("upload-brand-image-step", async ({ brandId, imageType, fileData }, { container }) => {
7
- const brandService = container.resolve("brandCustom");
8
- const gcsUploadService = new gcs_direct_upload_1.GcsDirectUploadService();
9
- // Generate unique filename for direct upload
10
- const timestamp = Date.now();
11
- const ext = fileData.filename.split('.').pop() || 'jpg';
12
- const filename = `brands/${imageType}-${brandId}-${timestamp}.${ext}`;
13
- // Convert base64 to buffer
14
- const buffer = Buffer.from(fileData.content, "base64");
15
- // Upload directly to GCS
16
- const publicUrl = await gcsUploadService.uploadFile(filename, buffer, fileData.mimeType);
17
- // Retrieve existing brand
18
- const brand = await brandService.retrieveBrand(brandId);
19
- if (!brand) {
20
- throw new Error(`Brand with id ${brandId} not found`);
21
- }
22
- // Delete old image if it exists
23
- const oldImageUrl = brand[imageType];
24
- if (oldImageUrl) {
25
- try {
26
- if (oldImageUrl.includes('storage.googleapis.com')) {
27
- const parts = oldImageUrl.split('/');
28
- const bucketIndex = parts.indexOf('sangaroon');
29
- if (bucketIndex !== -1 && bucketIndex < parts.length - 1) {
30
- const oldFilename = parts.slice(bucketIndex + 1).join('/');
31
- await gcsUploadService.deleteFile(oldFilename);
32
- }
33
- }
34
- }
35
- catch (error) {
36
- console.error(`Failed to delete old ${imageType}:`, error);
37
- // Continue even if deletion fails
38
- }
39
- }
40
- // Update brand with new image URL
41
- const updateData = {};
42
- updateData[imageType] = publicUrl;
43
- await brandService.updateBrands([{
44
- id: brandId,
45
- ...updateData
46
- }]);
47
- return new workflows_sdk_1.StepResponse({
48
- brandId,
49
- imageType,
50
- imageUrl: publicUrl,
51
- });
52
- });
53
- exports.uploadBrandImageWorkflow = (0, workflows_sdk_1.createWorkflow)("upload-brand-image", (input) => {
54
- const result = uploadBrandImageStep(input);
55
- return new workflows_sdk_1.WorkflowResponse(result);
56
- });
File without changes
File without changes