typed_eav 0.1.0 → 0.2.1

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -0
  3. data/README.md +634 -2
  4. data/app/models/typed_eav/field/base.rb +552 -6
  5. data/app/models/typed_eav/field/currency.rb +125 -0
  6. data/app/models/typed_eav/field/file.rb +98 -0
  7. data/app/models/typed_eav/field/image.rb +152 -0
  8. data/app/models/typed_eav/field/percentage.rb +100 -0
  9. data/app/models/typed_eav/field/reference.rb +230 -0
  10. data/app/models/typed_eav/section.rb +114 -4
  11. data/app/models/typed_eav/value.rb +461 -11
  12. data/app/models/typed_eav/value_version.rb +96 -0
  13. data/db/migrate/20260430000000_add_parent_scope_to_typed_eav_partitions.rb +188 -0
  14. data/db/migrate/20260501000000_add_cascade_policy_to_typed_eav_fields.rb +41 -0
  15. data/db/migrate/20260505000000_create_typed_eav_value_versions.rb +120 -0
  16. data/db/migrate/20260506000001_add_version_group_id_to_typed_eav_value_versions.rb +76 -0
  17. data/lib/generators/typed_eav/scaffold/templates/config/initializers/typed_eav.rb +7 -5
  18. data/lib/generators/typed_eav/scaffold/templates/controllers/typed_eav_controller.rb +72 -65
  19. data/lib/generators/typed_eav/scaffold/templates/views/typed_eav/forms/_common_fields.html.erb +13 -3
  20. data/lib/generators/typed_eav/scaffold/templates/views/typed_eav/index.html.erb +2 -0
  21. data/lib/generators/typed_eav/scaffold/templates/views/typed_eav/show.html.erb +3 -0
  22. data/lib/typed_eav/bulk_write.rb +147 -0
  23. data/lib/typed_eav/column_mapping.rb +46 -0
  24. data/lib/typed_eav/config.rb +215 -19
  25. data/lib/typed_eav/csv_mapper.rb +158 -0
  26. data/lib/typed_eav/currency_storage_contract.rb +46 -0
  27. data/lib/typed_eav/engine.rb +117 -0
  28. data/lib/typed_eav/event_dispatcher.rb +151 -0
  29. data/lib/typed_eav/field_storage_contract.rb +68 -0
  30. data/lib/typed_eav/has_typed_eav.rb +455 -58
  31. data/lib/typed_eav/partition.rb +64 -0
  32. data/lib/typed_eav/query_builder.rb +39 -3
  33. data/lib/typed_eav/registry.rb +48 -9
  34. data/lib/typed_eav/schema_portability.rb +250 -0
  35. data/lib/typed_eav/version.rb +1 -1
  36. data/lib/typed_eav/versioned.rb +73 -0
  37. data/lib/typed_eav/versioning/subscriber.rb +161 -0
  38. data/lib/typed_eav/versioning.rb +94 -0
  39. data/lib/typed_eav.rb +180 -12
  40. metadata +36 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d634ac47d7ecea149ffb2d61e837db1a59d7a5dd37f9f4e820baca35a4e5e6c6
4
- data.tar.gz: 507b9bfe48fb62694230196c838cd683050f770d711412d0b56fab35e93cfb5c
3
+ metadata.gz: 630fefbfa32546ed8863b3971600d58188322895db16e80525eac5b8500f7cea
4
+ data.tar.gz: 77a27d9c81984d5c109fac16d87dd79ea34eb15bd10d00a0d62d3c4d9716c65c
5
5
  SHA512:
6
- metadata.gz: 714f43c7d48e4592222298df3ba7065ee40efce7a6e31c49f1342aaa09ae7121082a48e4572035ff173562e077d723bbad5d9dd81a8da01305331ecc7d7ed795
7
- data.tar.gz: 54ee629ae6662faad51aa3357e194455bec33a3d30be5d2675b1d1ddfcc25e386b3d8e7a0cf6786bfb7bc0c2ce4de1b5a52e8444e12591ce7d3a5482cd4807d4
6
+ metadata.gz: 53ab3bd2e9ea76c602e9bfc556d97a20a4caa0b986fce7c3704c149f51b0ba8fedbe25994a40fa38fb227f5dfdec7c54db4c6e9c77af6f6a67fc33edc0edf3f0
7
+ data.tar.gz: 1e5abe7926aa77074b753edc7ad3b6f9b243595acc62d13bfdaf432ef5b71ee17afbb05566732c99543c6eaf30ee2d0bfbd368f1aec6ae02b6eab3415e60f4fe
data/CHANGELOG.md CHANGED
@@ -5,8 +5,97 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.1] - 2026-05-08
9
+
10
+ Metadata-only release.
11
+
12
+ ### Changed
13
+
14
+ - Updated the RubyGems package author metadata to `dchuk`.
15
+
16
+ ## [0.2.0] - 2026-04-29
17
+
18
+ Two-level scope partitioning. Field and section definitions now partition on
19
+ the tuple `(entity_type, scope, parent_scope)`, so an app can scope custom
20
+ fields per workspace inside a tenant (or any second axis your domain needs)
21
+ without giving up the existing single-scope ergonomics.
22
+
23
+ ### Added
24
+
25
+ - `parent_scope_method:` kwarg on `has_typed_eav` for two-level partition keys.
26
+ Requires `scope_method:` — declaring `parent_scope_method:` without it
27
+ raises at macro-expansion time.
28
+ - `parent_scope:` kwarg on `where_typed_eav`, `with_field`, and
29
+ `typed_eav_definitions` for explicit per-query overrides.
30
+ - `TypedEAV.with_scope` accepts a `[scope, parent_scope]` tuple form. The
31
+ scalar form `with_scope(value)` is preserved (treated as `[value, nil]`).
32
+ - `idx_te_sections_lookup` index for parity with `idx_te_fields_lookup`.
33
+
34
+ ### Changed
35
+
36
+ - **BREAKING** `Config.scope_resolver` callables MUST return a 2-element Array
37
+ `[scope, parent_scope]`. v0.1.x callables returning a bare scalar will raise
38
+ `ArgumentError` at the next ambient query — there is no silent fallback. If
39
+ you don't use parent_scope, return `[scope, nil]`.
40
+ - `TypedEAV.current_scope` now returns `[scope, parent_scope]` (or `nil`); was
41
+ a String/nil scalar.
42
+ - `Config::DEFAULT_SCOPE_RESOLVER` (the `acts_as_tenant` auto-detect) returns
43
+ `[ActsAsTenant.current_tenant, nil]`. The parent_scope slot is `nil`
44
+ because the tenant gem has no parent-scope analog.
45
+ - `Field::Base.for_entity` and `Section.for_entity` accept a `parent_scope:`
46
+ kwarg (defaults to `nil`).
47
+ - AR uniqueness validators on `Field` (on `:name`) and `Section` (on `:code`)
48
+ include `parent_scope` in their scope key.
49
+ - Three-way collision precedence in `definitions_by_name`: full-triple wins,
50
+ then scope-only, then global.
51
+ - Paired partial unique indexes now cover the new tuple. Old
52
+ `idx_te_fields_unique_scoped` / `idx_te_fields_unique_global` (and the
53
+ Section equivalents) are replaced by `_uniq_scoped_full` /
54
+ `_uniq_scoped_only` / `_uniq_global` per table.
55
+ - `idx_te_fields_lookup` recreated with `parent_scope` between `scope` and
56
+ `sort_order`.
57
+
58
+ ### Validation
59
+
60
+ - `Field::Base#validate_parent_scope_invariant` rejects rows where
61
+ `parent_scope.present?` and `scope.blank?` (no orphan-parent rows).
62
+ - `Section#validate_parent_scope_invariant` is the symmetric guard.
63
+ - `Value#validate_field_scope_matches_entity` extended to the parent_scope
64
+ axis: a `Value` whose host's `typed_eav_parent_scope` doesn't match the
65
+ field's `parent_scope` is rejected.
66
+
67
+ ### Migration steps
68
+
69
+ 1. Run `bin/rails typed_eav:install:migrations` to copy
70
+ `AddParentScopeToTypedEavPartitions` into your app.
71
+ 2. Run `bin/rails db:migrate`. The migration uses `CREATE INDEX CONCURRENTLY`
72
+ for all index changes and is safe on production tables — existing rows
73
+ are not rewritten.
74
+ 3. Update any custom `TypedEAV.config.scope_resolver` lambda to return
75
+ `[scope, parent_scope]`. If you don't use parent_scope, return
76
+ `[scope, nil]`. A bare scalar return surfaces as `ArgumentError` at
77
+ runtime — there is no silent fallback.
78
+ 4. Optional: declare `parent_scope_method:` on hosts that have an in-tenant
79
+ partition. Existing single-scope models continue to work without changes.
80
+
81
+ See the README ["Migrating from v0.1.x"](README.md#migrating-from-v01x)
82
+ section for the full guidance, including the orphan-parent invariant and
83
+ worked examples.
84
+
85
+ ### References
86
+
87
+ - `5ff7c30` — migration scaffolding (column + paired partials + lookup index).
88
+ - `52014a3` — resolver tuple contract on `with_scope` / `Config`.
89
+ - `6c3afb5` — `Field` partition tuple + orphan-parent guard.
90
+ - `9c7e916` — `Section` partition tuple + orphan-parent guard (symmetric).
91
+ - `c628372` — `parent_scope_method:` macro, query path wiring, `Value`
92
+ cross-axis guard.
93
+ - `e5e78a4` — spec coverage (440 examples, 0 failures).
94
+
8
95
  ## [0.1.0] - 2026-04-25
9
96
 
10
97
  Initial release.
11
98
 
99
+ [0.2.1]: https://github.com/dchuk/typed_eav/releases/tag/v0.2.1
100
+ [0.2.0]: https://github.com/dchuk/typed_eav/releases/tag/v0.2.0
12
101
  [0.1.0]: https://github.com/dchuk/typed_eav/releases/tag/v0.1.0