code: async function newFormSubmission(submission) {
      const submissionsPath = getSubmissionsPath(submission.formUuid);
      const newSubmission = {};
      newSubmission[submission.uuid] = submission;
      const oldSubmissions = await blockstack_1.getFile(submissionsPath) || {};
      await blockstack_1.putFile(submissionsPath, Object.assign({}, oldSubmissions, newSubmission));
  }
docs: function sortSubmissions(submissions: Submission[]): FormSubmissionMap { return submissions.reduce((acc: FormSubmissionMap, cur: Submission) => { acc[cur.formUuid] = acc[cur.formUuid] || {} as SubmissionMap acc[cur.formUuid][cur.uuid] = cur return acc }, {} as FormSubmissionMap) } // TODO: make the request concurrent for performance if needed async function updateFormSubmissions(forms: FormSubmissionMap) { for (const formUuid in forms) { if (forms.hasOwnProperty(formUuid)) { const newSubmissions = forms[formUuid] const submissionsPath = getSubmissionsPath(formUuid) const oldSubmissions = await getFile(submissionsPath) as SubmissionMap || {} as SubmissionMap console.debug(`form: ${formUuid} new submissions:`, newSubmissions) console.debug(`form: ${formUuid} old submissions:`, oldSubmissions) console.debug(`form: ${formUuid} old + new: `, { ...oldSubmissions, ...newSubmissions }) await putFile(submissionsPath, { ... oldSubmissions, ... newSubmissions }) } } } export async function updateSubmissionsFromBench(submissions: Submission[]) { return updateFormSubmissions(sortSubmissions(submissions)) }