@researchdatabox/sails-hook-redbox-storage-mongo 1.4.9 → 1.4.10
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.
|
@@ -664,9 +664,11 @@ var Services;
|
|
|
664
664
|
updateDatastream(oid, record, newMetadata, fileRoot, fileIdsAdded) {
|
|
665
665
|
return FormsService.getFormByName(record.metaMetadata.form, true)
|
|
666
666
|
.flatMap(form => {
|
|
667
|
+
form = form !== null && form !== void 0 ? form : { attachmentFields: [] };
|
|
668
|
+
const typedForm = form;
|
|
667
669
|
const reqs = [];
|
|
668
670
|
record.metaMetadata.attachmentFields = form.attachmentFields;
|
|
669
|
-
_.each(
|
|
671
|
+
_.each(typedForm.attachmentFields, (attField) => __awaiter(this, void 0, void 0, function* () {
|
|
670
672
|
const oldAttachments = record.metadata[attField];
|
|
671
673
|
const newAttachments = newMetadata[attField];
|
|
672
674
|
const removeIds = [];
|
package/package.json
CHANGED
|
@@ -706,9 +706,13 @@ export module Services {
|
|
|
706
706
|
// loop thru the attachment fields and determine if we need to add or remove
|
|
707
707
|
return FormsService.getFormByName(record.metaMetadata.form, true)
|
|
708
708
|
.flatMap(form => {
|
|
709
|
+
// For any generated, view-only forms, the form may be null, add a coalescence to avoid breaking
|
|
710
|
+
// the attachment update process.
|
|
711
|
+
form = form ?? { attachmentFields: [] };
|
|
712
|
+
const typedForm = form as { attachmentFields: string[] };
|
|
709
713
|
const reqs = [];
|
|
710
714
|
record.metaMetadata.attachmentFields = form.attachmentFields;
|
|
711
|
-
_.each(
|
|
715
|
+
_.each(typedForm.attachmentFields, async (attField) => {
|
|
712
716
|
const oldAttachments = record.metadata[attField];
|
|
713
717
|
const newAttachments = newMetadata[attField];
|
|
714
718
|
const removeIds = [];
|