Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+1
-1
@@ -143,7 +143,7 @@ function ConditionalLogicEditor({
|
||||
>
|
||||
{["equals", "not_equals", "contains", "not_empty", "empty", "in"].map((op) => (
|
||||
<option key={op} value={op}>
|
||||
{t(`settings.forms.builder.properties.conditional.operators.${op}`)}
|
||||
{t(`settings.forms.editor.questions.conditional.operators.${op}`)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
+3
-1
@@ -38,7 +38,8 @@ export type FormActionSetting = {
|
||||
| "send_email_to_team"
|
||||
| "send_email_to_submitter"
|
||||
| "webhook"
|
||||
| "trigger_automation";
|
||||
| "trigger_automation"
|
||||
| "start_double_opt_in";
|
||||
name: string;
|
||||
enabled: boolean;
|
||||
fieldMapping: Record<string, string>;
|
||||
@@ -76,6 +77,7 @@ const ACTION_OPTIONS: Array<{ value: FormActionSetting["actionType"]; labelKey:
|
||||
{ value: "send_email_to_submitter", labelKey: "settings.forms.builder.settings.actions.types.sendEmailToSubmitter" },
|
||||
{ value: "webhook", labelKey: "settings.forms.builder.settings.actions.types.webhook" },
|
||||
{ value: "trigger_automation", labelKey: "settings.forms.builder.settings.actions.types.triggerAutomation" },
|
||||
{ value: "start_double_opt_in", labelKey: "settings.forms.builder.settings.actions.types.startDoubleOptIn" },
|
||||
];
|
||||
|
||||
function joinLines(values: string[]): string {
|
||||
|
||||
+49
-44
@@ -1,9 +1,11 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
|
||||
import { withTenantStorageWriteReservation } from "@hivegrid/db/storage-capacity.server";
|
||||
import { buildFileStorageKeys } from "@hivegrid/storage";
|
||||
import type { FormDefinition } from "@hivegrid/form-widget";
|
||||
import { db } from "~/utils/db.server";
|
||||
import { enqueueFilePreview } from "~/utils/integrations/filePreviewQueue.server";
|
||||
import { withTenantRLS } from "~/utils/db/.server/tenantRls.server";
|
||||
import { enqueueFileScan } from "~/utils/integrations/fileScanQueue.server";
|
||||
import { putBufferAsFile, resolveStorageBucket } from "~/utils/integrations/storageService";
|
||||
import { deleteFile, putBufferAsFile, resolveStorageBucket } from "~/utils/integrations/storageService";
|
||||
|
||||
const FORM_FILE_MAX_BYTES = 25 * 1024 * 1024;
|
||||
|
||||
@@ -35,48 +37,51 @@ export async function prepareUploadedFiles(input: { tenantId: string; formBody:
|
||||
throw new Error(`file-type-blocked:${field.key}`);
|
||||
}
|
||||
}
|
||||
const created = await db.file.create({
|
||||
data: {
|
||||
tenantId: input.tenantId,
|
||||
createdByUserId: "system:form",
|
||||
displayName: file.name.slice(0, 255),
|
||||
mimeType: file.type || "application/octet-stream",
|
||||
sizeBytes: file.size,
|
||||
storageKey: "",
|
||||
source: "form_submission",
|
||||
previewStatus: "pending",
|
||||
scanStatus: "pending",
|
||||
},
|
||||
select: { id: true },
|
||||
});
|
||||
const { original } = buildFileStorageKeys(input.tenantId, created.id);
|
||||
try {
|
||||
await putBufferAsFile({
|
||||
bucket,
|
||||
key: original,
|
||||
body: new Uint8Array(await file.arrayBuffer()),
|
||||
contentType: file.type || "application/octet-stream",
|
||||
});
|
||||
await db.file.update({ where: { id: created.id }, data: { storageKey: original } });
|
||||
await enqueueFileScan({
|
||||
bucket,
|
||||
key: original,
|
||||
tenantId: input.tenantId,
|
||||
contentType: file.type || "application/octet-stream",
|
||||
fileId: created.id,
|
||||
}).catch(() => undefined);
|
||||
await enqueueFilePreview({
|
||||
fileId: created.id,
|
||||
tenantId: input.tenantId,
|
||||
bucket,
|
||||
storageKey: original,
|
||||
mimeType: file.type || "application/octet-stream",
|
||||
}).catch(() => undefined);
|
||||
prepared.push({ fieldKey: field.key, fileId: created.id, kind: field.type });
|
||||
} catch (error) {
|
||||
await db.file.delete({ where: { id: created.id } }).catch(() => undefined);
|
||||
throw error;
|
||||
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||
if (bytes.byteLength !== file.size) {
|
||||
throw new Error(`file-size-mismatch:${field.key}`);
|
||||
}
|
||||
const mimeType = file.type || "application/octet-stream";
|
||||
const displayName = file.name.slice(0, 255) || "upload.bin";
|
||||
const fileId = `file_${randomUUID()}`;
|
||||
const { original } = buildFileStorageKeys(input.tenantId, fileId);
|
||||
await withTenantStorageWriteReservation({
|
||||
reservation: {
|
||||
tenantId: input.tenantId,
|
||||
actorUserId: "system:form",
|
||||
targetFileId: fileId,
|
||||
originalFilename: displayName,
|
||||
mimeType,
|
||||
sizeBytes: bytes.byteLength,
|
||||
},
|
||||
runTransaction: (operation) => withTenantRLS(input.tenantId, operation),
|
||||
upload: () => putBufferAsFile({ bucket, key: original, body: bytes, contentType: mimeType }),
|
||||
commit: async (tx) => {
|
||||
await tx.file.create({
|
||||
data: {
|
||||
id: fileId,
|
||||
tenantId: input.tenantId,
|
||||
createdByUserId: "system:form",
|
||||
displayName,
|
||||
mimeType,
|
||||
sizeBytes: bytes.byteLength,
|
||||
storageKey: original,
|
||||
source: "form_submission",
|
||||
previewStatus: "pending",
|
||||
scanStatus: "pending",
|
||||
},
|
||||
});
|
||||
},
|
||||
rollbackUpload: () => deleteFile({ bucket, key: original }),
|
||||
});
|
||||
await enqueueFileScan({
|
||||
bucket,
|
||||
key: original,
|
||||
tenantId: input.tenantId,
|
||||
contentType: mimeType,
|
||||
fileId,
|
||||
}).catch(() => undefined);
|
||||
prepared.push({ fieldKey: field.key, fileId, kind: field.type });
|
||||
}
|
||||
return prepared;
|
||||
}
|
||||
Reference in new issue
Block a user