schema2type 0.2.3 → 0.4.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
- data/.ruby-version +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +25 -20
- data/README.md +13 -12
- data/lib/schema2type/cli.rb +0 -2
- data/lib/schema2type/conversion_table.yml +6 -6
- data/lib/schema2type/covert_service.rb +5 -0
- data/lib/schema2type/schema_converter.rb +0 -4
- data/lib/schema2type/version.rb +1 -1
- data/schema2type.gemspec +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c33b8832f843a68c17296439b5da86d0b9d34cefa4953d0c99ced68186b9bdce
|
4
|
+
data.tar.gz: 4c6a2641588b56ddb846903e7fa37c16b8a516733d6c98f300e4cddccba68d8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 057bb0162fb706753ca3d15e658349bd011961f5f7feb567c3f5eec329b981f51260c63da1280bb19030310507fdd8ae4c8a03d1afdc848c3d1672acad779d72
|
7
|
+
data.tar.gz: 749dcdbf746789d1d65957723a269d862dab7533170fd6577a7c43a182248f577911d72debbceb43f94cecef0e4baffe010a949b92c1b96c67b253555ec8adfb
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,39 +1,41 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
schema2type (0.
|
4
|
+
schema2type (0.4.0)
|
5
5
|
activesupport
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (
|
10
|
+
activesupport (6.0.3.1)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
12
|
i18n (>= 0.7, < 2)
|
13
13
|
minitest (~> 5.1)
|
14
14
|
tzinfo (~> 1.1)
|
15
|
-
|
15
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
16
|
+
concurrent-ruby (1.1.6)
|
16
17
|
diff-lcs (1.3)
|
17
|
-
i18n (1.
|
18
|
+
i18n (1.8.3)
|
18
19
|
concurrent-ruby (~> 1.0)
|
19
|
-
minitest (5.
|
20
|
-
rake (
|
21
|
-
rspec (3.
|
22
|
-
rspec-core (~> 3.
|
23
|
-
rspec-expectations (~> 3.
|
24
|
-
rspec-mocks (~> 3.
|
25
|
-
rspec-core (3.
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-expectations (3.
|
20
|
+
minitest (5.14.1)
|
21
|
+
rake (13.0.1)
|
22
|
+
rspec (3.9.0)
|
23
|
+
rspec-core (~> 3.9.0)
|
24
|
+
rspec-expectations (~> 3.9.0)
|
25
|
+
rspec-mocks (~> 3.9.0)
|
26
|
+
rspec-core (3.9.2)
|
27
|
+
rspec-support (~> 3.9.3)
|
28
|
+
rspec-expectations (3.9.2)
|
28
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-mocks (3.
|
30
|
+
rspec-support (~> 3.9.0)
|
31
|
+
rspec-mocks (3.9.1)
|
31
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-support (3.
|
33
|
+
rspec-support (~> 3.9.0)
|
34
|
+
rspec-support (3.9.3)
|
34
35
|
thread_safe (0.3.6)
|
35
|
-
tzinfo (1.2.
|
36
|
+
tzinfo (1.2.7)
|
36
37
|
thread_safe (~> 0.1)
|
38
|
+
zeitwerk (2.3.0)
|
37
39
|
|
38
40
|
PLATFORMS
|
39
41
|
ruby
|
@@ -41,9 +43,12 @@ PLATFORMS
|
|
41
43
|
DEPENDENCIES
|
42
44
|
activesupport
|
43
45
|
bundler (~> 2.0)
|
44
|
-
rake (~>
|
46
|
+
rake (~> 13.0)
|
45
47
|
rspec (~> 3.0)
|
46
48
|
schema2type!
|
47
49
|
|
50
|
+
RUBY VERSION
|
51
|
+
ruby 2.7.0p0
|
52
|
+
|
48
53
|
BUNDLED WITH
|
49
|
-
2.
|
54
|
+
2.1.4
|
data/README.md
CHANGED
@@ -22,12 +22,13 @@ Automatically have the following TypesScript type generated.
|
|
22
22
|
```typescript
|
23
23
|
declare namespace schema {
|
24
24
|
type User = {
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
id: number;
|
26
|
+
name: string | null;
|
27
|
+
age: number | null;
|
28
|
+
sales: number | null;
|
29
|
+
paid: boolean;
|
30
|
+
createdAt: string;
|
31
|
+
updatedAt: string;
|
31
32
|
}
|
32
33
|
}
|
33
34
|
```
|
@@ -72,8 +73,8 @@ the schema2type convert as per this conversion table.
|
|
72
73
|
|---|---|
|
73
74
|
| string | string |
|
74
75
|
| text | string |
|
75
|
-
| json | string |
|
76
|
-
| jsonb | string |
|
76
|
+
| json | Record<string, any> |
|
77
|
+
| jsonb | Record<string, any> |
|
77
78
|
| binary | string |
|
78
79
|
| inet | string |
|
79
80
|
| integer | number |
|
@@ -81,10 +82,10 @@ the schema2type convert as per this conversion table.
|
|
81
82
|
| float | number |
|
82
83
|
| decimal | number |
|
83
84
|
| boolean | boolean |
|
84
|
-
| date |
|
85
|
-
| datetime |
|
86
|
-
| timestamp |
|
87
|
-
| datetime_with_timezone |
|
85
|
+
| date | string |
|
86
|
+
| datetime | string |
|
87
|
+
| timestamp | string |
|
88
|
+
| datetime_with_timezone | string |
|
88
89
|
## License
|
89
90
|
|
90
91
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/schema2type/cli.rb
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
module Schema2type
|
2
|
-
|
3
2
|
DEFAULT_SCHEMA_PATH = "./db/schema.rb".freeze
|
4
3
|
DEFAULT_NAME_SPACE = "schema".freeze
|
5
4
|
|
6
5
|
def self.execute(input_file:, out_file:, name_space:, is_snake_case:)
|
7
|
-
|
8
6
|
resultHash = eval(File.read(input_file || DEFAULT_SCHEMA_PATH), CovertService.new(is_snake_case).get_binding)
|
9
7
|
|
10
8
|
File.open(out_file, "w") do |f|
|
@@ -2,15 +2,15 @@
|
|
2
2
|
string: string
|
3
3
|
inet: string
|
4
4
|
text: string
|
5
|
-
json: string
|
6
|
-
jsonb: string
|
5
|
+
json: Record<string, any>
|
6
|
+
jsonb: Record<string, any>
|
7
7
|
binary: string
|
8
8
|
integer: number
|
9
9
|
bigint: number
|
10
10
|
float: number
|
11
11
|
decimal: number
|
12
12
|
boolean: boolean
|
13
|
-
date:
|
14
|
-
datetime:
|
15
|
-
timestamp:
|
16
|
-
datetime_with_timezone:
|
13
|
+
date: string
|
14
|
+
datetime: string
|
15
|
+
timestamp: string
|
16
|
+
datetime_with_timezone: string
|
@@ -16,6 +16,10 @@ module Schema2type
|
|
16
16
|
@converted_types.concat converter.converted_type_lines
|
17
17
|
end
|
18
18
|
|
19
|
+
def skip_dsl(*)
|
20
|
+
@converted_types
|
21
|
+
end
|
22
|
+
|
19
23
|
def method_missing(*)
|
20
24
|
# To exclude unnecessary methods
|
21
25
|
# TODO: add error handling
|
@@ -41,5 +45,6 @@ module Schema2type
|
|
41
45
|
end
|
42
46
|
|
43
47
|
alias create_table convert_schema_to_type
|
48
|
+
alias add_foreign_key skip_dsl
|
44
49
|
end
|
45
50
|
end
|
@@ -5,10 +5,6 @@ module Schema2type
|
|
5
5
|
class SchemaConverter
|
6
6
|
attr_reader :property_lines, :table_name, :is_snake_case
|
7
7
|
|
8
|
-
TYPE_STRING = 'string'.freeze
|
9
|
-
TYPE_NUMBER = 'number'.freeze
|
10
|
-
TYPE_BOOLEAN = 'boolean'.freeze
|
11
|
-
TYPE_DATE = 'Date'.freeze
|
12
8
|
COLUMN_METHODS = YAML.load_file(File.expand_path(__dir__) + '/conversion_table.yml').to_a
|
13
9
|
ID_PROPERTY_LINE_TEXT = " id: number;".freeze
|
14
10
|
|
data/lib/schema2type/version.rb
CHANGED
data/schema2type.gemspec
CHANGED
@@ -24,6 +24,6 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.require_paths = ["lib"]
|
25
25
|
spec.add_runtime_dependency "activesupport"
|
26
26
|
spec.add_development_dependency "bundler", "~> 2.0"
|
27
|
-
spec.add_development_dependency "rake", "~>
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: schema2type
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '13.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '13.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -77,6 +77,7 @@ extra_rdoc_files: []
|
|
77
77
|
files:
|
78
78
|
- ".gitignore"
|
79
79
|
- ".rspec"
|
80
|
+
- ".ruby-version"
|
80
81
|
- ".travis.yml"
|
81
82
|
- CODE_OF_CONDUCT.md
|
82
83
|
- Gemfile
|
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
114
|
- !ruby/object:Gem::Version
|
114
115
|
version: '0'
|
115
116
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
117
|
+
rubygems_version: 3.1.2
|
117
118
|
signing_key:
|
118
119
|
specification_version: 4
|
119
120
|
summary: generate TypeScript type definitions from Rails schema.rb
|