twenty-backend 0.1.0 → 0.2.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 +4 -4
- metadata +2 -36
- data/.bundle/config +0 -3
- data/.rubocop.yml +0 -34
- data/Gemfile +0 -3
- data/Rakefile.rb +0 -12
- data/lib/twenty-backend/graphql/input/task_input.rb +0 -9
- data/lib/twenty-backend/graphql/input.rb +0 -4
- data/lib/twenty-backend/graphql/mutation/complete_task.rb +0 -15
- data/lib/twenty-backend/graphql/mutation/create_task.rb +0 -13
- data/lib/twenty-backend/graphql/mutation/destroy_task.rb +0 -15
- data/lib/twenty-backend/graphql/mutation/set_random_project_color.rb +0 -17
- data/lib/twenty-backend/graphql/mutation/update_task.rb +0 -15
- data/lib/twenty-backend/graphql/mutation.rb +0 -5
- data/lib/twenty-backend/graphql/schema.rb +0 -6
- data/lib/twenty-backend/graphql/type/mutation.rb +0 -14
- data/lib/twenty-backend/graphql/type/project.rb +0 -10
- data/lib/twenty-backend/graphql/type/query.rb +0 -27
- data/lib/twenty-backend/graphql/type/task.rb +0 -15
- data/lib/twenty-backend/graphql/type/task_status.rb +0 -8
- data/lib/twenty-backend/graphql/type.rb +0 -10
- data/lib/twenty-backend/graphql.rb +0 -7
- data/lib/twenty-backend/migration/1_create_projects.rb +0 -16
- data/lib/twenty-backend/migration/2_create_tasks.rb +0 -17
- data/lib/twenty-backend/migration/3_add_color_to_projects.rb +0 -10
- data/lib/twenty-backend/migration.rb +0 -34
- data/lib/twenty-backend/model/mixin/colorable_mixin.rb +0 -28
- data/lib/twenty-backend/model/project.rb +0 -22
- data/lib/twenty-backend/model/task.rb +0 -18
- data/lib/twenty-backend/model.rb +0 -7
- data/lib/twenty-backend/servlet/graphql.rb +0 -15
- data/lib/twenty-backend/servlet/mixin/server_mixin.rb +0 -27
- data/lib/twenty-backend/servlet.rb +0 -12
- data/lib/twenty-backend.rb +0 -55
- data/share/twenty-backend/schema.graphql +0 -91
- data/twenty-backend.gemspec +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5d3515333763cdd2addfbd7497437068d24021e530a31d6228dd2dd0273585f
|
4
|
+
data.tar.gz: b27b52828b792236211217e3e2b6c20a1cd51befc077b8d481408fdf9abab048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fc71db3d5ea3d155f9d3be4f009bb0b2da1a1177b49bc30a9ddf27d38675b01f01727e7bffc6d7170fefef7a401ba91f7d55700dc0fe9c4c2a59a6f6e8ba86f
|
7
|
+
data.tar.gz: 645e2f7a2bceb2aae04d9871dbf4895626a47db84e00c222012cc57b46b9c777daf25e9823bee87a307cd05b249f9bc3afc33e5c864b0f3fdcc3a42d590971e9
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty-backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- '0x1eef'
|
@@ -114,41 +114,7 @@ email:
|
|
114
114
|
executables: []
|
115
115
|
extensions: []
|
116
116
|
extra_rdoc_files: []
|
117
|
-
files:
|
118
|
-
- ".bundle/config"
|
119
|
-
- ".rubocop.yml"
|
120
|
-
- Gemfile
|
121
|
-
- Rakefile.rb
|
122
|
-
- lib/twenty-backend.rb
|
123
|
-
- lib/twenty-backend/graphql.rb
|
124
|
-
- lib/twenty-backend/graphql/input.rb
|
125
|
-
- lib/twenty-backend/graphql/input/task_input.rb
|
126
|
-
- lib/twenty-backend/graphql/mutation.rb
|
127
|
-
- lib/twenty-backend/graphql/mutation/complete_task.rb
|
128
|
-
- lib/twenty-backend/graphql/mutation/create_task.rb
|
129
|
-
- lib/twenty-backend/graphql/mutation/destroy_task.rb
|
130
|
-
- lib/twenty-backend/graphql/mutation/set_random_project_color.rb
|
131
|
-
- lib/twenty-backend/graphql/mutation/update_task.rb
|
132
|
-
- lib/twenty-backend/graphql/schema.rb
|
133
|
-
- lib/twenty-backend/graphql/type.rb
|
134
|
-
- lib/twenty-backend/graphql/type/mutation.rb
|
135
|
-
- lib/twenty-backend/graphql/type/project.rb
|
136
|
-
- lib/twenty-backend/graphql/type/query.rb
|
137
|
-
- lib/twenty-backend/graphql/type/task.rb
|
138
|
-
- lib/twenty-backend/graphql/type/task_status.rb
|
139
|
-
- lib/twenty-backend/migration.rb
|
140
|
-
- lib/twenty-backend/migration/1_create_projects.rb
|
141
|
-
- lib/twenty-backend/migration/2_create_tasks.rb
|
142
|
-
- lib/twenty-backend/migration/3_add_color_to_projects.rb
|
143
|
-
- lib/twenty-backend/model.rb
|
144
|
-
- lib/twenty-backend/model/mixin/colorable_mixin.rb
|
145
|
-
- lib/twenty-backend/model/project.rb
|
146
|
-
- lib/twenty-backend/model/task.rb
|
147
|
-
- lib/twenty-backend/servlet.rb
|
148
|
-
- lib/twenty-backend/servlet/graphql.rb
|
149
|
-
- lib/twenty-backend/servlet/mixin/server_mixin.rb
|
150
|
-
- share/twenty-backend/schema.graphql
|
151
|
-
- twenty-backend.gemspec
|
117
|
+
files: []
|
152
118
|
homepage: https://github.com/0x1eef/twenty#readme
|
153
119
|
licenses:
|
154
120
|
- 0BSD
|
data/.bundle/config
DELETED
data/.rubocop.yml
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Plugins
|
3
|
-
require:
|
4
|
-
- standard
|
5
|
-
|
6
|
-
##
|
7
|
-
# Defaults: standard-rb
|
8
|
-
inherit_gem:
|
9
|
-
standard: config/base.yml
|
10
|
-
|
11
|
-
##
|
12
|
-
# All cops
|
13
|
-
AllCops:
|
14
|
-
TargetRubyVersion: 3.2
|
15
|
-
Include:
|
16
|
-
- lib/*.rb
|
17
|
-
- lib/**/*.rb
|
18
|
-
- test/*_test.rb
|
19
|
-
|
20
|
-
##
|
21
|
-
# Enabled
|
22
|
-
Style/FrozenStringLiteralComment:
|
23
|
-
Enabled: true
|
24
|
-
|
25
|
-
##
|
26
|
-
# Disabled
|
27
|
-
Layout/ArgumentAlignment:
|
28
|
-
Enabled: false
|
29
|
-
Layout/MultilineMethodCallIndentation:
|
30
|
-
Enabled: false
|
31
|
-
Layout/EmptyLineBetweenDefs:
|
32
|
-
Enabled: false
|
33
|
-
Style/TrivialAccessors:
|
34
|
-
Enabled: false
|
data/Gemfile
DELETED
data/Rakefile.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require "fileutils"
|
3
|
-
|
4
|
-
namespace :schema do
|
5
|
-
desc "Generate share/twenty-backend/schema.graphql"
|
6
|
-
task :regen do
|
7
|
-
require "twenty-backend"
|
8
|
-
schema = File.join(__dir__, "share", "twenty-backend", "schema.graphql")
|
9
|
-
FileUtils.mkdir_p File.dirname(schema)
|
10
|
-
File.binwrite schema, Twenty::GraphQL::Schema.to_definition
|
11
|
-
end
|
12
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Input
|
2
|
-
class TaskInput < GraphQL::Schema::InputObject
|
3
|
-
require_relative "../type/task_status"
|
4
|
-
argument :title, String, required: false
|
5
|
-
argument :content, String, required: false
|
6
|
-
argument :project_id, Int, required: false
|
7
|
-
argument :status, Twenty::GraphQL::Type::TaskStatus, required: false
|
8
|
-
end
|
9
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Mutation
|
2
|
-
class CompleteTask < GraphQL::Schema::Mutation
|
3
|
-
argument :task_id, Int
|
4
|
-
field :ok, Boolean
|
5
|
-
field :errors, [String]
|
6
|
-
|
7
|
-
def resolve(task_id:)
|
8
|
-
task = Twenty::Task.find(task_id)
|
9
|
-
task.update!(status: :complete)
|
10
|
-
{ok: true, errors: []}
|
11
|
-
rescue => ex
|
12
|
-
{ok: false, errors: [ex.message]}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Mutation
|
2
|
-
class CreateTask < GraphQL::Schema::Mutation
|
3
|
-
field :errors, [String], null: false
|
4
|
-
argument :input, Twenty::GraphQL::Input::TaskInput
|
5
|
-
|
6
|
-
def resolve(input:)
|
7
|
-
Twenty::Task.new(input.to_h).save!
|
8
|
-
{"errors" => []}
|
9
|
-
rescue => ex
|
10
|
-
{"errors" => [ex.message]}
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Mutation
|
2
|
-
class DestroyTask < GraphQL::Schema::Mutation
|
3
|
-
argument :task_id, Int
|
4
|
-
field :ok, Boolean
|
5
|
-
field :errors, [String]
|
6
|
-
|
7
|
-
def resolve(task_id:)
|
8
|
-
task = Twenty::Task.find(task_id)
|
9
|
-
task.destroy!
|
10
|
-
{ok: true, errors: []}
|
11
|
-
rescue => ex
|
12
|
-
{ok: false, errors: [ex.message]}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Mutation
|
2
|
-
class SetRandomProjectColor < ::GraphQL::Schema::Mutation
|
3
|
-
require_relative "../type/project"
|
4
|
-
argument :project_id, Int, required: true
|
5
|
-
|
6
|
-
field :errors, [String], null: false
|
7
|
-
field :project, Twenty::GraphQL::Type::Project, null: true
|
8
|
-
|
9
|
-
def resolve(project_id:)
|
10
|
-
project = Twenty::Project.find(project_id)
|
11
|
-
project.update!(color: project.random_color)
|
12
|
-
{errors: [], project:}
|
13
|
-
rescue => ex
|
14
|
-
{errors: [ex.message]}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Mutation
|
2
|
-
class UpdateTask < GraphQL::Schema::Mutation
|
3
|
-
field :errors, [String], null: false
|
4
|
-
argument :task_id, Int
|
5
|
-
argument :input, Twenty::GraphQL::Input::TaskInput
|
6
|
-
|
7
|
-
def resolve(task_id:, input:)
|
8
|
-
task = Twenty::Task.find_by(id: task_id)
|
9
|
-
task.update!(input.to_h)
|
10
|
-
{"errors" => []}
|
11
|
-
rescue => ex
|
12
|
-
{"errors" => [ex.message]}
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Type
|
2
|
-
class Mutation < GraphQL::Schema::Object
|
3
|
-
require_relative "../mutation/destroy_task"
|
4
|
-
require_relative "../mutation/complete_task"
|
5
|
-
require_relative "../mutation/create_task"
|
6
|
-
require_relative "../mutation/update_task"
|
7
|
-
require_relative "../mutation/set_random_project_color"
|
8
|
-
field :destroy_task, mutation: Twenty::GraphQL::Mutation::DestroyTask
|
9
|
-
field :complete_task, mutation: Twenty::GraphQL::Mutation::CompleteTask
|
10
|
-
field :create_task, mutation: Twenty::GraphQL::Mutation::CreateTask
|
11
|
-
field :update_task, mutation: Twenty::GraphQL::Mutation::UpdateTask
|
12
|
-
field :set_random_project_color, mutation: Twenty::GraphQL::Mutation::SetRandomProjectColor
|
13
|
-
end
|
14
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Type
|
2
|
-
class Project < GraphQL::Schema::Object
|
3
|
-
require_relative "task"
|
4
|
-
field :id, Int, null: false
|
5
|
-
field :name, String, null: false
|
6
|
-
field :path, String, null: false
|
7
|
-
field :color, String, null: false
|
8
|
-
field :tasks, [Task], null: false
|
9
|
-
end
|
10
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Type
|
2
|
-
class Query < GraphQL::Schema::Object
|
3
|
-
field :find_task, Task, null: true do
|
4
|
-
argument :task_id, Int
|
5
|
-
end
|
6
|
-
field :tasks, [Task], null: false do
|
7
|
-
argument :status, TaskStatus
|
8
|
-
argument :project_id, Int, required: false
|
9
|
-
end
|
10
|
-
field :projects, [Project], null: false
|
11
|
-
|
12
|
-
def find_task(task_id:)
|
13
|
-
Twenty::Task.find_by(id: task_id)
|
14
|
-
end
|
15
|
-
|
16
|
-
def tasks(status:, project_id: nil)
|
17
|
-
tasks = Twenty::Task
|
18
|
-
.where(status:)
|
19
|
-
.order(updated_at: :desc)
|
20
|
-
project_id ? tasks.where(project_id:) : tasks
|
21
|
-
end
|
22
|
-
|
23
|
-
def projects
|
24
|
-
Twenty::Project.all
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
module Twenty::GraphQL::Type
|
2
|
-
class Task < GraphQL::Schema::Object
|
3
|
-
require_relative "project"
|
4
|
-
field :id, Int, null: false
|
5
|
-
field :title, String, null: false
|
6
|
-
field :status, TaskStatus, null: false
|
7
|
-
field :content, String, null: false
|
8
|
-
field :project, Project, null: false
|
9
|
-
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
|
10
|
-
field :is_ready, Boolean, null: false, method: :ready?
|
11
|
-
field :is_backlogged, Boolean, null: false, method: :backlog?
|
12
|
-
field :is_complete, Boolean, null: false, method: :complete?
|
13
|
-
field :in_progress, Boolean, null: false, method: :in_progress?
|
14
|
-
end
|
15
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateProjects < ActiveRecord::Migration[7.1]
|
4
|
-
def up
|
5
|
-
create_table(:projects) do |t|
|
6
|
-
t.string :name, null: false
|
7
|
-
t.string :path, null: false
|
8
|
-
t.timestamps
|
9
|
-
end
|
10
|
-
add_index :projects, [:name, :path], unique: true
|
11
|
-
end
|
12
|
-
|
13
|
-
def down
|
14
|
-
drop_table(:projects)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class CreateTasks < ActiveRecord::Migration[7.1]
|
4
|
-
def up
|
5
|
-
create_table(:tasks) do |t|
|
6
|
-
t.string :title, null: false
|
7
|
-
t.text :content, null: false
|
8
|
-
t.integer :status, null: false, default: 0
|
9
|
-
t.belongs_to :project, null: false
|
10
|
-
t.timestamps
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def down
|
15
|
-
drop_table(:tasks)
|
16
|
-
end
|
17
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::Migration
|
4
|
-
##
|
5
|
-
# @return [String]
|
6
|
-
# Returns the path to twenty's migrations.
|
7
|
-
def self.migrations_path
|
8
|
-
[File.join(__dir__, "migration")]
|
9
|
-
end
|
10
|
-
|
11
|
-
##
|
12
|
-
# Runs migrations (if neccessary).
|
13
|
-
# @return [void]
|
14
|
-
def self.run!
|
15
|
-
context.migrate
|
16
|
-
end
|
17
|
-
ActiveRecord.timestamped_migrations = false
|
18
|
-
|
19
|
-
##
|
20
|
-
# @return [Boolean]
|
21
|
-
# Returns true when there are pending migrations.
|
22
|
-
def self.pending_migrations?
|
23
|
-
context.open.pending_migrations.any?
|
24
|
-
end
|
25
|
-
|
26
|
-
##
|
27
|
-
# @return [ActiveRecord::MigrationContext]
|
28
|
-
# Returns an instance of
|
29
|
-
# {ActiveRecord::MigrationContext ActiveRecord::MigrationContext}.
|
30
|
-
def self.context
|
31
|
-
@context ||= ActiveRecord::MigrationContext.new(migrations_path)
|
32
|
-
end
|
33
|
-
private_class_method :context
|
34
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Twenty::ColorableMixin
|
2
|
-
extend self
|
3
|
-
|
4
|
-
COLORS = [
|
5
|
-
'#222222', '#333333', '#444444', '#555555', '#666666',
|
6
|
-
'#777777', '#888888', '#999999', '#AA2222', '#22AA22',
|
7
|
-
'#2222AA', '#AA22AA', '#CC9900', '#0099CC', '#9900CC',
|
8
|
-
'#FF9900', '#00CC99', '#99CC00', '#CC0099', '#990000',
|
9
|
-
'#112233', '#445566', '#778899', '#AA4455', '#5544AA',
|
10
|
-
'#88AA44', '#AA88AA', '#CCBB00', '#1155CC', '#9900BB',
|
11
|
-
'#DD6600', '#00BBCC', '#CC0099', '#BB3300', '#006688',
|
12
|
-
'#993366', '#2200AA', '#557788', '#998877', '#BB4400'
|
13
|
-
]
|
14
|
-
|
15
|
-
def self.included(klass)
|
16
|
-
klass.before_validation :set_random_color, on: :create
|
17
|
-
end
|
18
|
-
|
19
|
-
def random_color
|
20
|
-
COLORS.sample
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def set_random_color
|
26
|
-
self.color = random_color
|
27
|
-
end
|
28
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Twenty::Project < Twenty::Model
|
4
|
-
include Twenty::ColorableMixin
|
5
|
-
self.table_name = "projects"
|
6
|
-
|
7
|
-
##
|
8
|
-
# Validations
|
9
|
-
validates :name, presence: true
|
10
|
-
validates :path, presence: true
|
11
|
-
|
12
|
-
##
|
13
|
-
# Associations
|
14
|
-
has_many :tasks, class_name: "Twenty::Task"
|
15
|
-
|
16
|
-
##
|
17
|
-
# @return [String]
|
18
|
-
# The path to a project.
|
19
|
-
def path
|
20
|
-
super&.sub(Dir.home, "~")
|
21
|
-
end
|
22
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class Twenty::Task < Twenty::Model
|
4
|
-
self.table_name = "tasks"
|
5
|
-
|
6
|
-
STATUS = {backlog: 0, ready: 1, in_progress: 2, complete: 3}
|
7
|
-
enum :status, STATUS, default: :backlog
|
8
|
-
|
9
|
-
##
|
10
|
-
# Validations
|
11
|
-
validates :title, presence: true
|
12
|
-
validates :content, presence: true
|
13
|
-
validates :project, presence: true
|
14
|
-
|
15
|
-
##
|
16
|
-
# Associations
|
17
|
-
belongs_to :project, class_name: "Twenty::Project"
|
18
|
-
end
|
data/lib/twenty-backend/model.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class Twenty::Servlet::GraphQL < Twenty::Servlet
|
2
|
-
##
|
3
|
-
# POST /servlet/graphql/
|
4
|
-
def do_POST(req, res)
|
5
|
-
params = JSON.parse(req.body)
|
6
|
-
result = Twenty::GraphQL::Schema.execute(
|
7
|
-
params['query'],
|
8
|
-
variables: params['variables'],
|
9
|
-
context: {}
|
10
|
-
)
|
11
|
-
res['content_type'] = 'application/json'
|
12
|
-
res.status = 200
|
13
|
-
res.body = result.to_json
|
14
|
-
end
|
15
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty::Servlet::ServerMixin
|
4
|
-
##
|
5
|
-
# @param [Hash] options
|
6
|
-
# Server options that take precedence over
|
7
|
-
# {ServerMixin#server_options ServerMixin#server_options}.
|
8
|
-
#
|
9
|
-
# @return [WEBrick::HTTPServer]
|
10
|
-
# Returns an instance of WEBrick::HTTPServer.
|
11
|
-
def server(options = {})
|
12
|
-
server = WEBrick::HTTPServer.new server_options.merge(options)
|
13
|
-
server.mount "/graphql", Twenty::Servlet::GraphQL
|
14
|
-
server
|
15
|
-
end
|
16
|
-
|
17
|
-
##
|
18
|
-
# @return [Hash<Symbol, String>]
|
19
|
-
# The default server options given to WEBrick::HTTPServer.new.
|
20
|
-
def server_options
|
21
|
-
{
|
22
|
-
DocumentRoot: Twenty.build,
|
23
|
-
BindAddress: "127.0.0.1",
|
24
|
-
Port: 2020
|
25
|
-
}
|
26
|
-
end
|
27
|
-
end
|
data/lib/twenty-backend.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Twenty
|
4
|
-
require "fileutils"
|
5
|
-
require "webrick"
|
6
|
-
require "active_record"
|
7
|
-
require_relative "twenty-backend/graphql"
|
8
|
-
require_relative "twenty-backend/servlet"
|
9
|
-
require_relative "twenty-backend/migration"
|
10
|
-
require_relative "twenty-backend/model"
|
11
|
-
extend FileUtils
|
12
|
-
|
13
|
-
##
|
14
|
-
# @return [String]
|
15
|
-
# Returns the directory where twenty stores data.
|
16
|
-
def self.data_dir
|
17
|
-
File.join(Dir.home, ".local", "share", "20")
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# @return [String]
|
22
|
-
# Returns the location of the default SQLite database.
|
23
|
-
def self.default_database
|
24
|
-
@default_database ||= File.join(data_dir, "database.sqlite")
|
25
|
-
end
|
26
|
-
|
27
|
-
##
|
28
|
-
# Establishes a database connection.
|
29
|
-
#
|
30
|
-
# @param [String] path
|
31
|
-
# The path to a SQLite3 database file.
|
32
|
-
#
|
33
|
-
# @return [void]
|
34
|
-
def self.establish_connection(path:)
|
35
|
-
ActiveRecord::Base.establish_connection(
|
36
|
-
adapter: "sqlite3",
|
37
|
-
database: path,
|
38
|
-
pool: 16
|
39
|
-
)
|
40
|
-
end
|
41
|
-
|
42
|
-
##
|
43
|
-
# Prepares the parent directory of the database.
|
44
|
-
# @return [void]
|
45
|
-
# @api private
|
46
|
-
def self.prepare_dir
|
47
|
-
return if File.exist?(default_database)
|
48
|
-
mkdir_p(data_dir)
|
49
|
-
touch(default_database)
|
50
|
-
rescue => ex
|
51
|
-
warn "prepare_dir error: #{ex.message} (#{ex.class})"
|
52
|
-
end
|
53
|
-
private_class_method :prepare_dir
|
54
|
-
prepare_dir
|
55
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
"""
|
2
|
-
Autogenerated return type of CompleteTask.
|
3
|
-
"""
|
4
|
-
type CompleteTaskPayload {
|
5
|
-
errors: [String!]
|
6
|
-
ok: Boolean
|
7
|
-
}
|
8
|
-
|
9
|
-
"""
|
10
|
-
Autogenerated return type of CreateTask.
|
11
|
-
"""
|
12
|
-
type CreateTaskPayload {
|
13
|
-
errors: [String!]!
|
14
|
-
}
|
15
|
-
|
16
|
-
"""
|
17
|
-
Autogenerated return type of DestroyTask.
|
18
|
-
"""
|
19
|
-
type DestroyTaskPayload {
|
20
|
-
errors: [String!]
|
21
|
-
ok: Boolean
|
22
|
-
}
|
23
|
-
|
24
|
-
"""
|
25
|
-
An ISO 8601-encoded datetime
|
26
|
-
"""
|
27
|
-
scalar ISO8601DateTime @specifiedBy(url: "https://tools.ietf.org/html/rfc3339")
|
28
|
-
|
29
|
-
type Mutation {
|
30
|
-
completeTask(taskId: Int!): CompleteTaskPayload
|
31
|
-
createTask(input: TaskInput!): CreateTaskPayload
|
32
|
-
destroyTask(taskId: Int!): DestroyTaskPayload
|
33
|
-
setRandomProjectColor(projectId: Int!): SetRandomProjectColorPayload
|
34
|
-
updateTask(input: TaskInput!, taskId: Int!): UpdateTaskPayload
|
35
|
-
}
|
36
|
-
|
37
|
-
type Project {
|
38
|
-
color: String!
|
39
|
-
id: Int!
|
40
|
-
name: String!
|
41
|
-
path: String!
|
42
|
-
tasks: [Task!]!
|
43
|
-
}
|
44
|
-
|
45
|
-
type Query {
|
46
|
-
findTask(taskId: Int!): Task
|
47
|
-
projects: [Project!]!
|
48
|
-
tasks(projectId: Int, status: TaskStatus!): [Task!]!
|
49
|
-
}
|
50
|
-
|
51
|
-
"""
|
52
|
-
Autogenerated return type of SetRandomProjectColor.
|
53
|
-
"""
|
54
|
-
type SetRandomProjectColorPayload {
|
55
|
-
errors: [String!]!
|
56
|
-
project: Project
|
57
|
-
}
|
58
|
-
|
59
|
-
type Task {
|
60
|
-
content: String!
|
61
|
-
id: Int!
|
62
|
-
inProgress: Boolean!
|
63
|
-
isBacklogged: Boolean!
|
64
|
-
isComplete: Boolean!
|
65
|
-
isReady: Boolean!
|
66
|
-
project: Project!
|
67
|
-
status: TaskStatus!
|
68
|
-
title: String!
|
69
|
-
updatedAt: ISO8601DateTime!
|
70
|
-
}
|
71
|
-
|
72
|
-
input TaskInput {
|
73
|
-
content: String
|
74
|
-
projectId: Int
|
75
|
-
status: TaskStatus
|
76
|
-
title: String
|
77
|
-
}
|
78
|
-
|
79
|
-
enum TaskStatus {
|
80
|
-
backlog
|
81
|
-
complete
|
82
|
-
in_progress
|
83
|
-
ready
|
84
|
-
}
|
85
|
-
|
86
|
-
"""
|
87
|
-
Autogenerated return type of UpdateTask.
|
88
|
-
"""
|
89
|
-
type UpdateTaskPayload {
|
90
|
-
errors: [String!]!
|
91
|
-
}
|
data/twenty-backend.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
Gem::Specification.new do |gem|
|
4
|
-
gem.name = "twenty-backend"
|
5
|
-
gem.authors = ["0x1eef"]
|
6
|
-
gem.email = ["0x1eef@protonmail.com"]
|
7
|
-
gem.homepage = "https://github.com/0x1eef/twenty#readme"
|
8
|
-
gem.version = "0.1.0"
|
9
|
-
gem.licenses = ["0BSD"]
|
10
|
-
gem.files = `git ls-files`.split($/)
|
11
|
-
gem.require_paths = ["lib"]
|
12
|
-
gem.summary = "twenty: backend"
|
13
|
-
gem.description = gem.summary
|
14
|
-
gem.add_runtime_dependency "activerecord", "~> 7.1"
|
15
|
-
gem.add_runtime_dependency "sqlite3", "~> 1.6"
|
16
|
-
gem.add_runtime_dependency "webrick", "~> 1.8"
|
17
|
-
gem.add_runtime_dependency "graphql", "~> 2.2"
|
18
|
-
gem.add_development_dependency "test-unit", "~> 3.5.7"
|
19
|
-
gem.add_development_dependency "standard", "~> 1.13"
|
20
|
-
gem.add_development_dependency "rake", "~> 13.1"
|
21
|
-
end
|