Class: Apiwork::Export::SorbusMapper

Inherits:
Object
  • Object
show all
Defined in:
lib/apiwork/export/sorbus_mapper.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(export) ⇒ SorbusMapper

Returns a new instance of SorbusMapper.



12
13
14
15
16
# File 'lib/apiwork/export/sorbus_mapper.rb', line 12

def initialize(export)
  @export = export
  @zod_mapper = ZodMapper.new(export)
  @type_script_mapper = TypeScriptMapper.new(export)
end

Class Method Details

.map(export, surface) ⇒ Object



7
8
9
# File 'lib/apiwork/export/sorbus_mapper.rb', line 7

def map(export, surface)
  new(export).map(surface)
end

Instance Method Details

#map(surface) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/apiwork/export/sorbus_mapper.rb', line 18

def map(surface)
  @surface = surface

  [
    "import { z } from 'zod';",
    @zod_mapper.build_enum_schemas(surface.enums).presence,
    @zod_mapper.build_type_schemas(surface.types).presence,
    build_typescript_types.presence,
    build_contract,
  ].compact.join("\n\n")
end