+ {#if value?.key}
rewriteAttachmentUrl(prodAppId, attachment)
)
} else if (
- columnType === FieldType.ATTACHMENT_SINGLE &&
+ (columnType === FieldType.ATTACHMENT_SINGLE ||
+ columnType === FieldType.SIGNATURE) &&
row[column]
) {
row[column] = rewriteAttachmentUrl(prodAppId, row[column])
diff --git a/packages/server/src/sdk/app/rows/utils.ts b/packages/server/src/sdk/app/rows/utils.ts
index dc9821aba3..a9df4f89cd 100644
--- a/packages/server/src/sdk/app/rows/utils.ts
+++ b/packages/server/src/sdk/app/rows/utils.ts
@@ -181,15 +181,13 @@ export async function validate({
errors[fieldName] = [`${fieldName} is required`]
}
} else if (
- (type === FieldType.ATTACHMENTS ||
- type === FieldType.JSON ||
- type === FieldType.SIGNATURE) &&
+ (type === FieldType.ATTACHMENTS || type === FieldType.JSON) &&
typeof row[fieldName] === "string"
) {
// this should only happen if there is an error
try {
const json = JSON.parse(row[fieldName])
- if (type === FieldType.ATTACHMENTS || type === FieldType.SIGNATURE) {
+ if (type === FieldType.ATTACHMENTS) {
if (Array.isArray(json)) {
row[fieldName] = json
} else {
diff --git a/packages/server/src/sdk/tests/attachments.spec.ts b/packages/server/src/sdk/tests/attachments.spec.ts
index 823e1a575d..d8673b02e6 100644
--- a/packages/server/src/sdk/tests/attachments.spec.ts
+++ b/packages/server/src/sdk/tests/attachments.spec.ts
@@ -94,14 +94,14 @@ describe("should be able to re-write attachment URLs", () => {
},
},
{
- signature: [{ ...attachment }],
+ signature: { ...attachment },
otherCol: "string",
}
)
for (const row of rows) {
expect(row.otherCol).toBe("string")
- expect(row.signature[0].url).toBe("")
- expect(row.signature[0].key).toBe(`${db.name}/attachments/a.png`)
+ expect(row.signature.url).toBe("")
+ expect(row.signature.key).toBe(`${db.name}/attachments/a.png`)
}
})
})
diff --git a/packages/server/src/utilities/rowProcessor/attachments.ts b/packages/server/src/utilities/rowProcessor/attachments.ts
index 762ab6cb07..1d788e5a62 100644
--- a/packages/server/src/utilities/rowProcessor/attachments.ts
+++ b/packages/server/src/utilities/rowProcessor/attachments.ts
@@ -35,7 +35,7 @@ export class AttachmentCleanup {
return []
}
- if (type === FieldType.ATTACHMENTS || type === FieldType.SIGNATURE) {
+ if (type === FieldType.ATTACHMENTS) {
return rowData.map((attachment: any) => attachment.key)
}
return [rowData.key]
diff --git a/packages/server/src/utilities/rowProcessor/index.ts b/packages/server/src/utilities/rowProcessor/index.ts
index ae5ae7992c..11f5e033e6 100644
--- a/packages/server/src/utilities/rowProcessor/index.ts
+++ b/packages/server/src/utilities/rowProcessor/index.ts
@@ -148,17 +148,17 @@ export async function inputProcessing(
}
// remove any attachment urls, they are generated on read
- if (
- field.type === FieldType.ATTACHMENTS ||
- field.type === FieldType.SIGNATURE
- ) {
+ if (field.type === FieldType.ATTACHMENTS) {
const attachments = clonedRow[key]
if (attachments?.length) {
attachments.forEach((attachment: RowAttachment) => {
delete attachment.url
})
}
- } else if (field.type === FieldType.ATTACHMENT_SINGLE) {
+ } else if (
+ field.type === FieldType.ATTACHMENT_SINGLE ||
+ field.type === FieldType.SIGNATURE
+ ) {
const attachment = clonedRow[key]
if (attachment?.url) {
delete clonedRow[key].url
@@ -224,10 +224,7 @@ export async function outputProcessing(
// process complex types: attachements, bb references...
for (let [property, column] of Object.entries(table.schema)) {
- if (
- column.type === FieldType.ATTACHMENTS ||
- column.type === FieldType.SIGNATURE
- ) {
+ if (column.type === FieldType.ATTACHMENTS) {
for (let row of enriched) {
if (row[property] == null || !Array.isArray(row[property])) {
continue
@@ -238,7 +235,10 @@ export async function outputProcessing(
}
})
}
- } else if (column.type === FieldType.ATTACHMENT_SINGLE) {
+ } else if (
+ column.type === FieldType.ATTACHMENT_SINGLE ||
+ column.type === FieldType.SIGNATURE
+ ) {
for (let row of enriched) {
if (!row[property] || Object.keys(row[property]).length === 0) {
continue
diff --git a/packages/server/src/utilities/rowProcessor/map.ts b/packages/server/src/utilities/rowProcessor/map.ts
index 956efc9a4f..2e0ac9efe1 100644
--- a/packages/server/src/utilities/rowProcessor/map.ts
+++ b/packages/server/src/utilities/rowProcessor/map.ts
@@ -113,14 +113,6 @@ export const TYPE_TRANSFORM_MAP: any = {
[undefined]: undefined,
parse: parseArrayString,
},
- //Review this
- [FieldType.SIGNATURE]: {
- //@ts-ignore
- [null]: [],
- //@ts-ignore
- [undefined]: undefined,
- parse: parseArrayString,
- },
[FieldType.BOOLEAN]: {
"": null,
//@ts-ignore
diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts
index 40bde42a5d..2bdc5653af 100644
--- a/packages/server/src/utilities/schema.ts
+++ b/packages/server/src/utilities/schema.ts
@@ -149,7 +149,8 @@ export function parse(rows: Rows, schema: TableSchema): Rows {
}
} else if (
(columnType === FieldType.ATTACHMENTS ||
- columnType === FieldType.ATTACHMENT_SINGLE) &&
+ columnType === FieldType.ATTACHMENT_SINGLE ||
+ columnType === FieldType.SIGNATURE) &&
typeof columnData === "string"
) {
parsedRow[columnName] = parseCsvExport(columnData)