easy_talk_two 1.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/.rubocop.yml +36 -0
- data/CHANGELOG.md +127 -0
- data/CONSTRAINTS.md +70 -0
- data/LICENSE.txt +21 -0
- data/README.md +1060 -0
- data/Rakefile +11 -0
- data/docs/.gitignore +5 -0
- data/docs/404.html +25 -0
- data/docs/Gemfile +38 -0
- data/docs/_config.yml +53 -0
- data/docs/_posts/2024-05-07-welcome-to-jekyll.markdown +29 -0
- data/docs/about.markdown +18 -0
- data/docs/index.markdown +7 -0
- data/lib/easy_talk/active_record_schema_builder.rb +299 -0
- data/lib/easy_talk/builders/base_builder.rb +65 -0
- data/lib/easy_talk/builders/boolean_builder.rb +23 -0
- data/lib/easy_talk/builders/collection_helpers.rb +12 -0
- data/lib/easy_talk/builders/composition_builder.rb +77 -0
- data/lib/easy_talk/builders/integer_builder.rb +28 -0
- data/lib/easy_talk/builders/null_builder.rb +16 -0
- data/lib/easy_talk/builders/number_builder.rb +27 -0
- data/lib/easy_talk/builders/object_builder.rb +180 -0
- data/lib/easy_talk/builders/string_builder.rb +27 -0
- data/lib/easy_talk/builders/temporal_builder.rb +49 -0
- data/lib/easy_talk/builders/typed_array_builder.rb +56 -0
- data/lib/easy_talk/builders/union_builder.rb +37 -0
- data/lib/easy_talk/configuration.rb +29 -0
- data/lib/easy_talk/errors.rb +8 -0
- data/lib/easy_talk/errors_helper.rb +147 -0
- data/lib/easy_talk/keywords.rb +37 -0
- data/lib/easy_talk/model.rb +197 -0
- data/lib/easy_talk/property.rb +130 -0
- data/lib/easy_talk/schema_definition.rb +78 -0
- data/lib/easy_talk/sorbet_extension.rb +15 -0
- data/lib/easy_talk/tools/function_builder.rb +40 -0
- data/lib/easy_talk/types/base_composer.rb +23 -0
- data/lib/easy_talk/types/composer.rb +88 -0
- data/lib/easy_talk/version.rb +5 -0
- data/lib/easy_talk.rb +29 -0
- metadata +265 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38f786e608af9dce72fc8fe00badb22cd0bcb9b4301180a83c8737f582b05f60
|
4
|
+
data.tar.gz: d0369a177d46a64ece53fe7b6b1c8ba1efb7b7b2615dabfc3bb65c85ee1bcd82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa2088c592d2e88dc06e13c4a685ecd2a50c0bd06158c53f7fcaf290782cc4c4ecf7866923792a6e2911ffe4f6655f01b882cf055270500d0abada13a5c1e6c8
|
7
|
+
data.tar.gz: 11b8a0fe99e9188df1d1ae965ec4a5ff3e01a31c51a456d034501cbb5d4e54c9007b74580dc484ad468e2349a5ba577236cb888268bff4f9b76a0ce776f1a797
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
5
|
+
AllCops:
|
6
|
+
TargetRubyVersion: 3.2
|
7
|
+
|
8
|
+
RSpec/SpecFilePathFormat:
|
9
|
+
Enabled: true
|
10
|
+
|
11
|
+
RSpec/SpecFilePathSuffix:
|
12
|
+
Enabled: true
|
13
|
+
|
14
|
+
RSpec/ExampleLength:
|
15
|
+
Max: 10
|
16
|
+
Exclude:
|
17
|
+
- 'spec/easy_talk/examples/**/*'
|
18
|
+
|
19
|
+
Metrics/BlockLength:
|
20
|
+
Exclude:
|
21
|
+
- 'spec/**/*'
|
22
|
+
|
23
|
+
Lint/ConstantDefinitionInBlock:
|
24
|
+
Exclude:
|
25
|
+
- 'spec/**/*'
|
26
|
+
|
27
|
+
Layout/LineLength:
|
28
|
+
Exclude:
|
29
|
+
- 'spec/**/*'
|
30
|
+
|
31
|
+
RSpec/DescribeClass:
|
32
|
+
Exclude:
|
33
|
+
- 'spec/easy_talk/examples/**/*'
|
34
|
+
|
35
|
+
RSpec/MultipleExpectations:
|
36
|
+
Max: 4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
## [1.0.4] - 2024-03-12
|
2
|
+
### Changed
|
3
|
+
- Combined composition builders into a single file (#47)
|
4
|
+
- Improved code organization and maintainability
|
5
|
+
- Refactored internal builder implementation
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
- Added support for nilable properties when database column is null (#45)
|
9
|
+
- Better handling of nullable database columns
|
10
|
+
- More accurate schema generation for ActiveRecord models
|
11
|
+
|
12
|
+
## [1.0.3] - 2025-03-11
|
13
|
+
### Added
|
14
|
+
- Unified schema generation for both plain Ruby classes and ActiveRecord models (#40)
|
15
|
+
- Single code path for generating schemas regardless of model type
|
16
|
+
- More consistent behavior between different model types
|
17
|
+
- Better handling of schema properties in ActiveRecord models
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- Improved error handling throughout the library (#31)
|
21
|
+
- Added custom error types for better error classification
|
22
|
+
- More descriptive error messages for constraint violations
|
23
|
+
- Centralized validation of constraint values
|
24
|
+
- Better type checking for array properties
|
25
|
+
|
26
|
+
### Developer Experience
|
27
|
+
- Removed unnecessary dependencies
|
28
|
+
- Removed dartsass-rails from development dependencies
|
29
|
+
- Code quality improvements
|
30
|
+
- Better test coverage for error conditions
|
31
|
+
- More consistent return values in builder methods
|
32
|
+
|
33
|
+
## [1.0.2] - 2024-13-01
|
34
|
+
- Support "AdditionalProperties". see https://json-schema.org/understanding-json-schema/reference/object#additionalproperties
|
35
|
+
You can now define a schema that allows any additional properties.
|
36
|
+
```ruby
|
37
|
+
class Company
|
38
|
+
include EasyTalk::Model
|
39
|
+
|
40
|
+
define_schema do
|
41
|
+
property :name, String
|
42
|
+
additional_properties true # or false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
You can then do:
|
48
|
+
```ruby
|
49
|
+
company = Company.new
|
50
|
+
company.name = "Acme Corp" # Defined property
|
51
|
+
company.location = "New York" # Additional property
|
52
|
+
company.employee_count = 100 # Additional property
|
53
|
+
```
|
54
|
+
|
55
|
+
company.as_json
|
56
|
+
# => {
|
57
|
+
# "name" => "Acme Corp",
|
58
|
+
# "location" => "New York",
|
59
|
+
# "employee_count" => 100
|
60
|
+
# }
|
61
|
+
```
|
62
|
+
- Fix that we don't conflate nilable properties with optional properties.
|
63
|
+
## [1.0.1] - 2024-09-01
|
64
|
+
- Fixed that property with custom type does not ignore the constraints hash https://github.com/sergiobayona/easy_talk/issues/17
|
65
|
+
## [1.0.0] - 2024-06-01
|
66
|
+
- Use `Hash` instead of `:object` for inline object schema definition.
|
67
|
+
example:
|
68
|
+
```ruby
|
69
|
+
property :email, Hash do
|
70
|
+
property :address, :string
|
71
|
+
property :verified, :boolean
|
72
|
+
end
|
73
|
+
```
|
74
|
+
- Loosen up the gemspec version requirement. Makes it flexible to use the library with future versions of Rails (i.e 8.*).
|
75
|
+
- Removed JSONScheemer gem dependency.
|
76
|
+
- The library does not validate by default anymore. Validating an instance requires that you explicitly define ActiveModel validations in your EasyTalk model. See: https://github.com/sergiobayona/easy_talk/blob/main/spec/easy_talk/activemodel_integration_spec.rb.
|
77
|
+
- Internal improvements to `EasyTalk::ObjectBuilder` class. No changes to the public API.
|
78
|
+
- Expanded the test suite.
|
79
|
+
|
80
|
+
## [0.2.2] - 2024-05-17
|
81
|
+
- Fixed a bug where optional properties were not excluded from the required list.
|
82
|
+
|
83
|
+
## [0.2.1] - 2024-05-06
|
84
|
+
- Run JSON Schema validations using ActiveModel's validations.
|
85
|
+
|
86
|
+
## [0.2.0] - 2024-05-01
|
87
|
+
- Added ActiveModel::API functionality to EasyTalk::Model module. That means you get all the benefits of ActiveModel::API including attribute assignment, introspections, validations, translation (i18n) and more. See https://api.rubyonrails.org/classes/ActiveModel/API.html for more information.
|
88
|
+
|
89
|
+
## [0.1.10] - 2024-04-29
|
90
|
+
- Accept `:optional` key as constraint which excludes property from required node.
|
91
|
+
- Spec fixes
|
92
|
+
## [0.1.9] - 2024-04-29
|
93
|
+
- Added the ability to describe an object schema withing the define_schema block. Example:
|
94
|
+
```ruby
|
95
|
+
...
|
96
|
+
property :email, :object do
|
97
|
+
property :address, :string
|
98
|
+
property :verified, :boolean
|
99
|
+
end
|
100
|
+
```
|
101
|
+
|
102
|
+
## [0.1.8] - 2024-04-24
|
103
|
+
- mostly refactoring without changes to the public API.
|
104
|
+
|
105
|
+
## [0.1.7] - 2024-04-16
|
106
|
+
- general cleanup and refactoring.
|
107
|
+
|
108
|
+
## [0.1.6] - 2024-04-16
|
109
|
+
- model instance takes a hash and converts it to attribute methods.
|
110
|
+
|
111
|
+
## [0.1.5] - 2024-04-15
|
112
|
+
- Added helper method for generating an openai function.
|
113
|
+
|
114
|
+
## [0.1.4] - 2024-04-12
|
115
|
+
- Bumped activesupport gem version.
|
116
|
+
|
117
|
+
## [0.1.3] - 2024-04-12
|
118
|
+
- Bumped json-schema gem version.
|
119
|
+
|
120
|
+
## [0.1.2] - 2024-04-12
|
121
|
+
- Added json validation.
|
122
|
+
|
123
|
+
## [0.1.1] - 2024-04-10
|
124
|
+
- Removed pry-byebug.
|
125
|
+
|
126
|
+
## [0.1.0] - 2024-04-09
|
127
|
+
- Initial release
|
data/CONSTRAINTS.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
The following constraints are supported by the JSON Schema generator:
|
2
|
+
|
3
|
+
## String Properties
|
4
|
+
|
5
|
+
| Constraint | Description |
|
6
|
+
|---------------|---------------|
|
7
|
+
| format | Specifies the format that the string should match (e.g., email, uuid). |
|
8
|
+
| pattern | A regular expression pattern that the string must match. |
|
9
|
+
| min_length | The minimum number of characters for the string. |
|
10
|
+
| max_length | The maximum number of characters for the string. |
|
11
|
+
| enum | An array that specifies the enumerated values the string can take. |
|
12
|
+
| const | Specifies a single constant value the string must be equal to. |
|
13
|
+
| default | The default value for the string. |
|
14
|
+
|
15
|
+
## Integer and Number Properties
|
16
|
+
| Constraint | Description |
|
17
|
+
|-----------------------|---------------|
|
18
|
+
| minimum | The minimum value the integer can be. |
|
19
|
+
| maximum | The maximum value the integer can be. |
|
20
|
+
| exclusive_minimum | If true, the value must be strictly greater than the minimum value. |
|
21
|
+
| exclusive_maximum | If true, the value must be strictly less than the maximum value. |
|
22
|
+
| multiple_of | A number that the integer must be a multiple of. |
|
23
|
+
| enum | An array that specifies the enumerated values the integer can take. |
|
24
|
+
| const | Specifies a single constant value the integer must be equal to. |
|
25
|
+
| default | The default value for the integer. |
|
26
|
+
|
27
|
+
|
28
|
+
## Array Properties
|
29
|
+
| Constraint | Description |
|
30
|
+
|-----------------------|---------------|
|
31
|
+
| min_items | The minimum number of items in the array. |
|
32
|
+
| max_items | The maximum number of items in the array. |
|
33
|
+
| unique_items | If true, all items in the array must be unique. |
|
34
|
+
| items | An object that specifies the schema for each item in the array. |
|
35
|
+
| enum | An array that specifies the enumerated values the array can take. |
|
36
|
+
| const | Specifies a single constant value the array must be equal to. |
|
37
|
+
| default | The default value for the array. |
|
38
|
+
|
39
|
+
|
40
|
+
## Boolean Properties
|
41
|
+
| Constraint | Description |
|
42
|
+
|-----------------------|---------------|
|
43
|
+
| enum | An array that specifies the enumerated values the boolean can take. |
|
44
|
+
| const | Specifies a single constant value the boolean must be equal to. |
|
45
|
+
| default | The default value for the boolean. |
|
46
|
+
|
47
|
+
## Object Properties
|
48
|
+
|
49
|
+
| Constraint | Description |
|
50
|
+
|-----------------------|---------------|
|
51
|
+
| properties | An object that specifies the schema for each property in the object. |
|
52
|
+
| required | An array that specifies the required properties in the object. |
|
53
|
+
| min_properties | The minimum number of properties in the object. |
|
54
|
+
| max_properties | The maximum number of properties in the object. |
|
55
|
+
| additional_properties | An object that specifies the schema for additional properties in the object. |
|
56
|
+
| pattern_properties | An object that specifies the schema for properties that match a regular expression pattern. |
|
57
|
+
|
58
|
+
## Null Properties
|
59
|
+
| Constraint | Description |
|
60
|
+
|-----------------------|---------------|
|
61
|
+
| enum | An array that specifies the enumerated values the null can take. |
|
62
|
+
| const | Specifies a single constant value the null must be equal to. |
|
63
|
+
| default | The default value for the null. |
|
64
|
+
|
65
|
+
|
66
|
+
## All Properties
|
67
|
+
| Constraint | Description |
|
68
|
+
|---------------|---------------|
|
69
|
+
| title | A short summary of what the property represents. |
|
70
|
+
| description | A detailed description of what the property represents. |
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2024 Sergio Bayona
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|