{"flow":{"id":63,"summary":"SQS flow with preprocessor template","versions":[226],"created_by":"dieriba.pro916","created_at":"2025-03-03T16:02:17.286Z","votes":0,"approved":false,"apps":["windmill"],"value":{"modules":[],"preprocessor_module":{"id":"preprocessor","value":{"tag":"","type":"rawscript","content":"/**\n * General Trigger Preprocessor\n * \n * ⚠️ This function runs BEFORE the main function.\n * \n * It processes raw trigger data (e.g., MQTT, HTTP, SQS) before passing it to `main()`.\n * Common tasks:\n * - Convert binary payloads to string/JSON\n * - Extract metadata\n * - Filter messages\n * - Add timestamps/context\n * \n * The returned object determines `main()` parameters:\n * - `{a: 1, b: 2}` → `main(a, b)`\n * - `{msg}` → `main(msg)`\n * \n * @param wm_trigger - Trigger details (e.g., MQTT, HTTP, SQS)\n * @param msg - Raw trigger data (format varies by trigger type)\n * @returns Processed data for `main()`\n */\nexport async function preprocessor(\n  wm_trigger: {\n    kind: 'http' | 'email' | 'webhook' | 'websocket' | 'kafka' | 'nats' | 'postgres' | 'sqs' | 'mqtt',\n    sqs?: {\n      queue_url: string,\n      message_id?: string,\n      receipt_handle?: string,\n      attributes: Record<string, string>,\n      message_attributes?: Record<string, {\n        string_value?: string,\n        data_type: string\n      }>\n    }\n  },\n  msg: string\n) {\n  if (wm_trigger.kind === 'sqs' && wm_trigger.sqs) {\n    return {\n      queueUrl: wm_trigger.sqs.queue_url,\n      messageId: wm_trigger.sqs.message_id,\n      receiptHandle: wm_trigger.sqs.receipt_handle,\n      attributes: wm_trigger.sqs.attributes,\n      messageAttributes: wm_trigger.sqs.message_attributes,\n      msg\n    };\n  }\n  throw new Error(`Expected sqs trigger kind, got: ${wm_trigger.kind}`);\n}\n","language":"bun","input_transforms":{"wm_trigger":{"type":"static"}}}}},"schema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["queueUrl","attributes","msg"],"properties":{"msg":{"type":"string","description":"The actual message body received from SQS."},"queueUrl":{"type":"string","description":"The URL of the SQS queue."},"messageId":{"type":["string","null"],"description":"The unique ID of the SQS message."},"attributes":{"type":"object","description":"Message attributes as key-value pairs.","additionalProperties":{"type":"string"}},"receiptHandle":{"type":["string","null"],"description":"The receipt handle associated with the message for deletion."},"messageAttributes":{"type":"object","description":"Structured message attributes, including data type information.","additionalProperties":{"type":"object","properties":{"data_type":{"type":"string"},"string_value":{"type":["string","null"]}}}}}},"description":"","recording":null,"vcreated_at":"2025-03-03T16:02:17.286Z","vcreated_by":"dieriba.pro916","comments":[]}}