Skip to content

Commit 35de6d4

Browse files
committed
fix: preserve referencedComponentHashes in project export
1 parent 1dc1660 commit 35de6d4

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

pkg/services/projects.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,14 @@ type Project struct {
171171
// AccessControl defines fine-grained permission levels for the project.
172172
// Not supported for import operations.
173173
AccessControl ProjectAccessControl `json:"accessControl"`
174+
175+
// ReferencedComponentHashes lists components that the project references
176+
// but does not contain, each paired with a content hash the platform uses
177+
// to validate the reference during import. It is modeled as a slice of maps
178+
// rather than a typed struct so that every platform-provided field is
179+
// preserved on round-trip. Omitted from the payload when the project has no
180+
// referenced components, matching the platform's UI export.
181+
ReferencedComponentHashes []map[string]interface{} `json:"referencedComponentHashes,omitempty"`
174182
}
175183

176184
// Import returns a map representation of the Project suitable for importing.
@@ -184,7 +192,7 @@ func (p Project) Import() map[string]interface{} {
184192
logging.Trace()
185193

186194
// Pre-allocate map with exact capacity to avoid reallocations
187-
result := make(map[string]interface{}, 11)
195+
result := make(map[string]interface{}, 13)
188196

189197
result["_id"] = p.Id
190198
result["name"] = p.Name
@@ -199,6 +207,13 @@ func (p Project) Import() map[string]interface{} {
199207
result["lastUpdatedBy"] = p.LastUpdatedBy
200208
result["thumbnail"] = p.Thumbnail
201209

210+
// Preserve referenced component hashes so the platform can validate
211+
// externally referenced components on import. Only include the key when
212+
// present to avoid sending a null value for projects without references.
213+
if len(p.ReferencedComponentHashes) > 0 {
214+
result["referencedComponentHashes"] = p.ReferencedComponentHashes
215+
}
216+
202217
return result
203218
}
204219

0 commit comments

Comments
 (0)