@programisto/edrm-storage 1.0.6 → 1.0.7

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.
@@ -47,6 +47,9 @@ class EdrmStorageRouter extends EnduranceRouter {
47
47
  * entityId:
48
48
  * type: string
49
49
  * description: Identifiant de l’entité métier associée
50
+ * public:
51
+ * type: boolean
52
+ * description: Si true, image publique accessible depuis n'importe quelle entité (portalEntityId non défini)
50
53
  * provider:
51
54
  * type: string
52
55
  * enum: [S3]
@@ -70,14 +73,23 @@ class EdrmStorageRouter extends EnduranceRouter {
70
73
  */
71
74
  this.post('/files/init', userOptions, async (req, res) => {
72
75
  try {
73
- const { originalName, mimeType, size, tenantId, entityName, entityId, provider = 'S3', metadata, tags } = req.body;
74
- if (!originalName || !mimeType || !size || !tenantId || !entityName || !entityId) {
76
+ const { originalName, mimeType, size, tenantId, entityName, entityId, public: isPublic = false, provider = 'S3', metadata, tags } = req.body;
77
+ const isPublicFile = isPublic === true;
78
+ const effectiveEntityName = isPublicFile ? 'portal' : entityName;
79
+ const effectiveEntityId = isPublicFile ? 'all' : entityId;
80
+ if (!originalName || !mimeType || !size || !tenantId) {
75
81
  return res.status(400).json({
76
82
  success: false,
77
- message: 'Paramètres manquants: originalName, mimeType, size, tenantId, entityName, entityId'
83
+ message: 'Paramètres manquants: originalName, mimeType, size, tenantId'
78
84
  });
79
85
  }
80
- const result = await this.storageService.initUpload(originalName, mimeType, size, tenantId, entityName, entityId, provider, metadata, tags, req.entity?._id?.toString());
86
+ if (!isPublicFile && (!entityName || !entityId)) {
87
+ return res.status(400).json({
88
+ success: false,
89
+ message: 'Paramètres manquants: entityName et entityId (ou public: true)'
90
+ });
91
+ }
92
+ const result = await this.storageService.initUpload(originalName, mimeType, size, tenantId, effectiveEntityName, effectiveEntityId, provider, metadata, tags, isPublicFile ? undefined : req.entity?._id?.toString());
81
93
  return res.json({
82
94
  success: true,
83
95
  data: result
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@programisto/edrm-storage",
4
- "version": "1.0.6",
4
+ "version": "1.0.7",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },