|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +FlowType.seed_once :runtime_id, :identifier do |ft| |
| 4 | + ft.runtime_id = Runtime.find_by(name: 'Code1-Runtime').id |
| 5 | + ft.identifier = 'sample-flow-type' |
| 6 | + ft.version = '0.0.0' |
| 7 | + ft.names = [ |
| 8 | + Translation.new( |
| 9 | + code: 'en', |
| 10 | + content: 'Sample Flow Type' |
| 11 | + ) |
| 12 | + ] |
| 13 | + ft.descriptions = [ |
| 14 | + Translation.new( |
| 15 | + code: 'en', |
| 16 | + content: 'A sample flow type for demonstration purposes.' |
| 17 | + ) |
| 18 | + ] |
| 19 | + ft.aliases = [ |
| 20 | + Translation.new( |
| 21 | + code: 'en', |
| 22 | + content: 'SFT' |
| 23 | + ) |
| 24 | + ] |
| 25 | + ft.display_messages = [ |
| 26 | + Translation.new( |
| 27 | + code: 'en', |
| 28 | + content: 'This is a sample flow type.' |
| 29 | + ) |
| 30 | + ] |
| 31 | + ft.flow_type_settings = [ |
| 32 | + FlowTypeSetting.new( |
| 33 | + identifier: 'url', |
| 34 | + unique: false, |
| 35 | + data_type: DataType.find_by(identifier: 'string', runtime_id: Runtime.find_by(name: 'Code1-Runtime').id), |
| 36 | + names: [ |
| 37 | + Translation.new( |
| 38 | + code: 'en', |
| 39 | + content: 'Url for callback' |
| 40 | + ) |
| 41 | + ], |
| 42 | + descriptions: [ |
| 43 | + Translation.new( |
| 44 | + code: 'en', |
| 45 | + content: 'The URL to be used for callback operations.' |
| 46 | + ) |
| 47 | + ] |
| 48 | + ) |
| 49 | + ] |
| 50 | +end |
| 51 | + |
| 52 | +RuntimeFunctionDefinition.seed_once :runtime_id, :runtime_name do |rfd| |
| 53 | + rfd.runtime_id = Runtime.find_by(name: 'Code1-Runtime').id |
| 54 | + rfd.runtime_name = 'std::math::square' |
| 55 | + rfd.version = '0.0.0' |
| 56 | + rfd.names = [ |
| 57 | + Translation.new( |
| 58 | + code: 'en', |
| 59 | + content: 'Square Function' |
| 60 | + ) |
| 61 | + ] |
| 62 | + rfd.descriptions = [ |
| 63 | + Translation.new( |
| 64 | + code: 'en', |
| 65 | + content: 'Calculates the square of a number.' |
| 66 | + ) |
| 67 | + ] |
| 68 | + rfd.aliases = [ |
| 69 | + Translation.new( |
| 70 | + code: 'en', |
| 71 | + content: '^2' |
| 72 | + ) |
| 73 | + ] |
| 74 | + rfd.parameters = [ |
| 75 | + RuntimeParameterDefinition.new( |
| 76 | + runtime_name: 'std::math::square::value', |
| 77 | + data_type: DataTypeIdentifier.new(data_type: DataType.find_by(identifier: 'number', |
| 78 | + runtime_id: Runtime.find_by( |
| 79 | + name: 'Code1-Runtime' |
| 80 | + ).id)), |
| 81 | + names: [ |
| 82 | + Translation.new( |
| 83 | + code: 'en', |
| 84 | + content: 'Value' |
| 85 | + ) |
| 86 | + ], |
| 87 | + descriptions: [ |
| 88 | + Translation.new( |
| 89 | + code: 'en', |
| 90 | + content: 'The number to be squared.' |
| 91 | + ) |
| 92 | + ] |
| 93 | + ) |
| 94 | + ] |
| 95 | +end |
| 96 | + |
| 97 | +Flow.seed_once :project_id, :name do |flow| |
| 98 | + flow.project_id = NamespaceProject.find_by( |
| 99 | + namespace: Organization.find_by(name: 'Code1').ensure_namespace, |
| 100 | + name: 'First Project' |
| 101 | + ).id |
| 102 | + flow.name = 'Sample Flow' |
| 103 | + |
| 104 | + flow.flow_settings = [ |
| 105 | + FlowSetting.new( |
| 106 | + flow_setting_id: FlowType.find_by(identifier: 'sample-flow-type').flow_type_settings.first.identifier, |
| 107 | + object: 'https://example.com/callback' |
| 108 | + ) |
| 109 | + ] |
| 110 | + |
| 111 | + flow.flow_type = FlowType.find_by(identifier: 'sample-flow-type') |
| 112 | + flow.starting_node = NodeFunction.new( |
| 113 | + runtime_function: RuntimeFunctionDefinition.find_by(runtime_name: 'std::math::square'), |
| 114 | + node_parameters: [ |
| 115 | + NodeParameter.new( |
| 116 | + literal_value: '5', |
| 117 | + runtime_parameter_id: RuntimeFunctionDefinition.find_by(runtime_name: 'std::math::square').parameters.first.id |
| 118 | + ) |
| 119 | + ] |
| 120 | + ) |
| 121 | +end |
0 commit comments