alembic 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +105 -0
- data/Rakefile +6 -0
- data/app/assets/builds/alembic/canvas.js +1 -0
- data/app/assets/builds/alembic/page_builder.css +1 -0
- data/app/assets/builds/alembic/page_builder.js +5 -0
- data/app/assets/stylesheets/alembic/application.css +15 -0
- data/app/controllers/alembic/application_controller.rb +32 -0
- data/app/controllers/alembic/flows_controller.rb +104 -0
- data/app/controllers/alembic/manage/base_controller.rb +16 -0
- data/app/controllers/alembic/manage/canvas_controller.rb +183 -0
- data/app/controllers/alembic/manage/definitions_controller.rb +15 -0
- data/app/controllers/alembic/manage/flows_controller.rb +55 -0
- data/app/controllers/alembic/manage/page_blocks_controller.rb +19 -0
- data/app/controllers/alembic/manage/pages_controller.rb +38 -0
- data/app/controllers/alembic/manage/previews_controller.rb +38 -0
- data/app/controllers/alembic/manage/versions_controller.rb +22 -0
- data/app/controllers/concerns/alembic/manage/authenticates_admin.rb +19 -0
- data/app/controllers/concerns/alembic/manage/draws_canvas.rb +35 -0
- data/app/helpers/alembic/application_helper.rb +11 -0
- data/app/javascript/alembic/canvas/Canvas.jsx +197 -0
- data/app/javascript/alembic/canvas/Connector.jsx +30 -0
- data/app/javascript/alembic/canvas/ConnectorLayer.jsx +31 -0
- data/app/javascript/alembic/canvas/Control.jsx +42 -0
- data/app/javascript/alembic/canvas/Inspector.jsx +44 -0
- data/app/javascript/alembic/canvas/Panel.jsx +67 -0
- data/app/javascript/alembic/canvas/Placeholder.jsx +24 -0
- data/app/javascript/alembic/canvas/Port.jsx +16 -0
- data/app/javascript/alembic/canvas/Records.jsx +34 -0
- data/app/javascript/alembic/canvas/StepCard.jsx +57 -0
- data/app/javascript/alembic/canvas/Toolbar.jsx +19 -0
- data/app/javascript/alembic/canvas/TypePicker.jsx +21 -0
- data/app/javascript/alembic/canvas/changes.js +5 -0
- data/app/javascript/alembic/canvas/choices.js +4 -0
- data/app/javascript/alembic/canvas/flow.js +7 -0
- data/app/javascript/alembic/canvas/flowSender.js +22 -0
- data/app/javascript/alembic/canvas/ids.js +7 -0
- data/app/javascript/alembic/canvas/rows.js +2 -0
- data/app/javascript/alembic/canvas/styles.js +3 -0
- data/app/javascript/alembic/canvas/useConnectors.js +75 -0
- data/app/javascript/alembic/canvas/useFlow.js +17 -0
- data/app/javascript/alembic/canvas.jsx +13 -0
- data/app/javascript/alembic/page_builder/PageBuilder.jsx +18 -0
- data/app/javascript/alembic/page_builder.jsx +10 -0
- data/app/jobs/alembic/application_job.rb +4 -0
- data/app/mailers/alembic/application_mailer.rb +6 -0
- data/app/models/alembic/application_record.rb +5 -0
- data/app/models/alembic/asked.rb +3 -0
- data/app/models/alembic/choice.rb +7 -0
- data/app/models/alembic/flow/admission.rb +19 -0
- data/app/models/alembic/flow/canvas.rb +167 -0
- data/app/models/alembic/flow/change.rb +18 -0
- data/app/models/alembic/flow/condition.rb +24 -0
- data/app/models/alembic/flow/definition.rb +132 -0
- data/app/models/alembic/flow/digest.rb +116 -0
- data/app/models/alembic/flow/document.rb +131 -0
- data/app/models/alembic/flow/drawing.rb +15 -0
- data/app/models/alembic/flow/edge.rb +9 -0
- data/app/models/alembic/flow/edit_history.rb +75 -0
- data/app/models/alembic/flow/layout.rb +88 -0
- data/app/models/alembic/flow/name.rb +15 -0
- data/app/models/alembic/flow/node.rb +5 -0
- data/app/models/alembic/flow/output.rb +23 -0
- data/app/models/alembic/flow/progress/kept.rb +38 -0
- data/app/models/alembic/flow/progress/loose.rb +43 -0
- data/app/models/alembic/flow/progress.rb +11 -0
- data/app/models/alembic/flow/registry.rb +25 -0
- data/app/models/alembic/flow/run.rb +54 -0
- data/app/models/alembic/flow/runner.rb +65 -0
- data/app/models/alembic/flow/settings.rb +80 -0
- data/app/models/alembic/flow/start.rb +13 -0
- data/app/models/alembic/flow/step.rb +42 -0
- data/app/models/alembic/flow/step_type/declaration.rb +118 -0
- data/app/models/alembic/flow/step_type.rb +69 -0
- data/app/models/alembic/flow/summaries.rb +44 -0
- data/app/models/alembic/flow/summary_version.rb +13 -0
- data/app/models/alembic/flow/switch.rb +17 -0
- data/app/models/alembic/flow/terminal.rb +13 -0
- data/app/models/alembic/flow/validator.rb +171 -0
- data/app/models/alembic/flow/version.rb +26 -0
- data/app/models/alembic/flow/violation.rb +9 -0
- data/app/models/alembic/flow.rb +44 -0
- data/app/models/alembic/outputs/band.rb +22 -0
- data/app/models/alembic/outputs/grouped.rb +26 -0
- data/app/models/alembic/outputs/lowest.rb +20 -0
- data/app/models/alembic/outputs/percentage.rb +31 -0
- data/app/models/alembic/outputs/tally.rb +23 -0
- data/app/models/alembic/outputs/weighted_sum.rb +26 -0
- data/app/models/alembic/page.rb +11 -0
- data/app/models/alembic/runner.rb +13 -0
- data/app/models/alembic/steps/question.rb +52 -0
- data/app/models/alembic/summary/output_type.rb +40 -0
- data/app/models/alembic/summary/registry.rb +25 -0
- data/app/models/alembic/summary/report.rb +31 -0
- data/app/models/alembic/summary/result.rb +5 -0
- data/app/models/alembic/summary/run.rb +13 -0
- data/app/models/alembic/summary.rb +15 -0
- data/app/views/alembic/flow/steps/_choosing.html.erb +9 -0
- data/app/views/alembic/flows/complete.html.erb +34 -0
- data/app/views/alembic/flows/show.html.erb +17 -0
- data/app/views/alembic/flows/step.html.erb +27 -0
- data/app/views/alembic/manage/definitions/edit.html.erb +13 -0
- data/app/views/alembic/manage/flows/edit.html.erb +29 -0
- data/app/views/alembic/manage/flows/index.html.erb +32 -0
- data/app/views/alembic/manage/flows/show.html.erb +26 -0
- data/app/views/alembic/manage/pages/_block_content.html.erb +1 -0
- data/app/views/alembic/manage/pages/index.html.erb +20 -0
- data/app/views/alembic/manage/pages/show.html.erb +11 -0
- data/app/views/alembic/manage/versions/index.html.erb +41 -0
- data/app/views/layouts/alembic/application.html.erb +17 -0
- data/config/routes.rb +42 -0
- data/db/migrate/20260604215031_create_alembic_diagnostics.rb +14 -0
- data/db/migrate/20260605015051_create_alembic_questions.rb +12 -0
- data/db/migrate/20260605021526_create_alembic_options.rb +14 -0
- data/db/migrate/20260605023308_create_alembic_conditions.rb +11 -0
- data/db/migrate/20260605025623_create_alembic_bands.rb +12 -0
- data/db/migrate/20260605032859_create_alembic_condition_options.rb +10 -0
- data/db/migrate/20260605032900_reshape_conditions_for_placement.rb +11 -0
- data/db/migrate/20260605125119_create_alembic_results.rb +14 -0
- data/db/migrate/20260605130338_create_alembic_rules.rb +10 -0
- data/db/migrate/20260605130339_create_alembic_rule_results.rb +10 -0
- data/db/migrate/20260605210714_add_definition_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260606000855_add_guide_copy_to_alembic_diagnostics.rb +9 -0
- data/db/migrate/20260606005430_create_alembic_nodes.rb +22 -0
- data/db/migrate/20260606010312_create_alembic_build_steps.rb +12 -0
- data/db/migrate/20260606011110_create_alembic_warnings.rb +11 -0
- data/db/migrate/20260804180000_create_alembic_domains.rb +14 -0
- data/db/migrate/20260804180100_add_domain_to_alembic_questions.rb +5 -0
- data/db/migrate/20260822120000_create_alembic_definition_versions.rb +14 -0
- data/db/migrate/20260822120100_backfill_alembic_definition_versions.rb +17 -0
- data/db/migrate/20260822130000_remove_definition_from_alembic_diagnostics.rb +28 -0
- data/db/migrate/20260822140000_create_alembic_responses.rb +14 -0
- data/db/migrate/20260824120000_create_alembic_transitions.rb +10 -0
- data/db/migrate/20260824130000_drop_alembic_builder_tables.rb +17 -0
- data/db/migrate/20260824140000_add_definition_cursor_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260824160000_add_summary_definition_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260824170000_drop_alembic_guide_copy_columns.rb +8 -0
- data/db/migrate/20260825120000_create_alembic_summary_versions.rb +14 -0
- data/db/migrate/20260825130000_add_summary_cursor_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260825140000_move_summary_definitions_into_versions.rb +26 -0
- data/db/migrate/20260825150000_drop_summary_definition_from_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260825160000_add_summary_version_to_alembic_responses.rb +6 -0
- data/db/migrate/20260825170000_rename_question_settings_in_current_definitions.rb +51 -0
- data/db/migrate/20260825180000_add_document_to_alembic_diagnostics.rb +6 -0
- data/db/migrate/20260825190000_seed_documents_from_current_definitions.rb +29 -0
- data/db/migrate/20260825200000_add_published_version_to_alembic_diagnostics.rb +6 -0
- data/db/migrate/20260825210000_publish_current_definitions.rb +29 -0
- data/db/migrate/20260825220000_add_undone_changes_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260825223322_add_status_to_alembic_definition_versions.rb +8 -0
- data/db/migrate/20260825224538_remove_published_version_from_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260825225015_change_alembic_diagnostic_status_to_availability.rb +16 -0
- data/db/migrate/20260825230000_add_undo_history_to_alembic_diagnostics.rb +5 -0
- data/db/migrate/20260825230500_add_changes_to_alembic_definition_versions.rb +5 -0
- data/db/migrate/20260826230000_rename_alembic_responses_to_flow_runs.rb +5 -0
- data/db/migrate/20260826234500_rename_answers_to_recorded_on_flow_runs.rb +5 -0
- data/db/migrate/20260826235000_rename_definition_versions_to_flow_versions.rb +5 -0
- data/db/migrate/20260826235500_rename_summary_versions_to_flow_summaries.rb +5 -0
- data/db/migrate/20260827000000_rename_diagnostics_to_flows.rb +8 -0
- data/db/migrate/20260831000000_add_persists_to_alembic_flows.rb +5 -0
- data/db/migrate/20260914120000_create_alembic_pages.rb +9 -0
- data/db/migrate/20260915120000_add_blocks_to_alembic_pages.rb +5 -0
- data/lib/alembic/engine.rb +43 -0
- data/lib/alembic/leftover_stylesheet.rb +14 -0
- data/lib/alembic/version.rb +3 -0
- data/lib/alembic.rb +34 -0
- data/lib/tasks/alembic_tasks.rake +4 -0
- metadata +252 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class RemoveDefinitionFromAlembicDiagnostics < ActiveRecord::Migration[8.1]
|
|
2
|
+
class Diagnostic < ActiveRecord::Base
|
|
3
|
+
self.table_name = "alembic_diagnostics"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class DefinitionVersion < ActiveRecord::Base
|
|
7
|
+
self.table_name = "alembic_definition_versions"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def up
|
|
11
|
+
record_definitions_held_only_by_the_column
|
|
12
|
+
remove_column :alembic_diagnostics, :definition
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def down
|
|
16
|
+
add_column :alembic_diagnostics, :definition, :json
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
def record_definitions_held_only_by_the_column
|
|
22
|
+
Diagnostic.where.not(definition: nil).find_each do |diagnostic|
|
|
23
|
+
next if DefinitionVersion.exists?(diagnostic_id: diagnostic.id)
|
|
24
|
+
|
|
25
|
+
DefinitionVersion.create!(diagnostic_id: diagnostic.id, number: 1, definition: diagnostic.definition)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateAlembicResponses < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :alembic_responses do |t|
|
|
4
|
+
t.references :diagnostic, null: false, foreign_key: { to_table: :alembic_diagnostics }
|
|
5
|
+
t.references :definition_version, null: false, foreign_key: { to_table: :alembic_definition_versions }
|
|
6
|
+
t.references :owner, polymorphic: true, null: true
|
|
7
|
+
t.json :answers
|
|
8
|
+
t.string :status
|
|
9
|
+
t.string :label
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
class CreateAlembicTransitions < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :alembic_transitions do |t|
|
|
4
|
+
t.references :from_question, null: false, foreign_key: { to_table: :alembic_questions }
|
|
5
|
+
t.references :to_question, null: false, foreign_key: { to_table: :alembic_questions }
|
|
6
|
+
|
|
7
|
+
t.timestamps
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class DropAlembicBuilderTables < ActiveRecord::Migration[8.1]
|
|
2
|
+
def up
|
|
3
|
+
drop_table :alembic_condition_options
|
|
4
|
+
drop_table :alembic_conditions
|
|
5
|
+
drop_table :alembic_transitions
|
|
6
|
+
drop_table :alembic_options
|
|
7
|
+
drop_table :alembic_build_steps
|
|
8
|
+
drop_table :alembic_rule_results
|
|
9
|
+
drop_table :alembic_rules
|
|
10
|
+
drop_table :alembic_results
|
|
11
|
+
drop_table :alembic_questions
|
|
12
|
+
drop_table :alembic_nodes
|
|
13
|
+
drop_table :alembic_warnings
|
|
14
|
+
drop_table :alembic_bands
|
|
15
|
+
drop_table :alembic_domains
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class DropAlembicGuideCopyColumns < ActiveRecord::Migration[8.1]
|
|
2
|
+
def up
|
|
3
|
+
remove_column :alembic_diagnostics, :kicker
|
|
4
|
+
remove_column :alembic_diagnostics, :headline
|
|
5
|
+
remove_column :alembic_diagnostics, :blurb
|
|
6
|
+
remove_column :alembic_diagnostics, :resolver_key
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class CreateAlembicSummaryVersions < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :alembic_summary_versions do |t|
|
|
4
|
+
t.references :diagnostic, null: false, foreign_key: { to_table: :alembic_diagnostics }
|
|
5
|
+
t.integer :number, null: false
|
|
6
|
+
t.json :summary
|
|
7
|
+
|
|
8
|
+
t.datetime :created_at, null: false
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
add_index :alembic_summary_versions, [ :diagnostic_id, :number ], unique: true,
|
|
12
|
+
name: "index_alembic_summary_versions_on_diagnostic_and_number"
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class MoveSummaryDefinitionsIntoVersions < ActiveRecord::Migration[8.1]
|
|
2
|
+
class Diagnostic < ActiveRecord::Base
|
|
3
|
+
self.table_name = "alembic_diagnostics"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class SummaryVersion < ActiveRecord::Base
|
|
7
|
+
self.table_name = "alembic_summary_versions"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def up
|
|
11
|
+
Diagnostic.where.not(summary_definition: nil).find_each do |diagnostic|
|
|
12
|
+
version = SummaryVersion.create!(diagnostic_id: diagnostic.id, number: 1,
|
|
13
|
+
summary: diagnostic.summary_definition, created_at: Time.current)
|
|
14
|
+
|
|
15
|
+
diagnostic.update_columns(summary_cursor: version.number)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def down
|
|
20
|
+
SummaryVersion.where(number: 1).find_each do |version|
|
|
21
|
+
Diagnostic.where(id: version.diagnostic_id)
|
|
22
|
+
.update_all(summary_definition: version.summary, summary_cursor: nil)
|
|
23
|
+
version.delete
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
class RenameQuestionSettingsInCurrentDefinitions < ActiveRecord::Migration[8.1]
|
|
2
|
+
RENAMED = { "text" => "question", "options" => "answers", "tag" => "category" }.freeze
|
|
3
|
+
|
|
4
|
+
class Diagnostic < ActiveRecord::Base
|
|
5
|
+
self.table_name = "alembic_diagnostics"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
class DefinitionVersion < ActiveRecord::Base
|
|
9
|
+
self.table_name = "alembic_definition_versions"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def up
|
|
13
|
+
Diagnostic.find_each do |diagnostic|
|
|
14
|
+
definition = current_definition(diagnostic)
|
|
15
|
+
renamed = rename(definition)
|
|
16
|
+
next if renamed.nil? || renamed == definition
|
|
17
|
+
|
|
18
|
+
record_definition(diagnostic, renamed)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def down
|
|
23
|
+
raise ActiveRecord::IrreversibleMigration,
|
|
24
|
+
"definition versions are append-only; step back the diagnostic's cursor to undo this"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def current_definition(diagnostic)
|
|
30
|
+
versions = DefinitionVersion.where(diagnostic_id: diagnostic.id)
|
|
31
|
+
versions.find_by(number: diagnostic.definition_cursor || versions.maximum(:number))&.definition
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def record_definition(diagnostic, definition)
|
|
35
|
+
number = (DefinitionVersion.where(diagnostic_id: diagnostic.id).maximum(:number) || 0) + 1
|
|
36
|
+
DefinitionVersion.create!(diagnostic_id: diagnostic.id, number: number, definition: definition)
|
|
37
|
+
diagnostic.update!(definition_cursor: number)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def rename(definition)
|
|
41
|
+
return if definition.blank?
|
|
42
|
+
|
|
43
|
+
definition.merge("nodes" => Array(definition["nodes"]).map { |node| rename_node(node) })
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def rename_node(node)
|
|
47
|
+
return node unless node["type"] == "question"
|
|
48
|
+
|
|
49
|
+
node.to_h { |key, value| [ RENAMED.fetch(key, key), value ] }
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class SeedDocumentsFromCurrentDefinitions < ActiveRecord::Migration[8.1]
|
|
2
|
+
class Diagnostic < ActiveRecord::Base
|
|
3
|
+
self.table_name = "alembic_diagnostics"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class DefinitionVersion < ActiveRecord::Base
|
|
7
|
+
self.table_name = "alembic_definition_versions"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def up
|
|
11
|
+
Diagnostic.find_each do |diagnostic|
|
|
12
|
+
definition = current_definition(diagnostic)
|
|
13
|
+
next if definition.blank?
|
|
14
|
+
|
|
15
|
+
diagnostic.update_columns(document: definition)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def down
|
|
20
|
+
Diagnostic.update_all(document: nil)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def current_definition(diagnostic)
|
|
26
|
+
versions = DefinitionVersion.where(diagnostic_id: diagnostic.id)
|
|
27
|
+
versions.find_by(number: diagnostic.definition_cursor || versions.maximum(:number))&.definition
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
class PublishCurrentDefinitions < ActiveRecord::Migration[8.1]
|
|
2
|
+
class Diagnostic < ActiveRecord::Base
|
|
3
|
+
self.table_name = "alembic_diagnostics"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class DefinitionVersion < ActiveRecord::Base
|
|
7
|
+
self.table_name = "alembic_definition_versions"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def up
|
|
11
|
+
Diagnostic.find_each do |diagnostic|
|
|
12
|
+
current = current_definition_version(diagnostic)
|
|
13
|
+
next if current.nil?
|
|
14
|
+
|
|
15
|
+
diagnostic.update_columns(published_version_id: current.id, status: "published")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def down
|
|
20
|
+
Diagnostic.update_all(published_version_id: nil)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def current_definition_version(diagnostic)
|
|
26
|
+
versions = DefinitionVersion.where(diagnostic_id: diagnostic.id)
|
|
27
|
+
versions.find_by(number: diagnostic.definition_cursor || versions.maximum(:number))
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class AddStatusToAlembicDefinitionVersions < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
add_column :alembic_definition_versions, :status, :string, null: false, default: "draft"
|
|
4
|
+
|
|
5
|
+
add_index :alembic_definition_versions, :diagnostic_id, unique: true,
|
|
6
|
+
where: "status = 'live'", name: "index_alembic_definition_versions_on_one_live_per_diagnostic"
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class ChangeAlembicDiagnosticStatusToAvailability < ActiveRecord::Migration[8.1]
|
|
2
|
+
class Diagnostic < ActiveRecord::Base
|
|
3
|
+
self.table_name = "alembic_diagnostics"
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def up
|
|
7
|
+
Diagnostic.update_all(status: "active")
|
|
8
|
+
change_column_default :alembic_diagnostics, :status, "active"
|
|
9
|
+
change_column_null :alembic_diagnostics, :status, false, "active"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def down
|
|
13
|
+
change_column_null :alembic_diagnostics, :status, true
|
|
14
|
+
change_column_default :alembic_diagnostics, :status, nil
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
class RenameDiagnosticsToFlows < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
rename_table :alembic_diagnostics, :alembic_flows
|
|
4
|
+
rename_column :alembic_flow_versions, :diagnostic_id, :flow_id
|
|
5
|
+
rename_column :alembic_flow_summaries, :diagnostic_id, :flow_id
|
|
6
|
+
rename_column :alembic_flow_runs, :diagnostic_id, :flow_id
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require "alembic/leftover_stylesheet"
|
|
2
|
+
require "keystone_ui-blocks"
|
|
3
|
+
require "keystone_ui-react"
|
|
4
|
+
|
|
5
|
+
module Alembic
|
|
6
|
+
class Engine < ::Rails::Engine
|
|
7
|
+
isolate_namespace Alembic
|
|
8
|
+
|
|
9
|
+
initializer "alembic.remove_leftover_stylesheet" do |app|
|
|
10
|
+
Alembic::LeftoverStylesheet.new(app.root).remove
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
initializer "alembic.tailwind" do
|
|
14
|
+
next unless Gem.loaded_specs.key?("keystone_ui")
|
|
15
|
+
|
|
16
|
+
require "keystone_ui"
|
|
17
|
+
KeystoneUi.configuration.tailwind_sources << root.join("app/views/**/*.erb").to_s
|
|
18
|
+
KeystoneUi.configuration.tailwind_sources << root.join("app/javascript/**/*.{js,jsx}").to_s
|
|
19
|
+
KeystoneUi.configuration.tailwind_sources << root.join("app/assets/builds/alembic/*.js").to_s
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
initializer "alembic.step_types" do |app|
|
|
23
|
+
app.config.to_prepare do
|
|
24
|
+
Alembic::Flow::Start.register
|
|
25
|
+
Alembic::Flow::Terminal.register
|
|
26
|
+
|
|
27
|
+
Alembic::Steps::Question.register
|
|
28
|
+
Alembic::Flow::Condition.register
|
|
29
|
+
Alembic::Flow::Switch.register
|
|
30
|
+
|
|
31
|
+
Alembic::Flow.check(:unrouted_value)
|
|
32
|
+
Alembic::Flow.check(:unfollowed_path)
|
|
33
|
+
Alembic::Flow.check(:dead_end)
|
|
34
|
+
Alembic::Outputs::WeightedSum.register
|
|
35
|
+
Alembic::Outputs::Percentage.register
|
|
36
|
+
Alembic::Outputs::Grouped.register
|
|
37
|
+
Alembic::Outputs::Lowest.register
|
|
38
|
+
Alembic::Outputs::Tally.register
|
|
39
|
+
Alembic::Outputs::Band.register
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require "pathname"
|
|
2
|
+
|
|
3
|
+
module Alembic
|
|
4
|
+
class LeftoverStylesheet
|
|
5
|
+
def initialize(root)
|
|
6
|
+
@root = Pathname.new(root)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def remove
|
|
10
|
+
leftover = @root.join("app/assets/builds/tailwind/alembic.css")
|
|
11
|
+
leftover.delete if leftover.exist?
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/alembic.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
require "alembic/version"
|
|
3
|
+
require "alembic/engine"
|
|
4
|
+
|
|
5
|
+
module Alembic
|
|
6
|
+
class NotPublished < StandardError; end
|
|
7
|
+
class NotPermitted < StandardError; end
|
|
8
|
+
class OutOfService < StandardError; end
|
|
9
|
+
class Withdrawn < StandardError; end
|
|
10
|
+
|
|
11
|
+
class << self
|
|
12
|
+
attr_writer :layout, :base_controller, :admin_layout
|
|
13
|
+
attr_accessor :lead_partial, :admin_authentication_method, :visitor_authorization_method, :refusal_method
|
|
14
|
+
|
|
15
|
+
# The host app sets this to render the engine inside its own layout
|
|
16
|
+
# (e.g. "marketing"). Defaults to the engine's own layout.
|
|
17
|
+
def layout
|
|
18
|
+
@layout || "alembic/application"
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# The host app sets this (e.g. "ApplicationController") so the engine's
|
|
22
|
+
# controllers inherit the host's helpers, layout chrome, and concerns.
|
|
23
|
+
# Defaults to a plain controller.
|
|
24
|
+
def base_controller
|
|
25
|
+
@base_controller || "ActionController::Base"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The host app sets this to render the builder inside its own admin
|
|
29
|
+
# chrome. Defaults to the conventional application layout.
|
|
30
|
+
def admin_layout
|
|
31
|
+
@admin_layout || "application"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|