Class: AppBridge::FileProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/app_bridge/file_processor.rb

Overview

Processes file data from WASM component responses.

Uses the output schema to find fields with format: "file-output" and replaces the file data (base64, content_type, filename) with blob IDs via the configured file_uploader.

The WASM component should use file.read to normalize any input format (URL, data URI, raw base64) into a consistent hash structure before output.

Constant Summary collapse

FILE_OUTPUT_FORMAT =
"file-output"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, schema) ⇒ FileProcessor

Returns a new instance of FileProcessor.

Parameters:

  • data (Hash)

    The response data from a WASM component

  • schema (Hash)

    The JSON schema for the response data



28
29
30
31
# File 'lib/app_bridge/file_processor.rb', line 28

def initialize(data, schema)
  @data = deep_dup(data)
  @schema = schema
end

Class Method Details

.call(data, schema) ⇒ Hash

Process file data in a response hash.

Parameters:

  • data (Hash)

    The response data from a WASM component

  • schema (Hash)

    The JSON schema for the response data

Returns:

  • (Hash)

    The processed data with file IDs instead of file data



22
23
24
# File 'lib/app_bridge/file_processor.rb', line 22

def self.call(data, schema)
  new(data, schema).call
end

Instance Method Details

#callHash

Processes the data, uploading files and replacing file data with IDs.

Returns:

  • (Hash)

    The processed data with file IDs



36
37
38
39
# File 'lib/app_bridge/file_processor.rb', line 36

def call
  process_node(@data, @schema)
  @data
end