-
Notifications
You must be signed in to change notification settings - Fork 152
Subscription Addons #2626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subscription Addons #2626
Conversation
📝 WalkthroughWalkthroughThis pull request introduces comprehensive support for subscription add-ons in the OpenMeter system. The changes span multiple packages and involve creating new database schemas, entities, repositories, and services to manage subscription add-ons with their associated rate cards and quantities. The implementation adds four primary database tables: Key additions include new structs like Changes
Possibly related PRs
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 golangci-lint (1.64.8)Error: you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2 🔧 SQLFluff (3.3.0)tools/migrate/migrations/20250409142535_subscriptionaddon.up.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: tools/migrate/migrations/20250409142535_subscriptionaddon.down.sqlUser Error: No dialect was specified. You must configure a dialect or specify one on the command line using --dialect after the command. Available dialects: ✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🧹 Nitpick comments (43)
pkg/framework/entutils/mapping.go (2)
10-18: Consider adding documentation for better developer experience.The
MapPagedfunction is well-implemented, using generics effectively to provide type-safe mapping of paginated responses. It correctly preserves the pagination metadata while transforming the items.+// MapPaged transforms a paginated response of type I to a paginated response of type O +// by applying the provided mapper function to each item while preserving pagination metadata. func MapPaged[I, O any](paged pagination.PagedResponse[I], mapper func(I) O) pagination.PagedResponse[O] {
20-31: Error handling approach is appropriate for API usage.The
MapPagedWithErrfunction correctly leverages theslicesx.MapWithErrutility to handle potential errors during mapping. The implementation correctly returns early with an empty response when errors occur, ensuring consumers are notified of failures.+// MapPagedWithErr transforms a paginated response of type I to a paginated response of type O +// by applying the provided mapper function to each item. If any mapping operation results in an error, +// the function returns an empty paginated response along with the error. func MapPagedWithErr[I, O any](paged pagination.PagedResponse[I], mapper func(I) (O, error)) (pagination.PagedResponse[O], error) {openmeter/ent/schema/ratecard.go (4)
13-15: Add documentation for the RateCard structThe
RateCardstruct appears to be a base schema for rate cards in the system, but it lacks documentation explaining its purpose and usage. Consider adding a comment block above the struct definition to clarify its role within the subscription addon feature.+// RateCard defines the base schema for rate cards in the system. +// It provides common fields used by various rate card implementations. type RateCard struct { mixin.Schema }
17-19: Clarify the comment about missing fieldsThe comment on line 18 mentions missing fields that are present in the
UniqueResourceMixin, but this mixin isn't imported or referenced elsewhere in the file. Consider clarifying this comment to provide more context for future developers.func (RateCard) Fields() []ent.Field { - // Name fields (name, description) and key field are missing as they're present in the UniqueResourceMixin... + // Name fields (name, description) and key field are not defined here + // as they're expected to be provided by the UniqueResourceMixin when this schema is used. var fields []ent.Field
23-25: Consider adding documentation for the type fieldThe
typefield is marked as immutable, which indicates it's an important field that shouldn't change after creation. Consider adding a comment explaining the significance of this field and why it's immutable.+ // Type defines the category of rate card and cannot be changed after creation field.Enum("type"). GoType(productcatalog.RateCardType("")). Immutable(),
29-37: Consistent JSON field pattern can be refactoredThe pattern of defining JSON fields with custom value scanners is repeated four times with nearly identical structure. Consider extracting this pattern into a helper function to reduce duplication and improve maintainability.
+// jsonbField creates a string field with JSONB storage and custom value scanner +func jsonbField(name string, goType interface{}, scanner field.ValueScanner) ent.Field { + return field.String(name). + GoType(goType). + ValueScanner(scanner). + SchemaType(map[string]string{ + dialect.Postgres: "jsonb", + }). + Optional(). + Nillable() +} func (RateCard) Fields() []ent.Field { // Name fields (name, description) and key field are missing as they're present in the UniqueResourceMixin... var fields []ent.Field fields = append( fields, field.Enum("type"). GoType(productcatalog.RateCardType("")). Immutable(), field.String("feature_key"). Optional(). Nillable(), - field.String("entitlement_template"). - GoType(&productcatalog.EntitlementTemplate{}). - ValueScanner(EntitlementTemplateValueScanner). - SchemaType(map[string]string{ - dialect.Postgres: "jsonb", - }). - Optional(). - Nillable(), - field.String("tax_config"). - GoType(&productcatalog.TaxConfig{}). - ValueScanner(TaxConfigValueScanner). - SchemaType(map[string]string{ - dialect.Postgres: "jsonb", - }). - Optional(). - Nillable(), + jsonbField("entitlement_template", &productcatalog.EntitlementTemplate{}, EntitlementTemplateValueScanner), + jsonbField("tax_config", &productcatalog.TaxConfig{}, TaxConfigValueScanner), field.String("billing_cadence"). GoType(isodate.String("")). Optional(). Nillable(), - field.String("price"). - GoType(&productcatalog.Price{}). - ValueScanner(PriceValueScanner). - SchemaType(map[string]string{ - dialect.Postgres: "jsonb", - }). - Optional(). - Nillable(), - field.String("discounts"). - GoType(&productcatalog.Discounts{}). - ValueScanner(DiscountsValueScanner). - SchemaType(map[string]string{ - dialect.Postgres: "jsonb", - }). - Optional(). - Nillable(), + jsonbField("price", &productcatalog.Price{}, PriceValueScanner), + jsonbField("discounts", &productcatalog.Discounts{}, DiscountsValueScanner), )Also applies to: 37-45, 49-57, 57-65
openmeter/subscription/addon/README.md (5)
1-3: Enhance Header Clarity and DescriptionConsider refining the header and introductory sentence for improved clarity. For example, you might change from:
-# Subscription Addon -This package contains the subscription addon related functionality. +# Subscription Add-On +This package contains functionality related to subscription add-ons.
5-6: Clarify Diagram ContextThe "Entity Relationship Diagram" heading is clear. It may be beneficial to add a brief introductory note explaining the diagram’s scope or purpose before diving into the rendered diagram.
24-28: SubscriptionAddon Entity ReviewThe
SubscriptionAddonentity correctly encapsulates the relationship between a subscription and an add-on through its foreign keys. In your database implementation, ensure that appropriate indexing and referential integrity constraints are applied to these keys.
40-44: SubscriptionAddonRateCardItemLink EntityThe linking entity is well defined, establishing clear associations via foreign keys. Consider, if applicable, enforcing composite uniqueness constraints to prevent duplicate link entries in the actual database schema.
1-50: Overall Documentation QualityThis README provides a solid introduction to the Subscription Add-On package and includes a helpful ER diagram that illustrates the relationships between the various entities. For further enhancement, consider expanding the documentation with usage examples, installation instructions, or more detailed context regarding how these entities interact within the broader system.
test/customer/testenv.go (1)
113-115: Refactored variable name to improve clarity.The variable name change from
subsServicestosubsDepsreflects the refactoring of the dependency structure in the subscription test utilities, making it clearer that this variable contains various subscription-related dependencies rather than just services.openmeter/subscription/addon/addon.go (1)
20-21: Consider removing commented-out code.There is a commented-out
AddonIDfield that seems to be replaced by theAddonfield. If this is no longer needed, consider removing it completely to avoid confusion.- // AddonID string `json:"addonID"`openmeter/subscription/addon/repo/mapping.go (2)
15-63: Validate error handling inMapSubscriptionAddon.The mapping logic correctly handles conversions and potential errors for both
addonrepo.FromAddonRowand the rate card mapping. However, consider expanding error context or wrapping the original error for better diagnostics when debugging issues related to the addon or rate card mapping.
72-116: Consider consolidating shared logic inMapSubscriptionAddonRateCard.This method correctly maps entity fields and edges. Because the code performs repeated transformations (e.g., copying timestamps, metadata) also seen in other mapping functions, consider extracting a helper to avoid duplication and enhance maintainability.
openmeter/subscription/addon/service.go (1)
25-33: Validation logic could be improved to provide more specific error messages.While the validation checks if
SubscriptionIDis empty, the error message is generic and doesn't specifically mention that the subscription ID is required.Consider using a more specific error message:
- errs = append(errs, errors.New("filter has to be provided, all values are empty")) + errs = append(errs, errors.New("subscriptionID is required"))openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
24-40: Create method handles transactions correctly but lacks error context.The
Createmethod appropriately usesentutils.TransactingRepoto ensure database operations occur within a transaction. However, when an error occurs during entity creation, it's returned without additional context, which might make debugging more difficult.Consider wrapping the error with additional context:
- return nil, err + return nil, fmt.Errorf("failed to create subscription addon quantity: %w", err)Don't forget to add
"fmt"to the imports if you make this change.openmeter/subscription/addon/repository.go (1)
1-2: Package name inconsistencyThe package name
subscriptionaddondoesn't match the directory structuresubscription/addon. Consider renaming the package toaddonto maintain consistency between package names and directory structure.-package subscriptionaddon +package addonopenmeter/subscription/addon/service/create_test.go (2)
66-66: Fix typo in test nameThere's a typo in the test name: "Shoul" should be "Should".
- t.Run("Shoul error if addon doesn't exist", func(t *testing.T) { + t.Run("Should error if addon doesn't exist", func(t *testing.T) {
147-186: Skipped test with implemented codeThis test is marked as skipped with an explanation that a conflict error will always precede it, yet it contains a full implementation. Consider either:
- Removing the skip if the test is actually valid
- Commenting out the implementation if it's truly not possible to test this scenario currently
- Refactoring the test to isolate the specific error case you want to test
openmeter/subscription/addon/service/service.go (3)
1-19: Consider utilizingslog.Loggeror removing the unused import.
Currently, this file imports"log/slog", but there's no usage of theLoggerwithin these lines. To maintain a clean codebase, either log relevant messages or remove the unused import.
49-139: Correct the misspelling of "inconsitency" and address TODO items.
- Lines 65 and 101: Change "inconsitency error" to "inconsistency error".
- Lines 91–92: Consider addressing the TODOs for
NameandDescriptionor track them as separate tasks to ensure they aren't overlooked.Do you want me to open a new issue or provide a follow-up patch to address these TODOs and typos?
154-196: Add a negative/zero quantity safeguard for multi-instance addons.
Currently, the code only checks for quantity > 1 in the single-instance case. Consider additional validation to disallow negative or zero quantities for multi-instance scenarios if that’s not intended by the business logic.openmeter/ent/db/migrate/schema.go (2)
1869-1911: Consider adding composite indexes for frequent queries involving subscription and addon IDs.
The newsubscription_addonstable looks solid. However, if you anticipate frequent lookups by bothsubscription_idandaddon_idtogether, a composite or unique index might improve query performance and enforce uniqueness constraints if that's a business requirement.
1912-1953: Evaluate uniqueness or partial indexes onsubscription_addon_quantities.
If multiple quantities for the same addon are allowed during overlapping periods, everything is fine; otherwise, consider adding a unique constraint on(subscription_addon_id, active_from)to prevent unintended duplication or overlap.openmeter/ent/db/subscriptionaddonratecard.go (3)
56-65: Refine error message for missing SubscriptionAddon edge.
Currently, this returns a generic “not found” error. Consider including additional context (e.g., subscription_addon_id) for more detailed diagnostics.
105-169: Handle partial data gracefully when unmarshalling metadata.
The code works, but consider providing an explicit log or wrap-around to ensure partial or corrupt JSON data does not silently disrupt the application.
210-239: Consider escaping or sanitizingMetadatainString().
IfMetadatacould contain special characters, formatting them safely can help logs/tooling. Overall, the method is otherwise descriptive.openmeter/ent/db/subscriptionaddon.go (1)
98-180: SQL scanning and assignment logic.The
scanValuesandassignValuesfunctions properly distinguish among string, time, and JSON fields (metadata). JSON unmarshaling ofMetadatawith error wrapping is handled well. The usage offmt.Errorf("unmarshal field metadata: %w", err)is a best practice to preserve original error context.Consider uniformly applying
%wfor all error wrapping (e.g., mismatch number of scan values, unexpected type, etc.) to maintain consistent error-chaining and debugging.openmeter/ent/db/subscriptionaddonquantity_update.go (2)
62-88: Use caution withSaveX/ExecXpanics.
CallingSaveXorExecXwill panic on errors. Ensure that panics are recovered or tested when used in production. If panics are not desirable, prefer usingSaveorExecto propagate errors.- func (saqu *SubscriptionAddonQuantityUpdate) SaveX(ctx context.Context) int { + // Consider removing SaveX in favor of only Save if you prefer returning errors + func (saqu *SubscriptionAddonQuantityUpdate) SaveX(ctx context.Context) int { ... }
139-287: Consider adding test coverage for single-entity update flows.
While the generated builder for updating a singleSubscriptionAddonQuantityentity is standard, ensure thorough unit tests cover edge cases (e.g., clearing required edges, partial updates, and error scenarios).openmeter/ent/db/subscriptionaddonratecard_update.go (1)
70-83: Validate item references inAddItems.
Adding item edges by ID could introduce silent errors if any provided IDs are invalid or no longer exist. Consider verifying that all item IDs exist in the system before adding them to avoid partial updates.openmeter/ent/db/subscriptionaddon_query.go (2)
72-92: Verify lazy-loading vs. eager-loading of theQuerySubscriptionedge.
If subscription details are frequently required, consider using an eager load (WithSubscription) early to reduce multiple round trips. Perform load tests to ensure it suits your usage pattern.
160-171: Edge case handling inFirstmethod.
Returns aNotFoundErrorif no result is found. Ensure that client code checks for this error to avoid unexpected panics in production.openmeter/ent/db/subscriptionaddonratecard_query.go (4)
23-37: Use consistent annotation or documentation for the primary query struct.
While the code is clear, consider adding a top-level code comment or docstring to explain how queries are chained and how the internal fields (such asctx,inters, etc.) interact for clarity.
70-90: Consider validating or logging empty query results in relational edges.
When chaining queries on edges likeQuerySubscriptionAddon, code that handles zero matched records could help diagnose misconfigurations at the caller level, or highlight data inconsistencies.
185-197: Ensure your validations handle concurrency or partial data updates.
For example, if a concurrent process modifies the record between a read and the "Only" fetch and the record count changes, theNotSingularErrorlogic is triggered. The code handles it properly, though consider logging or user-friendly error messages if usage extends beyond internal APIs.
661-669: Ensure paging constraints are enforced to avoid large dataset loads.
By default, the query usesmath.MaxInt32if an offset is present but no explicit limit is set. Consider imposing a safer upper bound or requiring a limit to be explicitly set in higher-level code.openmeter/ent/db/subscriptionaddonquantity_create.go (2)
226-247: Provide a clearer error message for constraint errors.
Whensqlgraph.CreateNodefails with a constraint error, you wrap it inConstraintError. Consider adding more context (e.g., which fields caused the constraint violation) if available from the DB engine.
495-534: Structure the bulk creation loop for better maintainability
The block from lines ~495 onward is correct but slightly verbose. Consider extracting multi-line logic into helper functions (e.g., a function to create specs and apply hooks) to keep the method shorter and more readable.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (1)
188-209: Handling constraint errors for cross-table references.
When a mismatch or invalid foreign key is requested, the code setsConstraintError. You might want to log these events or map them to domain-specific errors for clarity.openmeter/ent/db/subscriptionaddonquantity/where.go (1)
68-167: Namespace-related predicates are comprehensive.Having Contains, HasPrefix, HasSuffix, EqualFold, and ContainsFold for the “namespace” field allows flexible string matching. If large data volumes are expected or queries are frequently performed on this field, consider an appropriate database index for performance.
openmeter/ent/db/subscriptionaddon_create.go (1)
613-697: Bulk creation and upsert logic are well-structured.The bulk creation (
SubscriptionAddonCreateBulk) and optional upsert strategies (OnConflict) are implemented cleanly. The approach avoids partial writes by chaining operations and applying conflict resolution. Review any domain-specific concurrency requirements to ensure the existingOnConflictbehavior aligns with expected data consistency.If you need additional concurrency handling or custom conflict resolution strategies (e.g., version fields or timestamp comparisons), let me know. I can help outline or implement them.
Also applies to: 699-880
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/migrate/migrations/atlas.sumis excluded by!**/*.sum
📒 Files selected for processing (107)
openmeter/ent/db/addon.go(3 hunks)openmeter/ent/db/addon/addon.go(3 hunks)openmeter/ent/db/addon/where.go(1 hunks)openmeter/ent/db/addon_create.go(3 hunks)openmeter/ent/db/addon_query.go(7 hunks)openmeter/ent/db/addon_update.go(7 hunks)openmeter/ent/db/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/where.go(2 hunks)openmeter/ent/db/addonratecard_create.go(7 hunks)openmeter/ent/db/addonratecard_query.go(8 hunks)openmeter/ent/db/addonratecard_update.go(9 hunks)openmeter/ent/db/client.go(15 hunks)openmeter/ent/db/ent.go(2 hunks)openmeter/ent/db/expose.go(1 hunks)openmeter/ent/db/hook/hook.go(1 hunks)openmeter/ent/db/migrate/schema.go(3 hunks)openmeter/ent/db/paginate.go(1 hunks)openmeter/ent/db/planratecard.go(3 hunks)openmeter/ent/db/planratecard/planratecard.go(3 hunks)openmeter/ent/db/planratecard/where.go(1 hunks)openmeter/ent/db/planratecard_create.go(4 hunks)openmeter/ent/db/planratecard_update.go(2 hunks)openmeter/ent/db/predicate/predicate.go(1 hunks)openmeter/ent/db/runtime.go(4 hunks)openmeter/ent/db/setorclear.go(3 hunks)openmeter/ent/db/subscription.go(3 hunks)openmeter/ent/db/subscription/subscription.go(4 hunks)openmeter/ent/db/subscription/where.go(1 hunks)openmeter/ent/db/subscription_create.go(3 hunks)openmeter/ent/db/subscription_query.go(8 hunks)openmeter/ent/db/subscription_update.go(7 hunks)openmeter/ent/db/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/where.go(1 hunks)openmeter/ent/db/subscriptionaddon_create.go(1 hunks)openmeter/ent/db/subscriptionaddon_delete.go(1 hunks)openmeter/ent/db/subscriptionaddon_query.go(1 hunks)openmeter/ent/db/subscriptionaddon_update.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/where.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_create.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_query.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go(1 hunks)openmeter/ent/db/subscriptionitem.go(3 hunks)openmeter/ent/db/subscriptionitem/subscriptionitem.go(4 hunks)openmeter/ent/db/subscriptionitem/where.go(1 hunks)openmeter/ent/db/subscriptionitem_create.go(3 hunks)openmeter/ent/db/subscriptionitem_query.go(7 hunks)openmeter/ent/db/subscriptionitem_update.go(7 hunks)openmeter/ent/db/tx.go(2 hunks)openmeter/ent/schema/addon.go(3 hunks)openmeter/ent/schema/productcatalog.go(1 hunks)openmeter/ent/schema/ratecard.go(1 hunks)openmeter/ent/schema/subscription.go(2 hunks)openmeter/ent/schema/subscription_addon.go(1 hunks)openmeter/productcatalog/addon/adapter/addon.go(4 hunks)openmeter/productcatalog/addon/adapter/mapping.go(3 hunks)openmeter/productcatalog/subscription/service/change_test.go(4 hunks)openmeter/productcatalog/subscription/service/migrate_test.go(4 hunks)openmeter/productcatalog/subscription/service/plan_test.go(3 hunks)openmeter/productcatalog/subscriptionaddon.go(1 hunks)openmeter/subscription/addon/README.md(1 hunks)openmeter/subscription/addon/addon.go(1 hunks)openmeter/subscription/addon/addonratecard.go(1 hunks)openmeter/subscription/addon/quantity.go(1 hunks)openmeter/subscription/addon/repo/mapping.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddon.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonquantity.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonratecard.go(1 hunks)openmeter/subscription/addon/repo/transaction.go(1 hunks)openmeter/subscription/addon/repository.go(1 hunks)openmeter/subscription/addon/service.go(1 hunks)openmeter/subscription/addon/service/change_test.go(1 hunks)openmeter/subscription/addon/service/create_test.go(1 hunks)openmeter/subscription/addon/service/list_test.go(1 hunks)openmeter/subscription/addon/service/service.go(1 hunks)openmeter/subscription/patch/removeitem_test.go(1 hunks)openmeter/subscription/service/service_test.go(8 hunks)openmeter/subscription/service/sync_test.go(2 hunks)openmeter/subscription/testutils/addon.go(1 hunks)openmeter/subscription/testutils/compare.go(2 hunks)openmeter/subscription/testutils/feature.go(3 hunks)openmeter/subscription/testutils/plan.go(2 hunks)openmeter/subscription/testutils/ratecard.go(4 hunks)openmeter/subscription/testutils/service.go(3 hunks)openmeter/subscription/workflow/service/subscription_test.go(16 hunks)pkg/framework/entutils/mapping.go(1 hunks)test/customer/testenv.go(2 hunks)test/subscription/framework_test.go(2 hunks)tools/migrate/migrations/20250408100627_subscriptionaddon.down.sql(1 hunks)
⛔ Files not processed due to max files limit (1)
- tools/migrate/migrations/20250408100627_subscriptionaddon.up.sql
🧰 Additional context used
🧬 Code Definitions (89)
openmeter/subscription/testutils/plan.go (1)
openmeter/subscription/testutils/ratecard.go (1)
ExampleRateCard3ForAddons(54-77)
openmeter/ent/db/tx.go (8)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/client.go (4)
SubscriptionAddonClient(6216-6218)SubscriptionAddonQuantityClient(6413-6415)SubscriptionAddonRateCardClient(6562-6564)SubscriptionAddonRateCardItemLinkClient(6743-6745)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/planratecard.go (2)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/planratecard/planratecard.go (2)
FieldDiscounts(49-49)ValueScanner(124-129)
test/subscription/framework_test.go (1)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)
openmeter/subscription/addon/addonratecard.go (4)
pkg/models/model.go (1)
ManagedModel(107-113)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)openmeter/ent/schema/addon.go (5)
AddonRateCard(83-85)AddonRateCard(87-91)AddonRateCard(93-107)AddonRateCard(109-125)AddonRateCard(127-140)openmeter/ent/schema/ratecard.go (2)
RateCard(13-15)RateCard(17-68)
openmeter/subscription/patch/removeitem_test.go (1)
openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey(13-13)
openmeter/subscription/addon/addon.go (4)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/subscription/addon/addonratecard.go (2)
SubscriptionAddonRateCard(8-15)CreateSubscriptionAddonRateCardInput(17-21)pkg/timeutil/timeline.go (1)
Timeline(42-44)openmeter/subscription/addon/quantity.go (2)
SubscriptionAddonQuantity(11-17)CreateSubscriptionAddonQuantityInput(25-28)
openmeter/ent/db/subscription.go (5)
openmeter/ent/db/addon.go (1)
Addons(311-311)openmeter/ent/schema/subscription_addon.go (4)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-52)openmeter/ent/db/ent.go (1)
NotLoadedError(324-326)openmeter/ent/schema/subscription.go (5)
Subscription(16-18)Subscription(20-29)Subscription(31-39)Subscription(41-46)Subscription(48-56)openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)
openmeter/ent/schema/ratecard.go (5)
pkg/isodate/date.go (1)
String(16-16)openmeter/productcatalog/entitlement.go (1)
EntitlementTemplate(34-39)openmeter/ent/db/addonratecard/addonratecard.go (1)
ValueScanner(133-138)openmeter/ent/schema/productcatalog.go (4)
EntitlementTemplateValueScanner(175-175)TaxConfigValueScanner(176-176)PriceValueScanner(177-177)DiscountsValueScanner(178-178)openmeter/productcatalog/discount.go (1)
Discounts(346-346)
openmeter/ent/schema/subscription.go (2)
openmeter/ent/schema/subscription_addon.go (9)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-52)SubscriptionAddonRateCardItemLink(140-142)SubscriptionAddonRateCardItemLink(144-149)SubscriptionAddonRateCardItemLink(151-156)SubscriptionAddonRateCardItemLink(158-166)SubscriptionAddonRateCardItemLink(168-183)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/addon/where.go (2)
openmeter/ent/db/predicate/predicate.go (2)
Addon(10-10)SubscriptionAddon(219-219)openmeter/ent/db/addon/addon.go (3)
Table(53-53)SubscriptionAddonsTable(62-62)SubscriptionAddonsColumn(67-67)
openmeter/subscription/service/service_test.go (3)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)
test/customer/testenv.go (2)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/entitlement/validators/customer/validator.go (1)
NewValidator(17-29)
openmeter/ent/db/subscriptionitem/where.go (4)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionItem(231-231)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)FieldID(18-18)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)
openmeter/productcatalog/addon/adapter/mapping.go (3)
openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/productcatalog/addon/addon.go (1)
Addon(12-20)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)
openmeter/productcatalog/addon/adapter/addon.go (1)
openmeter/productcatalog/addon/adapter/mapping.go (1)
FromAddonRow(16-66)
openmeter/subscription/testutils/addon.go (6)
openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey(13-13)openmeter/subscription/testutils/global.go (2)
ISOMonth(7-7)ExampleNamespace(5-5)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)openmeter/productcatalog/addon/service.go (1)
CreateAddonInput(98-101)pkg/models/model.go (1)
NamespacedModel(155-157)openmeter/productcatalog/addon.go (1)
AddonMeta(37-63)
openmeter/ent/db/addon.go (3)
openmeter/ent/schema/subscription_addon.go (4)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-52)openmeter/ent/db/ent.go (1)
NotLoadedError(324-326)openmeter/ent/schema/addon.go (5)
Addon(16-18)Addon(20-24)Addon(26-51)Addon(53-64)Addon(66-81)
openmeter/ent/db/subscription/where.go (4)
openmeter/ent/db/predicate/predicate.go (2)
Subscription(216-216)SubscriptionAddon(219-219)openmeter/ent/db/subscription.go (2)
Subscription(20-54)Subscription(123-140)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/addon_query.go (8)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
OrderOption(111-111)FieldID(16-16)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/ent/db/predicate/predicate.go (2)
Addon(10-10)SubscriptionAddon(219-219)openmeter/ent/db/addonratecard_query.go (1)
AddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/client.go (1)
SubscriptionAddonClient(6216-6218)openmeter/ent/db/addon/where.go (1)
ID(15-17)openmeter/ent/db/subscriptionaddon/where.go (2)
ID(14-16)AddonID(89-91)
openmeter/productcatalog/subscription/service/plan_test.go (2)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)
openmeter/subscription/workflow/service/subscription_test.go (6)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)openmeter/subscription/testutils/db.go (1)
DBDeps(15-19)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/subscription/workflow/service.go (2)
CreateSubscriptionWorkflowInput(17-21)Service(10-15)openmeter/subscription/service.go (1)
Service(10-31)
openmeter/subscription/addon/quantity.go (4)
pkg/models/model.go (1)
ManagedModel(107-113)openmeter/ent/db/subscriptionaddonquantity/where.go (2)
ActiveFrom(89-91)Quantity(94-96)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)pkg/timeutil/timeline.go (2)
AsTimed(20-27)Timed(29-32)
openmeter/subscription/testutils/ratecard.go (4)
openmeter/productcatalog/ratecard.go (3)
UsageBasedRateCard(256-262)FlatFeeRateCard(161-168)RateCardMeta(49-77)openmeter/subscription/testutils/global.go (1)
ISOMonth(7-7)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/productcatalog/price.go (1)
NewPriceFrom(338-360)
openmeter/subscription/addon/repository.go (7)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionitem.go (4)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/ent.go (1)
NotLoadedError(324-326)openmeter/ent/schema/subscription.go (5)
SubscriptionItem(97-99)SubscriptionItem(101-108)SubscriptionItem(110-166)SubscriptionItem(168-173)SubscriptionItem(175-182)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)
openmeter/productcatalog/subscription/service/migrate_test.go (1)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)
openmeter/ent/db/subscription/subscription.go (3)
openmeter/ent/db/addon/addon.go (1)
Table(53-53)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/migrate/schema.go (1)
AddonsTable(31-75)
openmeter/productcatalog/subscription/service/change_test.go (2)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)
pkg/framework/entutils/mapping.go (1)
pkg/slicesx/map.go (1)
MapWithErr(23-47)
openmeter/ent/db/addonratecard/where.go (2)
openmeter/ent/db/addonratecard/addonratecard.go (5)
FieldDiscounts(49-49)Table(61-61)FieldID(19-19)SubscriptionAddonRateCardsTable(77-77)SubscriptionAddonRateCardsColumn(82-82)openmeter/ent/db/subscriptionitem/subscriptionitem.go (3)
FieldDiscounts(60-60)Table(70-70)FieldID(18-18)
openmeter/subscription/addon/service/change_test.go (7)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)pkg/clock/clock.go (1)
SetTime(23-27)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (1)
GenericValidationError(145-147)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
openmeter/ent/db/subscription/subscription.go (1)
Table(54-54)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (1)
Table(38-38)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (1)
Table(32-32)
openmeter/ent/db/subscription_create.go (3)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (1)
Table(34-34)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (1)
Table(38-38)
openmeter/ent/db/addon_create.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/ent/db/addonratecard.go (6)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/subscriptionaddonratecard.go (3)
SubscriptionAddonRateCards(242-242)SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/ent.go (1)
NotLoadedError(324-326)openmeter/ent/db/addonratecard/addonratecard.go (2)
FieldDiscounts(49-49)ValueScanner(133-138)openmeter/ent/db/addon/addon.go (1)
ValueScanner(119-121)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)
openmeter/ent/db/ent.go (1)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
Table(40-40)ValidColumn(84-91)
openmeter/subscription/addon/service/list_test.go (12)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)openmeter/subscription/addon/service.go (1)
ListSubscriptionAddonsInput(19-23)openmeter/subscription/testutils/addon.go (1)
GetExampleAddonInput(24-51)openmeter/productcatalog/addon/service.go (1)
PublishAddonInput(258-263)openmeter/subscription/testutils/compare.go (1)
SubscriptionAddonsEqual(182-193)
openmeter/ent/db/subscriptionitem_create.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)FieldID(18-18)
openmeter/ent/db/runtime.go (5)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
AddonIDValidator(103-103)SubscriptionIDValidator(105-105)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (4)
DefaultActiveFrom(76-76)DefaultQuantity(78-78)QuantityValidator(80-80)SubscriptionAddonIDValidator(82-82)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
SubscriptionAddonIDValidator(94-94)AddonRatecardIDValidator(96-96)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)
openmeter/ent/db/addonratecard_query.go (7)
openmeter/ent/db/addonratecard/addonratecard.go (5)
OrderOption(152-152)Table(61-61)FieldID(19-19)SubscriptionAddonRateCardsTable(77-77)SubscriptionAddonRateCardsColumn(82-82)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
OrderOption(102-102)Table(38-38)FieldID(16-16)openmeter/ent/db/predicate/predicate.go (2)
AddonRateCard(24-24)SubscriptionAddonRateCard(225-225)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonRateCardsTable(1966-2006)openmeter/ent/db/addonratecard/where.go (1)
ID(16-18)openmeter/ent/db/subscriptionaddonratecard/where.go (2)
ID(14-16)AddonRatecardID(94-96)
openmeter/ent/db/subscriptionitem_query.go (3)
openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/subscription/addon/repo/transaction.go (7)
openmeter/ent/db/tx.go (1)
Tx(15-104)openmeter/ent/db/client.go (2)
Driver(250-254)Client(63-147)pkg/framework/entutils/transaction.go (2)
NewTxDriver(47-52)TxDriver(76-88)openmeter/ent/db/expose.go (1)
NewTxClientFromRawConfig(78-172)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)
openmeter/ent/db/planratecard/where.go (2)
openmeter/ent/db/planratecard.go (2)
PlanRateCard(21-63)PlanRateCard(99-122)openmeter/ent/db/planratecard/planratecard.go (1)
FieldDiscounts(49-49)
openmeter/ent/schema/addon.go (2)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)
openmeter/ent/db/planratecard_update.go (1)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)
openmeter/ent/db/subscription_update.go (1)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
FieldID(16-16)
openmeter/ent/db/subscriptionaddon_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)Label(14-14)
openmeter/subscription/addon/service.go (3)
openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
openmeter/ent/db/subscriptionaddonratecard_delete.go (4)
openmeter/ent/db/ent.go (3)
IsConstraintError(361-367)ConstraintError(345-348)NotFoundError(278-280)openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardMutation(43471-43492)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCard(225-225)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/subscriptionaddonquantity.go (3)
openmeter/ent/db/subscriptionaddonquantity/where.go (8)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)ActiveFrom(89-91)Quantity(94-96)SubscriptionAddonID(99-101)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonquantity_update.go (1)
SubscriptionAddonQuantityUpdateOne(140-145)
openmeter/subscription/testutils/feature.go (2)
openmeter/productcatalog/feature/connector.go (2)
CreateFeatureInputs(17-24)FeatureConnector(27-34)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)
openmeter/ent/db/hook/hook.go (1)
openmeter/ent/db/mutation.go (4)
SubscriptionAddonMutation(41738-41762)SubscriptionAddonQuantityMutation(42703-42721)SubscriptionAddonRateCardMutation(43471-43492)SubscriptionAddonRateCardItemLinkMutation(44353-44369)
openmeter/subscription/service/sync_test.go (1)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)
openmeter/ent/db/subscriptionitem_update.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/subscription/testutils/service.go (8)
openmeter/subscription/workflow/service.go (1)
Service(10-15)openmeter/subscription/entitlement.go (1)
EntitlementAdapter(60-68)openmeter/subscription/addon/service/service.go (2)
NewService(41-47)Config(21-33)openmeter/subscription/service/service.go (1)
New(37-41)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)openmeter/subscription/testutils/addon.go (1)
NewTestAddonService(57-59)
openmeter/ent/db/addon_update.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/subscription/addon/repo/subscriptionaddon.go (5)
openmeter/subscription/addon/repository.go (3)
SubscriptionAddonRepository(28-32)CreateSubscriptionAddonRepositoryInput(12-20)ListSubscriptionAddonRepositoryInput(22-26)openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)pkg/framework/entutils/transaction.go (1)
TransactingRepo(199-221)pkg/framework/entutils/mapping.go (1)
MapPagedWithErr(20-31)
openmeter/ent/db/subscription_query.go (5)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscription/subscription.go (4)
Table(54-54)FieldID(16-16)AddonsTable(84-84)AddonsColumn(89-89)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)FieldSubscriptionID(30-30)openmeter/ent/db/predicate/predicate.go (2)
Subscription(216-216)SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonratecard.go (4)
openmeter/ent/db/ent.go (3)
NotFoundError(278-280)NotLoadedError(324-326)Value(64-64)openmeter/ent/db/addonratecard/addonratecard.go (5)
Label(17-17)FieldID(19-19)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (5)
Label(14-14)FieldID(16-16)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (5)
Label(14-14)FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/migrate/schema.go (3)
openmeter/ent/db/subscription/subscription.go (2)
Table(54-54)AddonsTable(84-84)openmeter/ent/db/subscriptionitem/subscriptionitem.go (1)
Table(70-70)openmeter/ent/db/addonratecard/addonratecard.go (1)
SubscriptionAddonRateCardsTable(77-77)
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
openmeter/ent/db/addonratecard/addonratecard.go (10)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(30-30)ValidColumn(57-64)Columns(45-54)ByID(91-93)OrderOption(88-88)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (8)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)
openmeter/ent/db/subscriptionaddon.go (4)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/ent.go (3)
NotFoundError(278-280)NotLoadedError(324-326)Value(64-64)openmeter/ent/db/client.go (1)
NewSubscriptionAddonClient(6221-6223)
openmeter/ent/db/addonratecard/addonratecard.go (2)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (5)
FieldDiscounts(60-60)ByDiscounts(267-269)OrderOption(164-164)Table(70-70)FieldID(18-18)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
OrderOption(102-102)Table(38-38)FieldID(16-16)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (4)
openmeter/ent/db/ent.go (2)
NotFoundError(278-280)NotLoadedError(324-326)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (5)
Label(14-14)FieldID(16-16)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (7)
Label(14-14)FieldID(16-16)FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)openmeter/ent/db/subscriptionitem/subscriptionitem.go (5)
Label(16-16)FieldID(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)
openmeter/ent/schema/subscription_addon.go (6)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/subscription/addon/repo/mapping.go (12)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/schema/subscription_addon.go (19)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-52)SubscriptionAddonQuantity(54-56)SubscriptionAddonQuantity(58-64)SubscriptionAddonQuantity(66-72)SubscriptionAddonQuantity(74-78)SubscriptionAddonQuantity(80-89)SubscriptionAddonRateCard(91-93)SubscriptionAddonRateCard(95-102)SubscriptionAddonRateCard(104-112)SubscriptionAddonRateCard(114-130)SubscriptionAddonRateCard(132-137)SubscriptionAddonRateCardItemLink(140-142)SubscriptionAddonRateCardItemLink(144-149)SubscriptionAddonRateCardItemLink(151-156)SubscriptionAddonRateCardItemLink(158-166)SubscriptionAddonRateCardItemLink(168-183)pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/productcatalog/addon/adapter/mapping.go (1)
FromAddonRow(16-66)pkg/timeutil/timeline.go (2)
NewTimeline(46-55)Timed(29-32)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/addonratecard_create.go (3)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/addonratecard/addonratecard.go (5)
Table(61-61)SubscriptionAddonRateCardsTable(77-77)Columns(86-105)FieldID(19-19)FieldDiscounts(49-49)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
Table(38-38)Columns(63-72)FieldID(16-16)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(90-97)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscription/subscription.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(28-28)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)ByActiveFrom(172-174)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (16)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)ValidColumn(75-82)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)BySubscriptionAddonID(130-132)BySubscriptionAddonField(140-144)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (15)
FieldID(18-18)FieldNamespace(20-20)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldActiveFrom(30-30)ValidColumn(128-135)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)ByActiveFrom(192-194)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (16)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldAddonID(51-51)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)ByAddonID(230-232)ByAddonField(240-244)openmeter/ent/db/subscription/subscription.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (12)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(45-54)ByID(91-93)OrderOption(88-88)ByNamespace(96-98)ByCreatedAt(101-103)ByUpdatedAt(106-108)ByDeletedAt(111-113)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (10)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (13)
FieldID(18-18)FieldNamespace(20-20)FieldMetadata(28-28)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)
openmeter/ent/db/setorclear.go (8)
openmeter/ent/db/addonratecard_update.go (1)
AddonRateCardUpdate(24-28)openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/planratecard_update.go (1)
PlanRateCardUpdate(23-27)openmeter/ent/db/subscriptionaddon_update.go (1)
SubscriptionAddonUpdate(21-25)api/api.gen.go (1)
SubscriptionAddonUpdate(5525-5549)api/client/go/client.gen.go (1)
SubscriptionAddonUpdate(5207-5231)openmeter/ent/db/subscriptionaddonratecard_update.go (1)
SubscriptionAddonRateCardUpdate(20-24)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (1)
SubscriptionAddonRateCardItemLinkUpdate(19-23)
openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonratecard_update.go (6)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardMutation(43471-43492)openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonRateCard(225-225)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecard/where.go (3)
ID(14-16)UpdatedAt(79-81)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (3)
ID(14-16)UpdatedAt(74-76)DeletedAt(79-81)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
FieldID(16-16)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (3)
FieldID(16-16)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddonquantity_create.go (2)
openmeter/ent/db/subscriptionaddonquantity/where.go (8)
ID(14-16)CreatedAt(74-76)UpdatedAt(79-81)ActiveFrom(89-91)Quantity(94-96)Namespace(69-71)SubscriptionAddonID(99-101)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (8)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)FieldSubscriptionAddonID(30-30)
openmeter/ent/db/addonratecard_update.go (7)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/subscriptionaddonratecard/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/addonratecard/addonratecard.go (5)
Table(61-61)SubscriptionAddonRateCardsTable(77-77)Columns(86-105)SubscriptionAddonRateCardsColumn(82-82)FieldID(19-19)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
Table(38-38)Columns(63-72)FieldID(16-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (3)
Table(32-32)Columns(50-57)FieldID(16-16)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonRateCardsTable(1966-2006)
openmeter/ent/db/subscriptionaddon_query.go (5)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddonquantity_query.go (1)
SubscriptionAddonQuantityQuery(21-32)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (4)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)
openmeter/ent/db/subscriptionaddonratecard_query.go (4)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)
openmeter/ent/db/subscriptionaddonratecard_create.go (4)
openmeter/ent/db/addonratecard/addonratecard.go (6)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (6)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (8)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)FieldSubscriptionAddonID(28-28)FieldAddonRatecardID(30-30)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (4)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/subscriptionaddonquantity_query.go (3)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (5)
OrderOption(88-88)Table(34-34)FieldID(16-16)SubscriptionAddonTable(36-36)FieldSubscriptionAddonID(30-30)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonquantity/where.go (3)
SubscriptionAddonID(99-101)IDIn(29-31)ID(14-16)
openmeter/subscription/addon/service/create_test.go (7)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/subscription/testutils/compare.go (1)
SubscriptionAddonsEqual(182-193)openmeter/subscription/testutils/plan.go (1)
GetExamplePlanInput(20-72)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)Table(32-32)SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)SubscriptionItemTable(41-41)SubscriptionItemColumn(46-46)
openmeter/ent/db/subscriptionaddonquantity/where.go (10)
openmeter/ent/db/subscription/where.go (6)
ID(15-17)Namespace(70-72)CreatedAt(75-77)UpdatedAt(80-82)DeletedAt(85-87)ActiveFrom(90-92)openmeter/ent/db/subscriptionaddon/where.go (5)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (4)
ID(14-16)CreatedAt(69-71)UpdatedAt(74-76)DeletedAt(79-81)openmeter/ent/db/subscriptionitem/where.go (6)
ID(15-17)Namespace(70-72)CreatedAt(75-77)UpdatedAt(80-82)DeletedAt(85-87)ActiveFrom(90-92)openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonQuantity(222-222)SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/addon/addon.go (5)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldSubscriptionAddonID(30-30)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (6)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (4)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddon_update.go (5)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/predicate/predicate.go (3)
SubscriptionAddon(219-219)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddon_create.go (4)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/subscriptionaddonquantity_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddonratecard/where.go (4)
openmeter/ent/db/predicate/predicate.go (3)
SubscriptionAddonRateCard(225-225)SubscriptionAddon(219-219)AddonRateCard(24-24)openmeter/ent/db/addonratecard/addonratecard.go (7)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)Table(61-61)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)FieldAddonRatecardID(30-30)FieldMetadata(26-26)Table(38-38)SubscriptionAddonTable(40-40)SubscriptionAddonColumn(45-45)ItemsTable(47-47)ItemsColumn(52-52)AddonRatecardTable(54-54)AddonRatecardColumn(59-59)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (5)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)Table(32-32)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Analyze (go)
🔇 Additional comments (424)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (5)
1-42: Well-structured entity definition with clear field and table relationships.The constant definitions provide a clear mapping of database fields to their internal representations and establish the relationship with the parent SubscriptionAddon entity. The naming conventions follow the established patterns seen in other entity files in the project.
44-64: Complete column definition with proper validation function.The
Columnsslice andValidColumnfunction follow the standard pattern used throughout the codebase. This consistency helps maintain code quality and ensures field validation works correctly throughout the application.
66-85: Well-defined validators and default value handlers.The validator and default value declarations conform to the project standards. Defining
DefaultQuantityas an integer with validators ensures proper data integrity for the quantity field, which is crucial for subscription addon quantity tracking.
87-128: Comprehensive ordering options for all entity fields.The ordering functions provide a complete set of options for querying SubscriptionAddonQuantity entities. Each field has its own ordering function, allowing for flexible query construction in the application code.
130-142: Well-implemented relationship ordering capabilities.The implementation of
BySubscriptionAddonFieldwith the helper functionnewSubscriptionAddonStep()correctly establishes the navigation path for ordering by fields in the related SubscriptionAddon entity. This follows the established pattern in other entity files and ensures proper relationship traversal in SQL queries.pkg/framework/entutils/mapping.go (2)
1-9: Imports and package structure look good.The package organization and imports are appropriate for this utility file. The use of both internal packages (
pagination,slicesx) and the externalsamber/lolibrary makes sense for the mapping functionality being implemented.
1-32: Well-designed utility functions for pagination processing.These generic functions provide a clean, type-safe way to transform paginated responses, which will be valuable for the subscription addon functionality being implemented. The separation into error and non-error variants gives consumers flexibility based on their needs.
openmeter/ent/schema/ratecard.go (1)
21-65: Consider which fields should be required vs. optionalAlmost all fields in the RateCard schema are marked as optional and nillable. For a production system, consider if some fields should be required based on business rules. For example, should a rate card always have a type and price?
Please review the business requirements for rate cards to determine if any fields should be required rather than optional.
openmeter/subscription/addon/README.md (7)
7-9: Validate Mermaid Code BlockThe mermaid code block is correctly initiated. Please verify that the chosen mermaid syntax renders correctly in your documentation environment to ensure the ER diagram displays as intended.
9-15: Review Relationship CardinalityThe relationships outlined in the ER diagram appear well structured. However, double-check that the one-to-one relationships (e.g.,
Subscription ||--|| SubscriptionAddonandAddon ||--|| SubscriptionAddon) accurately mirror your intended data model. In many subscription systems, subscriptions might support multiple add-ons, so please confirm that one-to-one is the correct design choice here.
16-18: Subscription Entity DefinitionThe
Subscriptionentity is succinctly defined with its primary key. If additional attributes (such as name or status) are expected to evolve in the model, consider including them or documenting future extensions. Otherwise, this minimal design is acceptable.
20-22: Addon Entity DefinitionThe
Addonentity is defined clearly with just a primary key. This definition works well if the entity currently does not require more attributes, though future enhancements might require further detail.
30-33: SubscriptionAddonQuantity EntityThe definition of
SubscriptionAddonQuantityis straightforward and clear. If there are additional business rules or constraints regarding quantities, consider including notes or documentation to clarify their intended usage.
35-38: SubscriptionAddonRateCard EntityThe
SubscriptionAddonRateCardentity is defined appropriately with its primary and foreign key. The concise structure works for now, so no modifications are necessary.
46-48: SubscriptionItem EntityThe
SubscriptionItementity is minimalistic with only a primary key. This definition is acceptable given the current scope; ensure that any future attributes are added as needed.openmeter/ent/schema/productcatalog.go (2)
130-142: Good refactoring of field definitions using compositionThe approach of reusing
RateCard{}.Fields()and appending specific fields follows good DRY principles and simplifies maintenance. The bug comment explains why this particular implementation approach was chosen.Make sure that future changes to
RateCard{}.Fields()properly consider their impact onPlanRateCard.
166-170:Details
✅ Verification successful
Verify that feature_key field is still defined
The index on line 166 references a
feature_keyfield, but this field is no longer explicitly defined in theFields()method. Please confirm that this field is included inRateCard{}.Fields()to ensure the index remains valid.
🏁 Script executed:
#!/bin/bash # Check if feature_key is defined in RateCard to ensure the index remains valid rg -A 5 -B 5 "type RateCard struct" --type go rg -A 30 "func \(RateCard\) Fields\(\)" --type goLength of output: 6709
Field Definition Verified: "feature_key" is Present
The verification confirms that the
feature_keyfield is properly defined within theRateCard{}.Fields()method (located inopenmeter/ent/schema/ratecard.go), as it appears through the following snippet:
field.String("feature_key").Optional().Nillable(),Thus, the index referencing
"feature_key"inopenmeter/ent/schema/productcatalog.goremains valid, and no further changes are needed.test/customer/testenv.go (1)
130-130: Updated accessor to match refactored dependency structure.This change ensures consistency with the renamed variable and its updated structure in the subscription test utilities.
openmeter/subscription/addon/addonratecard.go (2)
8-15: Well-structured model for subscription addon rate cards.The
SubscriptionAddonRateCardstruct properly embeds common model fields and includes necessary relationships to the associated addon rate card and affected subscription items.
17-21: Appropriate input structure for rate card creation.The
CreateSubscriptionAddonRateCardInputstruct provides a well-defined interface for creating subscription addon rate cards, capturing the necessary fields while avoiding exposing implementation details.test/subscription/framework_test.go (3)
16-18: Updated dependency structure type for improved consistency.The struct now uses the refactored
SubscriptionDependenciestype instead of the previousExposedServiceDeps, aligning with the changes made throughout the codebase.
33-38: Simplified dependency initialization and access.The code now directly assigns the result of
NewServicetodepsand accesses the workflow and subscription services through this variable, making the code more concise and consistent.
43-48: Updated return value structure to use refactored dependencies.This change properly initializes the
testDepsstruct with the refactored dependency structure and correctly accesses the required services.openmeter/subscription/addon/addon.go (3)
12-26: Well-designed subscription addon entity structure.The
SubscriptionAddonstruct properly embeds common model fields and includes all necessary associations with related entities. The use of timeline for quantities is a good approach for tracking time-based changes.
28-36: Clear input structure for creating subscription addons.The
CreateSubscriptionAddonInputstruct appropriately includes all required fields for creating a subscription addon, including metadata, associated IDs, rate cards, and initial quantity.
38-62: Thorough validation for subscription addon creation.The validation method ensures all required fields are present and valid, collecting multiple validation errors for a comprehensive response. The approach of using
errors.Jointo combine multiple validation errors is a good practice.openmeter/subscription/testutils/feature.go (3)
12-16: LGTM: New example features for test utils.The addition of
ExampleFeatureKey2alongside the existingExampleFeatureKeycreates a clear and consistent naming pattern for test constants. This will facilitate testing of subscription addons that need multiple features.
25-30: LGTM: Well-structured example for second feature.The
ExampleFeature2is properly structured following the same pattern asExampleFeature, maintaining consistency in the test utilities. The reuse ofExampleNamespaceandExampleFeatureMeterSlugis appropriate as they represent common test context.
40-51: Improved test utility function to create multiple features.The function has been correctly renamed from
CreateExampleFeaturetoCreateExampleFeaturesto match its new behavior of creating multiple features. The implementation properly handles error cases for both feature creations and returns a slice containing both features.openmeter/subscription/patch/removeitem_test.go (3)
168-170: Updated assertion to support multiple items in test phase.The test now correctly expects 2 items in phase 3 instead of 1, which aligns with the changes to support subscription addons functionality.
171-171: Added validation for specific feature item presence.Good addition to verify that the
ExampleFeatureKeyitem exists in the phase before attempting to delete it, ensuring test reliability.
174-174: Improved item removal with targeted deletion.The change from resetting the entire
ItemsByKeymap to using thedeletefunction to remove only the specific item is a more precise approach that maintains other items in the phase.openmeter/ent/db/addonratecard/where.go (2)
765-773: Added null check predicates for discounts field.These new functions
DiscountsIsNilandDiscountsNotNilfollow the same pattern as other IsNil/NotNil predicate functions in the file, allowing for proper querying of null discounts in the database.
961-982: Added edge predicates for subscription addon rate cards relationships.The new functions
HasSubscriptionAddonRateCardsandHasSubscriptionAddonRateCardsWithprovide necessary query capabilities for the relationship between addon rate cards and subscription addon rate cards, following the established pattern for edge predicates in the codebase.openmeter/subscription/testutils/ratecard.go (6)
17-17: Improved type definition for ExamplePriceAmount.Changed
ExamplePriceAmountto explicitly be anint64which is more appropriate for monetary values and avoids potential integer overflow issues that could occur with the defaultinttype.
18-19: Changed ExampleRateCard1 to UsageBasedRateCard.The rate card has been changed from a
FlatFeeRateCardto aUsageBasedRateCard, which better represents the subscription addon model being implemented.
36-37: Removed unnecessary type conversion.Good improvement to directly use
ExamplePriceAmountas anint64without explicit type conversion, making the code cleaner and more type-safe.
39-40: Changed BillingCadence from pointer to direct value.Using
ISOMonthdirectly instead of a pointer (&ISOMonth) for theBillingCadencefield inUsageBasedRateCardis appropriate since theUsageBasedRateCardstruct expects a non-nullable field, unlikeFlatFeeRateCardwhich accepts a nullable pointer.
54-77: Added ExampleRateCard3ForAddons for addon testing.This new example rate card is well-structured and provides a complete test fixture for subscription addon functionality. It correctly uses the second feature key (
ExampleFeatureKey2) and includes all necessary fields including entitlement template, tax config, and appropriate pricing information.
96-97: Consistent use of ExamplePriceAmount.Good update to use the same
ExamplePriceAmountconstant in all price configurations throughout the test utilities, promoting consistency and making future price-related test changes easier.openmeter/ent/db/addonratecard/addonratecard.go (7)
48-49: New field for addon rate card discounts added.This addition of the
FieldDiscountsconstant aligns with the subscription addon functionality being implemented. This field will enable storing discount information in the database for addon rate cards.
58-59: Edge relationship with subscription addon rate cards defined correctly.The new edge constant and related table/column definitions properly establish the relationship between addon rate cards and subscription addon rate cards, which is essential for the subscription addon functionality.
Also applies to: 76-82
102-102: Discounts field added to Columns slice.Correctly adds the Discounts field to the Columns slice to ensure it's included in database operations.
224-227: Ordering function for discounts field implemented.The
ByDiscountsfunction enables ordering query results by the discounts field, providing necessary query functionality.
253-258: Ordering by subscription addon rate cards count implemented.This function allows for ordering addon rate cards based on the count of their associated subscription addon rate cards, which is useful for analytics and sorting in the UI.
260-265: Ordering by subscription addon rate cards terms implemented.This function provides the ability to order addon rate cards based on specific terms of their associated subscription addon rate cards, enabling more flexible querying capabilities.
280-286: SQL graph step helper for subscription addon rate cards implemented.This helper function defines the necessary SQL graph traversal for subscription addon rate cards, supporting the new ordering functions and ensuring proper relationship navigation.
openmeter/subscription/addon/repo/transaction.go (6)
1-11: Appropriate imports for transaction handling.The imports include the necessary packages for transaction management and error handling, which are essential for implementing the transaction functionality.
15-23: Transaction handling for subscriptionAddonRepo correctly implemented.The
Txmethod properly initializes a non-read-only transaction and returns the appropriate context and transaction driver. The error handling follows the project's conventions.
25-27: Self method for repository identity implemented.The
Selfmethod returns a pointer to the repository instance, which is a simple but important pattern for method chaining and self-referencing in repositories.
29-32: WithTx method for subscriptionAddonRepo correctly implemented.This method creates a new repository instance with a transaction client, ensuring that repository operations can be performed within a transaction context.
36-53: Transaction handling for subscriptionAddonRateCardRepo follows the pattern.The implementation mirrors that of the subscriptionAddonRepo, maintaining consistency across repositories. This is good for code maintainability and understanding.
57-74: Transaction handling for subscriptionAddonQuantityRepo follows the pattern.Again, the implementation is consistent with the other repositories, which is a good practice for code maintainability. All necessary transaction functionality is provided.
openmeter/subscription/testutils/service.go (6)
16-18: Necessary imports added for addon functionality.The imports for addon repositories and services have been correctly added to support the new subscription addon functionality being implemented.
Also applies to: 25-27
38-52: SubscriptionDependencies struct updated with addon-related fields.The renamed and expanded struct now includes fields for SubscriptionAddonService and AddonService, which are necessary for the new subscription addon functionality.
54-54: Function signature updated to return the consolidated dependencies.The
NewServicefunction now returns a singleSubscriptionDependenciesstruct instead of multiple return values, which simplifies usage and improves code clarity.
136-149: Addon repository and service initialization added.The code initializes the addon repository and service with appropriate configuration, handling errors correctly through the test's require statements.
150-162: Subscription addon repositories and service initialization added.The initialization of subscription addon repositories and service is properly implemented, with the necessary dependencies being passed to the respective constructors.
164-178: Updated return value with all necessary dependencies.The return statement now includes all required services and repositories, properly structured within the
SubscriptionDependenciesstruct, making them accessible to tests.openmeter/subscription/workflow/service/subscription_test.go (8)
76-77: Test code updated to use the new dependencies structure.The initialization of dependencies now correctly uses the refactored
subscriptiontestutils.NewServicefunction that returns a singleSubscriptionDependenciesstruct.
87-87: Reference to WorkflowService updated.The code now correctly references
deps.WorkflowServicerather than the previous approach, aligning with the new dependency structure.
244-244: Consistent usage of the new dependency structure in tests.The test continues to use the new approach to initializing dependencies, which ensures consistency across the test file.
271-272: Dependencies initialization and service references updated.The code properly initializes the dependencies using the new structure and correctly references the SubscriptionService and WorkflowService from the deps object.
Also applies to: 293-294
464-465: Consistent pattern of dependency initialization and service usage.The test continues to follow the same pattern of initializing dependencies and using services from the deps object, maintaining consistency throughout the file.
Also applies to: 486-487
707-708: Additional instances of updated dependency usage.The code follows the same pattern throughout the file, ensuring that all tests are using the new dependency structure correctly.
Also applies to: 735-736
863-864: Final instances of updated dependency initialization and usage.The remaining instances of dependency initialization and service usage have been properly updated to use the new structure.
Also applies to: 875-876
1092-1093: Complete adoption of the new dependency pattern.The file has been thoroughly updated to use the new dependency pattern consistently throughout all test cases.
Also applies to: 1103-1104
openmeter/subscription/addon/repo/mapping.go (4)
65-70: No issues inMapSubscriptionAddons.The function’s usage of
slicesx.MapWithErrfor batch mapping is well-structured. It cleanly propagates errors, aligning with best practices for batched operations.
118-123: No issues inMapSubscriptionAddonRateCards.The batch mapping is straightforward and consistent with other list-based mappings. Good use of
slicesx.MapWithErr.
125-140: Validate usage ofMapSubscriptionAddonQuantity.The straightforward field-by-field mapping suits the struct fields well. Consider adding an error return if future expansions require complex validations (e.g., invalid quantity).
142-149: Ensure ordering is preserved inMapSubscriptionAddonQuantities.The function constructs a simple slice in the original order, which is fine for many use cases. If you need a time-based timeline or strict ordering, verify that the slice ordering is correct by the time these entities are fetched and appended.
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (1)
1-144: Auto-generated Ent schema file looks good.This file defines fields, edges, ordering, and validation logic for the new subscription add-on rate card item link entity. Everything appears standard for an Ent-generated file, with no issues to address.
openmeter/ent/db/subscriptionaddonratecard/where.go (1)
1-516: Auto-generatedwhere.gopredicates forSubscriptionAddonRateCard.These predicate functions are generated by Ent to offer granular query filtering. No modifications appear necessary, and this standard code is aligned with Ent’s conventions.
openmeter/subscription/testutils/plan.go (1)
54-54: Added test rate card for subscription add-ons.The changes appropriately include
&ExampleRateCard3ForAddonsin theRateCardsslices for both phases 2 and 3 of the example plan. This addition aligns with the PR objectives of introducing subscription add-on functionality by making the test data more comprehensive.Also applies to: 66-66
openmeter/ent/db/planratecard.go (3)
53-54: Added Discounts field to PlanRateCard struct.This addition implements the necessary field to support discount functionality for plan rate cards. The field is properly defined with appropriate JSON tags and is consistent with the overall project structure.
228-233: Added Discounts field handling in assignValues.The implementation correctly handles the assignment of Discounts values from database scan results, following the same pattern as other fields in the struct. Error handling is properly implemented.
349-352: Added Discounts field to String representation.The String method is properly updated to include the Discounts field in the string representation of the PlanRateCard struct, maintaining consistency with how other fields are represented.
openmeter/ent/db/subscription.go (3)
66-67: Added Addons field to SubscriptionEdges struct.This change properly introduces the relationship between subscriptions and add-ons, allowing subscriptions to reference their associated add-ons. The loadedTypes array is also correctly updated to accommodate the new edge.
Also applies to: 70-70
113-120: Added AddonsOrErr method for consistent error handling.The implementation follows the established pattern for edge retrieval methods in the codebase, providing proper error handling when the add-ons edge is not loaded or not found.
273-276: Added QueryAddons method for relationship traversal.This method provides the necessary functionality to query the "addons" edge of the Subscription entity, maintaining consistency with other edge query methods in the struct.
openmeter/productcatalog/addon/adapter/addon.go (1)
141-142: Function visibility change from fromAddonRow to FromAddonRow.The renaming of this function from private to public scope is a good practice when the functionality needs to be accessed from other packages. This change maintains consistency across all occurrences of the function call.
Also applies to: 212-213, 395-396, 504-505
openmeter/ent/schema/subscription.go (2)
54-54: New edge adds proper bidirectional relationship with SubscriptionAddonThis edge completes the bidirectional relationship with the new
SubscriptionAddonentity, allowing subscriptions to reference their addons. This aligns well with the PR objective of introducing subscription add-ons functionality.
180-180: New edge creates relationship with SubscriptionAddonRateCardItemLinkThis edge establishes the relationship between subscription items and their associated addon rate card items, which is essential for the addon billing structure. This corresponds with the
subscription_itemedge defined in theSubscriptionAddonRateCardItemLinkentity's schema.openmeter/ent/db/addon.go (3)
60-64: New SubscriptionAddons edge added to AddonEdges structThe addition of the
SubscriptionAddonsfield and update toloadedTypesarray size correctly implements the ORM support for the new edge defined in the schema.
76-83: Added SubscriptionAddonsOrErr method for edge accessThis method follows the standard pattern for edge access in ent, providing a way to retrieve subscription addons associated with an addon or return an error if they haven't been loaded.
229-232: Added QuerySubscriptionAddons method for querying the edgeThis method completes the implementation by allowing queries on the subscription_addons edge, following the same pattern as other edge query methods.
openmeter/subscription/testutils/compare.go (1)
12-12: Added import for subscription addon packageThe import is correctly added to support the new SubscriptionAddonsEqual function.
openmeter/subscription/service/service_test.go (6)
31-36: Updated service initialization patternThe service initialization has been simplified by directly accessing services through the deps object. The change from
CreateExampleFeaturetoCreateExampleFeaturesreflects a new method that likely supports creating multiple features at once.
96-114: Consistent service initialization updateThis change maintains consistency with the updated pattern throughout the test file.
140-158: Consistent service initialization updateThis change maintains consistency with the updated pattern throughout the test file.
195-200: Consistent service initialization updateThis change maintains consistency with the updated pattern throughout the test file.
311-316: Consistent service initialization updateThis change maintains consistency with the updated pattern throughout the test file.
398-403: Consistent service initialization updateThis change maintains consistency with the updated pattern throughout the test file.
openmeter/ent/db/planratecard/planratecard.go (3)
48-49: Field added for discounts support.The addition of the
FieldDiscountsconstant properly defines the string representation of the discounts field in the database.
93-93: Updated column list properly includes the new field.The
Discountsfield has been correctly added to the columns list, ensuring it's recognized by the DB operations.
215-218: Added ordering capability for Discounts field.The
ByDiscountsfunction follows the same pattern as other ordering functions, providing consistent querying capabilities for the new field.openmeter/ent/db/addon/where.go (2)
802-811: Added HasSubscriptionAddons predicate.This predicate function properly implements the capability to filter addons based on whether they have associated subscription addons, following the established pattern in the codebase.
813-823: Added HasSubscriptionAddonsWith predicate for advanced filtering.This function extends the basic subscription addons filtering by allowing additional predicates to be applied, providing more granular control over the query conditions.
openmeter/productcatalog/addon/adapter/mapping.go (3)
16-16: Function visibility changed from private to public.The function has been made public (renamed from
fromAddonRowtoFromAddonRow), which allows it to be used by other packages. This change aligns with the need to expose this functionality as part of the subscription addon implementation.
52-52: Updated function call to use the new public name.The function call has been properly updated to use the renamed public function
FromAddonRateCardRow.
68-68: Function visibility changed from private to public.The function has been made public (renamed from
fromAddonRateCardRowtoFromAddonRateCardRow), which allows it to be used by other packages. This change is consistent with the needs of the subscription addon implementation.openmeter/ent/db/subscription/where.go (2)
891-900: Added HasAddons predicate.This predicate function correctly implements the capability to filter subscriptions based on whether they have associated addons, following the established pattern in the codebase.
902-912: Added HasAddonsWith predicate for advanced filtering.This function extends the basic addon filtering by allowing additional predicates to be applied to subscription addons, providing more refined query capabilities that align with the subscription addon feature.
openmeter/ent/db/predicate/predicate.go (1)
218-229: New predicate types for the subscription addon functionalityThe new predicate types follow the established pattern in the codebase and are consistently defined as function types that operate on SQL selectors. This is essential for enabling query filtering on the new subscription addon entities.
openmeter/productcatalog/subscriptionaddon.go (3)
3-4: Address the TODO comment before final releaseThere's a TODO indicating that the type should be changed to
AddonInstanceTypeonce defined. This suggests a potential refactoring need in the future.Is there a planned timeline for this refactoring? Consider either addressing it before merging or creating a tracking issue.
6-9: Enum values with descriptive namingThe enum values use clear and descriptive naming that effectively communicates their purpose - differentiating between single and multiple instances of subscription addons.
11-16: Well-implemented StringValues methodThe
StringValuesmethod provides a convenient way to access all possible enum values as strings, which is useful for validation and UI rendering purposes.openmeter/ent/db/subscriptionitem/where.go (2)
1278-1287: Well-implemented edge predicate for subscription addon rate card itemsThe
HasSubscriptionAddonRateCardItemsfunction correctly implements the predicate pattern using sqlgraph to check for the existence of related entities, maintaining consistency with the rest of the codebase.
1289-1299: Comprehensive implementation of conditional edge predicateThe
HasSubscriptionAddonRateCardItemsWithfunction correctly extends the basic edge predicate by allowing additional filtering conditions on the related entities. This follows the established pattern in the codebase for complex relationship queries.openmeter/productcatalog/subscription/service/plan_test.go (3)
22-23: Update to use new dependency structureThe change from
ExposedServiceDepsto the more comprehensiveSubscriptionDependenciesaligns the test with the expanded functionality provided by the new subscription addon features.
32-38: Simplified test dependency initializationThe refactored dependency setup appropriately leverages the enhanced
NewServicefunction, making the test code more maintainable by reducing duplication and directly accessing the consolidated dependency structure.
58-58: Updated feature creation method nameThe change from
CreateExampleFeature(singular) toCreateExampleFeatures(plural) suggests the test now creates multiple features. Ensure that this aligns with the actual implementation in the feature connector.Verify that the
CreateExampleFeaturesmethod in the feature connector is implemented to support this call pattern and that the test assertions still work correctly with potentially multiple features.openmeter/ent/db/tx.go (2)
83-90: Correctly added subscription addon clients to the Tx structThe added fields appropriately extend the Tx struct with clients for the new subscription addon functionality. This follows the established pattern used for other entity clients in the file.
261-264: Properly initialized subscription addon clients in the init methodThe initialization of the subscription addon clients follows the consistent pattern used for other clients in the init method, ensuring proper configuration of transaction clients.
openmeter/ent/db/expose.go (1)
158-164: Correctly added subscription addon clients to NewTxClientFromRawConfigThe addition of subscription addon clients to the returned Tx struct is consistent with the changes in tx.go and follows the established pattern for other entity clients.
openmeter/ent/db/planratecard/where.go (1)
765-773: Added null check predicates for the discounts fieldThese functions provide the ability to filter PlanRateCard entities based on whether they have discounts set or not, correctly implementing the SQL null check pattern used throughout the file.
openmeter/ent/db/subscriptionitem_create.go (3)
17-17: Correctly added import for subscriptionaddonratecarditemlink packageThe import is properly added to support the new subscription addon rate card item link functionality.
285-298: Added methods for establishing subscription addon rate card item relationshipsThese methods correctly implement the pattern for adding edges between SubscriptionItem and SubscriptionAddonRateCardItemLink entities, allowing for proper relationship management.
591-606: Added subscription addon rate card items edge handling to createSpecThis code properly establishes the edge specification for subscription addon rate card items in the created SubscriptionItem entity, following the pattern used for other edges in the file.
openmeter/productcatalog/subscription/service/migrate_test.go (3)
29-29: Update to use new dependency typeThe dependency type has been updated from
ExposedServiceDepstoSubscriptionDependencies. This aligns with the updated dependency structure that now includes subscription addon support.
39-45: Simplified dependency initialization and accessThe code now uses a cleaner approach to initialize and access service dependencies:
- Direct assignment of
NewServicereturn value todeps- Using the fields from
depsdirectly in thetDepsstructThis improves code readability and maintenance compared to the previous implementation.
66-66: Method name change from singular to pluralThe method name has been updated from
CreateExampleFeaturetoCreateExampleFeatures, suggesting it now creates multiple features instead of a single one. Ensure all test cases handle this change properly.Also applies to: 144-144
openmeter/ent/db/addon_create.go (3)
17-17: Added import for SubscriptionAddon packageNew import for the
subscriptionaddonpackage to support the subscription addon relationship in the Addon entity.
206-219: Added methods for managing SubscriptionAddon relationshipsTwo new methods have been added to support the relationship between Addon and SubscriptionAddon entities:
AddSubscriptionAddonIDs: Adds subscription addon edges by IDAddSubscriptionAddons: Adds subscription addon edges by entity referenceThese methods follow the same pattern as the existing
AddRatecardsIDsandAddRatecardsmethods, maintaining consistency in the codebase.
444-459: Added edge handling for SubscriptionAddons in createSpecThis code properly sets up the database edge relationship for subscription addons in the
createSpecmethod. It correctly defines:
- Relationship type (O2M)
- Table and column names
- Target entity specification
This implementation follows the same pattern as the existing edge handling for ratecards, maintaining consistency in the codebase.
openmeter/subscription/addon/quantity.go (3)
11-17: New SubscriptionAddonQuantity structThis struct defines the data model for tracking subscription addon quantities with time-based activation. It properly embeds standard models for namespacing and management (created/updated/deleted timestamps).
19-23: AsTimed method for timeline representationThe
AsTimedmethod enables timeline-based operations for subscription addon quantities by leveraging thetimeutilpackage. This allows for time-based queries and operations on quantities.
25-42: Input struct with validationThe
CreateSubscriptionAddonQuantityInputstruct includes proper validation that:
- Ensures
ActiveFromis set (not zero time)- Ensures
Quantityis non-negativeThe validation collects all errors and returns them together using
errors.Join, which is a good practice for providing comprehensive error information.openmeter/subscription/service/sync_test.go (3)
24-24: Updated dependency type in test structThe dependency type has been updated from
ExposedServiceDepstoSubscriptionDependencies. This aligns with the updated dependency structure that now includes subscription addon support.
351-353: Simplified service initialization in testsThe code now directly initializes dependencies with
NewServiceand accesses the subscription service viadeps.SubscriptionService. This is cleaner than the previous approach and maintains consistency with other test files.
357-357: Updated feature creation method callThe method call has been changed from
CreateExampleFeaturetoCreateExampleFeatures, making it consistent with the same change in other test files.openmeter/ent/db/ent.go (2)
51-54: LGTM: Clean integration of subscription addon imports.These imports correctly reference the newly created packages for the subscription addon functionality, which will be used for column validation in the
checkColumnfunction.
151-154: LGTM: Proper column validation for new subscription addon entities.These additions correctly extend the column validation to include the new subscription addon-related tables, following the established pattern in the codebase.
openmeter/ent/db/subscriptionitem.go (4)
81-82: LGTM: Well-structured edge definition for SubscriptionAddonRateCardItems.This field properly defines the relationship between subscription items and subscription addon rate card item links, enabling efficient loading of related entities.
85-85: LGTM: Correct update to loadedTypes array size.The loadedTypes array is correctly expanded from size 3 to 4 to accommodate the new edge, ensuring proper tracking of loaded edges.
119-126: LGTM: Well-implemented edge accessor method.This method follows the established pattern for edge accessor methods, returning either the loaded edge or an appropriate error.
335-338: LGTM: Consistent implementation of edge query method.This method correctly implements querying functionality for the SubscriptionAddonRateCardItems edge, maintaining consistency with other query methods in the codebase.
openmeter/productcatalog/subscription/service/change_test.go (3)
29-29: LGTM: Updated dependency type for better structure.The type change from
ExposedServiceDepstoSubscriptionDependenciessuggests an improved API design that likely better encapsulates the implementation details.
39-45: LGTM: Simplified dependency initialization.The dependency initialization has been streamlined by using the
NewServicefunction directly, which improves readability and maintainability.
66-66: LGTM: Updated method name to reflect multi-feature creation.The method name change from
CreateExampleFeaturetoCreateExampleFeaturessuggests a more flexible API that can create multiple features at once.Also applies to: 170-170
openmeter/ent/db/addon_query.go (7)
19-19: LGTM: Necessary import for subscription addon functionality.This import correctly brings in the required package for the subscription addon functionality.
30-30: LGTM: Well-defined query field for subscription addons.This field properly extends the AddonQuery struct to support eager-loading of subscription addons.
90-110: LGTM: Well-implemented edge query method.The QuerySubscriptionAddons method correctly sets up the SQL query path for retrieving subscription addons associated with an addon, following the established pattern in the codebase.
305-305: LGTM: Correct implementation of clone functionality.The Clone method has been properly updated to include the new field, ensuring that cloned queries maintain all necessary state.
323-332: LGTM: Well-implemented eager-loading method.The WithSubscriptionAddons method correctly implements eager-loading for subscription addons, following the established pattern in the codebase.
412-414: LGTM: Proper handling of subscription addons in sqlAll.The sqlAll method has been updated to correctly include subscription addons in the loadedTypes array and to load them when requested.
Also applies to: 445-453
487-516: LGTM: Well-implemented loading method for subscription addons.The loadSubscriptionAddons method correctly implements the logic for loading subscription addons, following the same pattern as other loading methods.
openmeter/ent/db/subscription_create.go (4)
19-19: Dependency import looks appropriate.
The new import forsubscriptionaddonis consistent with its usage in the newly added methods below.
229-232: Consistent ENT-style edge addition.
TheAddAddonIDsfunction aligns well with the existing pattern of adding edge IDs (e.g.,AddPhaseIDs,AddBillingLineIDs). No concerns.
234-241: Convenient utility method matches established convention.
AddAddonsfollows the same approach as other edge-related helper methods, forwarding the extracted IDs toAddAddonIDs. Looks good.
495-510: Edge specification continues the existing subscription O2M pattern.
This logic mirrors other edges, such asPhasesandBillingLines. Ensure that the one-to-many relationship fromSubscriptiontoSubscriptionAddonis intentional. Otherwise, no issues.openmeter/subscription/testutils/addon.go (3)
15-22: Example rate card configuration looks fine.
DefiningExampleAddonRateCard1as a global test variable is consistent with other test constructs.
24-51: Clear utility function for building test addon inputs.
GetExampleAddonInputnicely centralizes test data creation, making tests more maintainable and readable.
61-78: Robust test helper for addon creation and publishing.
CreateExampleAddonincludes both creation and publishing steps, offering a convenient end-to-end test flow.openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
29-80: Transactional batch creation approach is solid.
TheCreateManymethod correctly handles multiple rate cards within a single transaction, rolling back on error. Handling constraint errors by returning a “not found” error is consistent with the existing patterns. Overall, the design is clear and maintainable.openmeter/ent/db/planratecard_update.go (2)
183-193: Add missing tests for newly introduced discount setters.These functions correctly add and clear the
discountsfield on thePlanRateCardUpdatestruct. However, please ensure you have corresponding test coverage to validate the new discount logic, particularly around edge cases such as nil or empty discount data.Would you like to generate new unit tests to cover these scenarios and confirm the
discountsfield is being set and cleared properly?
648-658: Ensure consistency withPlanRateCardUpdatefor discount setters.Similar to the
PlanRateCardUpdatesetter methods, these additions forPlanRateCardUpdateOnelook correct. Confirm consistent usage patterns (e.g., same validation checks, test coverage) to reduce the risk of divergence or missed edge cases.openmeter/ent/db/runtime.go (8)
41-44: Imports for subscription addon functionality are clear and necessary.These new imports for
subscriptionaddon,subscriptionaddonquantity,subscriptionaddonratecard, andsubscriptionaddonratecarditemlinkcorrectly align with your new schema definitions. No issues spotted.
131-135: Initialize discounts descriptor forAddonRateCard.The descriptor for the newly introduced
discountsfield is being declared and mapped correctly. Ensure your application logic fully handles any discount validations and that you have tests validating the presence/absence of discount data for addons.
1158-1160: Add descriptor fordiscountsinPlanRateCard.This correctly mirrors the
discountsfield used in the plan rate card schema. Confirm your integration tests validate discount behavior on plan rate cards.
1162-1162: Validate the updated field index ordering.You updated the
phase_idindex from 6 to 7. Confirm existing references throughout the code (and any JSON mappings) still function correctly after this shift.
1231-1266: NewSubscriptionAddonschema fields and validators.These lines add validators for
namespace,addon_id, andsubscription_id. Everything looks consistent. Be sure you have coverage for invalid inputs, such as empty IDs, in your tests.
1267-1306:SubscriptionAddonQuantitydefault values and validators.Your default values (e.g.,
ActiveFrom,Quantity) and validators are set. Check boundary testing for quantities (negative or zero values) and ensure the active time usage is correct in the rest of the code.
1307-1341:SubscriptionAddonRateCardschema integration.The new descriptor properly validates
subscription_addon_idandaddon_ratecard_id. Looks good. Watch out for cyclical references or orphan records if these fields are cleared or updated incorrectly.
1342-1370:SubscriptionAddonRateCardItemLinkreferences.These lines create validators for linking rate cards to subscription items. Carefully verify that the correct item references are being used, and consider adding tests for scenario coverage (e.g., unsubscribed items).
openmeter/subscription/addon/service/list_test.go (2)
1-60: Improve the name verification inTestAddonServiceGet.This test ensures that the created subscription add-on inherits the correct name/description from the original addon. Consider adding negative scenarios (e.g., what if the addon has no description?) to bolster coverage.
62-187: Comprehensive tests for listing subscription addons.
- Validate error handling: Confirm that invalid inputs trigger proper errors.
- Multiple addon retrieval: The test ensures multiple addons, page-based fetching, and total count are handled correctly.
- Pagination logic: Good coverage for partial results and second-page retrieval.
Everything appears well-structured and complete. Great job ensuring thorough coverage of success and error paths in
TestAddonServiceList.openmeter/ent/db/addonratecard.go (6)
53-54: Well-structured addition of the Discounts fieldThe addition of the Discounts field to the AddonRateCard struct is properly documented with a comment describing its purpose.
71-72: Good implementation of new relationship edgeThe SubscriptionAddonRateCards field is correctly added to the AddonRateCardEdges struct, and the loadedTypes array size is properly updated from 2 to 3 to account for the new edge.
Also applies to: 75-75
100-107: Well-implemented edge access methodThe SubscriptionAddonRateCardsOrErr method follows the established pattern for edge access methods, checking if the edge was loaded and returning the appropriate values or errors.
239-244: Correct implementation of field assignmentThe assignment logic for the Discounts field follows the same pattern as other fields in the assignValues method.
281-284: Well-implemented query methodThe QuerySubscriptionAddonRateCards method follows the established pattern for edge query methods.
365-368: String representation properly updatedThe String method is correctly updated to include the Discounts field in the string representation of the AddonRateCard.
openmeter/ent/db/subscription/subscription.go (4)
51-52: Consistent naming for new edge constantThe EdgeAddons constant follows the naming convention established for other edge constants in the file.
83-89: Well-structured table relationship constantsThe table, inverse table, and column constants for the addons relationship are correctly defined and follow the established pattern.
253-265: Proper implementation of ordering functionsThe ByAddonsCount and ByAddons ordering functions follow the established pattern for other ordering functions in the file.
294-300: Correctly implemented SQL graph traversal stepThe newAddonsStep function follows the same pattern as other step creation functions, correctly defining the graph traversal for the addons edge.
openmeter/subscription/addon/service/change_test.go (6)
20-41: Good test coverage for invalid input scenarioThe test correctly verifies that the ChangeQuantity method returns an error when given an invalid negative quantity.
43-66: Proper validation for single instance addon quantitiesThis test nicely validates that a single instance addon cannot have a quantity greater than one, ensuring business logic constraints are maintained.
68-91: Well-structured positive test caseThe successful quantity update test verifies both the time of change and the new quantity value, ensuring complete validation of the functionality.
94-129: Comprehensive helper function for test setupThe helper function creates a complete subscription addon with the necessary relationships, making it easy to set up consistent test data across multiple test cases.
24-24:Details
✅ Verification successful
Verify the withDeps function
The test uses a
withDepsfunction that isn't defined in this file. Make sure this function is defined in an imported package or in another test file in the same package.Try running the following command to locate the definition:
Also applies to: 44-44, 69-69
🏁 Script executed:
#!/bin/bash # Find the definition of the withDeps function rg "func withDeps" -A 5 --type goLength of output: 581
withDeps is Properly Defined in the Package
The search confirms that the
withDepsfunction is defined in theopenmeter/subscription/addon/service/create_test.gofile. Thus, its usage inchange_test.go(and similarly at lines 44 and 69) is valid, as it is imported from the same package.
106-106:Details
✅ Verification successful
Verify helper function dependencies
The test uses a
getRateCardsOfAddonfunction that isn't defined in this file. Ensure this function is properly defined and accessible.Try running the following command to locate the definition:
🏁 Script executed:
#!/bin/bash # Find the definition of the getRateCardsOfAddon function rg "func getRateCardsOfAddon" -A 5 --type goLength of output: 707
Helper Function Verified: No Changes Required
ThegetRateCardsOfAddonfunction is defined inopenmeter/subscription/addon/service/create_test.goand is accessible from the test inchange_test.go. No modifications are needed.tools/migrate/migrations/20250408100627_subscriptionaddon.down.sql (4)
1-10: Well-organized index and table cleanup for rate card item linksThe migration script correctly drops indexes before dropping the table and includes clear comments describing each action.
11-20: Proper cleanup of rate cards table and indexesIndexes are correctly dropped before the table itself, following best practices for database schema changes.
21-28: Proper cleanup of quantities table and indexesThe migration script follows a logical sequence for dropping the quantities-related database objects.
29-34: Proper cleanup of main subscription_addons tableThe script correctly drops the main subscription_addons table last, after all dependent tables have been removed.
openmeter/ent/db/addon/addon.go (4)
50-51: Edge definition for subscription addons looks good.The
EdgeSubscriptionAddonsconstant correctly defines the edge name for subscription addons in mutations, following the naming convention of other edge constants in the file.
61-67: Table and column definitions for subscription addons are properly defined.These constants correctly define the table names and column names for the subscription addons relationship, following the same pattern as the existing rate cards relationship.
223-235: Ordering functions for subscription addons are implemented correctly.The functions
BySubscriptionAddonsCountandBySubscriptionAddonsproperly implement ordering by subscription addon count and specific subscription addon terms, following the same pattern as the existing rate cards ordering functions.
243-249: Helper function for subscription addons step is properly implemented.The
newSubscriptionAddonsStepfunction correctly creates a step for the subscription addons relationship, using the appropriate table and column constants, and defining a one-to-many edge relationship.openmeter/subscription/addon/service.go (2)
11-17: Service interface for subscription addons is well-defined.The
Serviceinterface provides a comprehensive set of operations for managing subscription addons, including creation, retrieval, listing, and quantity management. The method signatures clearly convey their purpose and follow a consistent pattern.
19-23: ListSubscriptionAddonsInput structure includes necessary fields.The input structure for listing subscription addons correctly includes the
SubscriptionIDfor filtering and embeds thepagination.Pagestruct for pagination support.openmeter/ent/db/subscription_query.go (7)
36-36: SubscriptionQuery struct correctly includes withAddons field.The addition of the
withAddonsfield to theSubscriptionQuerystruct properly enables eager loading of subscription addons.
162-182: QueryAddons method is correctly implemented.The
QueryAddonsmethod properly chains the current query on the "addons" edge, following the same pattern as other relationship query methods in the file.
380-380: Clone method correctly includes withAddons field.The
Clonemethod properly clones thewithAddonsfield to ensure complete duplication of the query builder.
431-440: WithAddons method is correctly implemented.The
WithAddonsmethod properly configures the query builder to eager-load subscription addon nodes, following the same pattern as other relationship loading methods.
520-526: loadedTypes array is correctly updated.The
loadedTypesarray in thesqlAllmethod is properly updated to include the newwithAddonsfield, ensuring correct tracking of loaded edge types.
575-581: Logic to load addons is correctly implemented.The condition to load addons in the
sqlAllmethod follows the same pattern as other relationship loading conditions, ensuring that addons are loaded when requested.
710-739: loadAddons method is correctly implemented.The
loadAddonsmethod correctly handles the loading of subscription addon entities, following the same pattern as other relationship loading methods in the file. The method properly maps foreign keys, retrieves related entities, and assigns them to the appropriate subscription nodes.openmeter/subscription/addon/repo/subscriptionaddonquantity.go (4)
12-14: Repository struct is appropriately defined.The
subscriptionAddonQuantityRepostruct correctly encapsulates the database client needed for repository operations.
16-16: Type assertion ensures interface implementation.The type assertion correctly verifies that
subscriptionAddonQuantityRepoimplements theSubscriptionAddonQuantityRepositoryinterface.
18-22: Constructor function is properly implemented.The
NewSubscriptionAddonQuantityRepofunction correctly initializes a new repository instance with the provided database client.
37-38:Details
✅ Verification successful
Map function usage without definition.
The code calls
MapSubscriptionAddonQuantity(entity)but the definition of this function is not visible in this file. Ensure this mapping function is properly defined elsewhere in the package.
🏁 Script executed:
#!/bin/bash # Look for the MapSubscriptionAddonQuantity function definition echo "Searching for MapSubscriptionAddonQuantity function..." rg -A 3 "func MapSubscriptionAddonQuantity" --type goLength of output: 587
Mapping Function Definition Verified
TheMapSubscriptionAddonQuantityfunction is defined inopenmeter/subscription/addon/repo/mapping.go, so its usage insubscriptionaddonquantity.gois correct. No further changes or investigations are necessary.openmeter/ent/schema/addon.go (4)
59-62: Confirm cascade usage for the newsubscription_addonsedge.
Deleting anAddonnow triggers deletion of all relatedSubscriptionAddonrecords. Ensure this behavior is intentional.
94-95: ReusingRateCardfields.
This workaround for an ent bug is acceptable. No further issues here.
96-106: New fields inAddonRateCardschema.
Addingaddon_idandfeature_idfields appears correct. The optional setting forfeature_idaligns with potential absence of a specific feature.
120-123: New edgesubscription_addon_rate_cards.
Applying cascade deletion to child records is consistent with typical parent-child relationships. Looks good.openmeter/ent/db/paginate.go (4)
1596-1643: NewPaginatemethod forSubscriptionAddonQuery.
This auto-generated code follows the established pagination pattern. No issues.
1644-1691: NewPaginatemethod forSubscriptionAddonQuantityQuery.
Consistent with other pagination methods. No concerns.
1692-1739: NewPaginatemethod forSubscriptionAddonRateCardQuery.
Matches the auto-generated pattern. Good job.
1740-1787: NewPaginatemethod forSubscriptionAddonRateCardItemLinkQuery.
Follows the same pagination logic. LGTM.openmeter/ent/db/subscription_update.go (8)
18-18: New import forsubscriptionaddon.
The import is required for referencingSubscriptionAddon. No concerns.
196-210: New methodsAddAddonIDs&AddAddonsinSubscriptionUpdate.
These methods align with typical ent usage for adding edges by ID or entity. Looks good.
264-268:ClearAddonsmethod inSubscriptionUpdate.
Clearing all add-ons from a subscription is standard ent practice.
270-283: MethodsRemoveAddonIDs&RemoveAddonsinSubscriptionUpdate.
These methods cleanly remove edges to existing add-ons. No concerns.
498-542: Edge modification logic forAddonsinsqlSave.
The approach for clearing, removing, and adding add-on edges is consistent with Ent’s edge specifications.
724-738: New methodsAddAddonIDs&AddAddonsinSubscriptionUpdateOne.
Mirrors the multi-entity builder logic. Implementation is correct.
792-811: MethodsClearAddons,RemoveAddonIDs, andRemoveAddonsinSubscriptionUpdateOne.
These methods provide expected functionality for updating singleSubscriptionentities.
1056-1100: Edge modification logic forAddonsinSubscriptionUpdateOne.sqlSave.
Standard ent pattern for edge updates. Looks good.openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
67-68: New edge constant follows naming conventionsThe new edge constant properly follows the project's naming conventions for edge relationships.
92-98: Constants properly define relation tables and columnsThese constants correctly define the database table relationships and follow the established pattern. The naming is consistent with other similar constants in the file.
299-311: Well-implemented ordering functionsThe new functions for ordering subscription items by subscription addon rate card items follow the established pattern in the codebase. They provide a convenient way to order results based on the count or attributes of related entities.
333-339: SQL graph step function follows the patternThe new helper function
newSubscriptionAddonRateCardItemsStepcorrectly constructs a SQL graph step for traversing the subscription addon rate card items relationship. The O2M (one-to-many) edge type accurately represents that one subscription item can have multiple subscription addon rate card items.openmeter/subscription/addon/repository.go (3)
11-32: Clean SubscriptionAddon repository interface designThe SubscriptionAddon repository interface and input types follow good design principles by clearly separating concerns. The interface provides standard CRUD operations and the input type contains appropriate fields.
34-43: SubscriptionAddonRateCard repository supports bulk creationThe repository interface provides a
CreateManymethod for efficient batch creation of rate card entries. This is a good design choice for potentially high-volume operations.
45-53: Simple and focused SubscriptionAddonQuantity repositoryThe repository interface is concise and focused on the creation of subscription addon quantities with appropriate fields for tracking active date ranges and quantity values.
openmeter/ent/db/hook/hook.go (4)
408-418: SubscriptionAddonFunc adapter follows established patternThe adapter type and its Mutate implementation correctly follow the pattern used throughout the file for other entity types. This allows ordinary functions to be used as subscription addon mutators.
420-430: SubscriptionAddonQuantityFunc adapter implements mutation handlingThe adapter and its implementation correctly handle mutations for subscription addon quantities, maintaining consistency with other adapter types.
432-442: SubscriptionAddonRateCardFunc adapter provides mutation supportThe implementation properly checks for the correct mutation type and follows the project's error handling pattern.
444-454: SubscriptionAddonRateCardItemLinkFunc completes mutation adapter setThis adapter rounds out the set of mutation handlers for the subscription addon entity group. The error message is descriptive and follows the same format as other adapters.
openmeter/ent/db/subscriptionitem_query.go (7)
19-20: Added import and query struct field for subscription addon rate card itemsThe new import and field in the SubscriptionItemQuery struct properly establish the relationship with subscription addon rate card items.
Also applies to: 34-34
138-158: Query method for subscription addon rate card itemsThe new query method follows the established pattern for edge traversal and correctly sets up the relationship parameters using the constants defined in the subscriptionitem package.
355-355: Clone method properly includes the new fieldThe Clone method correctly includes the new withSubscriptionAddonRateCardItems field, ensuring that cloned queries maintain all configuration options.
395-404: WithSubscriptionAddonRateCardItems method for eager loadingThe method properly implements eager loading functionality for the new relationship, following the pattern established for other relationships.
484-489: Loaded types array updated to include new relationshipThe array size is correctly incremented to accommodate the new relationship type, maintaining the loadedTypes tracking mechanism.
533-543: sqlAll method updated to load subscription addon rate card itemsThe method now properly handles loading subscription addon rate card items when the corresponding query is set, maintaining consistency with how other relationships are loaded.
642-671: loadSubscriptionAddonRateCardItems implementationThe function follows the established pattern for loading related entities. It correctly maps subscription items to their associated subscription addon rate card items based on foreign keys.
openmeter/ent/db/subscriptionaddon_delete.go (1)
1-89: Code looks good - standard Ent-generated file for entity deletionThis file appears to be auto-generated by the Ent framework and follows the standard Ent pattern for entity deletion operations. It provides well-structured builders for both batch and single entity deletion with appropriate error handling.
openmeter/ent/db/addon_update.go (7)
17-17: LGTM: Appropriate import for subscription addon dependencyThe addition of this import is necessary to support the new subscription addon relationship management functionality.
208-221: Implementation follows Ent patterns for relationship managementThe implementation of methods to add subscription addon relationships follows the standard Ent pattern, consistent with how other relationships are managed in this file (e.g., ratecards).
249-268: Consistent implementation for clearing and removing relationshipsThe implementation for clearing and removing subscription addon relationships follows the same pattern as other relationship management methods in the file, maintaining consistency in the API.
433-477: Appropriate edge management in SQL executionThe implementation of subscription addon edge handling in the
sqlSavemethod follows the standard Ent pattern and correctly handles clearing, removing, and adding edges based on the mutation state.
672-685: Consistent implementation in AddonUpdateOneThe implementation in
AddonUpdateOnemirrors that inAddonUpdate, maintaining a consistent API across both single-entity and multi-entity update operations.
713-732: Consistent implementation for clearing and removing relationships in AddonUpdateOneThe implementation for relationship management in
AddonUpdateOnefollows the same pattern as inAddonUpdate, maintaining API consistency.
927-971: Appropriate edge handling in AddonUpdateOne sqlSaveThe implementation for handling subscription addon edges in the
sqlSavemethod ofAddonUpdateOnecorrectly mirrors the implementation inAddonUpdate, ensuring consistent behavior.openmeter/subscription/addon/service/create_test.go (5)
28-63: LGTM: Good test coverage for input validationThis test properly validates that the service rejects invalid inputs, specifically checking for validation errors when the quantity is set to zero.
95-96: Address TODO for error type verificationThere's a commented-out assertion with a TODO that should be addressed once the Addon Service returns the correct error type. Consider adding a ticket or issue to track this improvement.
139-145: Implement skipped tests for rate card validationThese skipped tests are important for validating the integrity of the subscription addon creation process. They should be implemented once the AddonRateCard type is properly defined.
314-320: Plan for implementing skipped addon-plan validation testsThese skipped tests relate to important business logic that will validate whether an addon can be purchased for a specific plan. Consider creating tickets to track the implementation of these tests once the addon-plan linking functionality is available.
386-416: Well-structured test helpersThe helper functions for creating test data and setting up dependencies are well-structured and promote test code reuse. The
withDepsfunction in particular provides a clean way to manage test dependencies and cleanup.openmeter/ent/db/subscriptionaddonquantity_delete.go (1)
1-89: Code looks good - standard Ent-generated file for entity deletionThis file is auto-generated by the Ent framework and follows the standard pattern for entity deletion operations. It correctly implements both batch and single-entity deletion with appropriate error handling.
openmeter/subscription/addon/service/service.go (3)
21-33: Configuration struct appears well-structured.
Each field is clearly named, enhancing readability and maintainability. No concerns here.
141-143: Implementation looks good.
This method straightforwardly delegates to the repository without issues.
145-152: Query and pagination code appear proper.
No issues found with the listing logic.openmeter/ent/db/addonratecard_query.go (7)
7-7: Import usage is consistent with Ent requirements.
The addition of"database/sql/driver"looks typical for scanning driver values.
20-20: Import ofsubscriptionaddonratecardis valid.
This ensures references to the Subscription Addon Rate Card structures are resolvable in this query.
26-33: New field in struct.
AddingwithSubscriptionAddonRateCards *SubscriptionAddonRateCardQueryis a standard Ent pattern for eagerly loading related edges.
114-134: Edge query method is properly set up.
The method correctly configures a new traversal step on the "subscription_addon_rate_cards" edge.
359-368: Eager-load helper for subscription addon rate cards is properly named and consistent.
This aligns with typical Ent usage conventions.
444-495: Conditional loading logic for subscription addon rate cards is well-structured.
It properly initializes slice fields and assigns related nodes using the foreign key.
560-589: Helper function correctly establishes relationships.
TheloadSubscriptionAddonRateCardsfunction follows Ent's pattern of mapping foreign keys to their parent nodes, ensuring accurate eager-loading.openmeter/ent/db/subscriptionaddonratecard_delete.go (9)
1-14: File creation and imports look standard.
This file adheres to the generated Ent pattern for entity deletion.
15-20: Deletion builder struct is defined properly.
No issues found with the high-level setup forSubscriptionAddonRateCardDelete.
22-26: Chaining predicates withWhereis consistent.
This preserves a fluent API design, aligning with typical Ent usage.
28-40: Execution method design.
TheExecandExecXmethods are standard Ent patterns, returning the count of affected rows and controlling error flow.
42-57:sqlExecproperly handles constraint errors.
Wrapping the error withConstraintErroris beneficial for advanced error handling.
59-62: Deletion builder for single entity is logically separated.
This separation helps ensure a straightforward usage for single-entity operations.
64-68: Continuing to allow predicate chaining is consistent.
The design remains uniform with the multi-delete builder.
70-81: Exec method properly detection of zero affected rows.
ReturningNotFoundErrorensures clarity when no matching entities exist.
83-88:ExecXdesign mirrorsExec.
This is in line with the established Ent code generation pattern.openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (6)
1-14: Code follows good naming conventions and import structure.The file follows consistent naming patterns, and imports are properly organized, with standard library imports first, followed by external and internal packages.
15-20: Well-structured builder pattern for deletion operations.The
SubscriptionAddonRateCardItemLinkDeletestruct properly follows the builder pattern with the necessary fields for configuration, hooks, and mutation tracking.
22-26: Effective implementation of the Where predicate method.The
Wheremethod correctly appends predicates to the mutation and returns the builder itself for method chaining, following established patterns for query building.
28-40: Execution methods provide both error handling and panic variants.The implementation includes both
Exec(returns error) andExecX(panics on error) methods, offering flexibility for different error handling approaches.
42-57: SQL execution properly handles errors and constraints.The
sqlExecmethod correctly:
- Creates a deletion spec with the appropriate field
- Adds predicates to filter the deletion
- Wraps SQL constraint errors appropriately
- Manages the mutation lifecycle
59-88: Single entity deletion properly handles not found cases.The
SubscriptionAddonRateCardItemLinkDeleteOneimplementation correctly returns aNotFoundErrorwhen no entity is deleted, which is important for proper error handling by consumers.openmeter/subscription/addon/repo/subscriptionaddon.go (6)
1-16: Clean package organization with appropriate imports.The package declaration and imports are well-organized, with a clear separation between external and internal dependencies.
17-27: Repository implementation with proper interface compliance check.The implementation correctly:
- Defines a concrete repository struct with DB client dependency
- Uses a compile-time type assertion to ensure interface compliance
- Provides a constructor function that follows dependency injection pattern
29-51: Create method follows transactional pattern with proper error handling.The method effectively:
- Uses transaction.Run for atomicity
- Correctly sets required fields (namespace, IDs)
- Conditionally sets optional fields (metadata)
- Returns a properly structured NamespacedID
53-79: Get method properly handles entity retrieval and not-found conditions.The implementation:
- Uses TransactingRepo for consistent data access
- Queries with appropriate filters
- Converts database not-found errors to domain-specific errors
- Maps database entities to domain models
81-115: List method handles pagination effectively and ensures consistent results.The method:
- Properly filters by namespace and subscription ID
- Provides special handling for zero-pagination case (returns all)
- Uses structured pagination when requested
- Maps database entities to domain models consistently
117-129: Query helper enhances reusability and ensures consistent eager loading.The querySubscriptionAddon function:
- Centralizes eager loading logic for reuse across repository methods
- Specifies proper ordering for time-based quantities
- Ensures all related entities are loaded with appropriate depth
openmeter/ent/db/subscriptionitem_update.go (6)
1-21: Added import for the new entity type.The import for
subscriptionaddonratecarditemlinkhas been correctly added to support the new relationship management functions.
330-343: Methods for adding SubscriptionAddonRateCardItemLink relationships follow established patterns.The
AddSubscriptionAddonRateCardItemIDsandAddSubscriptionAddonRateCardItemsmethods correctly implement the pattern for managing relationships, allowing both direct ID addition and entity pointer conversion.
377-396: Relationship removal methods properly support different usage patterns.The implementation includes:
ClearSubscriptionAddonRateCardItems- removes all relationshipsRemoveSubscriptionAddonRateCardItemIDs- removes specific relationships by IDRemoveSubscriptionAddonRateCardItems- removes relationships via entity pointersAll methods follow established patterns in the codebase.
651-695: SQL generation for relationship management is properly implemented.The changes to
sqlSavecorrectly:
- Handle clearing all relationships
- Handle removing specific relationships while preserving others
- Handle adding new relationships
- Use appropriate edge specifications with proper table and column references
1010-1076: Update-one methods mirror the multi-update methods for consistency.The relationship management methods for
SubscriptionItemUpdateOnemirror those ofSubscriptionItemUpdate, maintaining consistent patterns and behavior across both update types.
1361-1405: SQL generation for single-entity updates follows the same pattern as multi-entity updates.The SQL generation in the
sqlSavemethod forSubscriptionItemUpdateOnecorrectly mirrors the implementation from the multi-entity method, ensuring consistent behavior.openmeter/ent/db/subscriptionaddonquantity.go (8)
1-15: Clean package declaration with appropriate imports.The file starts with appropriate package declarations and imports required dependencies in an organized manner.
16-39: Well-structured entity definition with proper field annotations.The
SubscriptionAddonQuantitystruct is well-defined with:
- Properly named fields following consistent naming conventions
- Appropriate JSON annotations for serialization
- Clear field documentation
- Proper relationship to the parent SubscriptionAddon entity
41-59: Edge handling follows best practices with clear error reporting.The
SubscriptionAddonQuantityEdgesstruct and itsSubscriptionAddonOrErrmethod properly:
- Store the edge relationship
- Track whether edges were loaded
- Return appropriate errors for different edge states (not loaded vs loaded but not found)
61-77: Type scanning is correctly implemented for all field types.The
scanValuesmethod properly handles all field types:
- Integer for Quantity
- Strings for ID and reference fields
- Time fields for timestamps
- Unknown type fallback for other fields
79-141: Value assignment implements thorough error checking and type safety.The
assignValuesmethod:
- Validates input array lengths match
- Includes type assertions with clear error messages
- Handles nullable fields correctly
- Uses selectValues for storing dynamic values
143-159: Query and update methods follow established entity patterns.The
Value,QuerySubscriptionAddon, andUpdatemethods follow best practices:
- Providing access to dynamically selected values
- Enabling relationship traversal
- Creating update builders with appropriate context
161-170: Transaction handling is properly implemented.The
Unwrapmethod correctly:
- Checks if the entity was returned from a transaction
- Resets the driver to the original one post-transaction
- Returns the unwrapped entity for continued use
172-204: String representation and slice type are well implemented.The code includes:
- A comprehensive
Stringmethod that formats all fields appropriately- Proper handling of nullable fields
- A type definition for slices of entities for consistency
openmeter/ent/db/planratecard_create.go (4)
162-166: Proper implementation of discount management for PlanRateCardThe
SetDiscountsmethod is correctly implemented to allow setting discount information on a plan rate card during creation, which aligns with the subscription add-on functionality introduced in this PR.
705-721: Comprehensive discount management methods for PlanRateCardUpsertThe discount management methods (
SetDiscounts,UpdateDiscounts, andClearDiscounts) provide a complete set of operations for managing discounts during upsert operations, following the same pattern as other fields in the struct.
1009-1029: Consistent discount management for single upsert operationsThe discount management methods for the
PlanRateCardUpsertOnestruct are implemented consistently with other fields, providing a comprehensive API for single upsert operations.
1491-1543: Complete bulk discount management implementationThe discount management methods for bulk operations are properly implemented, ensuring that discount information can be efficiently managed in bulk upsert scenarios.
openmeter/ent/db/subscriptionaddonratecarditemlink.go (6)
17-36: Well-structured entity model for subscription addon-item linkageThe
SubscriptionAddonRateCardItemLinkentity is properly designed to serve as a linking entity between subscription addon rate cards and subscription items, with all necessary fields for identification, timestamps, and relationship management.
38-47: Proper edge relationship structureThe
SubscriptionAddonRateCardItemLinkEdgesstruct correctly implements the relationship management between the link entity and its related entities, with a proper loading tracking mechanism.
49-69: Robust error handling for edge relationshipsThe edge accessor methods (
SubscriptionAddonRateCardOrErrandSubscriptionItemOrErr) properly handle all potential error cases, including not loaded and not found scenarios, ensuring robust relationship access.
71-143: Complete database interaction implementationThe database interaction methods (
scanValues,assignValues, andValue) properly handle all field types and provide comprehensive error reporting, ensuring reliable data persistence and retrieval.
145-160: Clean query interface implementationThe query methods provide a clean and consistent API for accessing related entities, following the established patterns in the codebase.
162-196: Robust entity lifecycle managementThe entity lifecycle methods (
UnwrapandString) are properly implemented, with good error handling and clear string representation for logging and debugging purposes.openmeter/ent/db/addonratecard_create.go (7)
18-18: Appropriate import for subscription addon rate card functionalityThe addition of the import for the
subscriptionaddonratecardpackage is necessary to support the new functionality for linking addon rate cards with subscription addons.
163-167: Proper discount management for addon rate cardsThe
SetDiscountsmethod is correctly implemented to enable setting discount information on addon rate cards, consistent with the implementation on plan rate cards.
227-241: Well-implemented relationship management methodsThe methods for adding subscription addon rate cards to an addon rate card entity (
AddSubscriptionAddonRateCardIDsandAddSubscriptionAddonRateCards) are properly implemented, with clear type conversions and consistent return values.
501-516: Comprehensive graph specification for relationshipsThe SQL graph specification for subscription addon rate cards is well-implemented, correctly defining the one-to-many relationship between addon rate cards and subscription addon rate cards with proper table and column references.
737-753: Complete discount management for AddonRateCardUpsertThe discount management methods for the
AddonRateCardUpsertstruct provide a comprehensive API for managing discounts during upsert operations, consistent with other field management methods.
1041-1060: Consistent discount management for single addon rate card upsertsThe discount management methods for the
AddonRateCardUpsertOnestruct follow the established pattern for field management, ensuring consistent behavior across the API.
1523-1542: Proper bulk discount management implementationThe bulk discount management methods for the
AddonRateCardUpsertBulkstruct complete the set of operations needed for comprehensive discount handling in all contexts.openmeter/ent/db/migrate/schema.go (4)
1954-2006: Verify if you need a composite unique index on(subscription_addon_id, addon_ratecard_id).
Thesubscription_addon_rate_cardstable might allow multiple identical mappings. If that's undesired, consider a composite unique index to prevent duplicates.
2007-2060: Good use of unique index on(subscription_item_id, subscription_addon_rate_card_id).
This effectively prevents duplicate item links and helps maintain data integrity. Overall, this design looks consistent and clear.
2315-2318: Table registration approach is consistent.
Adding the new tables (SubscriptionAddonsTable,SubscriptionAddonQuantitiesTable, etc.) to theTablesslice aligns with the existing schema definitions.
2366-2372: Confirm deletion policies for foreign keys referencingsubscription_addons.
You usedNoActionforsubscription_addonsreferences butCascadefor others. If you intend to keep orphaned rows or forbid cascade deletions, it's fine, but verify the consistency of this choice across the schema.openmeter/ent/db/subscriptionaddonratecard.go (10)
18-41: Struct definition appears correct.
TheSubscriptionAddonRateCardstruct neatly encapsulates ID, namespace, timestamps, and references. StoringMetadataas amap[string]stringis a good approach for flexible key-value data.
43-54: Edge definitions look consistent.
You've aligned with Ent’s pattern for referencing connected nodes, indicating clear edges:SubscriptionAddon,Items,AddonRatecard.
67-74:ItemsOrErrimplementation looks appropriate.
It gracefully warns if the edge is not loaded. This aligns with Ent’s lazy-loading approach.
76-85:AddonRatecardOrErrfunction is consistent with Ent patterns.
ReturningNotFoundErrorwhen it’s loaded but empty, andNotLoadedErrorotherwise, matches expected usage.
87-103:scanValuesimplementation is standard.
Correctly dispatches tosql.NullStringorsql.NullTimefor time fields and handles JSON for metadata. Looks good.
171-175: Value accessor is straightforward.
Retrieving dynamically selected values fromselectValuesis standard practice with Ent.
177-190: Query methods align with typical Ent usage.
Method calls (QuerySubscriptionAddon,QueryItems,QueryAddonRatecard) follow the standard client-based pattern.
192-197:Updatemethod is well-structured.
This matches the Ent pattern for applying an update builder to the current entity.
199-208:Unwrapmethod is correct for post-transaction usage.
Reassigning the driver ensures subsequent operations work outside of the closed transaction.
241-243: Type alias is consistent with Ent’s patterns.
SubscriptionAddonRateCardsis a convenient slice for batch operations.openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (8)
12-60: Constants correctly define schema field and edge names.
Naming convention aligns well with Ent’s labeling system, preventing potential conflicts or confusion.
62-72: Columns array is aligned with the field constants.
This array helps ensure consistency and offers a single source of truth for referencing columns.
74-82:ValidColumnfunction is straightforward and efficient.
Checks membership in theColumnsslice, which suffices for runtime validations.
84-99: Ensure validators are utilized.
You have placeholders forNamespaceValidator,SubscriptionAddonIDValidator, etc. Double-check that these functions are assigned and called appropriately in the builder.
101-103:OrderOptiontype is standard.
Defines a function signature to enrich the query’s ordering logic.
104-137: Basic ordering functions for common fields look good.
They align with Ent’s recommended approach for ordering queries by specific columns.
139-165: Advanced ordering by neighbor fields is well-implemented.
The usage ofsqlgraph.OrderByNeighborTermsandOrderByNeighborsCountis correct for edges likeitemsandsubscription_addon.
166-186:new*Step()functions provide clear steps for M2O/O2M edges.
They match how Ent typically constructs adjacency steps for advanced queries and ordering logic.openmeter/ent/db/subscriptionaddon.go (3)
18-41: Comprehensive entity struct looks good.The
SubscriptionAddonstruct cleanly defines fields for metadata, timestamps, and foreign key references. The use of*time.TimeforDeletedAtis appropriate for handling soft deletes. The approach of embeddingsql.SelectValuesis consistent with Ent’s design, letting you capture dynamic fields.
43-96: Edges and lazy-loading checks.The
SubscriptionAddonEdgesstruct and itsOrErrmethods follow Ent conventions to handle unloaded relationships, raising aNotLoadedErrororNotFoundErrorwhen data is not present. The clarity of eachOrErrmethod is excellent for instructing consumers about missing edges.
188-255: Query and update convenience methods.The
QueryX-style functions (e.g.,QuerySubscription(),QueryAddon()) streamline node retrieval.Update()andUnwrap()adhere to Ent’s transactional model. TheString()implementation is straightforward and helpful for debugging. This entire block aligns with recommended Ent patterns.openmeter/ent/schema/subscription_addon.go (4)
14-52: Schema definition for SubscriptionAddon.Your
Fields()method setsaddon_idandsubscription_idasNotEmpty().Immutable(), which helps maintain referential integrity. The edges tosubscriptionandaddonproperly enforce uniqueness and required constraints, reflecting a many-to-one relationship. Overall, the schema is clear and consistent with Ent’s approach.
54-89: SubscriptionAddonQuantity schema.Defining
active_from,quantity, andsubscription_addon_idwith.Immutable()fits well for historical quantity entries. Indexingsubscription_addon_idhelps query performance. TheEdgefromsubscription_addonis set to required and unique, aligning with the intended 1-to-1 style. Good coverage here.
91-130: SubscriptionAddonRateCard structured effectively.Fields for
subscription_addon_idandaddon_ratecard_idare also immutable. The edges to bothSubscriptionAddonandAddonRateCard, along with.Required()and.Unique(), strongly bind these entities. The additional unique index on(namespace, id)is a robust design choice for multi-tenant or partitioned setups.
139-184: SubscriptionAddonRateCardItemLink bridging table.This linking schema connects
subscription_addon_rate_card_idandsubscription_item_id, both of which are non-empty and immutable. The composite unique index ensures no duplicates remain after a soft delete, which suits the typical approach of “deleted_at” usage in such bridging tables. Nicely implemented.openmeter/ent/db/addonratecard_update.go (6)
18-18: New import for subscriptionaddonratecard.This import for the
subscriptionaddonratecardpackage indicates you are now referencing subscription addon rate cards from within AddonRateCard updates. It is a straightforward addition to manage the new relationships.
184-194: Introducing Discounts field methods.
SetDiscountsandClearDiscountsfor thediscountsfield permit flexible assignment and removal of discount data. The usage of pointer-based input aligns with the approach taken in other optional fields (e.g.,SetPrice).
254-305: Edge management for SubscriptionAddonRateCards (bulk add/remove).These new methods (
AddSubscriptionAddonRateCardIDs,AddSubscriptionAddonRateCards,ClearSubscriptionAddonRateCards,RemoveSubscriptionAddonRateCardIDs,RemoveSubscriptionAddonRateCards) extend usability by exposing high-level operations on the O2M relationship. This pattern simplifies bridging entity workflows and is consistent with other Ent auto-generated patterns.
517-561: Edge clearing logic in sqlSave (Update builder).
SubscriptionAddonRateCardsCleared()resets the entire edge set in the database, whileRemoveSubscriptionAddonRateCardsIDs()selectively removes edge linkages. This two-level approach ensures you can remove all or some edges. The usage ofsqlgraph.EdgeSpecfor O2M edges is correct for one-to-many relationships in Ent.
730-740: Equivalent methods for AddonRateCardUpdateOne.Providing the same edge management methods (
SetDiscounts,ClearDiscounts,AddSubscriptionAddonRateCardIDs, etc.) in the “UpdateOne” builder matches the approach in the “Update” builder, ensuring consistency and convenience when updating a single entity instance.Also applies to: 800-851
1093-1137: Additional edge logic in UpdateOne’s sqlSave.Similarly, these blocks mirror the multi-edge management logic for the single-entity update path. They correctly handle clearing the entire set or removing individual edges by ID, ensuring that the relationship can be manipulated in a granular fashion.
openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (6)
18-23: Struct declaration looks solid.
The struct forSubscriptionAddonRateCardItemLinkUpdatecorrectly references the mutation and config, aligning with ent’s builder pattern.
25-29: Predicate method usage is consistent.
Appending predicates to the builder inWherealigns with ent’s recommended usage.
31-55: Field setters and clearers are well-defined.
Methods likeSetUpdatedAt,SetDeletedAt, andClearDeletedAtcleanly manage fields, including the nillable variant. This follows best practices for optional timestamps.
98-107: Edge clearing checks are properly enforced.
Thecheck()method correctly prevents clearing required edges with additional IDs set, helping maintain relational integrity.
109-140: SQL update specification is accurate.
ThesqlSavemethod builds a robustUpdateSpec, properly setting and clearing fields while handling constraint errors.
142-220: UpdateOne builder is consistent with Update builder.
Defining parallel methods—likeSetNillableDeletedAt,ClearDeletedAt, anddefaults()—mirrors the multi-entity approach. This consistency keeps code predictable.openmeter/ent/db/setorclear.go (8)
212-224: SetOrClear pattern is correct for Discounts fields.
These methods cleanly check for nil pointers and toggle between setting and clearing. No issues identified.
226-238: FeatureID toggling follows a similar clean approach.
UsingSetOrClearFeatureIDensures consistency with the rest of the file.
2326-2352: PlanRateCardUpdate: SetOrClearDiscounts and FeatureID logic is consistent.
The same nil-check pattern is repeated for plan rate cards, indicating a unified approach across addon vs. plan code.
2424-2450: SubscriptionAddonUpdate: Metadata toggling is aligned.
Checking for nil before clearing or setting is the correct approach for optional fields.
2452-2464: SubscriptionAddonQuantityUpdate: consistent usage of clearing timestamps.
Mirrors the approach taken in other areas (deleted_at, metadata, etc.).
2466-2478: SubscriptionAddonRateCardUpdate: Extended pattern for DeletedAt.
No concerns; the code follows the same pattern as the rest of the file.
2480-2492: SubscriptionAddonRateCardUpdateOne: handle metadata the same way.
Again, consistent with the established SetOrClear logic.
2494-2506: SubscriptionAddonRateCardItemLinkUpdate: flexible approach to clearing fields.
Ensures that the nil scenario forcibly clears relevant columns.openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (5)
12-31: Field and edge definitions look correct.
Fields likeFieldAddonIDandFieldSubscriptionID, plus edges referencing those fields, align with ent’s typical M2O usage.
71-92: Columns array matches declared fields.
TheColumnsslice is consistent with the struct fields, ensuring correct reflection of database columns.
93-108: Validators and default value hooks seem properly declared.
Ensuring the default ID and updated timestamps are set at creation/update is a best practice.
138-153: Ordering by neighboring fields.
Methods likeByAddonFieldandBySubscriptionFieldshow an advanced usage of ent’s ordering by relationships. Nicely structured.
155-181: Counting neighbors withByRateCardsCount&ByQuantitiesCount.
This pattern is thorough and consistent, enabling advanced sorting in queries.openmeter/ent/db/subscriptionaddonquantity_update.go (1)
25-30: Solid usage of theWheremethod for predicate-based filtering.
This pattern cleanly composes multiple predicates for flexible query building. No issues observed.openmeter/ent/db/subscriptionaddonratecard_update.go (2)
26-30: Flexible predicate-based filtering withWhere.
This is a standard Ent pattern, no concerns here.
158-240: Check concurrency scenarios forsqlSave.
Although Ent typically handles transactions internally, concurrent updates to the sameSubscriptionAddonRateCardmight lead to race conditions if the logic outside of ent's transaction doesn't guard properly. Confirm that use cases needing strict concurrency control are properly managed (e.g., by using transactions or version checks).openmeter/ent/db/subscriptionaddon_query.go (2)
41-45: StraightforwardWherepredicate composition.
This is standard Ent usage allowing flexible filters. Looks good.
545-573: Robust foreign key check inloadSubscription.
Verifies the existence of matching subscriptions. This is a good practice, though ensure you handle cases where the foreign key was changed or removed concurrently.openmeter/ent/db/subscriptionaddonratecard_query.go (1)
138-147: Graceful handling for First() missing results.
In addition to returning *NotFoundError, you might consider logging the event or offering an alternative fallback, especially if there is a common scenario where no results is acceptable. This depends on your business logic.openmeter/ent/db/subscriptionaddonquantity_create.go (2)
161-183: Auto-generated default values are helpful, but review boundary conditions.
For instance, ifsubscriptionaddonquantity.DefaultQuantityis zero or negative, ensure that is genuinely acceptable. It's beneficial to confirm domain-level semantics if a negative or zero quantity could cause confusion.
185-224: Comprehensive field presence validation.
The code correctly fails fast withValidationErrorfor missing fields. This approach is solid. Just ensure you have thorough unit tests to confirm error messages and branching here.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (4)
70-80: Double-check references to subscription item field.
If your domain requires an existing subscription item in all cases, ensure there's a mechanism to detect invalid or deleted items before linking. A synchronous foreign-key check or additional domain checks might be warranted.
139-153: Default ID generation approach.
Since an ID is auto-set when none is provided, confirm that collisions won't happen in your environment (e.g., if using a simple UUID approach, it should be fine). Otherwise, consider a robust uniqueness approach for distributed systems.
155-186: Edge requirements are enforced robustly.
It’s beneficial that mandatory edges (e.g.,subscription_addon_rate_card,subscription_item) raiseValidationErrorif absent. Looks good from a data integrity standpoint.
365-377: Flexible conflict resolution approach.
This design with upsert skipping theIDfield is good for concurrency. Ensure that partial upserts with some updated fields do not produce unexpected partial merges. A comprehensive approach to testing each scenario is recommended.openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (4)
21-34: Auto-generated ENTerprise logic is consistent.
This struct follows the standard Ent pattern for query builders. The fields, such asctx,order,predicates, etc., are used consistently across different methods, ensuring readability and maintainability. No issues noted here.
68-87: Edge query methods are idiomatic.
TheQuerySubscriptionAddonRateCard()method correctly configures an M2O edge convergence, usingsqlgraph.NewStep. This is consistent with Ent's best practices for defining relationships. No specific improvements are warranted.
111-122: Graceful handling of empty results.
TheFirst()method ensures aNotFoundErroris returned when no results exist. This aligns with typical Ent usage and helps consumers of the API distinguish between an empty set and a system error.
606-617: Transaction concurrency locks.
TheForUpdate()method is properly restricted to PostgreSQL dialects by adjusting uniqueness to prevent duplicate rows from being filtered out incorrectly. This usage is consistent with locking semantics in Ent.openmeter/ent/db/subscriptionaddonratecard_create.go (4)
21-34: Builder pattern usage is clear and extensible.
TheSubscriptionAddonRateCardCreatebuilder follows standard Ent conventions for setting fields and edges. This approach promotes clarity when instantiating new records.
139-152: Error handling and defaults.
TheSave()method callsdefaults()before validation. This is a good practice, ensuring required fields (e.g.,created_at,updated_at, andid) are set explicitly. The error handling approach is consistent with Ent’s recommended pattern.
183-222: Validation ensures mandatory fields and edges.
Thecheck()method explicitly checks for required fields/edges such asnamespace,subscription_addon_id, andaddon_ratecard_id. This reduces runtime errors by failing fast on invalid conditions.
330-351: Upsert conflict strategy is comprehensive.
SupportingOnConflictwith multiple strategies (likeIgnore,DoNothing, or custom updates) is well-implemented, providing flexibility for inserting or updating records in one logical workflow.openmeter/ent/db/subscriptionaddonquantity_query.go (4)
20-32: Struct design matches Ent’s query pattern.
TheSubscriptionAddonQuantityQuerystruct fields, such asctx,predicates, andwithSubscriptionAddon, neatly encapsulate the chaining logic for building queries.
65-85: M2O edge traversal is consistent.
TheQuerySubscriptionAddon()method leveragessqlgraph.NewStepfor linking to theSubscriptionAddonentity. This approach mirrors the typical Ent pattern for cross-entity relations.
87-107: Graceful error handling for single-result retrieval.
TheFirst/FirstXmethods provide an intuitive workflow for fetching a single entity or panicking on error. This differentiates empty results from other failure modes.
529-553: Row-level locking logic.
TheForUpdate()andForShare()methods correctly handle row locks in PostgreSQL by disabling uniqueness filtering. This ensures the entire matched set is locked as intended.openmeter/ent/db/subscriptionaddon_update.go (5)
1-2: Auto-generated ent code notice
These lines indicate that the file is generated by Ent. Direct modifications here could be overwritten by future code generation. If you need to change behavior or add fields, update the Ent schema and re-generate.
20-25: Sensible struct definition
TheSubscriptionAddonUpdatestruct provides a standard Ent builder for updatingSubscriptionAddonentities, including hooks and mutation references. No issues are apparent.
148-174: Robust update operations
TheSave,SaveX,Exec, andExecXmethods follow the usual Ent convention for executing updates. Error handling and panic usage are consistent with typical Ent patterns.
195-322: Comprehensive SQL update specification
ThesqlSavemethod applies all mutation predicates, field updates, and edge modifications in a well-structured manner. The approach is consistent with Ent O2M references, including correct error mapping toNotFoundErrorandConstraintError.
324-330: Single-entity update struct
SubscriptionAddonUpdateOneallows focusing on a single entity update. This is a common Ent pattern, and everything appears to be generated correctly.openmeter/ent/db/subscriptionaddon/where.go (3)
1-2: Auto-generated ent code notice
These lines show Ent’s generated file header. As with other Ent files, changes here should be done via schema updates and code regeneration.
13-67: ID-based predicate checks
These predicates (e.g.,ID,IDEQ,IDIn) give fine-grained filtering options on theIDfield. No concerns; they follow Ent’s recommended usage.
433-454: Edge-based query predicates
HasSubscriptionandHasSubscriptionWithdemonstrate standard M2O usage. The step definition usessqlgraphcorrectly, ensuring relationships can be properly verified in queries.openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (3)
1-2: Auto-generated ent code notice
Again, this file is generated by Ent. Direct modifications might be lost if the schema is re-generated.
13-67: ID filtering predicates
The functions for comparing IDs (e.g.,ID,IDEQ,IDIn, etc.) conform to Ent's pattern. No issues found.
353-374: HasSubscriptionAddonRateCard relationship checks
The code properly defines an M2O edge and ensures that selecting neighbors with optional conditions is straightforward. This is standard for Ent queries.openmeter/ent/db/subscriptionaddonquantity/where.go (2)
13-66: Extensive ID-based predicates look good.These ID-based predicates (ID, IDEQ, IDNEQ, etc.) follow typical Ent conventions and provide a thorough set of operators. They appear correct and complete for filtering by string IDs.
443-464: Edge predicates for subscription addons are correctly generated.The
HasSubscriptionAddonandHasSubscriptionAddonWithfunctions correctly handle the M2O relationship. This is standard Ent practice to filter entities by their connected edges.openmeter/ent/db/subscriptionaddon_create.go (3)
22-54: Field setters and nillable setters are correctly structured.The builder pattern for fields like
SetNamespace,SetMetadata,SetCreatedAt, and their nillable counterparts is consistent with Ent conventions. This provides an intuitive interface for controlling which fields get set.
155-197: Default values are well-handled in thedefaults()method.Automatically setting
CreatedAt,UpdatedAt, andIDwhen not explicitly provided prevents null or invalid data. Verify thatsubscriptionaddon.DefaultID()reliably generates unique or valid IDs for your domain needs.Would you like to confirm the uniqueness guarantees or the generation logic behind
subscriptionaddon.DefaultID()in upstream code?
199-238: Validation checks are robust.The
check()method ensures essential fields are set and validates them. It also requires the mandatory edges (subscriptionandaddon). This approach significantly reduces the chance of inserting incomplete or inconsistent records.openmeter/ent/db/client.go (16)
51-54: Well-structured imports for the new subscription addon packagesThese new imports follow the established naming convention and organization of the project, maintaining consistency with the existing codebase structure.
133-140: Proper integration of addon clients into the main Client structThe new client fields are properly documented with clear comments explaining their purpose, maintaining consistent style with the existing client fields. The naming follows the established pattern of entity name followed by "Client" suffix.
191-194: Correct initialization of subscription addon clientsThe initialization code correctly instantiates each new client type with the appropriate configuration, following the same pattern used for other entity clients.
323-326: Proper transaction support for subscription addon clientsThe transaction configuration correctly includes the new subscription addon clients, ensuring they can participate in database transactions alongside other entity types.
382-385: Consistent transaction implementation for BeginTx methodSimilar to the Tx struct, the BeginTx method properly configures the new subscription addon clients for transaction support.
427-429: Appropriate hook and interceptor registrationThe implementation correctly registers the new addon clients for both hooks and interceptors, ensuring they can benefit from the same middleware functionality as other entity types.
Also applies to: 449-451
527-534: Complete mutation handling for subscription addon entitiesEach new entity type has proper mutation handling in the Client.Mutate method, routing mutations to the appropriate client based on their type.
670-684: Well-implemented edge query from Addon to SubscriptionAddonsThis method establishes a one-to-many relationship from Addon to SubscriptionAddons, allowing for efficient querying of subscription addons associated with a particular addon.
851-865: Correct edge implementation for AddonRateCard to SubscriptionAddonRateCardsThe query method properly sets up the relationship graph for retrieving subscription addon rate cards linked to an addon rate card.
6174-6188: Well-implemented relationship from Subscription to AddonsThis edge query method establishes the critical relationship that allows retrieving all addons associated with a subscription, which is key functionality for the subscription addon feature.
7063-7077: Properly defined relationship between SubscriptionItem and SubscriptionAddonRateCardItemsThis query method enables tracking which subscription items are linked to which subscription addon rate cards, completing the relationship model.
6215-6410: Complete and consistent implementation of SubscriptionAddonClientThe SubscriptionAddonClient follows the established pattern for entity clients in this codebase, with complete implementations of all necessary CRUD operations and relationship queries.
6412-6559: Well-structured SubscriptionAddonQuantityClient implementationThe SubscriptionAddonQuantityClient provides all necessary methods for managing subscription addon quantities, allowing clients to track how many of each addon are associated with a subscription.
6561-6740: Proper implementation of SubscriptionAddonRateCardClientThe rate card client implementation provides the functionality needed to manage pricing details for subscription addons, with appropriate relationships to other entities.
6742-6905: Complete implementation of SubscriptionAddonRateCardItemLinkClientThis client implements the many-to-many relationship between subscription addon rate cards and subscription items, following the established pattern for link entities in the codebase.
7445-7446: Proper integration into hooks and interceptors structsThe new entity types are correctly added to both the hooks and interceptors structs, ensuring they can participate in the middleware system consistently with other entity types.
Also applies to: 7458-7459
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (7)
openmeter/subscription/addon/repo/mapping.go (2)
48-53: Consider simplifying the nested functional calls.The timeline mapping uses nested functional calls which might reduce readability. While functionally correct, this could be refactored for clarity.
- quantities := MapSubscriptionAddonQuantities(entity.Edges.Quantities) - base.Quantities = timeutil.NewTimeline[subscriptionaddon.SubscriptionAddonQuantity](lo.Map(quantities, func(q subscriptionaddon.SubscriptionAddonQuantity, _ int) timeutil.Timed[subscriptionaddon.SubscriptionAddonQuantity] { - return q.AsTimed() - })) + quantities := MapSubscriptionAddonQuantities(entity.Edges.Quantities) + timedQuantities := lo.Map(quantities, func(q subscriptionaddon.SubscriptionAddonQuantity, _ int) timeutil.Timed[subscriptionaddon.SubscriptionAddonQuantity] { + return q.AsTimed() + }) + base.Quantities = timeutil.NewTimeline[subscriptionaddon.SubscriptionAddonQuantity](timedQuantities)
130-137: Consider using lo.Map for consistency.While functionally correct, consider using
lo.Mapinstead of a traditional for loop to maintain consistency with the functional style used elsewhere in the codebase.func MapSubscriptionAddonQuantities(entities []*db.SubscriptionAddonQuantity) []subscriptionaddon.SubscriptionAddonQuantity { - quantities := make([]subscriptionaddon.SubscriptionAddonQuantity, len(entities)) - for i, entity := range entities { - quantities[i] = MapSubscriptionAddonQuantity(entity) - } - return quantities + return lo.Map(entities, func(entity *db.SubscriptionAddonQuantity, _ int) subscriptionaddon.SubscriptionAddonQuantity { + return MapSubscriptionAddonQuantity(entity) + }) }openmeter/subscription/addon/service/create_test.go (3)
66-66: Correct the Typographical Error in Subtest Name"Shoul error if addon doesn't exist" contains a minor typo.
Apply the following diff to correct it:
- t.Run("Shoul error if addon doesn't exist", func(t *testing.T) { + t.Run("Should error if addon doesn't exist", func(t *testing.T) {
180-181: Skipping the Test for Missing SubscriptionItemsIt makes sense to skip this test until conflict-handling logic is refined. Consider leaving a more descriptive TODO comment or referencing a ticket/issue to track future completion and to improve maintainability and clarity.
417-448: DRY the Creation of Example Subscriptions and AddonsThe file repeatedly creates a subscription and an add-on for each test. This helper function (
createExampleSubscription) is beneficial, but you might also consider introducing a helper for creating an add-on to reduce repetitive code across subtests.openmeter/subscription/addon/service/service.go (2)
65-65: Fix Spelling of "inconsitency"There are repeated misspellings of "inconsitency error" at lines 65, 99, and 181.
Apply the following diff to fix the spelling:
- return nil, fmt.Errorf("inconsitency error: nil add-on received") + return nil, fmt.Errorf("inconsistency error: nil add-on received")(Repeat the fix for lines 65, 99, and 181.)
Also applies to: 99-99, 181-181
156-198: Consider Concurrency Constraints for Quantity ChangesWhile the transaction logic ensures atomic creation of new quantities, consider whether multiple concurrent calls might overwrite or conflict with existing quantities (especially for single-instance add-ons). Adding a uniqueness or concurrency safeguard at the repository level (e.g., unique constraints) can help prevent race conditions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
openmeter/subscription/addon/repo/mapping.go(1 hunks)openmeter/subscription/addon/service/change_test.go(1 hunks)openmeter/subscription/addon/service/create_test.go(1 hunks)openmeter/subscription/addon/service/list_test.go(1 hunks)openmeter/subscription/addon/service/service.go(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- openmeter/subscription/addon/service/change_test.go
- openmeter/subscription/addon/service/list_test.go
🧰 Additional context used
🧬 Code Definitions (3)
openmeter/subscription/addon/service/create_test.go (8)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)pkg/clock/clock.go (2)
SetTime(23-27)Now(14-21)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)pkg/models/error.go (2)
IsGenericNotFoundError(57-65)GenericNotFoundError(44-46)openmeter/subscription/subscriptionview.go (1)
SubscriptionView(21-26)
openmeter/subscription/addon/repo/mapping.go (11)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)pkg/timeutil/timeline.go (2)
NewTimeline(46-55)Timed(29-32)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/subscription/addon/service/service.go (11)
openmeter/subscription/addon/repository.go (7)
SubscriptionAddonRepository(28-32)SubscriptionAddonRateCardRepository(41-43)SubscriptionAddonQuantityRepository(51-53)CreateSubscriptionAddonRepositoryInput(12-20)CreateSubscriptionAddonRateCardRepositoryInput(35-39)CreateSubscriptionAddonQuantityRepositoryInput(46-49)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/transaction/transaction.go (2)
Creator(18-20)Run(31-49)openmeter/subscription/addon/service.go (2)
Service(11-17)ListSubscriptionAddonsInput(19-23)openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (2)
NewGenericValidationError(138-140)NewGenericConflictError(68-70)openmeter/subscription/subscriptionview.go (2)
SubscriptionPhaseView(71-75)SubscriptionItemView(99-105)pkg/models/metadata.go (1)
MetadataModel(26-28)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: E2E
- GitHub Check: CI
- GitHub Check: Lint
- GitHub Check: Developer environment
- GitHub Check: Test
- GitHub Check: Analyze (go)
🔇 Additional comments (12)
openmeter/subscription/addon/repo/mapping.go (7)
1-14: Well-structured package with appropriate imports.The imports are organized logically, bringing in necessary dependencies for database operations, domain models, and utility functions. The package name
subscriptionaddonrepoclearly indicates its purpose.
16-64: Clean implementation of entity-to-model mapping with thorough error handling.The
MapSubscriptionAddonfunction properly maps all fields from the database entity to the domain model, with appropriate error handling for nested entities. The use of timeline for quantities is a good approach for maintaining temporal relationships.
66-71: Efficient slice mapping with error handling.The
MapSubscriptionAddonsfunction efficiently uses theslicesx.MapWithErrutility to handle potential errors during mapping of multiple entities.
73-104: Good implementation with appropriate error checks.The mapping function properly handles related entities and includes appropriate error checks. The additional nil check for
arcon line 97 is a good defensive programming practice.
106-111: Consistent slice mapping approach.The
MapSubscriptionAddonRateCardsfunction follows the same pattern asMapSubscriptionAddons, providing a consistent approach to error handling when mapping slices.
113-128: Straightforward mapping without error handling.The
MapSubscriptionAddonQuantityfunction provides a clean mapping without error handling, which is appropriate since it doesn't involve any operations that could fail.
97-99:Details
❓ Verification inconclusive
Verify the behavior of FromAddonRateCardRow.
The code checks if
arcis nil after a successful call toFromAddonRateCardRow(no error returned). This suggests the function might return both nil values and nil errors in some cases, which is unusual.
🏁 Script executed:
#!/bin/bash # Check the implementation of FromAddonRateCardRow to understand its nil return behavior ast-grep --pattern 'func FromAddonRateCardRow($args) ($ret_type, error) { $$$ }'Length of output: 84
Below is a revised review comment requesting further manual verification of the function’s behavior:
Action Required: Manually Verify
FromAddonRateCardRowBehaviorIt appears that the automated search using
ast-grepdid not return any output regarding the implementation ofFromAddonRateCardRow. This leaves open the possibility that the function might return a nil value (forarc) with no accompanying error in certain scenarios, which is uncommon and merits a closer manual review.
Please verify:
Ensure thatFromAddonRateCardRowdoes not allow for a case where it returns a nil value for its rate card while also returning a nil error. An unexpected nil result might lead to the error handling at lines 97–99 inopenmeter/subscription/addon/repo/mapping.gomasking a deeper issue.Next Steps:
Manually inspect the implementation ofFromAddonRateCardRow(or search the repository using another tool such asrg "func FromAddonRateCardRow" -n .) to determine if there are edge cases where it could legitimately return nil without an error.openmeter/subscription/addon/service/create_test.go (2)
1-24: Overall Test Imports and Setup Look GoodNo major issues stand out in the imports and package definitions. They appear consistent with the testing strategy and appropriately pull in test utilities, third-party libraries, and supporting packages.
66-98: Validation Flow CoverageThe subtest checks behavior for a non-existing add-on. It verifies that the correct error is raised and ensures the not-found error is identified properly with
models.IsGenericNotFoundError(err). The flow is thorough and aligned with expectations.openmeter/subscription/addon/service/service.go (3)
49-71: Comprehensive Validations in Create MethodThe method thoroughly validates input, checks for single-instance add-ons, and fetches add-on & subscription details. Good use of
input.Validate()and add-on instance type checks.
80-86: Efficient Flattening of Subscription Item IDsThe usage of
lo.Flattenandlo.Mapto accumulate subscription item IDs is concise. This improves readability and avoids manual loops.
103-121: Robust Rate Card Mapping & ValidationUsing
slicesx.MapWithErrto map and validate each rate card is a clean approach. The conflict and validation errors for mismatched IDs are well-handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🔭 Outside diff range comments (1)
openmeter/ent/db/subscription_create.go (1)
228-510: 💡 Verification agent🧩 Analysis chain
Consider adding tests for the newly generated code.
While this is generated code, it's important to verify that the new subscription-addon relationship works correctly. Ensure there are tests that verify:
- Adding addons during subscription creation
- Retrieving addons from subscriptions
- Cascade behavior if subscriptions or addons are deleted
🏁 Script executed:
#!/bin/bash # Search for tests that verify subscription-addon relationships echo "Searching for tests covering subscription-addon relationships:" rg -A 5 "AddAddon(s|IDs)" --glob "**/*_test.go"Length of output: 184
Add tests to verify subscription-addon relationships
While the generated code appears to be functioning as intended, our investigation did not uncover any tests covering the subscription-addon functionality. Please add tests that verify the following:
- Adding addons during subscription creation: Validate that the addons added via
AddAddonIDsandAddAddonsare correctly associated with new subscriptions.- Retrieving addons from subscriptions: Ensure that querying for a subscription successfully retrieves its related addons.
- Cascade behavior: Confirm that deletions of subscriptions or addons trigger the correct cascade behavior.
♻️ Duplicate comments (2)
openmeter/subscription/testutils/compare.go (1)
182-193: Complete the TODO to check all Addon fieldsThe function follows the established pattern for equality assertion functions in this file. However, there's a TODO comment about checking all fields of the Addon entity.
Consider completing the implementation to check all relevant fields of the Addon entity rather than just the ID. This would ensure more thorough testing and prevent potential issues if two addons have the same ID but different properties.
- assert.Equal(t, a1.Addon.ID, a2.Addon.ID) // TODO: check all fields? + // Compare essential Addon fields + assert.Equal(t, a1.Addon.ID, a2.Addon.ID) + assert.Equal(t, a1.Addon.Key, a2.Addon.Key) + assert.Equal(t, a1.Addon.Name, a2.Addon.Name) + assert.Equal(t, a1.Addon.Currency, a2.Addon.Currency) + assert.Equal(t, a1.Addon.InstanceType, a2.Addon.InstanceType)openmeter/ent/db/subscriptionaddonquantity_create.go (1)
27-125: Field Setters and Edge Setter forSubscriptionAddonThe setter methods (e.g.,
SetNamespace,SetCreatedAt,SetUpdatedAt, etc.) are straightforward. They effectively handle nil values for optional fields.From a previous review: “Enforce domain-specific constraints in the setters.” You already apply validations via
NamespaceValidatorandSubscriptionAddonIDValidator, so additional setter-level checks may be optional unless more complex domain rules are needed.
🧹 Nitpick comments (27)
openmeter/subscription/testutils/compare.go (1)
182-193: Add descriptive error messages to assertionsOther equality functions in this file include descriptive error messages in their assertions to help with debugging. Consider adding similar messages to improve test failure diagnostics.
- assert.Equal(t, a1.Addon.ID, a2.Addon.ID) // TODO: check all fields? + assert.Equal(t, a1.Addon.ID, a2.Addon.ID, "addon ID mismatch") // TODO: check all fields? - assert.Equal(t, a1.SubscriptionID, a2.SubscriptionID) + assert.Equal(t, a1.SubscriptionID, a2.SubscriptionID, "subscription ID mismatch") - assert.Equal(t, a1.Metadata, a2.Metadata) + assert.Equal(t, a1.Metadata, a2.Metadata, "metadata mismatch") - assert.Equal(t, a1.RateCards, a2.RateCards) + assert.Equal(t, a1.RateCards, a2.RateCards, "rate cards mismatch") - require.Equal(t, len(a1.Quantities.GetTimes()), len(a2.Quantities.GetTimes())) + require.Equal(t, len(a1.Quantities.GetTimes()), len(a2.Quantities.GetTimes()), "quantity times count mismatch") - require.Equal(t, a1.Quantities.GetAt(i).GetValue().Quantity, a2.Quantities.GetAt(i).GetValue().Quantity) + require.Equal(t, a1.Quantities.GetAt(i).GetValue().Quantity, a2.Quantities.GetAt(i).GetValue().Quantity, "quantity value mismatch at index %d", i) - require.Equal(t, a1.Quantities.GetAt(i).GetTime(), a2.Quantities.GetAt(i).GetTime()) + require.Equal(t, a1.Quantities.GetAt(i).GetTime(), a2.Quantities.GetAt(i).GetTime(), "quantity time mismatch at index %d", i)openmeter/ent/schema/productcatalog.go (1)
130-142: Good refactoring approach with potential index considerationThe refactoring to reuse fields from
RateCard{}.Fields()while adding specific fields forPlanRateCardis clean and well-documented. The comment about the Ent runtime bug provides helpful context for this implementation approach.However, I notice that while
phase_idis included in the indexes defined in theIndexes()method,feature_idisn't specifically indexed. If this field will be frequently queried, you might want to consider adding an appropriate index.openmeter/subscription/addon/repo/transaction.go (3)
29-32: Consider handling possible errors in WithTxIf
NewTxClientFromRawConfigcan fail at runtime, consider returning and handling an error in this method.
50-53: Optional error handling in WithTxConsider returning an error if
db.NewTxClientFromRawConfigfails for any reason.
71-74: Consider handling potential errors in WithTxApply the same optional consideration about error handling if
NewTxClientFromRawConfigcan fail.openmeter/subscription/addon/repo/mapping.go (2)
16-64: Validate nil references before accessingentity.Edges.*.While the logic is well-structured, consider adding defensive checks (or clarifying assumptions) that
entityand its edges are non-nil. Ifentity.Edges.Addonis nil in unexpected circumstances, the code would skip setting essential fields and might silently cause inconsistent data.
73-104: Consider consistent error messages for failed mapping.In
MapSubscriptionAddonRateCard, the error return for an invalid addon rate card is helpful. For uniformity, ensure all error branches provide similarly descriptive messages. This improves debuggability across the codebase.openmeter/subscription/addon/service/list_test.go (2)
19-62: TestAddonServiceGet is well-structured but verify mock cleanup.The test effectively verifies that the subscription addon properly inherits name and description from the original addon. The setup and assertions are clear.
Consider using
t.Cleanup()instead ofdefer clock.ResetTime()to ensure cleanup even if the test panics.- defer clock.ResetTime() + t.Cleanup(func() { + clock.ResetTime() + })
1-193: Missing test for the empty list case.While the test covers valid inputs and pagination, it doesn't test the case where no addons exist for a subscription. Add a test case for an empty list to verify correct behavior.
t.Run("Should return empty list when no addons exist", func(t *testing.T) { withDeps(t, func(t *testing.T, deps subscriptiontestutils.SubscriptionDependencies) { clock.SetTime(now) defer clock.ResetTime() // Create a subscription with no addons sub := createExampleSubscription(t, deps, now) listInp := subscriptionaddon.ListSubscriptionAddonsInput{ SubscriptionID: sub.Subscription.ID, } resp, err := deps.SubscriptionAddonService.List(context.Background(), subscriptiontestutils.ExampleNamespace, listInp) require.NoError(t, err) require.Len(t, resp.Items, 0) require.Equal(t, resp.TotalCount, 0) }) })openmeter/subscription/addon/service/change_test.go (1)
20-92: Missing test for concurrent quantity updates.The tests don't verify behavior when multiple quantity changes occur at the same time. Add a test case that simulates concurrent updates to ensure proper handling.
t.Run("Should handle concurrent quantity updates correctly", func(t *testing.T) { withDeps(t, func(t *testing.T, deps subscriptiontestutils.SubscriptionDependencies) { clock.SetTime(now) defer clock.ResetTime() subAdd := createExampleSubscriptionAddon(t, deps, now) // Create two different change times changeTime1 := testutils.GetRFC3339Time(t, "2025-04-02T00:00:00Z") changeTime2 := testutils.GetRFC3339Time(t, "2025-04-03T00:00:00Z") // First update createInp1 := subscriptionaddon.CreateSubscriptionAddonQuantityInput{ ActiveFrom: changeTime1, Quantity: 1, } // Second update (earlier timestamp but called later) createInp2 := subscriptionaddon.CreateSubscriptionAddonQuantityInput{ ActiveFrom: changeTime2, Quantity: 1, } // Perform updates (simulating concurrent operations) subAddUpdated1, err := deps.SubscriptionAddonService.ChangeQuantity(context.Background(), subAdd.NamespacedID, createInp1) require.NoError(t, err) subAddUpdated2, err := deps.SubscriptionAddonService.ChangeQuantity(context.Background(), subAdd.NamespacedID, createInp2) require.NoError(t, err) // Verify final state contains both updates in correct order require.Equal(t, len(subAdd.Quantities.GetTimes())+2, len(subAddUpdated2.Quantities.GetTimes())) // Get all times and ensure they're ordered correctly times := subAddUpdated2.Quantities.GetTimes() for i := 1; i < len(times); i++ { require.True(t, times[i-1].Before(times[i]) || times[i-1].Equal(times[i])) } }) })openmeter/subscription/addon/service/create_test.go (2)
66-97: Fix typo in test nameThere's a minor typo in the test name that should be corrected.
-t.Run("Shoul error if addon doesn't exist", func(t *testing.T) { +t.Run("Should error if addon doesn't exist", func(t *testing.T) {
38-40: Consider consistent terminology for addon creationThroughout the tests, there are inconsistent references to creating an "add" versus an "addon". Consider standardizing to "addon" for clarity and consistency.
-// Let's create an add +// Let's create an addonAlso applies to: 107-110, 191-193, 279-281, 319-321
openmeter/ent/db/paginate.go (4)
1596-1639: Consider extracting pagination logic into a shared helper to reduce code duplication.These lines implement the
Paginatemethod forSubscriptionAddonQuery, mirroring the same offset-limit-count pattern repeated across the file. While the logic is clear and consistent, it might be worth refactoring the pagination boilerplate into a common utility function or mixin to minimize duplication and simplify future maintenance.
1646-1687: Refactor pagination boilerplate.This
Paginatemethod forSubscriptionAddonQuantityQueryfollows the same structure as the other pagination methods. If you plan to add more pagination methods, consolidating this repetitive logic into a shared helper or generator script will reduce maintenance overhead and risk of subtle inconsistencies.
1695-1735: Centralize pagination logic.Again, the pagination code for
SubscriptionAddonRateCardQueryis duplicated. If possible, consider unifying these patterns in one place—perhaps a pagination utility library—so that future updates (e.g., adding input validation, logging, or metrics) can be done in a single location.
1743-1784: Duplicate pagination approach.Similar manual offset-limit-count steps appear here for
SubscriptionAddonRateCardItemLinkQuery. By centralizing these steps, you can improve testability and maintain consistency across all queries that require pagination.openmeter/subscription/addon/repository.go (2)
11-20:CreateSubscriptionAddonRepositoryInput: consider validation.While this struct is straightforward, you may want optional validation checks (e.g., non-empty
AddonIDandSubscriptionID) to ensure integrity when creating subscription addons. Otherwise, malformed input might slip through.
28-53: Repository interfaces and data structures.
SubscriptionAddonRepository: Defines create, get, and list methods. If updates or deletions are needed, consider adding them.SubscriptionAddonRateCardRepositoryandSubscriptionAddonQuantityRepository: Single-purpose interfaces for creating rate cards and quantities. Make sure the targeted usage scenarios are clearly documented, especially regarding concurrency or partial failures inCreateMany.Everything else looks well-defined for a layered architecture. If you anticipate large volumes of items or batch operations, consider more robust error-handling for partial successes.
openmeter/subscription/addon/service/service.go (3)
32-32: Consider using the logger or removing it if not needed.
Currently,Loggeris defined in theConfigstruct but is never used. This may indicate a missed opportunity to log errors or important runtime information, or an unnecessary field if logging is not required.
65-65: Correct the typo in the error message.
Use "inconsistency" instead of "inconsitency" to ensure clearer messaging.- return nil, fmt.Errorf("inconsitency error: nil add-on received") + return nil, fmt.Errorf("inconsistency error: nil add-on received")Also applies to: 99-99, 181-181
49-141: Consider refactoring theCreatemethod for maintainability.
TheCreatemethod is quite large, performing multiple validations, lookups, and repository operations. Splitting out sub-steps into helper functions or separate domain services could improve readability and reusability.openmeter/subscription/addon/repo/subscriptionaddon.go (2)
17-19: Consider providing an interface-based constructor for testing.
The currentsubscriptionAddonRepostruct directly holds the DB client. For improved testability, consider providing an interface-based constructor or an abstraction around the DB client, so that external code and unit tests can swap in a mock or stub without modifying the repository itself.
81-115: Caution about unbounded queries.
Whenfilter.Page.IsZero(), the code fetches all matching entities in one go. This could be risky if the dataset grows large. Consider adding safeguards or a maximum default limit to avoid potential performance issues.openmeter/ent/db/subscriptionaddonratecard.go (1)
210-239: Potential risk of logging sensitive data inString().
While theString()method is helpful for debugging, it also logs the fullMetadata. IfMetadatacan contain sensitive or user-specific data, consider masking or redacting it in this output to avoid unintentional disclosure.openmeter/ent/db/subscriptionaddonratecard_update.go (2)
32-68: Field Setters Are Clear and ConsistentThe setter methods for
updated_at,deleted_at, andmetadatafields (including their nillable/clear variants) align well with Ent's conventions. No immediate issues found.Consider validating metadata contents for overly large payloads or restricting certain key/value patterns if domain requirements demand it.
158-240: SQL Update Spec ImplementationThe
sqlSavemethod properly applies field updates, clears, and edge additions/removals. It also handles constraints and not-found errors. No concurrency or transaction pitfalls stand out for typical use cases, though concurrent writes could still cause last-writer-wins scenarios.If domain logic requires more transactional or concurrency controls for complex updates, consider adopting explicit transactions with higher-level locking or optimistic concurrency patterns.
openmeter/ent/db/subscriptionaddonquantity_create.go (1)
326-708: Bulk Creation with OnConflict HandlingThe bulk creation logic is robust, chaining each builder’s defaults and checks. Handling conflicts across a batch of new objects is a common requirement. The structure looks correct.
Consider clarifying in documentation how partial successes or partial failures are handled if the bulk operation partially violates constraints.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/migrate/migrations/atlas.sumis excluded by!**/*.sum
📒 Files selected for processing (102)
openmeter/ent/db/addon.go(3 hunks)openmeter/ent/db/addon/addon.go(3 hunks)openmeter/ent/db/addon/where.go(1 hunks)openmeter/ent/db/addon_create.go(3 hunks)openmeter/ent/db/addon_query.go(7 hunks)openmeter/ent/db/addon_update.go(7 hunks)openmeter/ent/db/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/where.go(2 hunks)openmeter/ent/db/addonratecard_create.go(7 hunks)openmeter/ent/db/addonratecard_query.go(8 hunks)openmeter/ent/db/addonratecard_update.go(9 hunks)openmeter/ent/db/client.go(15 hunks)openmeter/ent/db/ent.go(2 hunks)openmeter/ent/db/expose.go(1 hunks)openmeter/ent/db/hook/hook.go(1 hunks)openmeter/ent/db/migrate/schema.go(3 hunks)openmeter/ent/db/paginate.go(1 hunks)openmeter/ent/db/predicate/predicate.go(1 hunks)openmeter/ent/db/runtime.go(4 hunks)openmeter/ent/db/setorclear.go(3 hunks)openmeter/ent/db/subscription.go(3 hunks)openmeter/ent/db/subscription/subscription.go(4 hunks)openmeter/ent/db/subscription/where.go(1 hunks)openmeter/ent/db/subscription_create.go(3 hunks)openmeter/ent/db/subscription_query.go(8 hunks)openmeter/ent/db/subscription_update.go(7 hunks)openmeter/ent/db/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/where.go(1 hunks)openmeter/ent/db/subscriptionaddon_create.go(1 hunks)openmeter/ent/db/subscriptionaddon_delete.go(1 hunks)openmeter/ent/db/subscriptionaddon_query.go(1 hunks)openmeter/ent/db/subscriptionaddon_update.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/where.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_create.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_query.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go(1 hunks)openmeter/ent/db/subscriptionitem.go(3 hunks)openmeter/ent/db/subscriptionitem/subscriptionitem.go(4 hunks)openmeter/ent/db/subscriptionitem/where.go(1 hunks)openmeter/ent/db/subscriptionitem_create.go(3 hunks)openmeter/ent/db/subscriptionitem_query.go(7 hunks)openmeter/ent/db/subscriptionitem_update.go(7 hunks)openmeter/ent/db/tx.go(2 hunks)openmeter/ent/schema/addon.go(3 hunks)openmeter/ent/schema/productcatalog.go(1 hunks)openmeter/ent/schema/ratecard.go(1 hunks)openmeter/ent/schema/subscription.go(3 hunks)openmeter/ent/schema/subscription_addon.go(1 hunks)openmeter/productcatalog/addon/adapter/addon.go(4 hunks)openmeter/productcatalog/addon/adapter/mapping.go(3 hunks)openmeter/productcatalog/subscription/service/change_test.go(4 hunks)openmeter/productcatalog/subscription/service/migrate_test.go(4 hunks)openmeter/productcatalog/subscription/service/plan_test.go(3 hunks)openmeter/subscription/addon/README.md(1 hunks)openmeter/subscription/addon/addon.go(1 hunks)openmeter/subscription/addon/addonratecard.go(1 hunks)openmeter/subscription/addon/quantity.go(1 hunks)openmeter/subscription/addon/repo/mapping.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddon.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonquantity.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonratecard.go(1 hunks)openmeter/subscription/addon/repo/transaction.go(1 hunks)openmeter/subscription/addon/repository.go(1 hunks)openmeter/subscription/addon/service.go(1 hunks)openmeter/subscription/addon/service/change_test.go(1 hunks)openmeter/subscription/addon/service/create_test.go(1 hunks)openmeter/subscription/addon/service/list_test.go(1 hunks)openmeter/subscription/addon/service/service.go(1 hunks)openmeter/subscription/patch/removeitem_test.go(1 hunks)openmeter/subscription/service/service_test.go(8 hunks)openmeter/subscription/service/sync_test.go(2 hunks)openmeter/subscription/testutils/addon.go(1 hunks)openmeter/subscription/testutils/compare.go(2 hunks)openmeter/subscription/testutils/feature.go(3 hunks)openmeter/subscription/testutils/plan.go(2 hunks)openmeter/subscription/testutils/ratecard.go(4 hunks)openmeter/subscription/testutils/service.go(3 hunks)openmeter/subscription/workflow/service/subscription_test.go(16 hunks)pkg/framework/entutils/mapping.go(1 hunks)test/customer/testenv.go(2 hunks)test/subscription/framework_test.go(2 hunks)tools/migrate/migrations/20250408104406_subscriptionaddon.down.sql(1 hunks)tools/migrate/migrations/20250408104406_subscriptionaddon.up.sql(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tools/migrate/migrations/20250408104406_subscriptionaddon.down.sql
- openmeter/ent/db/subscriptionaddon_query.go
🚧 Files skipped from review as they are similar to previous changes (38)
- openmeter/subscription/testutils/plan.go
- openmeter/subscription/addon/README.md
- openmeter/subscription/patch/removeitem_test.go
- test/customer/testenv.go
- openmeter/subscription/addon/addonratecard.go
- openmeter/productcatalog/addon/adapter/addon.go
- openmeter/ent/db/tx.go
- openmeter/ent/schema/ratecard.go
- openmeter/subscription/addon/quantity.go
- openmeter/productcatalog/subscription/service/migrate_test.go
- openmeter/productcatalog/subscription/service/change_test.go
- openmeter/subscription/addon/addon.go
- pkg/framework/entutils/mapping.go
- openmeter/productcatalog/addon/adapter/mapping.go
- openmeter/ent/db/expose.go
- openmeter/ent/db/ent.go
- openmeter/subscription/addon/repo/subscriptionaddonratecard.go
- openmeter/ent/db/addon.go
- openmeter/subscription/addon/service.go
- openmeter/ent/db/addon/where.go
- openmeter/ent/db/subscriptionitem/subscriptionitem.go
- openmeter/ent/db/predicate/predicate.go
- openmeter/subscription/testutils/feature.go
- openmeter/productcatalog/subscription/service/plan_test.go
- openmeter/ent/db/addon/addon.go
- test/subscription/framework_test.go
- openmeter/ent/db/addonratecard.go
- openmeter/ent/schema/subscription.go
- openmeter/subscription/addon/repo/subscriptionaddonquantity.go
- openmeter/ent/db/addonratecard/addonratecard.go
- openmeter/ent/db/subscription/where.go
- openmeter/ent/db/subscriptionaddonratecarditemlink.go
- openmeter/ent/db/hook/hook.go
- openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go
- openmeter/ent/db/subscriptionaddon.go
- openmeter/ent/db/addonratecard_create.go
- openmeter/ent/db/subscriptionaddonratecard_create.go
- openmeter/ent/db/subscriptionaddonratecard/where.go
🧰 Additional context used
🧬 Code Definitions (54)
openmeter/subscription/service/service_test.go (1)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)
openmeter/subscription/workflow/service/subscription_test.go (5)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)openmeter/subscription/testutils/plan.go (1)
GetExamplePlanInput(20-72)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/subscription/workflow/service.go (2)
CreateSubscriptionWorkflowInput(17-21)Service(10-15)
openmeter/ent/db/subscriptionitem_create.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)FieldID(18-18)
openmeter/ent/db/subscriptionitem/where.go (3)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionItem(231-231)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (1)
Table(32-32)openmeter/ent/db/subscriptionitem/subscriptionitem.go (3)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)
openmeter/subscription/testutils/addon.go (6)
openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey(13-13)openmeter/subscription/testutils/global.go (2)
ISOMonth(7-7)ExampleNamespace(5-5)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)openmeter/productcatalog/addon/service.go (1)
CreateAddonInput(98-101)pkg/models/model.go (1)
NamespacedModel(155-157)openmeter/productcatalog/addon.go (1)
AddonMeta(37-63)
openmeter/ent/db/subscriptionitem.go (4)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/schema/subscription_addon.go (5)
SubscriptionAddonRateCardItemLink(146-148)SubscriptionAddonRateCardItemLink(150-155)SubscriptionAddonRateCardItemLink(157-162)SubscriptionAddonRateCardItemLink(164-172)SubscriptionAddonRateCardItemLink(174-189)openmeter/ent/db/ent.go (1)
NotLoadedError(324-326)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)
openmeter/ent/db/subscription_query.go (22)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/client.go (1)
SubscriptionAddonClient(6216-6218)openmeter/ent/db/addon/addon.go (2)
Table(53-53)FieldID(19-19)openmeter/ent/db/addonratecard/addonratecard.go (2)
Table(61-61)FieldID(19-19)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)FieldSubscriptionID(30-30)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (2)
Table(34-34)FieldID(16-16)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
Table(38-38)FieldID(16-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (2)
Table(70-70)FieldID(18-18)openmeter/ent/db/subscriptionphase/subscriptionphase.go (3)
Table(44-44)FieldID(16-16)FieldSubscriptionID(28-28)openmeter/ent/db/predicate/predicate.go (2)
Subscription(216-216)SubscriptionAddon(219-219)openmeter/ent/db/addon.go (1)
Addons(311-311)openmeter/ent/db/addonratecard/where.go (1)
ID(16-18)openmeter/ent/db/subscription/where.go (1)
ID(15-17)openmeter/ent/db/subscriptionaddon/where.go (2)
ID(14-16)SubscriptionID(94-96)openmeter/ent/db/subscriptionaddonquantity/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecard/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionitem/where.go (1)
ID(15-17)openmeter/ent/db/billinginvoiceline/where.go (2)
ID(17-19)SubscriptionID(183-185)openmeter/ent/db/plan/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionphase/where.go (2)
ID(14-16)SubscriptionID(89-91)
openmeter/subscription/service/sync_test.go (1)
openmeter/subscription/testutils/service.go (2)
SubscriptionDependencies(38-52)NewService(54-179)
openmeter/ent/db/addon_query.go (4)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
OrderOption(111-111)Table(40-40)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/ent/db/predicate/predicate.go (2)
Addon(10-10)SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)
openmeter/ent/db/addon_create.go (2)
openmeter/ent/schema/subscription_addon.go (4)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-58)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/subscription/addon/service/service.go (11)
openmeter/subscription/addon/repository.go (7)
SubscriptionAddonRepository(28-32)SubscriptionAddonRateCardRepository(41-43)SubscriptionAddonQuantityRepository(51-53)CreateSubscriptionAddonRepositoryInput(12-20)CreateSubscriptionAddonRateCardRepositoryInput(35-39)CreateSubscriptionAddonQuantityRepositoryInput(46-49)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/transaction/transaction.go (2)
Creator(18-20)Run(31-49)openmeter/subscription/addon/service.go (2)
Service(11-17)ListSubscriptionAddonsInput(19-23)openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (2)
NewGenericValidationError(138-140)NewGenericConflictError(68-70)openmeter/subscription/subscriptionview.go (2)
SubscriptionPhaseView(71-75)SubscriptionItemView(99-105)pkg/models/metadata.go (1)
MetadataModel(26-28)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
openmeter/ent/db/addonratecard/where.go (2)
openmeter/ent/db/addonratecard/addonratecard.go (5)
FieldDiscounts(49-49)Table(61-61)FieldID(19-19)SubscriptionAddonRateCardsTable(77-77)SubscriptionAddonRateCardsColumn(82-82)openmeter/ent/db/subscriptionitem/subscriptionitem.go (3)
FieldDiscounts(60-60)Table(70-70)FieldID(18-18)
openmeter/subscription/addon/repository.go (4)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)
openmeter/subscription/addon/repo/transaction.go (7)
openmeter/ent/db/tx.go (1)
Tx(15-104)openmeter/ent/db/client.go (2)
Driver(250-254)Client(63-147)pkg/framework/entutils/transaction.go (2)
NewTxDriver(47-52)TxDriver(76-88)openmeter/ent/db/expose.go (1)
NewTxClientFromRawConfig(78-172)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)
openmeter/subscription/testutils/service.go (7)
openmeter/subscription/workflow/service.go (1)
Service(10-15)openmeter/subscription/addon/service/service.go (2)
NewService(41-47)Config(21-33)openmeter/subscription/service/service.go (1)
New(37-41)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)openmeter/subscription/testutils/addon.go (1)
NewTestAddonService(57-59)
openmeter/ent/db/subscriptionaddonquantity_delete.go (4)
openmeter/ent/db/ent.go (3)
IsConstraintError(361-367)ConstraintError(345-348)NotFoundError(278-280)openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (3)
Table(34-34)FieldID(16-16)Label(14-14)
openmeter/subscription/addon/service/create_test.go (7)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)
openmeter/subscription/addon/service/change_test.go (4)
openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (1)
GenericValidationError(145-147)
openmeter/subscription/addon/service/list_test.go (8)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)openmeter/subscription/addon/service.go (1)
ListSubscriptionAddonsInput(19-23)openmeter/subscription/testutils/compare.go (1)
SubscriptionAddonsEqual(182-193)
openmeter/subscription/addon/repo/mapping.go (7)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)pkg/timeutil/timeline.go (2)
NewTimeline(46-55)Timed(29-32)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)
openmeter/subscription/addon/repo/subscriptionaddon.go (3)
openmeter/subscription/addon/repository.go (3)
SubscriptionAddonRepository(28-32)CreateSubscriptionAddonRepositoryInput(12-20)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/entutils/transaction.go (1)
TransactingRepo(199-221)openmeter/subscription/addon/repo/mapping.go (1)
MapSubscriptionAddon(17-64)
openmeter/ent/db/subscriptionitem_query.go (3)
openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscription_update.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/ent/db/subscriptionaddon_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)Label(14-14)
openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/schema/addon.go (3)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/subscription/subscription.go (3)
openmeter/ent/db/addon/addon.go (1)
Table(53-53)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/migrate/schema.go (1)
AddonsTable(31-75)
openmeter/ent/db/subscriptionaddonratecard.go (4)
openmeter/ent/db/ent.go (2)
NotFoundError(278-280)NotLoadedError(324-326)openmeter/ent/db/addonratecard/addonratecard.go (7)
Label(17-17)FieldMetadata(23-23)FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (7)
Label(14-14)FieldMetadata(20-20)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (5)
Label(14-14)FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/addon_update.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/ent/db/subscriptionaddonquantity.go (3)
openmeter/ent/db/subscriptionaddonquantity/where.go (8)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)ActiveFrom(89-91)Quantity(94-96)SubscriptionAddonID(99-101)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonquantity_update.go (1)
SubscriptionAddonQuantityUpdateOne(140-145)
openmeter/subscription/testutils/ratecard.go (5)
openmeter/productcatalog/ratecard.go (3)
UsageBasedRateCard(256-262)FlatFeeRateCard(161-168)RateCardMeta(49-77)openmeter/subscription/testutils/global.go (1)
ISOMonth(7-7)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/productcatalog/entitlement.go (3)
EntitlementTemplate(34-39)NewEntitlementTemplateFrom(209-225)MeteredEntitlementTemplate(232-252)openmeter/productcatalog/price.go (1)
NewPriceFrom(338-360)
openmeter/ent/db/addonratecard_query.go (3)
openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (5)
openmeter/ent/db/addonratecard/addonratecard.go (10)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)openmeter/ent/db/subscription/subscription.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (11)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(30-30)ValidColumn(57-64)Columns(45-54)ByID(91-93)OrderOption(88-88)BySubscriptionAddonID(126-128)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (8)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)
openmeter/ent/db/paginate.go (7)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonquantity_query.go (1)
SubscriptionAddonQuantityQuery(21-32)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)
openmeter/ent/db/subscriptionitem_update.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(90-97)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscription/subscription.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(28-28)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)ByActiveFrom(172-174)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (16)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)ValidColumn(75-82)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)BySubscriptionAddonID(130-132)BySubscriptionAddonField(140-144)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (15)
FieldID(18-18)FieldNamespace(20-20)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldActiveFrom(30-30)ValidColumn(128-135)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)ByActiveFrom(192-194)
openmeter/ent/db/migrate/schema.go (2)
openmeter/ent/db/subscription/subscription.go (2)
Table(54-54)AddonsTable(84-84)openmeter/ent/db/addonratecard/addonratecard.go (1)
SubscriptionAddonRateCardsTable(77-77)
openmeter/ent/db/addonratecard_update.go (2)
openmeter/ent/db/addonratecard/addonratecard.go (5)
Table(61-61)SubscriptionAddonRateCardsTable(77-77)Columns(86-105)SubscriptionAddonRateCardsColumn(82-82)FieldID(19-19)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
Table(38-38)Columns(63-72)FieldID(16-16)
openmeter/ent/schema/subscription_addon.go (6)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/subscriptionaddonratecard_update.go (4)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardMutation(43471-43492)openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonRateCard(225-225)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
FieldID(16-16)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (3)
FieldID(16-16)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (7)
openmeter/ent/db/addon/addon.go (10)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(90-97)Columns(71-87)ByID(140-142)OrderOption(137-137)openmeter/ent/db/addonratecard/addonratecard.go (11)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldAddonID(51-51)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)openmeter/ent/db/subscription/subscription.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (9)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)ValidColumn(57-64)Columns(45-54)ByID(91-93)OrderOption(88-88)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (10)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)ValidColumn(75-82)Columns(63-72)ByID(105-107)OrderOption(102-102)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (8)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)openmeter/ent/db/subscriptionitem/subscriptionitem.go (10)
FieldID(18-18)FieldNamespace(20-20)FieldMetadata(28-28)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)ValidColumn(128-135)Columns(102-125)ByID(167-169)OrderOption(164-164)
openmeter/ent/db/subscriptionaddonquantity_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/setorclear.go (5)
openmeter/ent/db/addonratecard_update.go (1)
AddonRateCardUpdate(24-28)openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/subscriptionaddon_update.go (1)
SubscriptionAddonUpdate(21-25)openmeter/ent/db/subscriptionaddonratecard_update.go (1)
SubscriptionAddonRateCardUpdate(20-24)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (1)
SubscriptionAddonRateCardItemLinkUpdate(19-23)
openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (12)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)Table(32-32)FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)Columns(50-57)SubscriptionAddonRateCardColumn(39-39)SubscriptionItemColumn(46-46)FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)
openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/subscriptionaddonratecard_query.go (5)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)
openmeter/ent/db/subscriptionaddonquantity_create.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (9)
DefaultCreatedAt(97-97)DefaultUpdatedAt(99-99)DefaultID(107-107)NamespaceValidator(95-95)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (14)
DefaultCreatedAt(70-70)DefaultUpdatedAt(72-72)DefaultActiveFrom(76-76)DefaultQuantity(78-78)DefaultID(84-84)NamespaceValidator(68-68)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)FieldSubscriptionAddonID(30-30)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (7)
FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)Table(32-32)SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)SubscriptionItemTable(41-41)SubscriptionItemColumn(46-46)
openmeter/ent/db/subscriptionaddon/where.go (2)
openmeter/ent/db/predicate/predicate.go (5)
SubscriptionAddon(219-219)Subscription(216-216)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)Addon(10-10)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (17)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldAddonID(28-28)FieldSubscriptionID(30-30)FieldMetadata(20-20)Table(40-40)SubscriptionTable(42-42)SubscriptionColumn(47-47)RateCardsTable(49-49)RateCardsColumn(54-54)QuantitiesTable(56-56)QuantitiesColumn(61-61)AddonTable(63-63)AddonColumn(68-68)
openmeter/ent/db/subscriptionaddonquantity/where.go (9)
openmeter/ent/db/subscription/where.go (6)
ID(15-17)Namespace(70-72)CreatedAt(75-77)UpdatedAt(80-82)DeletedAt(85-87)ActiveFrom(90-92)openmeter/ent/db/subscriptionaddon/where.go (5)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (4)
ID(14-16)CreatedAt(69-71)UpdatedAt(74-76)DeletedAt(79-81)openmeter/ent/db/subscriptionitem/where.go (6)
ID(15-17)Namespace(70-72)CreatedAt(75-77)UpdatedAt(80-82)DeletedAt(85-87)ActiveFrom(90-92)openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonQuantity(222-222)SubscriptionAddon(219-219)openmeter/ent/db/addon/addon.go (6)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)Table(53-53)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (9)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)FieldSubscriptionAddonID(30-30)Table(34-34)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (7)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)Table(38-38)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (5)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)Table(32-32)
openmeter/ent/db/subscriptionaddonquantity_query.go (2)
openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonquantity/where.go (3)
SubscriptionAddonID(99-101)IDIn(29-31)ID(14-16)
openmeter/ent/db/subscriptionaddon_update.go (5)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/predicate/predicate.go (3)
SubscriptionAddon(219-219)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddon_create.go (8)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/subscription/where.go (6)
ID(15-17)CreatedAt(75-77)UpdatedAt(80-82)Namespace(70-72)Name(105-107)DeletedAt(85-87)openmeter/ent/db/subscriptionaddonquantity/where.go (5)
ID(14-16)CreatedAt(74-76)UpdatedAt(79-81)Namespace(69-71)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecard/where.go (5)
ID(14-16)CreatedAt(74-76)UpdatedAt(79-81)Namespace(69-71)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (4)
ID(14-16)CreatedAt(69-71)UpdatedAt(74-76)DeletedAt(79-81)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: E2E
- GitHub Check: Developer environment
- GitHub Check: CI
- GitHub Check: Test
- GitHub Check: Analyze (go)
🔇 Additional comments (313)
openmeter/ent/schema/addon.go (3)
59-62: New edge adds proper relationship to SubscriptionAddon with cascade deleteThis addition establishes the relationship from Addon to SubscriptionAddon entities with appropriate cascade delete behavior, ensuring that when an Addon is removed, all associated SubscriptionAddons will be deleted as well, maintaining data integrity.
93-107: Good refactoring of field definitionsThe refactoring to reuse fields from the RateCard schema reduces code duplication while maintaining proper field definitions. The added fields have appropriate constraints and helpful comments explaining their purpose.
120-123: Well-defined edge to SubscriptionAddonRateCard with cascade deleteThis addition properly establishes the relationship from AddonRateCard to SubscriptionAddonRateCard entities with cascade delete behavior, ensuring referential integrity when parent records are deleted.
openmeter/subscription/testutils/compare.go (1)
12-12: Import addition looks goodThe import of the subscription addon package is necessary for the new equality comparison function.
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (6)
1-12: Auto-generated Ent code structure looks solid.
All imports and package declarations are standard for Ent predicates. The generated header and package references appear consistent and correct.
13-67: ID-based equality, inequality, and pattern matching predicates are consistent.
These predicates (e.g.,ID,IDEQ,IDNEQ, etc.) follow the typical Ent code-generation pattern, using parameterized queries that mitigate SQL injection risks. No issues noticed.
68-91: Time-based predicates for CreatedAt, UpdatedAt, and DeletedAt are standard.
These predicates properly delegate to Ent’s parameterized queries (sql.FieldEQ,sql.FieldIn, etc.). They’ll help maintain robust filtering for time-based fields in typical usage scenarios.
92-221: Comprehensive coverage for time-range queries.
This block provides GT/GTE/LT/LTE, optional multi-value queries (In,NotIn), and nil checks forDeletedAt. This level of granularity ensures flexible filtering.
223-351: String-based filtering forSubscriptionAddonRateCardIDandSubscriptionItemID.
All relevant operators (Contains, HasSuffix, etc.) match Ent’s typical approach to string field predicates. The coverage is thorough and consistent, enabling advanced queries.
353-412: Edge-based predicates forHasSubscriptionAddonRateCardandHasSubscriptionItem.
These definitions correctly leverage Ent’ssqlgraph.NewStepto link the underlying tables, ensuring straightforward neighbor-based filtering. Everything here aligns with standard Ent patterns.openmeter/ent/schema/productcatalog.go (1)
166-170:Details
✅ Verification successful
Verify that feature_key field still exists
The Fields() method no longer explicitly defines
feature_key, but it's still referenced in this index. Make sure this field is included in what's returned fromRateCard{}.Fields()to avoid potential issues.
🏁 Script executed:
#!/bin/bash # Check if feature_key is defined in RateCard grep -r "field\..*\"feature_key\"" --include="*.go" ./openmeter/ent/schema/Length of output: 410
Verified: "feature_key" is present in RateCard fields
The grep results confirm that the
feature_keyfield is defined inopenmeter/ent/schema/ratecard.go(as afield.String("feature_key")), ensuring it is indeed included inRateCard{}.Fields(). The index inproductcatalog.goreferencingfeature_keyis therefore valid. No further changes are needed.openmeter/ent/schema/subscription_addon.go (8)
1-12: Good use of mixins and structured imports.All essential imports and utility mixins (e.g.,
IDMixin,NamespaceMixin, etc.) are properly included to keep the schema consistent with the existing patterns in the codebase.
14-33: Confirm immutability of primary identifiers.The
addon_idandsubscription_idfields are marked as.Immutable(). This prevents updating references after creation. Please verify that once a subscription addon is created, it should remain permanently attached to the same subscription and addon. If you intend to support transfers or corrections, consider removing.Immutable().
35-58: Edge definitions follow Ent conventions.The edges are well-structured:
- A required, unique edge from
SubscriptionAddontoSubscriptionensures each record belongs to exactly one subscription.- A corresponding edge from
Addonensures the link back to the original addon.- Rate cards and quantities are cascaded on delete, which generally aligns with typical usage where an addon’s removal deletes its child records.
60-78: Reassess immutability on quantity fields.By defaulting to
1with.Immutable(), your model treats a change in quantity as a distinct historical record. If your domain logic requires adjusting a quantity over time, you might want to confirm that creating a new row versus updating in place is the desired approach.
80-95: Edges forSubscriptionAddonQuantitylook solid.The edge references
SubscriptionAddonvia a required and unique field, ensuring each quantity record tightly corresponds to a single addon. The approach is consistent with historical-tracking patterns.
97-136: Validate references toaddon_ratecard_id.The
SubscriptionAddonRateCardstruct ties a subscription addon to an addon rate card. All fields (subscription_addon_idandaddon_ratecard_id) are set as.Immutable(). Confirm that referencing a different rate card once assigned should always require a new record, rather than an update in place.
138-143: Unique index is consistent with namespaced models.The unique index on
namespaceandidhelps maintain uniqueness across tenant boundaries. This usage aligns with the rest of the codebase’s ent design patterns.
145-189: Linking table design is robust.The
SubscriptionAddonRateCardItemLinkadds a composite unique index restricted bydeleted_at IS NULLto avoid duplicates among active records, which is important for soft-deletion scenarios. This design is clean and consistent with typical linking table patterns.openmeter/subscription/addon/repo/transaction.go (8)
1-2: No issues with package declarationThe package name is appropriate and matches the directory structure.
3-11: Imports appear valid and appropriateAll imported packages seem necessary for transaction handling and database operations.
15-23: Transaction logic for subscriptionAddonRepo looks correctThe function properly uses
HijackTx, returns an error on failure, and constructs a new driver on success.
25-27: Self method enables method chaining or referencingThe straightforward method simply returns the same
subscriptionAddonRepoinstance, which is useful for chaining.
36-44: Transaction logic for subscriptionAddonRateCardRepo is consistentThis replicates the same approach as
subscriptionAddonRepoand appears correct.
46-48: Self method is clear and consistentNo issues observed.
57-65: Transaction logic for subscriptionAddonQuantityRepo is properly alignedThis follows the established pattern and uses
HijackTxconsistently.
67-69: Self method is straightforwardNo further issues.
openmeter/subscription/service/service_test.go (2)
31-32: Code refactoring looks goodThe refactoring improves code clarity by directly accessing the SubscriptionService from deps rather than using an additional variable.
35-35: Method name updated to reflect multiple featuresThe method name change from
CreateExampleFeaturetoCreateExampleFeaturesbetter reflects its purpose of creating multiple features instead of a single one.openmeter/subscription/testutils/ratecard.go (3)
17-18: Type change improves consistency and correctnessChanging
ExamplePriceAmountfrominttoint64and changingExampleRateCard1fromFlatFeeRateCardtoUsageBasedRateCardimproves type consistency and better supports the subscription addon functionality.
39-39: Adjusted billing cadence field to match UsageBasedRateCard requirementsUpdated the billing cadence field from a pointer type to a direct reference, which aligns with the UsageBasedRateCard struct definition where BillingCadence is a non-pointer field.
54-77: Well-structured new rate card for addon testingThe new
ExampleRateCard3ForAddonsis well-defined with all necessary fields including metadata, billing cadence, and pricing configuration, which will be useful for testing the subscription addon functionality.openmeter/subscription/testutils/addon.go (4)
15-22: Good test data definition for addon rate cardThe example addon rate card is well-defined with appropriate test values for name, description, and billing cadence.
24-51: Comprehensive test input generator for addonsThe
GetExampleAddonInputfunction provides a thorough example addon with all required fields populated, which will be valuable for consistent testing.
53-59: Simple and effective test service wrapperThe
testAddonServicestruct elegantly embeds the actual service interface, allowing for extension while maintaining the full interface contract.
61-78: Helper method handles both creation and publishingThe
CreateExampleAddonmethod effectively manages the full lifecycle of test addon creation and publishing, with proper error handling and test failure reporting.openmeter/ent/db/runtime.go (3)
41-44: New imports for subscription addon functionalityThe added imports correctly include all the required entity packages for the subscription addon feature: subscriptionaddon, subscriptionaddonquantity, subscriptionaddonratecard, and subscriptionaddonratecarditemlink.
1158-1160: Updated descriptor for discounts fieldThe discounts field descriptor for planratecard is correctly integrated with the ValueScanner to handle productcatalog.Discounts type.
1231-1370: Comprehensive entity registration for subscription addon componentsThe added initialization code for subscription addon entities is complete and follows the same pattern as other entities in the codebase, with proper field validators, default values, and index descriptors.
openmeter/subscription/addon/repo/mapping.go (5)
1-15: No issues found in package declaration and imports.This file sets up a clean, well-organized structure with idiomatic import grouping. All imported libraries appear relevant to the mapping logic.
66-71: Good use ofslicesx.MapWithErr.This approach adequately handles partial error accumulation while converting a slice of entities. It is concise, reduces boilerplate, and supports aggregated error reporting.
106-111: Straightforward slice mapping logic.The function is concise and matches the approach used elsewhere. No issues from a logical or performance perspective.
113-128: Mapping logic for addon quantity looks correct.All required fields (IDs, timestamps, quantity, etc.) are properly mapped, aligning with the domain structure.
130-137: Efficient iteration over quantities.The code is direct, avoids repetition, and remains clear. The return type is well-defined.
openmeter/ent/db/subscriptionaddonratecard_query.go (1)
1-796: Auto-generated ent code – no manual changes required.This file is produced by the Ent framework. As such, it should not be edited directly. The generated code appears structurally correct and consistent with expected Ent-based patterns.
openmeter/ent/db/subscriptionaddon/where.go (1)
1-539: Auto-generated ent predicates – no concerns.This file contains standard, generated predicate logic for the Ent schema. It provides thorough filtering options with no evident mistakes or security concerns.
openmeter/ent/db/client.go (15)
51-54: Well-structured import declarations for the new subscription add-on packages.The code properly imports the necessary packages for the subscription add-on functionality, maintaining the alphabetical ordering convention used throughout the codebase.
133-140: Clean integration of subscription add-on clients into the main Client struct.The new client fields are properly added to the Client struct, following the established naming convention and ordering pattern. This enables access to subscription add-on operations through the main client interface.
191-194: Proper initialization of subscription add-on clients.The initialization code correctly instantiates all the new subscription add-on client types during the client initialization process, ensuring they're ready for use.
323-326: Comprehensive transaction support for subscription add-on operations.The subscription add-on clients are properly included in both transaction creation methods (
TxandBeginTx), ensuring that operations on subscription add-ons can be included in database transactions alongside other entity operations.Also applies to: 382-385
428-429: Well-integrated hooks and interceptors for subscription add-on entities.The new subscription add-on clients are properly added to the hooks and interceptors application mechanisms, allowing for consistent behavior modification across all entity types.
Also applies to: 450-451
527-534: Complete mutation handling for subscription add-on entities.The
Mutatemethod has been properly extended to handle mutations for all subscription add-on entity types, ensuring that the client can process operations on these new entities.
670-684: Well-implemented relationship query between Addon and SubscriptionAddon.The
QuerySubscriptionAddonsmethod properly sets up the database query to navigate from an Addon to its associated SubscriptionAddons, using the appropriate edge definition.
851-865: Properly defined query relationship between AddonRateCard and SubscriptionAddonRateCard.The implementation correctly establishes the one-to-many relationship from AddonRateCard to SubscriptionAddonRateCard entities, allowing for efficient traversal of this relationship.
6174-6188: Effective bidirectional relationship between Subscription and SubscriptionAddon.This method completes the bidirectional relationship between Subscription and SubscriptionAddon, allowing for queries that start from the subscription and retrieve its associated add-ons.
7063-7077: Well-defined relationship query from SubscriptionItem to SubscriptionAddonRateCardItemLink.The implementation correctly establishes the one-to-many relationship from SubscriptionItem to SubscriptionAddonRateCardItemLink entities, enabling efficient retrieval of rate card items linked to a subscription item.
6215-6410: Complete and well-structured SubscriptionAddonClient implementation.The SubscriptionAddonClient implementation follows the established patterns in the codebase, including proper CRUD operations, relationship queries, hooks and interceptors support, and mutation handling.
6412-6559: Comprehensive SubscriptionAddonQuantityClient implementation.The implementation provides all necessary operations for managing subscription add-on quantities, maintaining consistency with the codebase patterns and enabling proper relationship navigation.
6561-6740: Thorough SubscriptionAddonRateCardClient implementation.The client correctly implements all the necessary functionality for managing subscription add-on rate cards, including proper relationship querying to associated entities.
6742-6905: Well-designed SubscriptionAddonRateCardItemLinkClient implementation.This client properly implements the functionality needed to manage the links between subscription add-on rate cards and subscription items, facilitating the many-to-many relationship between these entities.
7445-7460: Proper integration with the hooks and interceptors system.The hooks and interceptors structs have been updated to include the new subscription add-on entity types, ensuring consistent behavior across all entities.
openmeter/ent/db/subscription.go (4)
66-67: Relationship enhancement for Subscription entity.The addition of the
Addonsfield to theSubscriptionEdgesstruct properly establishes a relationship between subscriptions and subscription addons, enabling the retrieval of addons associated with a subscription.
70-70: Correctly updated the loadedTypes array size.The increase of the
loadedTypesarray size from 4 to 5 aligns with the addition of the newAddonsedge, ensuring proper eager-loading tracking.
113-120: Well-implemented error handling for the new edge.The
AddonsOrErrmethod follows the established pattern for edge error handling, checking if the edge was loaded before returning the value or an appropriate error message.
273-276: Clear query method for the new edge.The
QueryAddonsmethod enables proper traversal of the new relationship, allowing clients to query subscription addons associated with a subscription.openmeter/subscription/workflow/service/subscription_test.go (4)
76-77: Simplified service dependency management.The code has been refactored to use the
depsvariable directly fromNewServiceinstead of unpacking it into a separateservicesvariable, which simplifies the dependency management in tests.
87-87: Consistent usage of the new dependency structure.Properly updated to use
deps.WorkflowServicefollowing the dependency structure simplification.
77-78: Updated method name from singular to plural.Changed from
CreateExampleFeaturetoCreateExampleFeatures, suggesting the method now creates multiple features instead of just one, which aligns with the subscription addon functionality that likely requires multiple features.
293-294: Consistent dependency reference updates.Updated service references to use the direct
depsstructure consistently throughout the file, maintaining code clarity and following the established pattern.openmeter/ent/db/subscriptionitem/where.go (2)
1278-1287: Added query predicate for subscription addon rate card items.The
HasSubscriptionAddonRateCardItemsfunction properly implements a predicate that checks for the presence of "subscription_addon_rate_card_items" edges, following the established pattern for edge predicates in the codebase.
1289-1299: Enhanced filtering capabilities for addon relationships.The
HasSubscriptionAddonRateCardItemsWithfunction extends filtering capabilities by allowing additional predicates to be applied to the associatedSubscriptionAddonRateCardItemLinkentities, enabling more complex queries.openmeter/ent/db/subscriptionitem.go (4)
81-82: Added new edge for subscription addon rate card items.The addition of the
SubscriptionAddonRateCardItemsfield to theSubscriptionItemEdgesstruct properly establishes a relationship between subscription items and their associated addon rate card item links.
85-85: Correctly updated loadedTypes array size.The increase of the
loadedTypesarray size from 3 to 4 aligns with the addition of the new edge, ensuring proper eager-loading tracking.
119-126: Well-implemented error handling for the new edge.The
SubscriptionAddonRateCardItemsOrErrmethod follows the established pattern for edge error handling, checking if the edge was loaded before returning the value or an appropriate error message.
335-338: Added query method for the new relationship.The
QuerySubscriptionAddonRateCardItemsmethod enables proper traversal of the new relationship, allowing clients to query subscription addon rate card item links associated with a subscription item.openmeter/ent/db/subscriptionitem_create.go (4)
17-17: Updated imports to include subscriptionaddonratecarditemlink package.The import statement has been properly added to support the new subscription addon functionality.
285-289: New method for adding subscription addon rate card item IDs.This method allows associating multiple subscription addon rate card items with a subscription item by their IDs.
291-298: New method for adding subscription addon rate card item entities.This helper method extracts IDs from entity references and delegates to the ID-based method, following the established pattern in the codebase.
591-606: Updated createSpec to handle subscription addon rate card items.The createSpec method has been properly extended to create the edge specification for subscription addon rate card items when IDs are provided. This implementation correctly:
- Checks if there are any subscription addon rate card item IDs
- Creates the edge specification with appropriate relationship type and column information
- Appends the edge to the specification's edges list
This follows the established pattern for handling edge relationships in the Ent framework.
openmeter/ent/db/addon_create.go (4)
17-17: Updated imports to include subscriptionaddon package.The import statement has been properly added to support the new subscription addon functionality.
206-210: New method for adding subscription addon IDs.This method enables associating multiple subscription addons with an addon by their IDs.
212-219: New method for adding subscription addon entities.This helper method follows the established pattern of extracting IDs from entity references and delegating to the ID-based method.
444-459: Updated createSpec to handle subscription addons.The createSpec method has been properly extended to create the edge specification for subscription addons when IDs are provided. This implementation correctly:
- Checks if there are any subscription addon IDs
- Creates the edge specification with appropriate relationship type and column information
- Appends the edge to the specification's edges list
This follows the established pattern for handling edge relationships in the Ent framework.
openmeter/ent/db/addonratecard/where.go (2)
765-773: Added null check predicates for the discounts field.These two utility methods provide predicates for checking if the discounts field is null or not null, following the pattern used for other nullable fields in the codebase.
961-982: Added relational predicates for subscription addon rate cards.These two methods enable querying for addon rate cards that have associated subscription addon rate cards, with or without additional filtering predicates. The implementation correctly:
- Sets up the relationship edge with proper table and column information
- Creates appropriate query building functionality
This follows the established pattern for relationship predicates in the Ent framework.
openmeter/ent/db/addon_query.go (8)
19-19: Updated imports to include subscriptionaddon package.The import statement has been properly added to support the new subscription addon functionality.
25-31: Updated AddonQuery struct with subscription addons field.The AddonQuery struct has been extended to include a field for eager loading subscription addons, following the pattern used for other relationship edges.
90-110: Added method to query subscription addons.This method enables traversing from an addon to its associated subscription addons. It correctly:
- Creates a subscription addon query
- Sets up a path function that configures the SQL join operation
- Uses the proper edge relationship information
This follows the established pattern for edge traversal in the Ent framework.
298-306: Updated Clone method to include subscription addons.The Clone method has been properly updated to include cloning of the subscription addons field, ensuring that all query state is preserved during cloning operations.
323-332: Added method for eager loading subscription addons.This method configures the query builder to eager-load subscription addons when executing the query, with optional configuration of the sub-query. It follows the established pattern for eager loading in the Ent framework.
412-414: Updated loadedTypes array to include subscription addons.The loadedTypes array has been properly updated to track whether subscription addons have been loaded, ensuring correct edge loading behavior.
445-453: Added conditional loading of subscription addons.This code segment properly checks if subscription addons should be loaded and calls the loading function if needed.
487-516: Added method to load subscription addons.This helper method implements the loading of subscription addons for a list of addon nodes. It correctly:
- Collects foreign keys from parent nodes
- Maps nodes by ID for efficient lookup
- Initializes edge slices
- Builds a query to fetch related subscription addons
- Associates fetched subscription addons with their parent nodes
This follows the established pattern for relationship loading in the Ent framework.
openmeter/subscription/addon/service/list_test.go (4)
1-17: The imports are well organized.The import structure follows good practices by grouping standard library packages first, followed by third-party libraries, and then internal packages.
64-79: Good validation testing pattern for invalid input.This test correctly validates that the service properly handles and returns validation errors for invalid inputs.
80-168: Comprehensive test for listing addons with multiple scenarios.The test thoroughly verifies the listing functionality by:
- Creating two different addons
- Verifying both are returned when listing
- Testing that the returned data structure contains the expected values
The test setup is detailed but clear, with good use of helper functions and assertions.
170-190: Good pagination testing pattern.The test properly verifies pagination functionality by:
- Setting page size to 1 and checking first page returns first addon
- Requesting second page and verifying second addon is returned
- Confirming total count remains consistent
This ensures the pagination works correctly without relying on implementation details.
openmeter/ent/db/subscription_create.go (3)
19-19: Appropriate import for the subscriptionaddon package.The import for the subscriptionaddon package is properly added to support the new addon functionality.
228-241: New methods follow consistent pattern for edge management.The added methods
AddAddonIDsandAddAddonsfollow the same pattern as other relationship management methods in the file (likeAddPhaseIDsandAddPhases), maintaining code consistency.
495-510: Edge specification follows consistent pattern.The added code for handling addon edges in
createSpecfollows the same pattern as the existing edge handling code for phases and billing lines, ensuring consistency in the generated code.openmeter/subscription/service/sync_test.go (3)
24-24: Good dependency structure update.Updating the
ServiceDepsfield type to use the consolidatedSubscriptionDependenciesstruct improves code organization and reduces scattered dependency management.
351-352: Simplified service initialization.The change simplifies service initialization by directly using the returned
SubscriptionDependenciesstructure, making the code more readable and maintainable.
357-357: Updated method name aligns with multi-feature support.Changing from
CreateExampleFeaturetoCreateExampleFeaturesaccurately reflects that the method now creates multiple features, improving code clarity.openmeter/subscription/addon/service/change_test.go (5)
1-19: Well-organized imports and package structure.The file follows good practices for import organization and package naming, maintaining consistency with the other test files.
20-41: Good negative test case for invalid input.This test properly verifies that negative quantity values are rejected with appropriate validation errors, ensuring data integrity.
43-66: Important constraint validation for single-instance addons.The test correctly verifies that single-instance addons cannot have quantities greater than one, preserving business rules.
68-92: Thorough positive test case verification.The test properly verifies the successful update of a quantity, checking both the timestamp and the quantity value of the newly added quantity entry.
94-131: Well-structured helper function for test setup.The
createExampleSubscriptionAddonhelper function encapsulates common setup logic, making tests more readable and maintainable.openmeter/ent/db/subscription/subscription.go (4)
51-52: New addon support looks goodThe addition of the EdgeAddons constant properly defines the edge name for subscription addons, maintaining consistency with the code structure pattern used throughout the codebase.
83-89: Schema relationship properly definedThe new constants for AddonsTable, AddonsInverseTable, and AddonsColumn correctly establish the relationship between subscriptions and subscription_addons, with appropriate references to avoid circular dependencies.
253-265: Query functionality for addons properly implementedThe ordering functions for subscriptions by addons follow the established pattern, providing both count-based ordering and term-based ordering options.
294-300: Step creation function follows consistent patternThe implementation of newAddonsStep() follows the same pattern as other edge step functions, correctly defining the relationship direction and cardinality between subscriptions and addons.
openmeter/ent/db/subscription_query.go (6)
36-37: Subscription query structure enhanced for addonsThe SubscriptionQuery struct is properly augmented with the withAddons field to support eager loading of subscription addons, consistent with how other edges are handled.
162-182: QueryAddons implementation follows established patternsThe QueryAddons method correctly chains queries on the "addons" edge, using the same pattern as other edge query methods in the codebase. This ensures consistent behavior when traversing from subscriptions to their associated addons.
431-440: WithAddons eager-loading implementation looks goodThe WithAddons method for eager-loading addon nodes follows the established pattern for query configuration, providing the ability to customize the subscription addon query with optional parameters.
520-526: Loadable types array properly updatedThe loadedTypes array is correctly updated from 4 to 5 elements to accommodate the new addon edge, ensuring that edge loading state is properly tracked.
575-581: Eager loading implementation for addonsThe modification to sqlAll to handle eager loading of addons follows the same pattern as other edges, ensuring consistency in how related entities are loaded.
710-739: loadAddons implementation is thorough and follows patternsThe loadAddons method correctly implements the loading of addon entities, with proper foreign key mapping and error handling. The implementation follows the same patterns as other entity loading methods in this file.
openmeter/subscription/addon/service/create_test.go (6)
29-64: Input validation test is comprehensiveThe test thoroughly validates that the service rejects invalid inputs, specifically checking that quantity cannot be zero. Good use of the Validate method to verify that the service returns the expected validation error.
180-221: Skipped test with detailed implementationThis test is skipped with a good explanation why (conflict error will precede it), but the implementation is still fully detailed. This is helpful for future debugging or when the underlying issue is resolved.
353-359: Placeholder tests for future implementationGood practice to include placeholder tests for functionality that will be implemented in the future (Addon-Plan linking). This ensures that requirements are documented as TODOs in the test suite.
361-415: Comprehensive test for successful addon creationThis test thoroughly verifies both the creation and subsequent retrieval of a subscription addon, ensuring that all aspects of the addon are correctly persisted and retrievable. Good verification of both the initial creation and subsequent retrieval operations.
417-437: Well-structured test helper functionThe createExampleSubscription helper function encapsulates the common logic for setting up a test subscription, making the test cases more readable and maintainable.
439-447: Clean dependency management and test setupThe withDeps function provides a clean way to manage test dependencies and ensures proper cleanup after each test, following best practices for test setup and teardown.
tools/migrate/migrations/20250408104406_subscriptionaddon.up.sql (5)
1-14: Well-structured subscription_addons table definitionThe subscription_addons table is well defined with appropriate columns, primary key, and foreign key constraints. The CASCADE delete behavior ensures referential integrity when parent records are removed.
19-31: subscription_addon_quantities table with appropriate defaultGood design choice to set a default value of 1 for the quantity field, which aligns with the common use case where a single instance of an addon is added. The CASCADE delete behavior maintains referential integrity.
38-51: Well-defined subscription_addon_rate_cards tableThe subscription_addon_rate_cards table properly establishes relationships with both addon_rate_cards and subscription_addons with appropriate foreign key constraints and CASCADE delete behavior.
60-71: Inconsistent deletion behavior in foreign key constraintWhile most foreign key constraints in this migration use ON DELETE CASCADE, the constraint for subscription_addon_rate_card_id uses ON DELETE NO ACTION. This inconsistency might lead to orphaned records if the parent record is deleted.
Consider whether this is intentional or if it should be changed to CASCADE to maintain consistency with other constraints:
- CONSTRAINT "subscription_addon_rate_card_item_links_subscription_addon_rate" FOREIGN KEY ("subscription_addon_rate_card_id") REFERENCES "subscription_addon_rate_cards" ("id") ON UPDATE NO ACTION ON DELETE NO ACTION, + CONSTRAINT "subscription_addon_rate_card_item_links_subscription_addon_rate" FOREIGN KEY ("subscription_addon_rate_card_id") REFERENCES "subscription_addon_rate_cards" ("id") ON UPDATE NO ACTION ON DELETE CASCADE,
72-79: Comprehensive indexes for efficient queryingThe indexes created for subscription_addon_rate_card_item_links are comprehensive, covering both individual foreign key columns and their combination with a conditional constraint. This will ensure efficient querying across different access patterns.
openmeter/ent/db/subscription_update.go (5)
18-18: New import for subscription addons.The import of
subscriptionaddonis consistent with the new edge logic. No issues noted.
196-210: Edge methods for adding addons.These methods match the existing pattern for edges (e.g.,
AddPhaseIDs,AddBillingLineIDs) and look correct. Make sure consumer code handles potential duplicate IDs if needed.
264-284: Edge methods for removing addons.Likewise, these removal methods follow the established pattern for clearing and removing edges. No immediate issues found.
498-542: Handling the subscription→addons O2M edge in sqlSave.This block clears, removes, and adds
SubscriptionAddonentities. The one-to-many relationship looks consistent if eachSubscriptionAddonbelongs to exactly one subscription. Please confirm that your conceptual model truly requires O2M (and not M2M).
1056-1100: Edge handling for SubscriptionUpdateOne.Same logic for single-entity updates, clearing and adding the O2M edge to
SubscriptionAddon. Confirm the cardinality is correctly one subscription to many addons, as the code indicates.openmeter/subscription/addon/repository.go (2)
1-9: Package and imports.All standard. The package name
subscriptionaddonis scoped appropriately for these repository interfaces. No issues with imports.
22-26:ListSubscriptionAddonRepositoryInputstructure.This input bundles a
SubscriptionIDwith a pagination page. Looks fine overall. Confirm whether you need to handle edge cases like an emptySubscriptionID.openmeter/ent/db/subscriptionitem_query.go (6)
19-19: No issues noted for this import.
27-35: Looks consistent with Ent’s query struct fields.
138-158: Query method for SubscriptionAddonRateCardItems appears correct.
348-355: Clone method changes align with new fields and look fine.
484-484: Eager loading logic is consistent with Ent patterns.Also applies to: 488-543
642-671: Helper method for loading SubscriptionAddonRateCardItems is well-structured.openmeter/ent/db/subscriptionaddon_delete.go (1)
1-89: New delete builder for SubscriptionAddon is standard and correct.openmeter/ent/db/addonratecard_query.go (9)
7-7: No particular issues with this import usage.
20-20: Import for subscriptionaddonratecard is suitably placed.
26-33: Query struct fields for SubscriptionAddonRateCards are added properly.
114-134: QuerySubscriptionAddonRateCards method follows Ent conventions.
323-330: Clone handles new edge data without issues.
359-368: WithSubscriptionAddonRateCards method is consistent with Ent’s eager-loading approach.
448-451: Loaded types array updated appropriately for new edge.
487-495: Addition of SubscriptionAddonRateCards loading block is correct.
560-589: Helper function for loading SubscriptionAddonRateCards is well-implemented.openmeter/ent/db/addon_update.go (7)
17-17: New import for SubscriptionAddon.No issues found with this additional import. It aligns with the new functionalities introduced for managing subscription add-ons.
208-221: AddSubscriptionAddon methods forAddonUpdate.These methods cleanly follow the Ent pattern for adding edges by IDs or entity references. The implementation appears consistent and correct, with no obvious logical issues or missing checks.
249-268: Clear and Remove methods forsubscription_addons.These methods effectively handle clearing and selectively removing subscription add-on edges. The naming is consistent with Ent conventions, and the edge-removal logic is straightforward.
433-477: Subscription add-on edge handling insqlSaveforAddonUpdate.The edge specification logic for clearing and adding subscription add-ons is standard and aligns with Ent's O2M edge management. No concerns regarding constraint handling or partial updates.
672-686: AddSubscriptionAddon methods forAddonUpdateOne.Similar to the
AddonUpdatestruct, these methods properly add subscription add-on edges by IDs or references. Implementation is consistent with Ent’s idiomatic approach.
713-732: Clear and Remove methods forsubscription_addonsinAddonUpdateOne.These methods mirror the logic found in
AddonUpdate. The clarity of naming and predictability of behavior facilitate maintainability.
927-971: Subscription add-on edge handling insqlSaveforAddonUpdateOne.Correctly follows the same pattern as
AddonUpdatefor clearing, removing, and adding edges. The usage ofsqlgraph.EdgeSpecensures reliable edge manipulation.openmeter/subscription/testutils/service.go (9)
16-17: New imports for addon adapter and service.Adding these imports is appropriate for referencing and setting up add-on-specific repositories and services. No issues noted.
25-27: New imports for subscription add-on logic.These references bring in the subscription add-on repository and service layers. Everything looks fine.
38-51: ExtendedSubscriptionDependenciesstruct.The struct now includes fields for
SubscriptionAddonServiceandAddonServiceas part of testing dependencies. The naming is consistent with other fields, aiding clarity.
54-54: Function signature updated to returnSubscriptionDependencies.Centralizing returned dependencies into a single struct improves maintainability. This is a clean interface change.
136-141: InitializingaddonRepo.Creating a new adapter for product catalog add-ons appears consistent with the rest of the code, following established patterns for repository initialization.
142-149: InitializingaddonService.Instantiating the addon service with logger, publisher, feature references, and adapter is well-patterned. Checks for error handling are handled properly.
150-153: New subscription add-on repositories.These lines initialize three separate repositories to manage subscription add-ons, rate cards, and quantities. This separation of concerns is clear and logical.
154-163: CreatingsubAddSvc.Configuring the subscription add-on service with the necessary repositories and references (e.g.,
SubService,AddonService) is coherent and consistent.
164-178: Return updatedSubscriptionDependencieswith new add-on fields.Returning the new subscription add-on services ensures tests have easy access to all relevant operations for add-ons. This final assembly is cohesive.
openmeter/ent/db/subscriptionaddonquantity_delete.go (10)
1-14: Package initialization and imports forSubscriptionAddonQuantityDelete.Introducing a dedicated file for deleting
SubscriptionAddonQuantityentities is a logical extension of the Ent pattern. Imports look correct for predicate handling and SQL operations.
15-21: Struct definition forSubscriptionAddonQuantityDelete.Establishes a general-purpose builder for batch deletions, adhering to Ent’s generator style. Clear references to
SubscriptionAddonQuantityMutationare in line with Ent's mutation architecture.
22-26:Wheremethod for building predicates.This method robustly collects any number of predicates for conditional deletion. Matches standard Ent approach.
28-32:Execmethod for batch deletion.Executes the delete mutation with hooks. Straightforward usage of
withHooksis consistent with other Ent code.
33-40:ExecXpanic wrapper.A conventional Ent pattern for panic on error. No issues identified.
42-57:sqlExecinternally executing the deletion.Builds a delete spec with
sqlgraph.NewDeleteSpec. Properly wraps constraint errors and marks the mutation as done. Looks correct.
59-62: Struct definition forSubscriptionAddonQuantityDeleteOne.Specialized for single-entity deletion. Clear naming and separation from batch deletion is beneficial for usage.
64-68:Wheremethod for single-entity deletion.Allows extra predicates for the single-deletion scenario. Implementation is consistent with the broader approach.
70-81:Execmethod for single-entity deletion.Includes standard error handling to identify “not found” cases vs. other errors. Well-handled outcomes.
83-88:ExecXpanic wrapper for single deletion.Mirrors the typical Ent approach of providing a panic version of the
Execmethod. Implementation is simple and correct.openmeter/subscription/addon/service/service.go (1)
72-79: Ensure single-instance addons can’t be created concurrently.
When creating single-instance addons, check if an existing addon of the same type and subscription already exists. Otherwise, you could experience race conditions if multiple requests attempt to create the same single-instance addon in parallel.Would you like a script that searches for concurrency checks within repository logic to ensure this is enforced?
openmeter/ent/db/subscriptionaddonratecard_delete.go (1)
1-89: Auto-generated deletion logic looks good.
This is standard Ent-generated code for delete operations, including constraint handling, which appears correct and consistent.openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (1)
1-89: Auto-generated deletion logic looks good.
This file follows the same Ent conventions, providing flexible predicate-based deletion and handling errors appropriately. No changes needed.openmeter/subscription/addon/repo/subscriptionaddon.go (4)
23-27: Constructor looks straightforward.
TheNewSubscriptionAddonRepofunction is concise and follows a clear DI approach by returning a concrete repo tied to the provided DB client.
29-51: Verify any uniqueness constraints or conflicts.
When creating a new subscription addon, consider whether the combination ofnamespace + addonID + subscriptionIDmight result in conflicts. If conflicts can occur, you may want to handle duplicate key errors by returning a more descriptive message or code.
53-79: Error handling looks good.
UsingGenericNotFoundErrorhelps maintain consistent errors across the codebase. The logic for retrieving and mapping the subscription addon is clear.
117-130: Eager-loading strategy appears appropriate.
The helper functionquerySubscriptionAddonpulls in related entities and orders them as specified. This approach ensures that the returned objects have the necessary linked data without requiring multiple queries.openmeter/ent/db/subscriptionitem_update.go (6)
330-344: Edge addition methods align with Ent patterns.
BothAddSubscriptionAddonRateCardItemIDsandAddSubscriptionAddonRateCardItemsappear consistent with Ent best practices for adding edges.
377-396: Edge removal methods are clear.
The removal methods (ClearSubscriptionAddonRateCardItems,RemoveSubscriptionAddonRateCardItemIDs, etc.) clearly convey intent and follow the Ent style for edge maintenance.
651-695: Ensure referential integrity of rate card items.
InsqlSave, the logic to clear and add edges forsubscription_addon_rate_card_itemsis correct. Ensure that external code enforces valid references to subscription addon rate card items before saving to avoid orphaned records or invalid references.
1010-1024: Parallel approach for single-entity updates.
These methods mirror the multi-entity update approach, but target a singleSubscriptionIteminstance. It favors consistency betweenUpdateandUpdateOne.
1057-1076: Edge clearing and removal handlers.
These helper methods logically encapsulate edge modifications. They help reduce boilerplate for the consumer.
1361-1405: Validate item existence before edge binding.
Similar to the update builder,sqlSavein theUpdateOneflow handles adding and clearing edges. If there's any concern about invalid references, ensure thorough checks or constraints upstream.openmeter/ent/db/subscriptionaddonquantity.go (10)
16-39: New entity definition is clear.
TheSubscriptionAddonQuantitystruct layout and field names are self-explanatory. This fosters good code readability.
41-59: Edge error handling is conventional.
Providing aSubscriptionAddonOrErrmethod is helpful for distinguishing cases when the edge has been eagerly loaded but is absent vs. not loaded at all.
61-77: Good use of dynamic scanning.
ThescanValuesfunction systematically assigns the correct type for each column. This reduces the risk of scan-time type mismatches.
79-141: Type-checking logic is robust.
TheassignValuesmethod carefully checks each column’s scanned type and sets the corresponding struct fields, including time.Time pointers forDeletedAt. This is a good practice to avoid null-handling issues.
143-147: Dynamic value retrieval is well-structured.
ExposingValue(name string)for custom query selections is consistent with Ent’s extensibility approach and can be quite powerful for expansions down the line.
149-152: Convenient query builder for related entity.
QuerySubscriptionAddonensures an idiomatic way to query the linked subscription addon. This minimization of direct foreign key usage encourages safer, type-driven logic.
154-159: Fluent update approach.
ReturningSubscriptionAddonQuantityUpdateOneafter calling.Update()follows Ent’s fluent pattern, making the API user-friendly.
161-170: Unwrap logic is correct.
Unwrapping the transactional driver ensures subsequent queries remain valid after the transaction has closed. This is essential in Ent for avoiding misuse of transaction-bound entities.
172-201: Provides a descriptive string representation.
TheString()method enumerates all key fields for debugging or logging, which is typically quite helpful for diagnosing data issues.
203-205: Exported slice type is consistent with Ent patterns.
SubscriptionAddonQuantitiestype aliasing helps maintain consistent naming and usage for sets ofSubscriptionAddonQuantity.openmeter/ent/db/subscriptionaddonratecard.go (3)
18-42: Consider validating or limiting size forMetadata.
TheMetadatafield is defined asmap[string]string, which can potentially grow large if user-provided data is stored here. This may affect performance or lead to excessive payload sizes. Consider adding validation or size constraints, if necessary.Would you like to search the codebase (or relevant documentation) for any existing input validations on this field to confirm it won’t lead to large unbounded input?
55-85: Edge-loading logic looks standard and consistent.
These methods (SubscriptionAddonOrErr,ItemsOrErr,AddonRatecardOrErr) properly return errors if the edges are not loaded or not found, aligning well with ent’s best practices.
105-169: Type-checking inassignValuesis handled correctly.
The switch statement inassignValuesthoroughly checks the expected types for each field, ensuring the correct assignment. The error messages provide helpful context if unexpected types appear.openmeter/ent/db/migrate/schema.go (2)
1869-1911: Check for potential unique constraint on (addon_id,subscription_id).
Currently, thesubscription_addonstable defines an index only on the primary key, namespace, and ID. If the intended domain rule is “one type of addon can only appear once per subscription,” you might consider a unique composite index to prevent duplicates.Would you like to verify the functional requirements and see if a unique constraint is needed?
1954-2060: New rate card schemas appear consistent with existing patterns.
Thesubscription_addon_rate_cardsandsubscription_addon_rate_card_item_linkstables align well with the rest of the schema, using typical foreign keys and indexing conventions. No immediate concerns here.openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
62-72: Columns array correctly enumerates field constants.
Defining all columns in one place is a common and effective pattern for Ent. This setup helps maintain consistency when comparing field names against valid columns.
101-158: Ordering logic is clear and follows Ent conventions.
The ordering options (e.g.,ByID,ByNamespace, etc.) are straightforward. Usingsqlgraph.OrderByNeighborTermsfor related fields is a standard technique to handle ordering via edges.
139-165: Name alignment in neighbor-based ordering.
The method names likeBySubscriptionAddonFieldandByAddonRatecardFieldare consistent with Ent’s neighbor ordering approach. This is a good design to keep cross-table ordering flexible.openmeter/ent/db/addonratecard_update.go (17)
18-18: New import forsubscriptionaddonratecard:
This import seamlessly integrates the newly referencedsubscriptionaddonratecardpackage for handling edge relationships.
184-188:SetDiscountsmethod for AddonRateCardUpdate:
Adds a convenient way to set thediscountsfield. No issues spotted. Consider adding unit tests covering discount logic to ensure correct storage and retrieval.
190-194:ClearDiscountsmethod for AddonRateCardUpdate:
Provides a straightforward way to clear thediscountsfield. Looks fine; just ensure calling code properly handles cleared discounts.
254-258:AddSubscriptionAddonRateCardIDsmethod (AddonRateCardUpdate):
Correctly adds IDs to link multipleSubscriptionAddonRateCardentities. Matches typical ent patterns; no concerns.
260-267:AddSubscriptionAddonRateCardsmethod (AddonRateCardUpdate):
Neatly wraps adding edges using entity references. This is consistent with ent’s approach.
286-290:ClearSubscriptionAddonRateCardsmethod (AddonRateCardUpdate):
Clears all associatedSubscriptionAddonRateCardedges. Be certain this is desired when clearing all references since it may remove critical relationships.
292-296:RemoveSubscriptionAddonRateCardIDsmethod (AddonRateCardUpdate):
Removes edges individually by IDs. Implementation follows the standard O2M ent approach.
298-305:RemoveSubscriptionAddonRateCardsmethod (AddonRateCardUpdate):
Convenient method for removing edges by entity references. No issues noted.
517-529: Clearing subscription_addon_rate_cards insqlSave(AddonRateCardUpdate):
Properly clears the edges in the SQL update spec. Implementation appears standard for an O2M relationship.
531-545: RemovingSubscriptionAddonRateCardsby ID insqlSave(AddonRateCardUpdate):
Conditionally removes edges only if they are not globally cleared. Looks correct and aligns with ent logic.
547-561: AddingSubscriptionAddonRateCardsinsqlSave(AddonRateCardUpdate):
Properly appends IDs to the Edges.Add specification. Implementation is consistent with ent's edge handling.
730-734:SetDiscountsmethod for AddonRateCardUpdateOne:
Mirrors the bulk-update version and sets thediscountsfield for a single entity update. Implementation is correct.
736-740:ClearDiscountsmethod for AddonRateCardUpdateOne:
Appropriately clears thediscountsfield at the single entity level. No issues noted.
800-804:AddSubscriptionAddonRateCardIDsmethod (AddonRateCardUpdateOne):
Adds edge references by ID to a single entity. Matches ent conventions and looks good.
806-813:AddSubscriptionAddonRateCardsmethod (AddonRateCardUpdateOne):
Adds multiple edge references using the entity objects. Straightforward and consistent.
832-836:ClearSubscriptionAddonRateCardsmethod (AddonRateCardUpdateOne):
Clears allSubscriptionAddonRateCardedges in a single-entity update. No issues.
838-845:RemoveSubscriptionAddonRateCardsmethod (AddonRateCardUpdateOne):
Removes the specified edges referencing the given entities. Standard ent pattern.openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (4)
1-55: Initial definitions and builder setup:
This file introduces the newSubscriptionAddonRateCardItemLinkUpdatebuilder, including imports, type definition, and basic field-set methods (SetUpdatedAt,SetDeletedAt, etc.). The code is auto-generated with standard ent patterns and no apparent flaws.
57-88: Mutation accessor and core update methods (Save,SaveX,Exec,ExecX):
Implements standard ent builder patterns for saving updates. The defaults assignment forupdated_atensures consistent timestamps. The logic is sound.
90-140:checkmethod andsqlSaveforSubscriptionAddonRateCardItemLinkUpdate:
Includes validation to prevent clearing required edges incorrectly. SQL specification updates are well structured. Error handling appears correct, returningNotFoundErrororConstraintErroras needed.
142-293:SubscriptionAddonRateCardItemLinkUpdateOneentity-specific builder:
Mirrors the multi-entity builder but scoped to a single ID. Methods (SetDeletedAt,ClearDeletedAt, etc.) follow ent conventions. Thechecklogic andsqlSavemaintain consistent validations and edge handling. Everything looks reliable.openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (4)
1-29: Package constants and field definitions forsubscriptionaddonquantity:
Defines schema-related labels, table, and field names. The structure is conventional for ent-based entities.
31-64:Columnsarray andValidColumnfunction:
Accurately enumerates the columns.ValidColumnimplementation is the typical linear check. No issues found.
66-85: Field validators and default value hooks:
Introduces potential validators fornamespace,quantity,subscription_addon_id, and default-time value functions. All are standard for ent.
87-143: Ordering options (OrderOption), variousBy...methods, and the neighbor-step function:
Provides consistent ordering by fields.BySubscriptionAddonFielduses an ent neighbor step to order via a joined relationship. Implementation looks correct.openmeter/ent/db/setorclear.go (20)
212-217: Consistent set-or-clear approach for Discount field
No issues found; the implementation correctly checks for nil before clearing or setting the Discounts.
219-224: No issues with Discount setter in UpdateOne
Implementation matches the method name and usage pattern.
226-231: Clear or set FeatureID correctly
This logic properly handles the pointer check before clearing or setting the feature ID.
233-238: FeatureID UpdateOne method is consistent
No concerns; approach aligns with other set-or-clear methods here.
2326-2331: PlanRateCard set-or-clear Discount field
Implementation is straightforward and correct for toggling discounts.
2333-2338: PlanRateCard set-or-clear Discount field in UpdateOne
Checks are intact; no issues spotted.
2340-2345: PlanRateCard set-or-clear FeatureID
The guarding logic for nil vs. non-nil is properly handled.
2347-2352: PlanRateCard UpdateOne for FeatureID
Implementation is in line with ent set-or-clear conventions; no concerns.
2424-2429: SubscriptionAddon set-or-clear Metadata
Simple and effective approach to optional metadata handling.
2431-2436: SubscriptionAddon UpdateOne for Metadata
Implementation is correct; no changes necessary.
2438-2443: SubscriptionAddon set-or-clear DeletedAt
Logic properly clears or sets the timestamp.
2445-2450: SubscriptionAddon UpdateOne for DeletedAt
No issues; consistent with other set-or-clear patterns.
2452-2457: SubscriptionAddonQuantity set-or-clear DeletedAt
Implementation handles nil checks appropriately.
2459-2464: SubscriptionAddonQuantity UpdateOne for DeletedAt
Pointer-based set-or-clear usage matches the rest of the file.
2466-2471: SubscriptionAddonRateCard set-or-clear DeletedAt
Timestamp logic is clear; no concerns here.
2473-2478: SubscriptionAddonRateCard UpdateOne for DeletedAt
Implementation aligns well with ent’s recommended approach.
2480-2485: SubscriptionAddonRateCard set-or-clear Metadata
Straightforward approach for optional metadata fields.
2487-2492: SubscriptionAddonRateCard UpdateOne for Metadata
No logical or syntactic issues detected.
2494-2499: SubscriptionAddonRateCardItemLink set-or-clear DeletedAt
Clear or set usage is consistent and properly guarded.
2501-2506: SubscriptionAddonRateCardItemLink UpdateOne for DeletedAt
Implementation follows the same set-or-clear pattern; looks good.openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
1-217: New SubscriptionAddon entity definition
This file establishes theSubscriptionAddonmodel and its relationships, including constants, columns, and edge definitions. The approach is compliant with ent’s generated patterns (e.g., scanning SQL columns, edge queries, data assignment). No issues identified. Ensure comprehensive test coverage for query relationships and edge usage.openmeter/ent/db/subscriptionaddonquantity_update.go (1)
1-287: New SubscriptionAddonQuantity update logic
This file introduces update builders for theSubscriptionAddonQuantityentity, including default value handling forUpdatedAt, nil-friendly methods forDeletedAt, and error checking to ensure required edges aren’t improperly cleared. The implementation aligns with ent’s generated code style. No concerns noted.openmeter/ent/db/subscriptionaddonratecard_update.go (8)
1-18: File Header & Imports Look GoodNo issues found with the package declaration, imported libraries, and initial comments. The structure is consistent with Ent-generated code, and the references to other internal packages appear correct.
19-24: Appropriate Struct DefinitionThe
SubscriptionAddonRateCardUpdatestruct follows the expected pattern for an Ent update builder. The fields are well-named, and the design is straightforward for chaining update operations.
70-109: Edge Setters and Clearers Are CorrectMethods like
AddItemIDs,AddItems,ClearItems,RemoveItemIDs, andRemoveItemsproperly handle one-to-many edge relationships. These are standard auto-generated functions from Ent.
111-137: Save and Exec Methods Follow Standard Ent PatternsThe
Save,SaveX,Exec, andExecXmethods are typical Ent code. They provide convenient ways to execute the update or panic on failures.
139-145: Defaulting UpdatedAt on UpdatesAutomatically setting
updated_atif missing ensures the entity’s timestamp remains accurate without requiring the caller to supply it every time. This is a good best practice for auditing.
147-156: Validation of Required Unique EdgesThe
check()method correctly prevents clearing required unique edges if items are still being added. This upholds data integrity rules.
242-340: Single-Entity UpdateOne Builder Logic
SubscriptionAddonRateCardUpdateOnemaintains a parallel structure to the batch update, offering convenience methods for single-entity operations. The code remains consistent and intuitive.
342-491: Final Save Methods and Edge HandlingThe second half of
UpdateOnelogic, particularly thesqlSavemethod, closely mirrors the batch variant. Error handling, field clears, and edge operations are consistent.openmeter/ent/db/subscriptionaddonquantity_create.go (7)
1-26: Header, Package, and Struct InitializationThe file-level comments and basic struct definitions for creating
SubscriptionAddonQuantityalign with Ent’s generated pattern. Import statements are correct, and references to packages likesubscriptionaddonquantityappear accurate.
133-183: Save Logic & Required Field ValidationsThe
SaveandSaveXmethods, along with thecheck()function, enforce the presence of required fields (namespace,created_at, etc.). This is a solid design for ensuring data integrity.
185-224: Check Function’s Extended ValidationGood job including custom validators (
NamespaceValidator,QuantityValidator, andSubscriptionAddonIDValidator). This ensures domain constraints are applied consistently before persisting data.
226-247: SQL Save Implementation
sqlSaveconstructs the create specification and executes an insert for a singleSubscriptionAddonQuantity. It gracefully handles constraint errors with a customConstraintError. No issues identified.
249-301: CreateSpec for Default & Edge SetupsThe default ID, timestamps, and edge references are all set properly in
createSpec(). Large domain logic or constraints might require additional checks on the entire specification, but for standard usage this is fine.
303-324: Upsert ConfigurationAllowing conflict handling policies such as
sql.ResolveWithNewValues()or ignoring conflicts is helpful for scenarios with high concurrency. The patterns align with typical Ent functionality.
710-767: Upsert Bulk OperationsThe ability to apply the same upsert strategy to a bulk of
SubscriptionAddonQuantityitems is well-supported. This is especially useful for use cases with large-scale inserts and concurrency.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (10)
1-26: File Initialization and Struct DefinitionAs with the other Ent-generated files, the header, imports, and naming follow convention. No issues found here.
28-105: Setters for Fields and Edges
SetCreatedAt/UpdatedAt/DeletedAtand ID-based edge setters are consistent with Ent patterns. Like the other files, validations for IDs occur in a separate step, which is a clean approach.
111-137: Save Methods and Execution Wrappers
Save,SaveX,Exec, andExecXmirror the Ent style. Users have both a standard and a panic-based approach to error handling. This is consistent with the framework’s generation logic.
139-153: Defaulting Timestamps and IDAutomatically setting creation/updated timestamps and generating an ID if not provided is a standard pattern. It’s a beneficial convenience and ensures uniform data across the system.
155-186: Mandatory Fields & Edge ValidationThe check function ensures none of the required fields/edges are missing. The domain-specific validators are invoked as well. This is essential for data integrity.
188-209: SQL Save Execution
sqlSavesets up theCreateSpec, executes it, and gracefully handles constraint errors. This is standard and reliable for persisting the entity.
211-268: Edge Specification SetupLinking the new entity to
SubscriptionAddonRateCardandSubscriptionItemwithM2Orelationships is correct. The approach of referencing the first ID in the slices for these edges aligns with how Ent usually handles single references.
270-304: Conflict Handling for Single Create
OnConflictand the ability to upsert singleSubscriptionAddonRateCardItemLinkrecords are well-defined. The code cleanly updates fields or ignores them based on user preference.
306-477: UpsertOne MethodsThe upsert logic again includes straightforward resolution strategies for
updated_atanddeleted_at. It’s consistent with typical Ent code generation and helps with concurrency scenarios.
479-722: Bulk Create and UpsertThe bulk creation mechanism, including conflict resolution, is thoroughly implemented. Partial updates, ignoring conflicts, or do-nothing semantics give flexibility in large-scale insert scenarios.
openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (7)
21-34: Solid struct definition and usage.This struct neatly encapsulates the query context, order predicates, relationship queries, and more. The design is consistent with ent’s conventions, and no issues appear in these lines.
36-65: Well-structured query builder methods.The
Where,Limit,Offset,Unique, andOrdermethods follow typical ent codegen patterns, providing a straightforward API for filtering and ordering results. The code is clear, coherent, and free from obvious errors.
67-109: Efficient edge-chaining.
QuerySubscriptionAddonRateCardandQuerySubscriptionItemcorrectly set up adjacency queries viasqlgraphsteps. This approach maintains ent’s flexible structure for relationships, and appears robust and error-free.
111-172: Comprehensive result retrieval methods.Methods like
First,FirstX,Only, andOnlyXoffer convenient patterns for different result cardinalities, with thorough error handling for not found or non-singular cases. Implementation aligns well with ent’s best practices.
211-310: Bulk and aggregated retrieval.Blocks handling
All,AllX,IDs, andCloneplus eager-loading are consistently implemented and match ent’s style. No performance or correctness issues detected.
333-395: Grouping and field selection.
GroupByandSelectmethods, along with their associated aggregator logic, facilitate advanced queries. This design is standard for ent code, and we see no logical issues.
606-630: Concurrency control via locking.
ForUpdateandForShareintegration is leveraged correctly for table-level locking in supported dialects. The fallback for other dialects is also well-handled.openmeter/ent/db/subscriptionaddonquantity_query.go (11)
20-32: Adequate struct fields for query building.The
SubscriptionAddonQuantityQuerystruct encapsulates context, ordering, predicates, and edge queries. It aligns with the typical ent pattern for building queries.
34-63: Predicate and limit methods look good.
Where,Limit,Offset,Unique, andOrderare standard ent patterns, and the code is consistent, providing essential query-building capabilities.
65-85: Relationship chaining to SubscriptionAddon.
QuerySubscriptionAddonsets up an M2O relationship traversal properly. The usage ofprepareQueryandsqlgraph.NewStepis correct, ensuring robust edge resolution.
87-130: Single-row retrieval logic.Methods such as
First,FirstX,Only,OnlyX, and their ID-focused variants handle cardinality errors and not found cases as expected. No issues identified.
187-225: Retrieving multiple rows or IDs.
All,AllX,IDs, andIDsXmethods are consistent, enabling multiple-entity retrieval. The code is coherent, with no apparent functional gaps.
227-265: Counting and existence checks.
Count,Exist, and their panic-throwing counterparts demonstrate secure error handling and adopt the typical ent approach to query existence.
267-284: Cloning queries.Allowing users to clone a query ensures reusability without side effects. This approach is standard for ent and appears logically correct.
286-343: Eager-loading strategy.
WithSubscriptionAddonuses standard ent patterns for preloading related edges. This fosters improved performance and clarity in service-level retrieval.
371-407: Query execution flow.The
sqlAllfunction manages node retrieval, hooking into ent’s interceptor architecture. The approach is standard, and the fallback for empty nodes is well-handled.
407-437: Eager-loading relationships.
loadSubscriptionAddonis well-structured for foreign key relationships, verifying that fetched neighbors are assigned appropriately.
529-553: Locking mechanisms for concurrency.Similar to the previous file,
ForUpdateandForSharepatterns are standard for ent. Properly togglingUnique(false)for Postgres is correct.openmeter/ent/db/subscriptionaddon_update.go (12)
20-25: Update builder structure.
SubscriptionAddonUpdateneatly manages hooks, mutation logic, and config. This approach parallels ent’s standard builder structure.
27-43: Predicate addition & metadata field management.
Where,SetMetadata, andClearMetadatashow flexible ways to filter and modify the metadata JSON field. These changes uniformly follow ent’s patterns.
45-69: Timestamp fields handling.
SetUpdatedAt,SetDeletedAt, and their nil-clearing variants handle time-based fields properly, respecting optional usage. No logical issues are observed.
71-99: Edge management for rate cards & quantities.Adding or removing related edges by ID or by entity ensures flexibility. This is an expected approach in ent for managing one-to-many edges.
148-174: Finalizing updates and saving.
SaveandSaveXrun validations and apply defaults (likeupdated_at) before executing. Proper error handling for the database operation adds resilience.
176-182: Default mutation behavior.The
defaultsmethod settingupdated_atif not provided is a good approach, ensuring consistent timestamps. This pattern helps maintain data integrity.
195-221: SQL update specification handling.The builder sets fields, handles JSON clearance, and ensures the correct mutation of edges. The code is straightforward and aligns well with ent-based routines.
222-311: Edge-clearing and edge-adding operations.Blocks clearing or adding
rate_cardsandquantitiesprecisely manage the edges with correctEdgeSpecusage. This is standard ent practice with no red flags.
324-372: Single-entity update structure.
SubscriptionAddonUpdateOneparallels the multi-entity update logic but focuses on a single record. The structure remains consistent and approachable.
400-445: Clearing and removing edges for single-entity updates.Methods like
ClearRateCardsorRemoveQuantitiesreflect the same pattern as multi-entity but applied to a single entity context. Implementation is coherent.
460-494: Save and defaults for single-entity updates.
Save,SaveX, and thedefaultsmethod mirror the patterns seen in multi-entity updates, ensuring a consistent developer experience.
507-654: SQL save for single-entity context.The
sqlSavemethod builds anUpdateSpec, sets or clears columns, and manages edges. Error handling for not found or constraint issues is well-defined.openmeter/ent/db/subscriptionaddonquantity/where.go (1)
1-480: Well-structured, auto-generated code.
This file provides numerous predicate functions for queryingSubscriptionAddonQuantityentities and follows the Ent framework's generated patterns. No correctness or performance issues are apparent.openmeter/ent/db/subscriptionaddon_create.go (1)
1-880: Consistent with Ent conventions.
The create builder manages field and edge setting with standard Ent patterns, employing default values, validations, conflict resolution, and bulk operations. Everything looks consistent and robust, with no changes needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (2)
openmeter/ent/db/migrate/schema.go (1)
1912-1923: Duplicate reminder about adding validations or constraints toquantity.
This table setsquantityto an integer with a default of 1, but it does not prevent invalid values (e.g., zero, negative, or extremely large numbers). As previously noted, consider enforcing a positive, reasonablequantityrange through database constraints or application-layer validation to avoid data anomalies.openmeter/subscription/testutils/compare.go (1)
182-193: 🛠️ Refactor suggestionComplete the Addon comparison as noted in the TODO comment
The function follows the established pattern for equality assertion functions in this file. However, as the TODO comment indicates, it only checks the
IDfield of the Addon entity and not other fields like Key, Name, Currency, and InstanceType.Apply the following changes to enhance the comparison:
- assert.Equal(t, a1.Addon.ID, a2.Addon.ID) // TODO: check all fields? + // Compare essential Addon fields + assert.Equal(t, a1.Addon.ID, a2.Addon.ID) + assert.Equal(t, a1.Addon.Key, a2.Addon.Key) + assert.Equal(t, a1.Addon.Name, a2.Addon.Name) + assert.Equal(t, a1.Addon.Currency, a2.Addon.Currency) + assert.Equal(t, a1.Addon.InstanceType, a2.Addon.InstanceType)
🧹 Nitpick comments (37)
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
62-82: Potential improvement: unify column validation checks or add test coverage.
TheColumnsslice and theValidColumnfunction follow the existing pattern seen in related files. However, ensure this functionality is tested to verify each expected column is included, especially for newly added fields likeaddon_ratecard_id.Ensure the tests in the associated builder or schema code verify that a known valid column passes
ValidColumnand an invalid one fails.
101-166: OrderOption functions are consistent with Ent patterns.
The ordering functions (ByID,ByNamespace, etc.) match the conventional approach used in Ent code. The dynamic field-based ordering (BySubscriptionAddonField,ByAddonRatecardField) is flexible, but consider verifying field names if user input can influence the order field.Consider adding validation or enumerating allowable fields when using dynamic ordering to prevent accidental misuse or ordering by non-existent columns.
openmeter/subscription/addon/repo/transaction.go (1)
15-32: Consider adding documentation for transaction methods.The transaction handling logic for
subscriptionAddonRepois correctly implemented, following the repository's transactional pattern. However, I recommend adding godoc comments to describe what each method does, its parameters, and return values to improve code maintainability.// Transaction handling for subscriptionAddonRepo +// Tx starts a new transaction and returns a transaction context and driver. +// The returned context should be used in subsequent database operations within the transaction. func (r *subscriptionAddonRepo) Tx(ctx context.Context) (context.Context, transaction.Driver, error) { // implementation unchanged } +// Self returns the repository itself, useful for method chaining. func (r *subscriptionAddonRepo) Self() *subscriptionAddonRepo { return r } +// WithTx creates a new repository instance that operates within the given transaction. +// This allows for transaction propagation across repository operations. func (r *subscriptionAddonRepo) WithTx(ctx context.Context, tx *entutils.TxDriver) *subscriptionAddonRepo { // implementation unchanged }openmeter/subscription/testutils/feature.go (2)
43-45: Improve error messages for better debugging.Consider using more specific error messages to identify which feature creation failed.
- t.Fatalf("failed to create feature: %v", err) + t.Fatalf("failed to create feature 1 (%s): %v", ExampleFeatureKey, err)
47-49: Improve error messages for better debugging.Use a more descriptive error message that indicates which feature failed to create.
- t.Fatalf("failed to create feature: %v", err) + t.Fatalf("failed to create feature 2 (%s): %v", ExampleFeatureKey2, err)openmeter/ent/db/migrate/schema.go (2)
1869-1911: Consider a unique index forsubscription_id+addon_idif only one entry per subscription-addon pair is desired.
Currently, the table defines a primary key onidbut allows multiple records with the samesubscription_idandaddon_id. If you want to enforce that each subscription can only have one instance of a particular addon, add a unique composite index on those columns (e.g., usingdeleted_at IS NULLif you want to exclude deleted rows).
1966-2006: Review the need for uniqueness onsubscription_addon_id+addon_ratecard_id.
If your business logic requires only one rate card record per subscription addon pair, consider adding a unique index. Otherwise, allowing duplicates might lead to confusion in searching or billing calculations.openmeter/ent/db/paginate.go (1)
1596-1643: Pagination method for SubscriptionAddonQuery is consistent with the established pattern.Consider factoring out common pagination logic if duplication becomes unwieldy in the long term.
openmeter/subscription/addon/service.go (2)
11-17: Optional: Add interface documentation.Consider adding a doc comment describing the responsibilities and usage of each method for future maintainers.
25-33: Refine the error message for clarity.Currently, the error message states "filter has to be provided, all values are empty," but only
SubscriptionIDis checked. Consider making it more specific, e.g., "subscription ID is required."-if i.SubscriptionID == "" { - errs = append(errs, errors.New("filter has to be provided, all values are empty")) +if i.SubscriptionID == "" { + errs = append(errs, errors.New("subscriptionID must not be empty")) }openmeter/subscription/addon/service/create_test.go (2)
26-64: Clarify test naming convention."Should error if input is formally invalid" is descriptive, but consider explicitly stating which field is invalid for clarity.
353-359: Test is deferred.It’s marked TODO. After implementing Addon-Plan linking, consider completing or removing this stub.
Would you like help drafting this test once the linking logic is ready?
openmeter/subscription/addon/repository.go (3)
11-20: Consider adding struct-level documentation.
TheCreateSubscriptionAddonRepositoryInputstruct is clear in its fields, but adding a short doc comment clarifying its purpose (e.g., “Holds the input data required to create a subscription add-on”) can improve readability and maintainability.
28-32: Repository interface considerations.
This interface defines core methods (Create,Get,List). Ensure the rest of the codebase doesn’t needUpdateorDeletemethods. If not required, this is fine.
35-39: Clarity for rate card creation.
AffectedSubscriptionItemIDsis well named. Adding doc comments could help future developers understand the expected usage for these IDs.openmeter/ent/db/subscriptionaddonquantity_delete.go (1)
83-88: ExecX for one-entity deletion
Similar caution as with multi-entityExecX: ensure production code handles panics gracefully or uses the non-panickingExecvariant.openmeter/ent/db/subscriptionaddonratecard_delete.go (1)
83-88: ExecX usage
Same note aboutExecX: consider usingExecif panics need to be avoided in production.openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (1)
83-88: Ensure robust error handling
Finally, the single entityExecXmethod also panics on error. This is standard for generated code, but consider your production usage.openmeter/subscription/addon/repo/subscriptionaddon.go (5)
17-19: Consider explicit interface documentation for maintainability.
While thesubscriptionAddonRepostruct is straightforward, adding explicit docstrings to clarify how it implementsSubscriptionAddonRepositorywould help new contributors quickly understand its purpose and responsibilities.
29-51: Validate input parameters to guard against unexpected data.
TheCreatemethod directly setsAddonIDandSubscriptionID, but it doesn't check if these fields are blank or invalid. Performing basic validations (e.g., non-empty strings) before saving could enhance robustness and prevent partial or inconsistent data states.
53-79: Leverage typed "not found" errors for clarity.
The method currently wraps the default error inmodels.NewGenericNotFoundError. It might be helpful to create or reuse a more domain-specific "subscription addon not found" error type for quick identification and error handling.
81-115: Potential performance concern when retrieving all.
Whenfilter.Page.IsZero(), the method fetches all subscription addons in the namespace. This could become inefficient if the dataset grows large. Consider enforcing pagination or imposing a maximum limit to mitigate potential performance bottlenecks and memory overhead.Do you want help in implementing a default pagination or limit?
117-129: Ensure consistent sorting for related entities.
The helper function orders quantities byactive_fromandcreated_at, but rate cards lack defined ordering. If deterministic sorting is desired, adding an order step forWithRateCards()would ensure stable results and consistent behavior.openmeter/ent/db/subscriptionitem_update.go (2)
377-381: Consider domain validations before clearing or removing edges.
Clearing and removing edges works correctly, but if there is a business rule that subscription addon rate card items cannot be removed once billed, you might introduce validations to prevent accidental data modifications.Also applies to: 383-387, 389-396
1361-1405: Ensure cohort-based or partial updates remain consistent.
When selecting fields or partially updating an entity, confirm that omitted fields (e.g., partial updates) won't cause logical inconsistencies. The code appears correct, but partial updates can sometimes lead to confusion in domain logic, especially if uninitialized references remain.openmeter/ent/db/subscriptionaddonquantity.go (3)
16-19: Add usage notes for future developers.
These struct fields and edges are well defined. Adding docstrings to explain the purpose of this entity (e.g., describing the notion of addon quantities) can improve discoverability and ease of maintenance.Also applies to: 20-39
143-147: Document dynamic value retrieval.
TheValue(name string)method is useful for advanced queries or custom modifications. A short usage comment noting that it returns values for non-standard columns or aggregated fields may reduce confusion for new team members.
161-170: Confirm thread-safety when unwrapping transactions.
Ent automatically handles concurrency, but ensure that theUnwrap()usage occurs in a context that doesn't allow concurrent updates from multiple goroutines on the same entity.openmeter/ent/db/addonratecard_create.go (1)
163-167: Check for potentialnilusage of discounts.
SinceSetDiscountsaccepts a pointer, consider validating or safely handlingnilto avoid unexpected runtime errors.openmeter/ent/db/subscriptionaddonquantity_create.go (3)
33-45: Review of setter methods
All setter methods (SetCreatedAt,SetNillableCreatedAt,SetUpdatedAt,SetNillableUpdatedAt,SetDeletedAt, etc.) follow the Ent convention of updating the mutation. This is clean and consistent. One optional improvement could be to add doc comments clarifying behavior (e.g., clarifying that Nillable methods are safe to call even withnil).Also applies to: 47-59, 61-73, 75-87, 89-101, 103-107, 109-121, 123-127
303-377: Review ofOnConflictand Upsert structures
These upsert helpers provide a good set of conflict resolution strategies (e.g.,Ignore,DoNothing). The “update with new values” or “update with custom logic” approach is well-structured. Consider including companion tests to ensure the upsert logic handles real-world conflict scenarios gracefully.
518-603: Review of bulk creation methods
The chain of mutations andBatchCreateSpecusage is typical for bulk inserts. The arrangement that each builder’scheckanddefaultsrun prior to final insertion is beneficial for overall data consistency. Consider verifying performance for large batches or providing instrumentation if usage scales.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (2)
28-54: Review of created/updated/deleted timestamps setters
Methods likeSetCreatedAtandSetNillableDeletedAtare consistent with standard patterns. As an optional improvement, consider logging or capturing the reason for deletion in the business logic if soft deletions have domain significance.
211-303: Review ofcreateSpecand upsert configurations
Building the spec with edges tosubscription_addon_rate_cardandsubscription_itemis neatly done. The upsert methods provide flexible resolution strategies. Ensure thorough testing to confirm all conflict resolution paths function as expected.openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
291-309: Clone method
Cloning the query ensures that specialized configurations (predicates, eager-load options, etc.) can be reused. This is great for re-entrant query logic.
381-405:prepareQuery
Your checks for valid columns and applying path-based selectors are essential for correctness. The interceptor pattern is also well-integrated.
407-452:sqlAlland loading of edges
This approach clearly loads nodes with their associated edges. Consider adding error logging or telemetry if loading edges fails, to help debug references or constraint issues in production.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/migrate/migrations/atlas.sumis excluded by!**/*.sum
📒 Files selected for processing (102)
openmeter/ent/db/addon.go(3 hunks)openmeter/ent/db/addon/addon.go(3 hunks)openmeter/ent/db/addon/where.go(1 hunks)openmeter/ent/db/addon_create.go(3 hunks)openmeter/ent/db/addon_query.go(7 hunks)openmeter/ent/db/addon_update.go(7 hunks)openmeter/ent/db/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/where.go(2 hunks)openmeter/ent/db/addonratecard_create.go(7 hunks)openmeter/ent/db/addonratecard_query.go(8 hunks)openmeter/ent/db/addonratecard_update.go(9 hunks)openmeter/ent/db/client.go(15 hunks)openmeter/ent/db/ent.go(2 hunks)openmeter/ent/db/expose.go(1 hunks)openmeter/ent/db/hook/hook.go(1 hunks)openmeter/ent/db/migrate/schema.go(3 hunks)openmeter/ent/db/paginate.go(1 hunks)openmeter/ent/db/predicate/predicate.go(1 hunks)openmeter/ent/db/runtime.go(4 hunks)openmeter/ent/db/setorclear.go(3 hunks)openmeter/ent/db/subscription.go(3 hunks)openmeter/ent/db/subscription/subscription.go(4 hunks)openmeter/ent/db/subscription/where.go(1 hunks)openmeter/ent/db/subscription_create.go(3 hunks)openmeter/ent/db/subscription_query.go(8 hunks)openmeter/ent/db/subscription_update.go(7 hunks)openmeter/ent/db/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/where.go(1 hunks)openmeter/ent/db/subscriptionaddon_create.go(1 hunks)openmeter/ent/db/subscriptionaddon_delete.go(1 hunks)openmeter/ent/db/subscriptionaddon_query.go(1 hunks)openmeter/ent/db/subscriptionaddon_update.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/where.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_create.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_query.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go(1 hunks)openmeter/ent/db/subscriptionitem.go(3 hunks)openmeter/ent/db/subscriptionitem/subscriptionitem.go(4 hunks)openmeter/ent/db/subscriptionitem/where.go(1 hunks)openmeter/ent/db/subscriptionitem_create.go(3 hunks)openmeter/ent/db/subscriptionitem_query.go(7 hunks)openmeter/ent/db/subscriptionitem_update.go(7 hunks)openmeter/ent/db/tx.go(2 hunks)openmeter/ent/schema/addon.go(3 hunks)openmeter/ent/schema/productcatalog.go(1 hunks)openmeter/ent/schema/ratecard.go(1 hunks)openmeter/ent/schema/subscription.go(3 hunks)openmeter/ent/schema/subscription_addon.go(1 hunks)openmeter/productcatalog/addon/adapter/addon.go(4 hunks)openmeter/productcatalog/addon/adapter/mapping.go(3 hunks)openmeter/productcatalog/subscription/service/change_test.go(4 hunks)openmeter/productcatalog/subscription/service/migrate_test.go(4 hunks)openmeter/productcatalog/subscription/service/plan_test.go(3 hunks)openmeter/subscription/addon/README.md(1 hunks)openmeter/subscription/addon/addon.go(1 hunks)openmeter/subscription/addon/addonratecard.go(1 hunks)openmeter/subscription/addon/quantity.go(1 hunks)openmeter/subscription/addon/repo/mapping.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddon.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonquantity.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonratecard.go(1 hunks)openmeter/subscription/addon/repo/transaction.go(1 hunks)openmeter/subscription/addon/repository.go(1 hunks)openmeter/subscription/addon/service.go(1 hunks)openmeter/subscription/addon/service/change_test.go(1 hunks)openmeter/subscription/addon/service/create_test.go(1 hunks)openmeter/subscription/addon/service/list_test.go(1 hunks)openmeter/subscription/addon/service/service.go(1 hunks)openmeter/subscription/patch/removeitem_test.go(1 hunks)openmeter/subscription/service/service_test.go(8 hunks)openmeter/subscription/service/sync_test.go(2 hunks)openmeter/subscription/testutils/addon.go(1 hunks)openmeter/subscription/testutils/compare.go(2 hunks)openmeter/subscription/testutils/feature.go(3 hunks)openmeter/subscription/testutils/plan.go(2 hunks)openmeter/subscription/testutils/ratecard.go(4 hunks)openmeter/subscription/testutils/service.go(3 hunks)openmeter/subscription/workflow/service/subscription_test.go(16 hunks)pkg/framework/entutils/mapping.go(1 hunks)test/customer/testenv.go(2 hunks)test/subscription/framework_test.go(2 hunks)tools/migrate/migrations/20250408104406_subscriptionaddon.down.sql(1 hunks)tools/migrate/migrations/20250408104406_subscriptionaddon.up.sql(1 hunks)
✅ Files skipped from review due to trivial changes (3)
- openmeter/ent/db/subscriptionaddon_query.go
- openmeter/ent/db/subscriptionaddonratecard_create.go
- openmeter/ent/db/subscriptionaddonratecard/where.go
🚧 Files skipped from review as they are similar to previous changes (41)
- openmeter/subscription/testutils/plan.go
- test/customer/testenv.go
- openmeter/productcatalog/addon/adapter/addon.go
- openmeter/ent/db/predicate/predicate.go
- openmeter/subscription/addon/README.md
- openmeter/productcatalog/addon/adapter/mapping.go
- openmeter/subscription/addon/addonratecard.go
- openmeter/ent/db/expose.go
- openmeter/ent/db/subscription/where.go
- openmeter/ent/db/addon.go
- openmeter/ent/db/subscriptionitem.go
- openmeter/ent/db/subscription.go
- openmeter/ent/schema/subscription.go
- openmeter/subscription/patch/removeitem_test.go
- openmeter/subscription/addon/service/list_test.go
- openmeter/subscription/service/sync_test.go
- openmeter/subscription/addon/repo/subscriptionaddonratecard.go
- openmeter/ent/db/ent.go
- openmeter/ent/db/subscriptionitem/where.go
- openmeter/productcatalog/subscription/service/migrate_test.go
- openmeter/ent/db/subscription_create.go
- openmeter/subscription/addon/service/change_test.go
- test/subscription/framework_test.go
- openmeter/ent/schema/ratecard.go
- openmeter/ent/db/subscriptionaddon_delete.go
- pkg/framework/entutils/mapping.go
- tools/migrate/migrations/20250408104406_subscriptionaddon.up.sql
- openmeter/ent/db/subscriptionitem/subscriptionitem.go
- openmeter/ent/db/hook/hook.go
- openmeter/subscription/addon/repo/subscriptionaddonquantity.go
- openmeter/productcatalog/subscription/service/plan_test.go
- openmeter/productcatalog/subscription/service/change_test.go
- openmeter/ent/db/runtime.go
- openmeter/subscription/addon/quantity.go
- openmeter/ent/db/addonratecard.go
- openmeter/ent/db/addon_update.go
- openmeter/ent/db/subscriptionaddonratecarditemlink.go
- tools/migrate/migrations/20250408104406_subscriptionaddon.down.sql
- openmeter/ent/db/subscriptionaddon.go
- openmeter/subscription/addon/service/service.go
- openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go
🧰 Additional context used
🧬 Code Definitions (54)
openmeter/subscription/service/service_test.go (3)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)
openmeter/subscription/workflow/service/subscription_test.go (5)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)openmeter/subscription/testutils/plan.go (1)
GetExamplePlanInput(20-72)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/subscription/workflow/service.go (2)
CreateSubscriptionWorkflowInput(17-21)Service(10-15)
openmeter/ent/db/addon/where.go (2)
openmeter/ent/db/predicate/predicate.go (2)
Addon(10-10)SubscriptionAddon(219-219)openmeter/ent/db/addon/addon.go (3)
Table(53-53)SubscriptionAddonsTable(62-62)SubscriptionAddonsColumn(67-67)
openmeter/ent/db/addon_create.go (2)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonsTable(1881-1911)
openmeter/ent/db/subscriptionitem_create.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)FieldID(18-18)
openmeter/ent/db/addon_query.go (3)
openmeter/ent/db/predicate/predicate.go (2)
Addon(10-10)SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/subscription/addon/addon.go (8)
pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)pkg/timeutil/timeline.go (1)
Timeline(42-44)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/subscription/testutils/addon.go (7)
openmeter/productcatalog/ratecard.go (2)
FlatFeeRateCard(161-168)RateCardMeta(49-77)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey(13-13)openmeter/subscription/testutils/global.go (2)
ISOMonth(7-7)ExampleNamespace(5-5)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)openmeter/productcatalog/addon/service.go (2)
CreateAddonInput(98-101)PublishAddonInput(258-263)pkg/models/model.go (1)
NamespacedModel(155-157)openmeter/productcatalog/addon.go (1)
AddonMeta(37-63)
openmeter/subscription/testutils/compare.go (3)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)api/api.gen.go (3)
SubscriptionAddon(5402-5462)Addon(767-819)Metadata(4051-4051)api/client/go/client.gen.go (3)
SubscriptionAddon(5084-5144)Addon(700-752)Metadata(3778-3778)
openmeter/ent/db/tx.go (7)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/client.go (8)
SubscriptionAddonClient(6216-6218)SubscriptionAddonQuantityClient(6413-6415)SubscriptionAddonRateCardClient(6562-6564)SubscriptionAddonRateCardItemLinkClient(6743-6745)NewSubscriptionAddonClient(6221-6223)NewSubscriptionAddonQuantityClient(6418-6420)NewSubscriptionAddonRateCardClient(6567-6569)NewSubscriptionAddonRateCardItemLinkClient(6748-6750)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/subscription/testutils/feature.go (2)
openmeter/productcatalog/feature/connector.go (2)
CreateFeatureInputs(17-24)FeatureConnector(27-34)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)
openmeter/subscription/addon/service/create_test.go (8)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)pkg/clock/clock.go (2)
SetTime(23-27)Now(14-21)openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/ent/db/customer/where.go (1)
PrimaryEmail(142-144)openmeter/subscription/subscriptionview.go (1)
SubscriptionView(21-26)
openmeter/ent/db/addon/addon.go (2)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonsTable(1881-1911)
openmeter/ent/db/subscription_query.go (5)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscription/subscription.go (4)
Table(54-54)FieldID(16-16)AddonsTable(84-84)AddonsColumn(89-89)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)FieldSubscriptionID(30-30)openmeter/ent/db/predicate/predicate.go (2)
Subscription(216-216)SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/subscription/addon/repository.go (7)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/addonratecard/where.go (2)
openmeter/ent/db/addonratecard/addonratecard.go (5)
FieldDiscounts(49-49)Table(61-61)FieldID(19-19)SubscriptionAddonRateCardsTable(77-77)SubscriptionAddonRateCardsColumn(82-82)openmeter/ent/db/subscriptionitem/subscriptionitem.go (3)
FieldDiscounts(60-60)Table(70-70)FieldID(18-18)
openmeter/ent/db/subscription_update.go (2)
openmeter/ent/db/subscription/subscription.go (4)
Table(54-54)AddonsTable(84-84)AddonsColumn(89-89)FieldID(16-16)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
Table(40-40)FieldID(16-16)
openmeter/subscription/addon/repo/transaction.go (7)
openmeter/ent/db/tx.go (1)
Tx(15-104)openmeter/ent/db/client.go (2)
Driver(250-254)Client(63-147)pkg/framework/entutils/transaction.go (2)
NewTxDriver(47-52)TxDriver(76-88)openmeter/ent/db/expose.go (1)
NewTxClientFromRawConfig(78-172)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)
openmeter/ent/db/subscriptionaddonquantity_delete.go (4)
openmeter/ent/db/ent.go (3)
IsConstraintError(361-367)ConstraintError(345-348)NotFoundError(278-280)openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (3)
Table(34-34)FieldID(16-16)Label(14-14)
openmeter/subscription/addon/repo/mapping.go (12)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/schema/subscription_addon.go (14)
SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-58)SubscriptionAddonQuantity(60-62)SubscriptionAddonQuantity(64-70)SubscriptionAddonQuantity(72-78)SubscriptionAddonQuantity(80-84)SubscriptionAddonQuantity(86-95)SubscriptionAddonRateCard(97-99)SubscriptionAddonRateCard(101-108)SubscriptionAddonRateCard(110-118)SubscriptionAddonRateCard(120-136)SubscriptionAddonRateCard(138-143)pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/productcatalog/addon/adapter/mapping.go (2)
FromAddonRow(16-66)FromAddonRateCardRow(68-147)pkg/timeutil/timeline.go (2)
NewTimeline(46-55)Timed(29-32)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/subscription/addon/service.go (5)
openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/ent/db/subscriptionaddon/where.go (1)
SubscriptionID(94-96)
openmeter/ent/db/subscriptionitem_query.go (2)
openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)
openmeter/ent/db/subscriptionitem_update.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/addonratecard/addonratecard.go (2)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (5)
FieldDiscounts(60-60)ByDiscounts(267-269)OrderOption(164-164)Table(70-70)FieldID(18-18)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
OrderOption(102-102)Table(38-38)FieldID(16-16)
openmeter/ent/db/subscription/subscription.go (3)
openmeter/ent/db/addon/addon.go (1)
Table(53-53)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/migrate/schema.go (1)
AddonsTable(31-75)
openmeter/ent/db/subscriptionaddonquantity.go (3)
openmeter/ent/db/subscriptionaddonquantity/where.go (8)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)ActiveFrom(89-91)Quantity(94-96)SubscriptionAddonID(99-101)openmeter/ent/db/client.go (1)
NewSubscriptionAddonQuantityClient(6418-6420)openmeter/ent/db/subscriptionaddonquantity_update.go (1)
SubscriptionAddonQuantityUpdateOne(140-145)
openmeter/ent/db/subscriptionaddonratecard_delete.go (4)
openmeter/ent/db/ent.go (2)
ConstraintError(345-348)NotFoundError(278-280)openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardMutation(43471-43492)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCard(225-225)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/ent/db/addonratecard_query.go (2)
openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)
openmeter/subscription/addon/repo/subscriptionaddon.go (4)
openmeter/subscription/addon/repository.go (3)
SubscriptionAddonRepository(28-32)CreateSubscriptionAddonRepositoryInput(12-20)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/entutils/transaction.go (1)
TransactingRepo(199-221)openmeter/subscription/addon/repo/mapping.go (1)
MapSubscriptionAddon(17-64)pkg/framework/entutils/mapping.go (1)
MapPagedWithErr(20-31)
openmeter/subscription/testutils/service.go (6)
openmeter/subscription/addon/service/service.go (2)
NewService(41-47)Config(21-33)openmeter/subscription/service/service.go (1)
New(37-41)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)openmeter/subscription/testutils/addon.go (1)
NewTestAddonService(57-59)
openmeter/subscription/testutils/ratecard.go (4)
openmeter/productcatalog/ratecard.go (3)
UsageBasedRateCard(256-262)FlatFeeRateCard(161-168)RateCardMeta(49-77)openmeter/subscription/testutils/global.go (1)
ISOMonth(7-7)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/productcatalog/price.go (1)
NewPriceFrom(338-360)
openmeter/ent/db/addonratecard_create.go (3)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/addonratecard/addonratecard.go (3)
Columns(86-105)FieldID(19-19)FieldDiscounts(49-49)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
Columns(63-72)FieldID(16-16)
openmeter/ent/db/addonratecard_update.go (4)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/addonratecard/addonratecard.go (4)
Table(61-61)SubscriptionAddonRateCardsTable(77-77)Columns(86-105)SubscriptionAddonRateCardsColumn(82-82)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
Table(38-38)Columns(63-72)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonRateCardsTable(1966-2006)
openmeter/ent/schema/subscription_addon.go (7)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/subscriptionaddonratecard.go (4)
openmeter/ent/db/ent.go (2)
NotFoundError(278-280)NotLoadedError(324-326)openmeter/ent/db/addonratecard/addonratecard.go (7)
Label(17-17)FieldMetadata(23-23)FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (7)
Label(14-14)FieldMetadata(20-20)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (5)
Label(14-14)FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
openmeter/ent/db/addonratecard/addonratecard.go (14)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (14)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(30-30)ValidColumn(57-64)Columns(45-54)ByID(91-93)OrderOption(88-88)ByNamespace(96-98)ByCreatedAt(101-103)ByUpdatedAt(106-108)ByDeletedAt(111-113)BySubscriptionAddonID(126-128)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (16)
FieldID(19-19)FieldNamespace(21-21)FieldMetadata(23-23)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldAddonID(51-51)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)ByAddonID(230-232)ByAddonField(240-244)openmeter/ent/db/subscription/subscription.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (12)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(45-54)ByID(91-93)OrderOption(88-88)ByNamespace(96-98)ByCreatedAt(101-103)ByUpdatedAt(106-108)ByDeletedAt(111-113)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldMetadata(26-26)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (10)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (13)
FieldID(18-18)FieldNamespace(20-20)FieldMetadata(28-28)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(90-97)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscription/subscription.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(28-28)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)ByActiveFrom(172-174)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (16)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)ValidColumn(75-82)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)BySubscriptionAddonID(130-132)BySubscriptionAddonField(140-144)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (15)
FieldID(18-18)FieldNamespace(20-20)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldActiveFrom(30-30)ValidColumn(128-135)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)ByActiveFrom(192-194)
openmeter/ent/db/subscriptionaddonquantity_update.go (4)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42703-42721)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonquantity/where.go (3)
UpdatedAt(79-81)DeletedAt(84-86)ID(14-16)
openmeter/ent/db/migrate/schema.go (3)
openmeter/ent/db/subscription/subscription.go (2)
Table(54-54)AddonsTable(84-84)openmeter/ent/db/subscriptionitem/subscriptionitem.go (1)
Table(70-70)openmeter/ent/db/addonratecard/addonratecard.go (1)
SubscriptionAddonRateCardsTable(77-77)
openmeter/ent/db/subscriptionaddonratecard_query.go (4)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)openmeter/ent/db/addonratecard_query.go (1)
AddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/setorclear.go (7)
openmeter/ent/db/addonratecard_update.go (1)
AddonRateCardUpdate(24-28)openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/planratecard_update.go (1)
PlanRateCardUpdate(23-27)openmeter/ent/db/subscriptionaddon_update.go (1)
SubscriptionAddonUpdate(21-25)openmeter/ent/db/subscriptionaddonquantity_update.go (1)
SubscriptionAddonQuantityUpdate(19-23)openmeter/ent/db/subscriptionaddonratecard_update.go (1)
SubscriptionAddonRateCardUpdate(20-24)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (1)
SubscriptionAddonRateCardItemLinkUpdate(19-23)
openmeter/ent/db/subscriptionaddonquantity_create.go (1)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (20)
DefaultCreatedAt(70-70)DefaultUpdatedAt(72-72)DefaultActiveFrom(76-76)DefaultQuantity(78-78)DefaultID(84-84)NamespaceValidator(68-68)QuantityValidator(80-80)SubscriptionAddonIDValidator(82-82)Table(34-34)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)SubscriptionAddonTable(36-36)Columns(45-54)SubscriptionAddonColumn(41-41)FieldSubscriptionAddonID(30-30)
openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44353-44369)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonratecard_update.go (4)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardMutation(43471-43492)openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonRateCard(225-225)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
FieldID(16-16)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (3)
FieldID(16-16)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/subscriptionaddon/where.go (4)
openmeter/ent/db/predicate/predicate.go (5)
SubscriptionAddon(219-219)Subscription(216-216)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)Addon(10-10)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (17)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldAddonID(28-28)FieldSubscriptionID(30-30)FieldMetadata(20-20)Table(40-40)SubscriptionTable(42-42)SubscriptionColumn(47-47)RateCardsTable(49-49)RateCardsColumn(54-54)QuantitiesTable(56-56)QuantitiesColumn(61-61)AddonTable(63-63)AddonColumn(68-68)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (6)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Table(34-34)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (7)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)Table(38-38)
openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (3)
openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)
openmeter/ent/db/subscriptionaddonquantity/where.go (4)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonQuantity(222-222)SubscriptionAddon(219-219)openmeter/ent/db/addon/addon.go (6)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)Table(53-53)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (11)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)FieldSubscriptionAddonID(30-30)Table(34-34)SubscriptionAddonTable(36-36)SubscriptionAddonColumn(41-41)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (9)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)Table(38-38)SubscriptionAddonTable(40-40)SubscriptionAddonColumn(45-45)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (7)
FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)Table(32-32)SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)SubscriptionItemTable(41-41)SubscriptionItemColumn(46-46)
openmeter/ent/db/subscriptionaddon_update.go (5)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/predicate/predicate.go (3)
SubscriptionAddon(219-219)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddon_create.go (7)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41738-41762)openmeter/ent/db/subscription.go (2)
Subscription(20-54)Subscription(123-140)openmeter/ent/db/subscriptionaddonquantity/where.go (5)
ID(14-16)CreatedAt(74-76)UpdatedAt(79-81)Namespace(69-71)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/client.go (5)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (8)
SubscriptionTable(42-42)SubscriptionColumn(47-47)RateCardsTable(49-49)RateCardsColumn(54-54)QuantitiesTable(56-56)QuantitiesColumn(61-61)AddonTable(63-63)AddonColumn(68-68)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (2)
SubscriptionAddonTable(36-36)SubscriptionAddonColumn(41-41)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
SubscriptionAddonTable(40-40)SubscriptionAddonColumn(45-45)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)
⏰ Context from checks skipped due to timeout of 90000ms (7)
- GitHub Check: E2E
- GitHub Check: CI
- GitHub Check: Developer environment
- GitHub Check: Lint
- GitHub Check: Commit hooks
- GitHub Check: Test
- GitHub Check: Analyze (go)
🔇 Additional comments (352)
openmeter/ent/db/tx.go (2)
83-90: Appropriate addition of subscription addon clients to the Tx structThe new client fields follow the existing pattern of the codebase and are properly documented with clear comments explaining their purpose. These additions align well with the PR objective of introducing subscription addon functionality.
261-264: Clean initialization of subscription addon clientsThe initialization of the new client fields follows the consistent pattern used throughout the codebase, maintaining the same structure and style as existing initializations.
Note that since this is a code-generated file (as indicated by the comment at line 1), these changes are likely the result of schema definitions elsewhere in the codebase, which is the correct approach for working with the Ent ORM framework.
openmeter/ent/db/addonratecard/addonratecard.go (6)
48-49: Addition of Discounts field definitionThis change properly defines the
FieldDiscountsconstant, making it available for database operations. This aligns with the PR's objective of enhancing subscription addon functionality by supporting discount capabilities.
58-59: Implementation of SubscriptionAddonRateCards relationshipThese constants establish the relationship between AddonRateCard and SubscriptionAddonRateCard entities, defining the table names and foreign key columns needed for the database schema. The naming follows the project's convention, and the documentation comments accurately describe the purpose of each constant.
Also applies to: 76-82
102-102: Added Discounts to Columns arrayThe Discounts field is properly added to the Columns array, ensuring it's recognized as a valid column in database operations and queries.
224-227: Added ByDiscounts ordering functionThis function enables ordering query results by the discounts field, following the same pattern as other ordering functions in this file. This is essential for consistent query capabilities across all entity fields.
253-265: Added subscription addon rate cards ordering functionsThese functions enable ordering AddonRateCard query results based on their relationship with SubscriptionAddonRateCards. The implementation follows the established pattern for relationship-based ordering in Ent.
BySubscriptionAddonRateCardsCount: Orders by the count of related entitiesBySubscriptionAddonRateCards: Orders by specified fields of related entitiesBoth functions correctly use the newSubscriptionAddonRateCardsStep helper for SQL graph traversal.
280-286: Added helper function for subscription addon rate cards relationshipThe
newSubscriptionAddonRateCardsStepfunction correctly defines the SQL graph step for the one-to-many relationship between AddonRateCard and SubscriptionAddonRateCard. The relationship is properly configured with:
- Source: AddonRateCard table and ID field
- Target: SubscriptionAddonRateCard table and ID field
- Edge type: O2M (one-to-many)
- Foreign key column: addon_ratecard_id
This implementation enables efficient querying of this relationship.
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (5)
1-4: File header and package declaration look good.
No issues with the generated header or the package name. The comment correctly specifies that the file is generated code.
5-10: Imports are minimal and appropriate.
The imports fortime,entgo.io/ent/dialect/sql, andentgo.io/ent/dialect/sql/sqlgraphalign with the usage throughout the file.
12-60: Constants and table references align with Ent conventions.
All string constants (for fields, edges, tables) look consistent with the typical Ent naming patterns. They match the usage in the relevant code snippets from other subscription-addons files.
84-99: Validators and default value hooks are well-defined but unimplemented.
The placeholders for validators (NamespaceValidator,SubscriptionAddonIDValidator, etc.) and default value hooks (DefaultID,DefaultCreatedAt, etc.) are standard for Ent. Confirm that they are assigned appropriate functions in builders or schema definitions and are included in unit tests for data integrity.Would you like to add placeholders for unit tests or open an issue to ensure coverage for each validator?
166-187: Neighbor steps appear correct for M2O and O2M edges.
The steps for navigating edges (newSubscriptionAddonStep,newItemsStep,newAddonRatecardStep) are aligned with the Ent approach: they define the directional edges necessary for advanced queries and ordering. No issues found.openmeter/subscription/addon/repo/transaction.go (3)
3-11: Clean import organization.The imports are well organized with standard library imports first, followed by project-specific imports. This follows good Go conventions.
36-53: Transaction implementation looks correct but repeats code pattern.The transaction handling logic for
subscriptionAddonRateCardRepois correctly implemented and follows the same pattern as the other repositories. This approach works, but as noted in my earlier comment, consider refactoring to reduce duplication.
57-74: Transaction implementation consistent with other repositories.The transaction handling for
subscriptionAddonQuantityRepocorrectly follows the same pattern implemented for the other repositories. This consistency is good for maintainability, though the code duplication could be addressed through refactoring.openmeter/subscription/workflow/service/subscription_test.go (8)
76-77: Refactoring updates service initialization.The code has been updated to use the new
NewServicesignature fromsubscriptiontestutilsthat now returns a singleSubscriptionDependenciesstruct instead of multiple values. The method call to create features has also been renamed fromCreateExampleFeaturetoCreateExampleFeatures.
87-87: Service reference correctly updated.The code now uses
deps.WorkflowServiceinstead of the previous pattern that likely used something likeservices.WorkflowService.
244-244: Updated service initialization.This test case correctly uses the new
NewServicesignature that returns a singleSubscriptionDependenciesstruct.
271-272: Service initialization and feature creation updated.Similar to other instances, this code has been updated to use the new
NewServicesignature and the renamed feature creation method.
293-294: Service references updated.The code correctly uses
deps.SubscriptionServiceanddeps.WorkflowServiceinstead of the previous pattern that likely used references from a separateservicesvariable.
464-465: Consistent service initialization across test cases.The refactoring has been applied consistently across all test cases, maintaining a uniform approach to service initialization and dependency management throughout the file.
Also applies to: 471-471
707-708: Service references consistently updated.The test cases for timing-related functionality have also been correctly updated to use the new dependency structure.
Also applies to: 720-720
863-864: Refactoring applied to all test helper functions.The same refactoring pattern has been applied to all test helper functions in the file, ensuring consistency across the entire test suite.
Also applies to: 966-967, 1092-1093
openmeter/ent/db/setorclear.go (9)
212-224: Method implementation now matches its nameThe
SetOrClearDiscountsmethod forAddonRateCardUpdateandAddonRateCardUpdateOnenow correctly handles discounts instead of feature IDs. This corrects what appears to have been a mismatch between method names and implementations.
226-238: Method implementation now matches its nameThe
SetOrClearFeatureIDmethod forAddonRateCardUpdateandAddonRateCardUpdateOnenow correctly handles feature IDs instead of discounts. This corrects what appears to have been a mismatch between method names and implementations.
2326-2338: Method implementation now matches its nameThe
SetOrClearDiscountsmethod forPlanRateCardUpdateandPlanRateCardUpdateOnenow correctly handles discounts instead of feature IDs. This corrects what appears to have been a mismatch between method names and implementations.
2340-2352: Method implementation now matches its nameThe
SetOrClearFeatureIDmethod forPlanRateCardUpdateandPlanRateCardUpdateOnenow correctly handles feature IDs instead of discounts. This corrects what appears to have been a mismatch between method names and implementations.
2424-2450: Well-structured helper methods for subscription addon metadata and deletionThese new helper methods for setting or clearing metadata and deletion timestamps in the
SubscriptionAddonentity follow the established pattern in the file, maintaining good consistency with the codebase.
2452-2464: Consistent implementation for handling deleted timestampsThe new
SetOrClearDeletedAtmethods forSubscriptionAddonQuantityfollow the same pattern as other entities in the codebase, providing a clean way to handle nullable deletion timestamps.
2466-2492: Well-structured helpers for subscription addon rate cardsThese new helper methods for
SubscriptionAddonRateCardprovide consistent handling of both deletion timestamps and metadata, following the established patterns in the codebase.
2494-2506: Consistent deletion timestamp handling for item linksThe new
SetOrClearDeletedAtmethods forSubscriptionAddonRateCardItemLinkproperly handle soft deletion, maintaining consistency with the rest of the subscription addon entity handling.
212-2506:Details
✅ Verification successful
Verify backward compatibility with swapped method implementations
The swapping of functionality between
SetOrClearFeatureIDandSetOrClearDiscountsmethods appears to be a correction, but it's worth verifying there are no backward compatibility issues in existing code that might be relying on the previous behavior.
🏁 Script executed:
#!/bin/bash # Description: Search for calls to the methods whose implementations have been swapped to ensure they are being used correctly echo "Searching for calls to SetOrClearFeatureID and SetOrClearDiscounts methods..." rg -A 2 -B 2 "SetOrClearFeatureID|SetOrClearDiscounts" --type go | grep -v "func.*SetOrClearFeatureID\|func.*SetOrClearDiscounts"Length of output: 2063
Backward Compatibility Verification – No Action Required
The verification script confirms that the swapped implementations for
SetOrClearFeatureIDandSetOrClearDiscountsare defined as expected in the file without any external usage suggesting breaking changes. There are no indications that existing code relies on the previous behavior.
- Confirmed that both methods handle
nilcorrectly by invoking their respective clear methods.- Search results show only the function definitions from
openmeter/ent/db/setorclear.gowithout external call anomalies.openmeter/subscription/testutils/feature.go (3)
12-16: Good organization of related constants.Grouping related constants improves code readability and organization.
25-30: LGTM! Addition of ExampleFeature2 for testing.The new example feature follows the same pattern as the existing one, with appropriate differentiation in the name and key.
40-51:Details
❓ Verification inconclusive
Consider API compatibility for existing test code.
Renaming
CreateExampleFeaturetoCreateExampleFeaturesand changing the return type from a single feature to a slice of features may break existing tests that depend on the original method signature.Consider either:
- Keeping the original method alongside the new one for backward compatibility
- Updating all dependent test code as part of this PR
+// CreateExampleFeature maintains backward compatibility with existing tests +func (c *testFeatureConnector) CreateExampleFeature(t *testing.T) feature.Feature { + t.Helper() + feat, err := c.FeatureConnector.CreateFeature(context.Background(), ExampleFeature) + if err != nil { + t.Fatalf("failed to create feature: %v", err) + } + return feat +}
🏁 Script executed:
#!/bin/bash # Search for usages of the original method to verify impact echo "Searching for uses of CreateExampleFeature..." rg "CreateExampleFeature\(" --type goLength of output: 140
Review Update: Ensure Backward Compatibility Is Manually Verified
Renaming from
CreateExampleFeaturetoCreateExampleFeatureschanges the API (i.e., a shift from returning a single feature to a slice of features), which might break tests expecting the original signature. Anrgsearch for"CreateExampleFeature("produced no matches, but this outcome is inconclusive. Please manually verify that no tests or other parts of the codebase depend on the originalCreateExampleFeaturemethod. If dependencies exist, consider either:
- Retaining the original method for backward compatibility, or
- Updating all impacted test code as part of this PR.
Proposed Backward Compatibility Addition:
// CreateExampleFeature maintains backward compatibility with existing tests func (c *testFeatureConnector) CreateExampleFeature(t *testing.T) feature.Feature { t.Helper() feat, err := c.FeatureConnector.CreateFeature(context.Background(), ExampleFeature) if err != nil { t.Fatalf("failed to create feature: %v", err) } return feat }openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (6)
1-12: Auto-generated code acknowledgment.
This file appears to be generated by Ent (as indicated by the header). Generally, we avoid manual modifications. If any custom logic is needed, consider using Ent’s code generation hooks or custom files.
13-66: ID-based predicate functions are consistent.
These functions (ID,IDEQ,IDNEQ, etc.) follow the standard Ent pattern for string IDs. No issues noted.
68-221: Timestamp-based predicates appear correct.
The generated predicates forcreated_at,updated_at, anddeleted_atalign with typical Ent usage for time comparisons. No potential pitfalls spotted.
223-351: String-based relational ID predicates.
All predicates forsubscription_addon_rate_card_idandsubscription_item_idappear valid. If large string IDs are used, ensure appropriate indexing on these columns to maintain query performance.Would you like to confirm that these columns are indexed in the database schema? I can generate a script to inspect the migration files if needed.
353-397: Edge-based predicates for relationships.
TheHasSubscriptionAddonRateCard/HasSubscriptionItemand their “With” variants properly handle M2O relationships. This is standard for Ent edges.
399-412: Logical operators are standard.
And,Or, andNotare typical Ent helpers. No concerns here.openmeter/subscription/addon/repo/mapping.go (6)
36-46: Well-structured error handling for addon mapping.This section appropriately checks for nil references and handles potential errors from
addonrepo.FromAddonRow. The clean structure makes it easy to follow the mapping logic.
92-101: Comprehensive nil checking and error handling for rate card mapping.The code properly checks if the AddonRatecard is present, handles potential mapping errors, and even verifies that the resulting mapped object is not nil. This thorough approach prevents potential nil pointer dereferences.
67-71: Effective use of utility functions for error propagation.The code leverages
slicesx.MapWithErrfor mapping slices of entities where errors may occur. This approach efficiently handles error collection and propagation when mapping multiple items.Also applies to: 107-111
130-137: Optimized implementation for quantities mapping.The function correctly pre-allocates the result slice with the exact size needed and uses a simple loop instead of
slicesx.MapWithErrsince the underlying quantity mapping doesn't produce errors. This is an appropriate optimization.
1-138: Overall well-designed entity mapping layer.The mapping functions in this file follow consistent patterns, handle edge cases appropriately, and show good attention to error handling and null safety. The code structure makes it clear how database entities are transformed into domain models, maintaining the separation of concerns between the persistence and domain layers.
49-52:Details
✅ Verification successful
Verify the existence of the
AsTimed()method.The code is calling
q.AsTimed()onsubscriptionaddon.SubscriptionAddonQuantityobjects. However, I don't see this method defined in the provided code snippets for theSubscriptionAddonQuantitytype. Please ensure this method is properly implemented, otherwise this will result in a compilation error.
🏁 Script executed:
#!/bin/bash # Search for the AsTimed method implementation on SubscriptionAddonQuantity rg -A 5 "func \(\w+ ((\*)?SubscriptionAddonQuantity|(\*)?subscriptionaddon\.SubscriptionAddonQuantity)\) AsTimed\(\)" --type goLength of output: 567
Action Confirmed:
AsTimed()method exists as implementedThe
AsTimed()method has been verified inopenmeter/subscription/addon/quantity.goand is properly implemented, so the previous concern is resolved.openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (5)
1-2: Auto-generated code acknowledgment.
This file is generated by Ent. Manual changes here may be overwritten upon regeneration.
12-69: Field & Edge constants are consistent.
All field and edge constants are well-aligned with Ent's conventions, clearly denoting namespaces, fields, and table references. No issues observed.
71-91: Column definitions and ValidColumn function.
The Columns slice and the ValidColumn check are standard. Ensure that any newly introduced fields in your schema are consistently added here to avoid invalid column references.
110-216: Order options and relationship steps.
The ordering methods (ByID, ByNamespace, etc.) and relationship steps (newSubscriptionStep, newRateCardsStep, etc.) appear correct and consistent with Ent’s patterns for sorting and navigating edges. No functional issues noted.
93-108:Details
❓ Verification inconclusive
Validators and default value placeholders.
Each validator placeholder (for namespace, addon ID, subscription ID) can help avoid invalid data entry. Confirm that you're invoking these validators in the builder before persisting the entity.Would you like to verify that the corresponding validators are properly called in create/update builders?
🏁 Script executed:
#!/bin/bash # Searching usage of the validators in subscriptionaddon builder code fd builder | xargs rg "NamespaceValidator|AddonIDValidator|SubscriptionIDValidator"Length of output: 85
Action Required: Manual Verification of Validator Usage
Our search for references toNamespaceValidator,AddonIDValidator, andSubscriptionIDValidatorin builder-related code produced no results. This could mean that the validators may not be explicitly invoked in the builder routines responsible for creating or updating the SubscriptionAddon entity. Please manually verify that these validator functions are indeed called before persisting data. If they are missing, incorporate the necessary validator invocations in the create/update builders to enforce proper data validation.
- File affected:
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go(Lines: 93-108)- Action: Manually inspect the builder implementations to confirm that:
NamespaceValidatoris called on the "namespace" field.AddonIDValidatoris applied to the "addon_id" field.SubscriptionIDValidatoris invoked for the "subscription_id" field.openmeter/ent/db/migrate/schema.go (6)
1924-1953: No immediate issues found.
The table definition, foreign key, and indexes look coherent. The cascade delete is consistent with the design for related subscription addon records.
1954-1965: Column definitions look good.
All columns, includingaddon_ratecard_idandsubscription_addon_id, follow the standard pattern. No constraints or logic issues stand out.
2007-2016: Definitions for the rate card item link columns look straightforward.
No structural concerns at this stage.
2017-2060: Appropriate use of composite uniqueness on(subscription_item_id, subscription_addon_rate_card_id).
This ensures that a single subscription item can only map once to a specific addon rate card (unless soft-deleted). Good job.
2315-2318: Tables array update looks correct.
Including the new tables in the globalTablesslice is consistent with the rest of the schema definitions.
2366-2372: Foreign key references are properly linked.
These references to the new tables in theinitfunction look sound and follow the established ent schema pattern.openmeter/ent/schema/addon.go (3)
59-62: Appropriate cascading relationship added for subscription addons.The new edge establishes a proper relationship between Addon and SubscriptionAddon entities with cascading delete behavior, ensuring data integrity when an addon is deleted.
93-107: Good refactoring of fields definition with clear rationale.The approach of reusing
RateCard{}.Fields()and appending addon-specific fields simplifies the code and reduces duplication. The comment explaining the workaround for an ent/runtime.go bug is helpful for future maintainers.
120-123: Appropriate cascading relationship for subscription addon rate cards.The new edge establishes a proper relationship between AddonRateCard and SubscriptionAddonRateCard with cascading delete behavior, ensuring data integrity when a rate card is deleted.
openmeter/subscription/testutils/service.go (5)
16-18: Imports correctly added for new addon-related packages.The imports properly include all necessary packages for the addon functionality being implemented.
Also applies to: 25-27
38-52: Well-structured dependencies type with clear responsibilities.The renamed and expanded
SubscriptionDependenciesstruct follows good design principles by clearly organizing all the components needed for subscription testing. The addition of addon-related services maintains the existing pattern.
136-149: Proper initialization of addon repository and service.The code correctly initializes the addon repository and service with appropriate configuration and error handling. The use of
require.NoErrorensures that tests will fail with clear errors if initialization fails.
150-162: Subscription addon components initialized correctly.The code properly sets up the subscription addon repositories and service, with clear dependency injection. All necessary components are provided to the service, following the established pattern in the codebase.
164-178: Return value properly includes all services and repositories.The updated return statement correctly includes all components, both existing and newly added, making them available for tests. The structure is well-organized and maintains consistency with the existing codebase patterns.
openmeter/ent/db/client.go (15)
51-54: Well-structured imports for subscription addon entities.All the necessary imports are correctly included to support the new subscription addon functionality. The naming follows the existing project conventions, which promotes consistency.
133-140: Clean integration of subscription addon clients into the main Client struct.The subscription addon clients are properly added to the Client struct, following the same pattern as existing clients. This ensures that these new clients are accessible through the main client interface.
191-194: Proper initialization of subscription addon clients.The initialization of subscription addon clients in the init method follows the established pattern in the codebase, ensuring that these clients are properly set up when a new client is created.
323-326: Consistent transaction support for subscription addon clients.The subscription addon clients are correctly included in the transaction setup, ensuring that operations with these clients can participate in database transactions. This is implemented consistently across both the Tx and BeginTx methods.
Also applies to: 382-385
427-429: Well-integrated hook and interceptor support.The subscription addon clients are properly integrated with the hooks and interceptors system, allowing for consistent application of cross-cutting concerns like logging, validation, or authorization across all entity types.
Also applies to: 449-451
527-534: Proper mutation handling for subscription addon entities.The Mutate method is correctly extended to handle mutations for the new subscription addon entities, ensuring that CRUD operations can be performed on these entities through the client's interface.
670-684: Correct implementation of QuerySubscriptionAddons in AddonClient.This method properly implements the ability to query subscription addons related to an addon, establishing the relationship between addons and subscription addons. The implementation follows the correct pattern for relationship queries in the Ent framework.
851-865: Properly implemented QuerySubscriptionAddonRateCards in AddonRateCardClient.This method correctly establishes the relationship between addon rate cards and subscription addon rate cards, allowing navigation from an addon rate card to its associated subscription addon rate cards.
6174-6188: Well-implemented QueryAddons method in SubscriptionClient.This method creates a proper relationship query from a subscription to its associated subscription addons, which is essential for accessing addon information from a subscription.
6215-6410: Complete and consistent SubscriptionAddonClient implementation.The SubscriptionAddonClient is thoroughly implemented with all necessary methods following the same pattern as other entity clients. It includes proper CRUD operations, query capabilities, and relationship navigation.
6412-6559: Comprehensive SubscriptionAddonQuantityClient implementation.The SubscriptionAddonQuantityClient implementation includes all required methods for CRUD operations and relationship querying, consistent with the rest of the codebase.
6561-6740: Well-structured SubscriptionAddonRateCardClient with proper relationship queries.The implementation of SubscriptionAddonRateCardClient includes all necessary operations and properly establishes relationships with subscription addons, subscription addon rate card item links, and addon rate cards.
6742-6905: Complete SubscriptionAddonRateCardItemLinkClient implementation.This client implementation correctly handles the relationship between subscription addon rate cards and subscription items through the item link entity, with all necessary CRUD and query methods.
7063-7077: Properly implemented relationship query for subscription items.The QuerySubscriptionAddonRateCardItems method correctly establishes the relationship between subscription items and subscription addon rate card item links, allowing for efficient navigation of the object graph.
7445-7447: Consistent hooks and interceptors structure update.The hooks and interceptors structs are correctly updated to include the new subscription addon entities, ensuring that they can participate in the application's cross-cutting concerns framework.
Also applies to: 7458-7460
openmeter/subscription/service/service_test.go (6)
31-35: LGTM: Simplified service instantiation and updated feature creationThe code has been refactored to simplify service instantiation and use the updated
CreateExampleFeaturesmethod instead ofCreateExampleFeature.
96-113: LGTM: Consistent refactoring of service instantiation patternThe refactoring pattern is consistently applied throughout the test file, improving readability.
140-157: LGTM: Consistent method usageThe changes maintain consistency with the updated pattern for instantiating services and creating features.
195-199: LGTM: Maintaining consistent patternThe refactoring maintains a consistent approach throughout the test file.
311-315: LGTM: Consistent implementation patternThe changes maintain consistency with the refactored approach for service instantiation and feature creation.
398-402: LGTM: Consistent implementation across test casesThe changes consistently apply the refactoring pattern throughout the test cases.
openmeter/ent/db/addon/where.go (2)
802-811: LGTM: Well-implemented subscription addons edge predicateThe
HasSubscriptionAddonsfunction correctly implements a predicate to filter addons based on whether they have any associated subscription addons, following the Ent ORM pattern.
813-823: LGTM: Comprehensive conditional filtering for subscription addonsThe
HasSubscriptionAddonsWithfunction extends the basic edge predicate by allowing additional filtering conditions on the subscription addons, providing more flexibility for complex queries.openmeter/ent/schema/productcatalog.go (1)
129-143: LGTM: Improved code reuse in PlanRateCard fieldsThe refactoring improves code reuse by leveraging the
RateCard{}.Fields()method to get common fields, then appending specific fields for thePlanRateCardentity. The comment about using this approach due to an ent/runtime.go bug provides helpful context.openmeter/ent/db/subscriptionitem_create.go (3)
17-17: Properly added import for new functionalityThe new import for
subscriptionaddonratecarditemlinkis correctly added to support the new relationship between subscription items and addon rate card items.
285-298: Well-structured relationship management methodsThese new methods for managing relationships between
SubscriptionItemandSubscriptionAddonRateCardItemLinkentities follow the established Ent pattern and are implemented correctly. The methods properly handle both ID-based and entity-based relationship creation.
591-606: Correctly implemented relationship specificationThe edge specification for the subscription addon rate card items follows the standard Ent pattern. The relationship type (O2M), table/column references, and target node handling are all correctly implemented.
openmeter/subscription/addon/addon.go (4)
1-11: Clean package structure and import declarationsThe new package
subscriptionaddonis properly defined with the necessary imports. The dependencies are well organized, importing only what's needed.
12-26: Well-designed SubscriptionAddon entity structureThe
SubscriptionAddonstruct is well-designed with:
- Proper embedding of base models (NamespacedID, ManagedModel, MetadataModel)
- Clear relationship fields for associated entities
- Good use of the Timeline generic for managing quantities with time-based versioning
28-36: Clean input structure with clear field responsibilitiesThe
CreateSubscriptionAddonInputstruct provides a well-defined interface for creating subscription addons with all necessary fields and proper JSON annotations.
38-62: Comprehensive input validationThe validation method is thorough and follows good error handling practices by:
- Collecting errors to return them all at once instead of failing fast
- Providing clear error messages for each validation check
- Properly leveraging nested validation through
InitialQuantity.Validate()- Using
errors.Joinfor combining multiple validation errorsopenmeter/ent/db/addon_create.go (3)
17-17: Properly added import for SubscriptionAddon functionalityThe import for the
subscriptionaddonpackage is correctly added to support the new relationship between Addons and SubscriptionAddons.
206-219: Well-implemented relationship management methodsThese methods follow the standard Ent pattern for managing entity relationships:
AddSubscriptionAddonIDstakes IDs directlyAddSubscriptionAddonstakes entity pointers and extracts their IDs
Both methods are correctly implemented and maintain the flow pattern by returning the builder instance.
444-459: Correctly implemented edge specificationThe edge specification for subscription addons is properly defined with:
- One-to-many relationship (O2M)
- Correct table and column references
- Proper target node identification
- Correct edge appending to the create specification
openmeter/ent/db/addonratecard/where.go (2)
765-773: Added necessary null check predicates for discounts fieldThe addition of
DiscountsIsNilandDiscountsNotNilfunctions allows for filtering AddonRateCard entities based on whether they have discounts defined. This follows the pattern used for other nullable fields.
961-982: Properly implemented edge predicates for SubscriptionAddonRateCardsThese new functions enable filtering AddonRateCard entities based on their relationship with SubscriptionAddonRateCard entities:
HasSubscriptionAddonRateCardschecks for the existence of related entitiesHasSubscriptionAddonRateCardsWithallows for applying additional predicates to those related entitiesThe implementation uses the correct SQL graph steps and follows the established pattern in the codebase.
openmeter/ent/db/addon_query.go (8)
19-19: Added import for SubscriptionAddon package.This import is necessary for the newly added SubscriptionAddon relationship features.
25-31: Addon query enhanced with subscription addons relationship.The AddonQuery struct has been expanded to include the
withSubscriptionAddonsfield, allowing it to track relationships with subscription addons in queries.
90-110: Added query method for subscription_addons edge.The
QuerySubscriptionAddonsmethod enables chaining queries on the "subscription_addons" edge, allowing for efficient traversal between Addon and SubscriptionAddon entities. The implementation follows the standard pattern for edge queries in the codebase.
304-305: Updated Clone method with subscription addons support.The Clone method now properly handles the cloning of the
withSubscriptionAddonsfield, ensuring that query state is preserved when cloning instances.
323-332: Added eager loading method for subscription_addons edge.The
WithSubscriptionAddonsmethod enables eager loading of subscription addons connected to an addon, following the same pattern as other relationships in the codebase.
412-415: Updated loadedTypes array to track subscription addons loading.The loadedTypes array has been expanded to include the new relationship type, ensuring proper tracking of loaded edges.
445-453: Added subscription addons loading in sqlAll method.This code segment properly checks for the presence of subscription addon queries and loads them when needed, consistent with the pattern used for other relationships.
487-516: Implemented loadSubscriptionAddons helper method.This method handles the loading of subscription addons related to addon entities, following the same implementation pattern as other relationship loaders in the codebase.
openmeter/subscription/testutils/ratecard.go (5)
17-17: Changed ExamplePriceAmount to int64.Good change from
inttoint64, ensuring consistency with the expected type for alpacadecimal.NewFromInt which requires int64 values.
18-18: Changed ExampleRateCard1 to UsageBasedRateCard.The change from
FlatFeeRateCardtoUsageBasedRateCardbetter models the rate card structure needed for the subscription addons feature.
36-37: Updated price initialization using the new ExamplePriceAmount.Now using the type-consistent
ExamplePriceAmountdirectly instead of casting, which improves code clarity and type safety.
39-39: Changed BillingCadence from pointer to direct reference.Updated to use
BillingCadence: ISOMonthinstead of a pointer, matching the expected structure for UsageBasedRateCard which requires a non-pointer billing cadence.
54-77: Added ExampleRateCard3ForAddons for subscription addon testing.This new rate card example is specifically designed for testing subscription addons, with appropriate configuration for billing cadence, feature keys, and price structure. It complements the existing test utilities well.
openmeter/subscription/testutils/addon.go (5)
1-14: New test utilities file for subscription addons.This file introduces necessary test utilities for the new subscription addon feature, with appropriate imports and package declaration.
15-22: Created example rate card for addon testing.The
ExampleAddonRateCard1provides a standardized test object for addon rate cards, with meaningful test values and proper references to the existing test infrastructure likeExampleFeatureKeyandISOMonth.
24-51: Implemented GetExampleAddonInput function.This helper function creates a standard test input for addon creation, with appropriate metadata, rate cards, and configuration. The implementation is well-structured and uses the testing helper pattern correctly.
53-59: Created testAddonService wrapper.Good implementation of a test service wrapper that embeds the original service interface. This pattern allows for extending the service with test-specific functionality while maintaining full compatibility with the original interface.
61-78: Implemented CreateExampleAddon helper method.This method provides a convenient way to create and publish test addons, with appropriate error handling and test helper annotations. It follows the testing best practices established in the codebase.
openmeter/ent/db/subscription_query.go (8)
21-21: Added import for SubscriptionAddon package.This import is necessary for the newly added SubscriptionAddon relationship features in the Subscription entity.
36-36: Enhanced SubscriptionQuery with addons relationship.The
withAddonsfield enables the query to track and manage the relationship between Subscriptions and SubscriptionAddons.
162-182: Added query method for addons edge.The
QueryAddonsmethod enables chaining queries on the "addons" edge, allowing for efficient traversal between Subscription and SubscriptionAddon entities. The implementation is consistent with other relationship queries in the codebase.
380-380: Updated Clone method with addons support.The Clone method now properly handles the cloning of the
withAddonsfield, ensuring that query state is preserved when cloning instances.
431-440: Added eager loading method for addons edge.The
WithAddonsmethod enables eager loading of subscription addons connected to a subscription, following the same pattern as other relationships in the codebase.
520-526: Updated loadedTypes array to track addons loading.The loadedTypes array has been expanded to include the new relationship type, ensuring proper tracking of loaded edges. The size has been updated from 4 to 5 to accommodate the new
withAddonsfield.
575-581: Added addons loading in sqlAll method.This code segment properly checks for the presence of addon queries and loads them when needed, consistent with the pattern used for other relationships.
710-739: Implemented loadAddons helper method.This method handles the loading of subscription addons related to subscription entities, following the same implementation pattern as other relationship loaders in the codebase.
openmeter/ent/db/subscription/subscription.go (4)
51-52: New edge constant appears well-structured and consistent with Ent patterns.
83-89: Table naming aligns with the SubscriptionAddon entity definitions.
253-265: Neighbor ordering functions support typical Ent querying use cases.
294-300: Step definition for addons edge is consistent and correct.openmeter/ent/db/addon/addon.go (4)
50-51: Edge constant follows Ent naming conventions for relationships.
61-67: SubscriptionAddons table references are accurate and mirror the SubscriptionAddon entity setup.
223-235: The new ordering functions for subscription addons look correct.
243-249: Helper step function properly configures the O2M relationship.openmeter/ent/db/paginate.go (3)
1644-1691: SubscriptionAddonQuantity pagination is properly mirroring other query paginators.
1692-1739: SubscriptionAddonRateCard pagination follows the same proven pattern.
1740-1787: Pagination method for SubscriptionAddonRateCardItemLink matches the existing style and logic.openmeter/subscription/addon/service.go (3)
1-2: Looks good!No issues found with the package declaration.
3-9: Imports are appropriate.All imported modules appear necessary.
19-23: Struct definition is straightforward.The embedding of
pagination.Pageis clear and aligns well with typical pagination patterns.openmeter/subscription/addon/service/create_test.go (10)
1-25: Good test setup structure.Package name
service_testand the imports are typical for a black-box style test approach. No immediate concerns here.
66-97: Test is valid.Verifies behavior when the addon does not exist. A thorough check for a
GenericNotFoundErroris appropriate.
99-138: Checks subscription existence properly.Test coverage ensures that a non-existing subscription leads to a not-found error. Looks good.
140-178: Validates RateCard ownership effectively.Verifies that referencing a mismatched RateCard triggers a validation error. This is good coverage.
180-221: Skipped test approach is noted.You’ve correctly marked this test with a skip due to a known conflict. Revisit once concurrency with other error checks is resolved.
223-308: Comprehensive cross-subscription reference check.Ensures referencing items tied to another subscription triggers a conflict error. Logical approach.
310-351: Single-instance enforcement is correct.Correctly verifies mismatched quantity for single-instance addon. No issues found.
361-414: Test covers successful creation thoroughly.Properly verifies that fetched data matches the initial creation. This ensures end-to-end correctness.
417-437: Helper function is clear and reusable.
createExampleSubscriptionencapsulates subscription setup effectively.
439-448: Dependency injection pattern is solid.
withDepssets up and tears down dependencies cleanly.openmeter/ent/db/subscription_update.go (6)
196-210: Edges for "addons" are well-introduced.Methods
AddAddonIDsandAddAddonsalign with the existing Ent pattern.
264-283: Consistent naming for removing addons.
ClearAddons,RemoveAddonIDs, andRemoveAddonsmirror established patterns for the other edges.
498-542: Edge clearing logic is correct.Ensures proper clearing of O2M edges for subscription addons when
AddonsClearedis set.
724-737: Adds parallel methods for SubscriptionUpdateOne.
AddAddonIDsandAddAddonsreplicate the multi-add pattern from SubscriptionUpdate. Implementation is consistent.
792-811: Mirror removal methods.
ClearAddons,RemoveAddonIDs,RemoveAddonsfor single-entity updates match the behavior in SubscriptionUpdate.
1056-1100: SQL generation properly handles addon edges.
AddonsCleared,RemovedAddonsIDs, andAddonsIDslogic is consistent with other O2M edges.openmeter/subscription/addon/repository.go (5)
1-9: No immediate issues.
These lines introduce the package and imports. Everything looks standard.
22-26: Pagination input looks good.
TheListSubscriptionAddonRepositoryInputstruct neatly embeds pagination, which should handle listing logic well.
41-43: Multi-create design looks sensible.
CreateManyaligns well if you foresee multiple items created in a batch. No further concerns.
46-49: Quantity input is straightforward.
Fields are clearly named. Keep in mind any potential time-zone nuances withActiveFrom.
51-53: Quantity repository interface.
Having a dedicated method for creating quantities is clear. No issues found.openmeter/ent/db/subscriptionitem_query.go (7)
19-19: New import usage.
Importingsubscriptionaddonratecarditemlinkfor the new edge reference is consistent with the ent schema approach.
27-35: New field in query struct.
withSubscriptionAddonRateCardItemsextends the query to support eager loading of related entities. This follows ent’s pattern well.
138-158: Implementation ofQuerySubscriptionAddonRateCardItems.
Edge definition and chaining viasqlgraph.NewSteplooks correct. Matches ent’s O2M best practices for reading the new relationship.
347-360: Clone method updated to handle new field.
CloningwithSubscriptionAddonRateCardItemspreserves query state. This is correctly aligned with other cloned fields.
395-404: Eager loading for subscription addon rate card items.
WithSubscriptionAddonRateCardItemsproperly wraps the new query, ensuring optional configuration. No issues found.
533-543: Conditional load insqlAll.
Checking ifwithSubscriptionAddonRateCardItemsis not nil ensures the loader only runs when needed, avoiding unnecessary queries.
642-671:loadSubscriptionAddonRateCardItemscorrectness.
The mapping betweenSubscriptionItemIDs and associated links is correct. The approach to building FK sets, querying, and assigning results is standard for ent.openmeter/ent/db/addonratecard_query.go (8)
7-7: Import for driver usage.
Adding"database/sql/driver"is expected for assigning and scanning data. This aligns with ent’s internal scanning logic.
20-20: Import for subscription addon rate card.
Includingsubscriptionaddonratecardproperly supports the newly introduced relationship.
26-33: FieldwithSubscriptionAddonRateCards.
Storing the query pointer for subscription addon rate cards aligns with ent’s typical approach for edges.
114-134:QuerySubscriptionAddonRateCardsmethod.
Edge chaining logic withsqlgraph.NewStepis correct for the O2M relationship fromAddonRateCard. No concerns.
323-330: Cloning new edge query.
Ensures thatwithSubscriptionAddonRateCardsis duplicated properly. The pattern is consistent with other edges.
359-368:WithSubscriptionAddonRateCardseager loading.
Optional argument usage to configureSubscriptionAddonRateCardQueryis standard. Nicely done.
448-452:loadedTypesupdated for new edge.
Including the subscription addon rate card edge in the loaded types array ensures correct eager-loading behavior.
560-589:loadSubscriptionAddonRateCardscorrectness.
The logic ties eachAddonRateCardto its respectiveSubscriptionAddonRateCardrecord(s) via the foreign key. The function follows the established ent pattern.openmeter/ent/db/subscriptionaddonquantity_delete.go (8)
15-20: Well-structured builder for deletion operations
TheSubscriptionAddonQuantityDeletestruct sets a clear foundation for deleting multiple entities. It follows the standard pattern of providing a mutation and hooks array to manage lifecycle events, which aligns well with typical Ent-based patterns.
22-26: Predicate chaining for flexible filtering
TheWheremethod's design is consistent, allowing multiple predicates to be appended. This ensures flexible filtering and improves readability. No issues found.
28-31: Consistent Exec pattern
TheExecmethod implements Ent’s recommended approach by returning the count of deleted records and any error. This is coherent and follows best practices for deletion flows.
33-40: Panicking in ExecX
UsingExecXto panic on error is standard in generated code but may be risky in production if not wrapped with careful error handling higher up. Confirm usage in your application context.
42-57: Constraint error handling
Wrapping constraint errors in aConstraintErrortype is beneficial for distinguishing them from generic errors. This approach ensures consistent error handling logic in the service layer.
59-62: Single-entity delete struct
SubscriptionAddonQuantityDeleteOneis well-structured for deleting a single entity by building onSubscriptionAddonQuantityDelete. This separation cleanly addresses single vs. bulk deletion.
64-68: Chaining predicates for single-entity deletes
TheWheremethod here mirrors the multi-delete approach. This consistency is good, ensuring minimal learning curve for developers.
70-81: Correct NotFoundError return
Returning aNotFoundErrorif no rows are affected ensures that the caller can distinguish between an actual error and an empty result. This aligns with best practices for robust data operation flows.openmeter/ent/db/subscriptionaddonratecard_delete.go (8)
15-20: Well-defined bulk deletion builder
SubscriptionAddonRateCardDeleteprovides a solid framework for bulk deletion, mirroring the established Ent design pattern.
22-26: Reusing predicates for filtering
Allowing multiple predicates inWhereensures flexibility. No immediate issues detected.
28-31: Exec’s return strategy
Returning the number of affected rows plus an error is standard and clear. This usage is appropriate for controlling flow in higher-level services.
33-40: Panic in ExecX
As with other files, do verify that usage ofExecXis acceptable in your environment.
42-57: Robust constraint handling
ThesqlExeclogic properly traps constraint errors and marks the mutation as done, aligning with established best practices in Ent-generated code.
59-62: Single-record deletion struct
Separate structSubscriptionAddonRateCardDeleteOnepromotes clarity and cleanly segregates one-record vs. multi-record deletions.
64-68: Consistent Where method
Same pattern as the multi-delete builder, keeping consistency across the codebase.
70-81: Returning NotFoundError
Correct usage ofNotFoundErrorwhen zero rows are affected ensures predictable behavior for consumers.openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go (8)
15-20: Deletion builder for item-link entities
SubscriptionAddonRateCardItemLinkDeleteneatly encapsulates bulk deletion logic for item-link entities. The struct setup is coherent.
22-26: Predicate-based filtering
TheWheremethod for appending predicates allows fine-grained selection for deletions. This is in line with the rest of the codebase.
28-31: Exec return design
Returning the count of deleted entities is consistent with typical usage and fosters clarity in handling the operation’s outcome.
33-40: Potential panic handling
ExecXwill panic on error. As before, confirm that your application flow can handle these panics or consider the safeExecmethod.
42-57: Constraint-aware SQL execution
ThesqlExecmethod properly checks for constraints and wraps them intoConstraintError. This pattern helps unify error handling for all CRUD operations.
59-62: Single-record deletion struct
A separate struct,SubscriptionAddonRateCardItemLinkDeleteOne, effectively mirrors the multi-delete builder. It’s a consistent design choice.
64-68: Consistent predicate approach
Reusing the mutation’sWheremethod ensures developers maintain a consistent approach across the codebase for single or multiple deletions.
70-81: Returning NotFoundError on zero deletions
ReturningNotFoundErrorin case no entities match is aligned with the rest of the file’s logic, enabling uniform client-side handling.openmeter/ent/db/subscriptionitem_update.go (4)
330-343: Edge addition methods look good.
The newly added methods for adding subscription addon rate card items correctly implement ID-based and struct-based edge additions. This maintains consistency with existing Ent patterns.
651-695: Perform edge modifications in a single transaction for reliability.
You're already using Ent’s internal transaction. Just be aware if you have additional logic (e.g., custom pre-checks or side effects) that should be included in the same transactional boundary to ensure all or none of the edge changes persist.
1010-1023: Edge addition looks consistent with the rest of Ent’s patterns.
The function parallels the approach for other edges, ensuring consistency and clarity when linking multipleSubscriptionAddonRateCardItemLinkentities.
1057-1061: Edge clearing and removal methods appear consistent.
The new methods for clearing and removing subscription addon rate card items match established Ent conventions, which helps maintain a uniform developer experience across the codebase.Also applies to: 1063-1067, 1069-1076
openmeter/ent/db/subscriptionaddonquantity.go (1)
172-201: Ensure comprehensive unit tests for string parsing.
TheString()method comprehensively logs key fields. Testing edge cases (e.g.,DeletedAtpresent vs. nil) and the correct formatting for each field can help avoid log or auditing mismatches.openmeter/ent/db/addonratecard_create.go (6)
18-18: Import reference is consistent.
The new import forsubscriptionaddonratecardaligns with usage in this file. No additional concerns.
227-241: Edge addition logic appears correct.
These methods properly link rate cards to subscription add-on entities by ID or object reference.
501-516: Edge specification handling looks consistent.
The logic for creating the subscription add-on rate cards edge follows the standard Ent pattern. Verify that theOnDeleterule is set elsewhere if cascading deletes are required.
737-753: Upsert methods for discounts align with existing patterns.
The approach to set, update, or clear the “discounts” field matches other upsert design.
1041-1061: Consistent discount operations in single upsert flow.
Mirrors the multi-record upsert approach. Ensure all references to discounts are consistently validated across the codebase.
1523-1542: Bulk discount upsert aligns with single-case usage.
No immediate concerns. This maintains feature parity for bulk operations.openmeter/ent/db/subscriptionaddonratecard.go (7)
1-16: New file import and package definitions look fine.
The package name and imports follow standard conventions for Ent-based code.
18-54: Entity struct & edges struct satisfy clarity.
TheSubscriptionAddonRateCardstruct definition, along with theSubscriptionAddonRateCardEdges, is clear and consistent. The naming aligns with the domain well.
56-75: Edge resolution methods handle missing edges gracefully.
SubscriptionAddonOrErrandItemsOrErrproperly differentiate between “not loaded” vs. “loaded but not found,” consistent with Ent best practices.
76-85: AddonRatecardOrErr parallels the existing error pattern.
No concerns noted. Consistency with other “OrErr” methods is maintained.
87-175: Scanning and assignment logic is rigorous.
The code thoroughly checks column types, preventing unexpected conversions. Good use of JSON unmarshaling for metadata.
177-208: Queries and update methods enhance usability.
The ent-generated query functions and theUpdatelogic for this entity provide straightforward references for related data.
210-239: String method is clear and helpful for debugging.
The formatted output of key fields (including timestamps and optional fields) supports quick inspection.openmeter/ent/schema/subscription_addon.go (4)
1-39: Schema mixins and field definitions are well-structured.
Use ofIDMixin,NamespaceMixin, andMetadataMixinunifies the schema across the project. Fields foraddon_idandsubscription_idmeet immutability needs.
40-80: Relationship edges and cascade behaviors.
Edges to subscription, rate cards, and quantities appropriately include theOnDelete: entsql.Cascadeannotation as needed. This helps maintain referential integrity.
81-136: Quantity schema correctly enforces constraints.
Fields foractive_fromandquantityare sensible, and indexing onsubscription_addon_idwill aid lookups.
137-190: RateCard item linking establishes necessary references.
Edges to both the add-on rate card and subscription item cover the linking table use case nicely. The unique index on(subscription_item_id, subscription_addon_rate_card_id)underdeleted_atconstraint is a valuable safeguard.openmeter/ent/db/addonratecard_update.go (21)
18-18: New import reference
The import forsubscriptionaddonratecardis introduced here to manage newly added subscription addon rate card edges. No issues found with this addition.
184-188:SetDiscountsimplementation
This setter method follows typical ent patterns, simply assigning a new value fordiscounts. No immediate concerns.
190-194:ClearDiscountsmethod
Clearing thediscountsfield aligns with ent conventions. Implementation looks clean.
254-258: Adding SubscriptionAddonRateCard IDs
The code segment adds multipleSubscriptionAddonRateCardedges by ID. Implementation is straightforward and consistent with ent’s O2M approach.
260-267:AddSubscriptionAddonRateCardsconvenience method
Converts entities to their IDs for edge addition. This is standard ent logic for bridging the domain objects with database references.
286-290: Clearing all SubscriptionAddonRateCards
Removes all edges at once. This approach is expected when performing a full reset of related records. No issues noted.
292-296:RemoveSubscriptionAddonRateCardIDs
Removes specific edge references by their IDs. Appropriate for partial record disassociation.
298-305:RemoveSubscriptionAddonRateCards
Like the previous method, but accepts entity objects instead of IDs. Typical ent convenience method.
517-529: Clearing SubscriptionAddonRateCards insqlSave
This portion properly clears the O2M edges by building the correct edge spec. Implementation appears correct for ent-based data removal.
530-545: Removing SubscriptionAddonRateCard by ID insqlSave
The logic ensures that these edges are removed only if they’re not already cleared completely. This is a safe approach to avoid conflicting instructions.
546-561: Adding SubscriptionAddonRateCards insqlSave
Adds new edges in the O2M relation, creating the necessary spec definitions. Follows ent best practices for linking records.
730-734:SetDiscountsfor single-entity update
Again, the single-builder version of the setter is consistent with the multi-entity version. Implementation is straightforward.
736-740:ClearDiscountsfor single-entity update
Clears thediscountsfield for a singleAddonRateCard. Uses the same pattern as in bulk updates.
800-804:AddSubscriptionAddonRateCardIDsin single-entity builder
Accepts ID references to link multipleSubscriptionAddonRateCardentities. Matches the multi-builder logic.
806-813:AddSubscriptionAddonRateCards
Gathers IDs from the passed entities and delegates toAddSubscriptionAddonRateCardIDs. Appropriately DRY.
832-836:ClearSubscriptionAddonRateCardsin single-entity builder
Removes all related edges for this singleAddonRateCardrecord. Implementation is consistent.
838-842:RemoveSubscriptionAddonRateCardIDs
Removes the relationship by ID for single-entity context. Straightforward logic.
844-851:RemoveSubscriptionAddonRateCards
Converts the given entities into IDs before removing them. This pattern remains consistent and clear.
1093-1105: Clearing SubscriptionAddonRateCards in single-entitysqlSave
Ensures the O2M edges are fully removed when flagged. Typical ent approach for clearing relations.
1106-1121: Removing SubscriptionAddonRateCards by ID (single-entity)
Checks if the edges are not already cleared and removes them selectively. Ensures consistent edge state.
1122-1137: Adding SubscriptionAddonRateCards in single-entitysqlSave
Adds newSubscriptionAddonRateCardedges if requested. This chunk completes the O2M edge operations thoroughly.openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (15)
1-16: Package, imports, and const disclaimers
All lines here establish required imports and basic setup for a new ent builder file. Everything appears standard.
18-23: Definition ofSubscriptionAddonRateCardItemLinkUpdate
This struct adheres to ent’s pattern for multi-entity updates, includingconfig,hooks, andmutation. Looks correct.
25-29:Whereclause
Allows filtering update queries by predicates. This is standard ent usage, no concerns found.
31-55: Setters and clearers (SetUpdatedAt,SetDeletedAt, etc.)
All field assignment and clearing methods match the typical approach for ent. Each one is clearly named and functionally cohesive.
57-60: Exposure ofMutationmethod
Permits direct access to the mutation object if needed. Implementation is minimal and consistent with ent style.
62-88:Save,SaveX,Exec,ExecX
These methods finalize the update operation. The panic variations (X) are standard in ent. Strongly typed usage is consistent.
90-107:defaultsandcheckfor multi-entity updates
Sets default values (e.g., updated_at) if unset, and checks for disallowed edge clearing. Appropriately handles required edges.
109-140:sqlSavefor multi-entity updates
Constructs the final SQL operation to update records in bulk. This includes clearing theDeletedAtfield if needed and handling constraint errors.
142-148:SubscriptionAddonRateCardItemLinkUpdateOnestruct
Defines a single-entity update builder. This approach mirrors the multi-entity struct but focuses on a single record.
150-174: Single-entity field setters
SetUpdatedAt,SetDeletedAt, and their nillable + clearing variants provide a thorough interface for partial updates.
176-185: Single-entityMutationmethod andWhere
Again mirrors the pattern from the multi-entity update, allowing direct mutation access and condition-based updates.
187-193:Selectmethod
Enables partial column selection for queries, ensuring we can limit the returning fields. Straightforward ent usage.
195-220:Save,SaveX,Exec,ExecX
One-entity analog of the same multi-entity methods. The panic variants are also included. Implementation is clean.
222-239:defaultsandcheckfor single-entity updates
Follows the same pattern of defaultingupdated_atif unset, and preventing clearing of required edges.
241-292:sqlSaveon single-entity
Builds and executes the final SQL update spec. Properly checks for the ID, sets/clears fields, and handles potential constraint or not-found errors.openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (5)
1-16: New package and constants
Defines the entity label and primary fields (ID,namespace, etc.). Aligns with ent’s design for describing database schema elements.
18-42: Field definitions and relationships
Lists out the remaining fields:created_at,updated_at, etc., along with the relationship edge namesubscription_addon. Typical ent structure.
44-64: Columns slice andValidColumnfunction
Collects all field constants inColumnsand checks them inValidColumn. This is standard ent practice to safeguard column references.
66-85: Default and validator definitions
Holds placeholders for validations (e.g.,QuantityValidator) and default providers (e.g.,DefaultActiveFrom), enabling flexible entity configuration and data integrity checks.
87-143: Order options
Implements ordering for each field (ID, namespace, created_at, etc.) and includes a neighbor-based order (BySubscriptionAddonField). This fully rounds out standard ent query patterns for sorting results.openmeter/ent/db/subscriptionaddonquantity_update.go (11)
1-16: Auto-generated and import section
No issues found in the header and import statements. This area appears to follow standard Ent conventions.
18-24: Type definition forSubscriptionAddonQuantityUpdate
The structure and attachedmutationfield meet Ent’s pattern for capturing update states. Good separation of concerns.
25-29:Wheremethod
Chaining predicates into the builder is handled correctly. No concerns.
31-35:SetUpdatedAtmethod
The approach to settingupdated_atis straightforward. This is consistent with typical timestamp updates.
37-61:SetDeletedAt,SetNillableDeletedAt,ClearDeletedAt, andMutationmethod
These methods cleanly handle nullable timestamps, symmetrical set/clear usage, and properly expose the underlying mutation object.
62-75:Save,SaveX,Exec, andExecX
Providing both error-returning and panic-throwing variants is standard in Ent’s generated code. This meets best practices for convenience methods.
90-96:defaultsmethod
Automatically populatingupdated_atif unset prevents partially updated records and fosters data consistency.
98-104:checkmethod
Validating a required unique edge before the update is a solid defensive approach, avoiding orphaned references.
106-137:sqlSavemethod
The generated SQL update specification blends field updates, edge handling, and error normalization well. No concerns regarding correctness.
139-225:SubscriptionAddonQuantityUpdateOnetype & methods
Single-entity update builder mirrors the multi-entity approach. Clear separation of standard update patterns (e.g.,SetDeletedAt,ExecX).
227-285:checkandsqlSaveforSubscriptionAddonQuantityUpdateOne
Edge clearance and entity checks are consistent with Ent patterns. Proper error handling for constraint or not-found scenarios is observed.openmeter/ent/db/subscriptionaddonratecard_update.go (13)
1-24: Package, imports, and type definition
TheSubscriptionAddonRateCardUpdatebuilder and its references to hooks/mutations align with Ent’s code generation style. Good structure.
25-30:Wheremethod
Predicate appending is standard. No issues identified.
32-56:SetUpdatedAt& timestamp handling
Proper usage of theupdated_atfield ensures consistent auditing. Also covers nullabledeleted_atlogic.
58-69:SetMetadataandClearMetadata
Storing metadata as JSON is common. Both set and clear operations are straightforward.
70-83: Edge additions:AddItemIDsandAddItems
These methods provide correct multi-edge linking for theitemsrelationship. Implementation is consistent with Ent’s O2M patterns.
90-112: Edge clearing and removal:ClearItems,RemoveItemIDs,RemoveItems
Maintains a symmetrical approach to removing associations. Combined withAddItemsmethods, this is well balanced.
111-137:Save,SaveX,Exec, andExecX
These follow the standard Ent approach for executing the update query. Exception handling is consistent across methods.
139-156:defaultsandcheck
Populating default timestamps and validating required unique edges is appropriate. Prevents erroneous updates or partial data.
158-240:sqlSavemethod
Constructs an update spec, handles metadata,deleted_at, and edges (items) accurately. Constraint and not-found errors are properly surfaced.
242-249:SubscriptionAddonRateCardUpdateOnetype
The single-entity update builder again mirrors the multi-entity approach. Good separation of fields and mutation references.
250-355: Single-entity update methods (SetX, ClearX, AddItems, etc.)
All set/clear operations for timestamps, metadata, and item edges are consistent. This robustly supports partial or full field updates.
357-379:checkmethod
Ensures mandatory edges are not improperly cleared, preventing orphan references. Aligned with the multi-update variant.
389-491: Single-entitysqlSave
The update logic for the single entity includes field updates, edge clears/additions, and error handling. Matches standard Ent patterns.openmeter/ent/db/subscriptionaddonratecard_query.go (20)
1-37: Package, imports, andSubscriptionAddonRateCardQuerystruct
Defines the basic placeholders for context, ordering, and relationship queries. This is consistent with Ent’s query builder structure.
39-43:Wheremethod
Appending predicates for further filtering is standard. Good use of variadic arguments to support multiple conditions.
45-62: Limit, Offset, Unique, and Order
Implements pagination and uniqueness constraints. Standard approach for controlling query results.
70-90: Relationship queries (QuerySubscriptionAddon)
Navigating M2O edges withsqlgraphsteps is correct. The usage of “SetNeighbors” to chain the query is properly structured.
92-112:QueryItems
O2M edge query logic appears consistent. Ensures correct selection of linkedSubscriptionAddonRateCardItemLinkentities.
114-134:QueryAddonRatecard
Another M2O edge query. Follows the same step-based approach. Clear and consistent.
136-225: Fetching methods (First,Only, ID retrieval, plus variant X)
Appropriately handle not found vs. multiple results. The ID-based shortcuts add convenience, aligning with Ent.
236-244:AllandAllX
Executes the query to retrieve all matching rows. Provides an error-returning variant and a panicking variant. Common in Ent patterns.
255-274:IDsmethod
Extracts only the IDs of the matched entities. SettingUnique(true)ensures duplicates are omitted. Straightforward approach.
276-292:Count,CountX,Exist,ExistX
Correct usage for counting and existence checks. The panicking variants facilitate simpler usage.
316-335:Clone
Clones the query builder, retaining context, modifiers, and edges. This is beneficial for reusability and reconfiguration.
337-368: Eager-loading withWithSubscriptionAddon,WithItems, andWithAddonRatecard
Offers flexible chaining for related data. The optional function parameters allow further refinement of subqueries.
370-416:GroupByandAggregate
Allows grouping and aggregations (e.g., count, max). Properly sets up the group-by context.
418-442:prepareQuery
Validates interceptors, checks fields, and sets the base SQL selector. The flow is logically sound, preventing invalid or incomplete queries.
444-497:sqlAlland subsequent load methods
Constructs the query spec, loads primary nodes, then eagerly loads connected edges (subscriptionAddon, items, addonRatecard).
499-557: Helper load methods
loadSubscriptionAddon,loadItems,loadAddonRatecardeach gather foreign keys and assign relationships. Solid approach to bridging edges.
588-643:sqlCountandquerySpec
Customizes the node selection, offset/limit, and ordering for a consistent query. Ent’ssqlgraphusage is correct.
646-679:sqlQuery
Constructs the final selector for the query with optional distinct, limit, offset, order, and any user-defined modifiers.
681-705: Locking methods:ForUpdateandForShare
Supports row-level locks on PostgreSQL to avoid concurrency issues. Properly toggles uniqueness settings for correct locking semantics.
707-796: Grouping and selecting (SubscriptionAddonRateCardGroupBy,SubscriptionAddonRateCardSelect)
Enables partial field selection, aggregate functions, and result scanning. Comprehensive coverage of advanced query needs.openmeter/ent/db/subscriptionaddonquantity_create.go (4)
19-31: Review of struct definition andSetNamespace
This struct and theSetNamespacemethod appear consistent with Ent’s pattern of tracking field mutations through a mutation object. The presence of a customNamespaceValidatorin thecheckmethod ensures domain constraints. Great job incorporating validation.
128-159: Review ofSave,SaveX,Exec, andExecX
All these methods properly delegate tosaqc.sqlSaveafter applying defaults and hooks. It’s standard Ent logic. It might be worth adding more unit tests for edge cases (e.g., missing required fields, conflict conditions), but functionally this is sound.
161-224: Review ofdefaultsandcheckmethods
defaults: Nicely ensures that all required fields have default values. This helps maintain data integrity.check: Good approach verifying required fields and domain constraints (NamespaceValidator,QuantityValidator, etc.). This is an excellent pattern to prevent invalid data from being saved.
226-301: Review ofsqlSaveandcreateSpec
This part cleanly defines how nodes are inserted. The usage ofsqlgraph.CreateNodeand the subsequent assignment of the generated ID is standard. The partitioning of logic between building a spec (createSpec) and performing the insert (sqlSave) keeps the flow maintainable.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (6)
20-26: Introduction toSubscriptionAddonRateCardItemLinkCreate
Your struct design (with config, mutation, hooks, and conflict slices) follows the Ent conventions well. It's straightforward and maintainable.
70-80: Review of ID and edge setters
- SetSubscriptionAddonRateCardID / SetSubscriptionItemID: Good usage of referencing parent IDs.
- SetSubscriptionAddonRateCard / SetSubscriptionItem: Nicely chain to the ID-based methods.
Ensure these references align with thesubscriptionaddonratecarditemlink.SubscriptionAddonRateCardIDValidator(...)andSubscriptionItemIDValidator(...).Also applies to: 82-104
111-137: Review ofSave,SaveX,Exec, andExecX
As with the quantity builder, these finalize creation, hooking intosarcilc.sqlSave. The approach is idiomatic to Ent, and the partition between “safe” and “panic” versions is well-handled.
155-209: Review ofcheckandsqlSave
- Field validations: Confirms the presence of required fields and references. The usage of
SubscriptionAddonRateCardIDValidatoris a good domain-level check.- Potential improvements: You might consider enhanced error messaging if the referencing entity is missing or inactive, though that can be domain-specific.
479-585: Review ofSubscriptionAddonRateCardItemLinkCreateBulk
Bulk creation logic is consistent with the single-entity approach, applying checks, defaults, and a unifiedBatchCreateSpec. The layering of mutations ensures each item is validated before insertion. Looks good.
139-153:Details
❓ Verification inconclusive
Review of
defaultsmethod
Assigning defaults for timestamps and IDs using the auto-generated ent defaults is extremely helpful. Confirm that thesubscriptionaddonratecarditemlink.DefaultID, etc., produce distinct, valid IDs.
🏁 Script executed:
#!/bin/bash # Verification script to ensure the default ID generator is distinct in each usage # (This usually relies on a uuid or similar mechanism). grep -A 5 "DefaultID" openmeter/ent/db/subscriptionaddonratecarditemlink/*.goLength of output: 1016
Action Required: Validate Uniqueness of Default ID Generator
The
defaultsmethod is correctly invoking the auto-generated functions for default timestamps and the ID. The grep output confirms the existence ofsubscriptionaddonratecarditemlink.DefaultIDas a function returning a string. However, please verify that its implementation in
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go
indeed returns distinct and valid IDs (for example, by ensuring it leverages a proper UUID or a similar uniqueness mechanism). Additionally, ensure that the corresponding default methods forCreatedAtandUpdatedAtcontinue to meet your expectations.openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (11)
21-34: Initialization ofSubscriptionAddonRateCardItemLinkQuery
Storing context, order options, predicates, and eager-load references is typical Ent logic. Good breakdown of fields to handle advanced query scenarios (e.g., offset, limit, uniqueness).
36-65: Predicates, limiting, and ordering
Where: Good approach for chaining multiple predicates.Limit/Offset/Unique: Standard usage to shape results.Order: Nicely extends the chain of query modifications.
67-109: Chaining queries on edges
QuerySubscriptionAddonRateCardandQuerySubscriptionItemexemplify good separation by using new clients and steps. This fosters stand-alone edge queries.
111-154: Retrieving single entities (First,FirstX,Only, etc.)
The distinction between returning errors vs. panics is consistent with Ent’s approach. Error handling for “not found” and “not singular” is well-labeled.
156-181: Ensuring only one result
ReturningNotSingularErrorif multiple entries exist is helpful to maintain domain constraints. The approach is consistent and easy to read.
211-290: Methods for retrieving and checking existence (All,IDs,Count,Exist)
The coverage of different retrieval patterns is robust. This aligns with typical usage for advanced queries. Especially helpful:Existfor quick checks.
311-331: Eager-loading with edges
TheWithSubscriptionAddonRateCardandWithSubscriptionItemshow a straightforward approach to preloading related records. The optional configure functions provide flexibility in how these edges are fetched.
333-380:GroupByandSelectconstructs
These are Ent’s advanced query features. TheGroupBywith aggregator is particularly handy for analytics. Similarly,Selectfor partial columns can reduce data overfetching.
454-511: Lazy loading of related entities
The loops collecting foreign keys and retrieving them in batch are efficient. This reduces N+1 queries. Great job preserving performance.
513-569:sqlCountandquerySpec
- The counting logic reuses
querySpec, ensuring consistent filters.- Reapplying fields/predicates is a robust approach.
- The fallback to retrieving columns if none are specified is especially helpful.
606-630: Row-level locks (ForUpdate,ForShare)
Ent’s approach to row-level locks is well integrated. This is often critical for transaction integrity in concurrent usage. The logic to disable uniqueness for Postgres is correct.openmeter/ent/db/subscriptionaddonquantity_query.go (4)
20-32: New query builder struct looks solid.No issues found in the initialization and field definitions. This struct cleanly encapsulates the necessary context for subsequent query operations.
65-85: Edge query chaining is well-structured.The
QuerySubscriptionAddon()method correctly sets up a separate query builder for the relatedSubscriptionAddon. The logic for linking the foreign key and selector is coherent and follows best practices.
286-295: Eager loading approach is consistent with Ent patterns.Using
WithSubscriptionAddonto eager-load connected entities is a common pattern in Ent. The optional configuration closure is a nice touch for extending the query.
532-540: Locking support for Postgres is properly gated.The
ForUpdatelogic is dialect-aware, ensuring exclusive row-level locking in Postgres. This is a good approach for avoiding unintended locks in other dialects.openmeter/ent/db/subscriptionaddon_update.go (4)
185-193: Edge-clearing validation is commendable.The check preventing clearing a required unique edge while also adding new IDs helps maintain data integrity. It's a good safeguard against contradictory mutation states.
196-222: Fields and edges update logic is straightforward.The
_specconstruction cleanly sets the relevant fields and properly handles cleared vs. set values. Great alignment with typical Ent usage.
176-182: Auto-updating timestamps is helpful.The default
UpdatedAtassignment indefaults()method ensures the entity always reflects the latest modification time, reducing the chance of stale data.
495-505: Single-entity validation is consistent.The
check()function forSubscriptionAddonUpdateOneensures that required edges are not improperly cleared. This keeps the database in a valid state.openmeter/ent/db/subscriptionaddon/where.go (2)
163-168: Nil-check predicates are well-defined.Having dedicated predicates for
MetadataIsNilandMetadataNotNilallows flexible and clear filtering on nullable JSON fields.
525-539: Logical operator predicates enhance query composability.The
And,Or, andNotfunctions are valuable for building complex queries. They match the typical Ent pattern and improve maintainability.openmeter/ent/db/subscriptionaddonquantity/where.go (5)
1-12: Auto-generated file disclaimer.This file is generated by the Ent framework, which discourages manual edits because the changes will be overwritten on regeneration. No issues spotted in import statements and package declaration.
13-67: ID-based predicate functions are correct and idiomatic.These predicate functions (ID, IDEQ, IDNEQ, IDIn, etc.) correctly handle string IDs and provide the expected filtering behavior. The approach is a standard Ent pattern.
68-167: String field predicates (Namespace, CreatedAt, etc.) follow Ent's best practices.All the string and time-based comparison predicates align with Ent's typical pattern for equality, inequality, and substring matching. The function naming is consistent (EQ, NEQ, In, NotIn, GT, etc.).
443-464: Relationship predicate for HasSubscriptionAddon is well-defined.The edge predicate uses an M2O relationship, with correct usage of
sqlgraph.HasNeighbors(...). This is a standard approach, enabling seamless queries for subscription addons.
466-479: Logical operators (And, Or, Not) ensure flexible query composition.These logical composition predicates provide robust chaining of conditions. The usage of
sql.AndPredicates,sql.OrPredicates, andsql.NotPredicatesis correct for Ent-based queries.openmeter/ent/db/subscriptionaddon_create.go (6)
1-28: File-level overview and builder struct definition look good.This file introduces builders for creating SubscriptionAddon entities. The structure with
SubscriptionAddonCreateand attached hooks matches standard Ent design. No issues identified in the import block or type definitions.
30-154: Setter methods (SetNamespace, SetMetadata, etc.) are clear and maintainable.Each setter method properly updates mutation fields. The design is consistent with Ent’s generated pattern. Calls to
sac.mutation.SetX()are straightforward and correct.
155-197: Save method and defaults logic appear robust.The
defaults()method ensures required fields (CreatedAt, UpdatedAt, and ID when not explicitly set) receive sensible values. This is coherent with the Ent model constraints. No issues found.
198-360: Validation checks (namespace, addon_id, subscription_id) effectively enforce required fields.The
check()method ensures all required fields and edges are set. Validation error messages are clear. This helps prevent incomplete data from being persisted.
362-611: OnConflict and upsert handling meets typical Ent usage standards.The methods allow advanced conflict resolution. MySQL’s limitation on non-numeric IDs after an upsert is clearly documented, preventing confusion. Flow is standard for Ent-based upsert logic.
613-880: Bulk-creation logic is well-structured.The
SubscriptionAddonCreateBulkbuilder orchestrates batch insertion with conflict handling. Each builder’s defaults and checks are invoked properly. This approach is consistent with Ent’s recommended patterns.
feat(subscription): define interfaces of addon package feat(subsaddon): implement repo fix(addon): use types and references after rebase feat(subs): write testutils for addons refactor(subs-test): change dependency interfaces fix(subsaddon): remove redundant fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
♻️ Duplicate comments (5)
openmeter/subscription/testutils/compare.go (1)
182-193: Compare function partially checks Addon fields
This matches a previous review recommendation to verify additional fields of theAddonobject and not just its ID. Completing that TODO will strengthen test reliability.- assert.Equal(t, a1.Addon.ID, a2.Addon.ID) // TODO: check all fields? + // Also check critical fields beyond ID: + assert.Equal(t, a1.Addon.Key, a2.Addon.Key) + // ...openmeter/subscription/addon/repo/transaction.go (1)
15-74: Consider consolidating repetitive transaction logic.All three repository structs (
subscriptionAddonRepo,subscriptionAddonRateCardRepo, andsubscriptionAddonQuantityRepo) define nearly identicalTx,Self, andWithTxmethods. Reusing a shared transaction handler would simplify the code, make it more maintainable, and reduce duplication. This was also pointed out in a previous review.openmeter/ent/db/subscriptionaddonquantity.go (2)
61-77: Validate integer domain constraints
Consider enforcing non-negative quantity values.
79-141: Assigning values
Consider domain checks to prevent invalid (negative) Quantity.openmeter/ent/db/subscriptionaddonquantity_create.go (1)
28-31: Reaffirm domain-specific constraints in the setter.This setter for
namespaceis functionally correct, but you might re-validate domain-specific constraints (string length, allowed characters, etc.) before storing or mutating the entity.
🧹 Nitpick comments (46)
openmeter/subscription/testutils/feature.go (2)
42-49: Consider context reuse and improved error messages.For better efficiency and clarity:
- feat1, err := c.FeatureConnector.CreateFeature(context.Background(), ExampleFeature) - if err != nil { - t.Fatalf("failed to create feature: %v", err) - } - feat2, err := c.FeatureConnector.CreateFeature(context.Background(), ExampleFeature2) - if err != nil { - t.Fatalf("failed to create feature: %v", err) - } + ctx := context.Background() + feat1, err := c.FeatureConnector.CreateFeature(ctx, ExampleFeature) + if err != nil { + t.Fatalf("failed to create feature 1: %v", err) + } + feat2, err := c.FeatureConnector.CreateFeature(ctx, ExampleFeature2) + if err != nil { + t.Fatalf("failed to create feature 2: %v", err) + }This reuses the context and provides clearer error messages to distinguish which feature creation failed.
40-51:Details
❓ Verification inconclusive
Consider backward compatibility for existing tests.
Renaming
CreateExampleFeaturetoCreateExampleFeaturesand changing the return type from a single feature to a slice may break existing tests that depend on the previous behavior.Consider one of these approaches:
- Keep both methods (old single-return and new multiple-return)
- Add a migration path with deprecation notices
- Update all calling tests simultaneously
🏁 Script executed:
#!/bin/bash # Search for existing usages of CreateExampleFeature to assess impact rg "CreateExampleFeature\(" --type goLength of output: 39
Attention: Verify External Test Dependencies
The search for any usages of
CreateExampleFeaturein the Go codebase returned no results, which suggests that the API change (renaming toCreateExampleFeaturesand modifying its return type) is not breaking any internal tests. However, please manually verify that no external tests or dependencies (possibly outside the main codebase) still reference the old method, as this would require a backward compatibility strategy such as maintaining both methods or providing a migration path.
- No internal usage detected: The grep search indicates that
CreateExampleFeatureisn’t used within the checked Go files.- Action Required: Manually confirm there are no external dependencies (or overlooked tests) relying on the singular feature-return version. If any are found, consider:
- Keeping both the old and new methods.
- Introducing deprecation warnings with a migration path.
- Simultaneously updating all affected tests.
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
19-20: Consider adding validation for themetadatafield.Currently, only
namespace,addon_id, andsubscription_idhave validation hooks specified. Ifmetadatawill store user-generated or unbounded data, consider adding a custom validator to catch invalid or large payloads early.
95-105: Review consistency of validators for all critical fields.You have validators for
namespace,addon_id, andsubscription_id, but not for other fields such asmetadata. If there are any constraints on these fields, consider implementing corresponding validators for full coverage.Do you want me to generate code that introduces a custom validator for
metadataor open an issue to track it?
110-216: Validate or index commonly queried fields.This file provides ordering by fields such as
created_at,updated_at, anddeleted_at. If these columns are heavily used for sorting or filtering in queries, consider defining indexes at the Ent schema layer to ensure efficient lookups.openmeter/ent/db/subscriptionaddonratecard_create.go (4)
139-152: Check fields and required edges before saving.The
Savemethod relies onsarcc.check()to ensure all mandatory fields and edges are set. This is crucial, as it helps prevent creating incomplete records. Ensure that any application-level logic also confirms relationships exist before calling the builder.
183-222: Validation function ensures integrity.The
check()function ensures required fields (namespace,subscription_addon_id, etc.) are present, and it validates them with the custom validators. This robust approach will help maintain data integrity in the database.Consider adding custom validations if there are domain-specific constraints (e.g., certain namespace patterns or maximum lengths).
330-351: OnConflict logic with upsert support.The optional
OnConflictmethod provides upsert-like behavior, allowing the insertion to be retried or updated if conflicts occur. This is a helpful pattern for handling concurrent insertions or repeated data.Do you need any additional reference code to ensure partial updates or conflict resolution strategies in your domain?
581-665: Bulk creation with batch handling.The bulk creation process merges multiple
SubscriptionAddonRateCardCreatebuilders. This is efficient for inserting many records in one transaction. Check that you have proper logging or error-handling for partial failures, especially if some records could be invalid while others are valid.openmeter/ent/db/planratecard.go (1)
228-233: Assigning Discounts during SQL row scan.The logic here unmarshals the raw database value into the
Discountspointer. Ensure that any malformed JSON is handled gracefully upstream or in the caller.openmeter/subscription/addon/addon.go (5)
1-10: Package needs documentation.Add package-level documentation explaining the purpose of the
subscriptionaddonpackage and its role in the subscription addon functionality.package subscriptionaddon + +// Package subscriptionaddon provides types and functionality for managing +// subscription add-ons, including creating, validating, and representing add-ons +// attached to subscriptions with their associated rate cards and quantities. import (
12-26: Add documentation for public types.The
SubscriptionAddonstruct is exported but lacks documentation comments explaining its purpose and usage.+// SubscriptionAddon represents an add-on attached to a subscription with its +// associated rate cards and quantities. It contains all the necessary information +// for representing a subscription add-on including the linked add-on definition and +// subscription relationship. type SubscriptionAddon struct { models.NamespacedID models.ManagedModel models.MetadataModel Name string `json:"name"` Description *string `json:"description,omitempty"` // AddonID string `json:"addonID"` Addon addon.Addon `json:"addon"` SubscriptionID string `json:"subscriptionID"` RateCards []SubscriptionAddonRateCard `json:"rateCards"` Quantities timeutil.Timeline[SubscriptionAddonQuantity] `json:"quantities"` }
20-20: Remove commented code.There's a commented-out field that should be removed as it appears to be replaced by the
Addonfield.- // AddonID string `json:"addonID"` Addon addon.Addon `json:"addon"`
28-36: Add documentation for the input type.The
CreateSubscriptionAddonInputstruct is exported but lacks documentation comments explaining its purpose and usage patterns.+// CreateSubscriptionAddonInput contains the necessary information to create a new +// subscription add-on. It includes references to the addon and subscription, as well +// as the initial rate cards and quantity to associate with the new subscription add-on. type CreateSubscriptionAddonInput struct { models.MetadataModel AddonID string `json:"addonID"` SubscriptionID string `json:"subscriptionID"` RateCards []CreateSubscriptionAddonRateCardInput `json:"rateCards"` InitialQuantity CreateSubscriptionAddonQuantityInput `json:"initialQuantity"` }
38-62: Enhance error messages in Validate method.The validation error messages could be more specific to help with troubleshooting.
func (i CreateSubscriptionAddonInput) Validate() error { var errs []error if i.AddonID == "" { - errs = append(errs, errors.New("addonID is required")) + errs = append(errs, errors.New("addonID is required for subscription addon creation")) } if i.SubscriptionID == "" { - errs = append(errs, errors.New("subscriptionID is required")) + errs = append(errs, errors.New("subscriptionID is required for subscription addon creation")) } if len(i.RateCards) == 0 { - errs = append(errs, errors.New("rateCards weren't provided")) + errs = append(errs, errors.New("at least one rateCard must be provided for subscription addon creation")) } if err := i.InitialQuantity.Validate(); err != nil { errs = append(errs, fmt.Errorf("initialQuantity: %w", err)) } if i.InitialQuantity.Quantity == 0 { - errs = append(errs, errors.New("initialQuantity.quantity cannot be 0")) + errs = append(errs, errors.New("initialQuantity.quantity must be non-zero for subscription addon creation")) } return errors.Join(errs...) }openmeter/subscription/addon/repo/subscriptionaddonratecard.go (2)
56-62: Improve error handling comment clarity.The comment about "magical reasons" for constraint error handling is a bit unclear. While it explains the current limitation in identifying specific constraint violations, it would be more professional to provide a clearer technical explanation.
- // For magical reasons, the constraint error looks like this: - // failed to create subscription addon rate cards: failed to create links to subscription items: db: constraint failed: insert nodes to table \"subscription_addon_rate_card_item_links\": ERROR: insert or update on table \"subscription_addon_rate_card_item_links\" violates foreign key constraint \"subscription_addon_rate_card_i_5443b55d7e58df21cd89a6726b500989\" (SQLSTATE 23503)" - // So we cannot assert for the specific type of constraint we're violating + // The constraint error message doesn't provide enough detail to identify the specific constraint type: + // ERROR: insert or update on table \"subscription_addon_rate_card_item_links\" violates foreign key constraint \"subscription_addon_rate_card_i_5443b55d7e58df21cd89a6726b500989\" (SQLSTATE 23503)" + // Therefore, we handle all constraint errors with a generic not found error
36-75: Consider grouping error handling for better code organization.The current implementation has error handling at different levels within the transaction. Consider extracting repeated error handling patterns into helper functions or consolidating error handling to improve readability and maintainability.
For example, consider a pattern like:
// Example of consolidated error handling for _, input := range inputs { rateCard, links, err := createRateCardWithLinks(ctx, repo, subscriptionAddonID, input) if err != nil { return nil, err } result, err := MapSubscriptionAddonRateCard(rateCard) if err != nil { return nil, fmt.Errorf("failed to map rate card to domain model: %w", err) } results = append(results, result) } // Helper function (defined elsewhere) func createRateCardWithLinks(ctx context.Context, repo *subscriptionAddonRateCardRepo, subscriptionAddonID models.NamespacedID, input subscriptionaddon.CreateSubscriptionAddonRateCardRepositoryInput) (*db.SubscriptionAddonRateCard, []*db.SubscriptionAddonRateCardItemLink, error) { // Implementation here }openmeter/subscription/addon/service.go (2)
11-17: Interface name clarity.
WhileServiceis a straightforward name, it might become confusing in a larger codebase if multiple “Service” interfaces exist in different packages. Consider making the interface more descriptive (e.g.,SubscriptionAddonService). Otherwise, it looks structurally sound.
25-33: Potentially clarify error message in Validate().
Currently, whenSubscriptionIDis missing, the error states "filter has to be provided, all values are empty". Consider making the error message more specific, e.g.,"subscriptionID must be provided". This improves clarity for the user.openmeter/subscription/addon/service/create_test.go (1)
180-221: Skipped test note.
The test for referencing nonexistent subscription items is currently skipped, indicating a potential conflict-lifetime constraint. Keep track of this scenario so it can be revisited once conflict error precedence is resolved.Shall we open a new issue or do you plan to revisit soon?
openmeter/subscription/addon/repository.go (1)
11-32: SubscriptionAddon repository interface and structures look good.The input structs and repository interface for SubscriptionAddon are well-designed with appropriate fields and methods. The
MetadataModelembedding provides consistency with other models in the system.Consider adding godoc comments to describe the purpose of each interface and method to improve code documentation.
+// CreateSubscriptionAddonRepositoryInput contains the data needed to create a subscription addon. type CreateSubscriptionAddonRepositoryInput struct { models.MetadataModel Name string `json:"name"` Description *string `json:"description,omitempty"` AddonID string `json:"addonID"` SubscriptionID string `json:"subscriptionID"` } +// ListSubscriptionAddonRepositoryInput defines the parameters for listing subscription addons. type ListSubscriptionAddonRepositoryInput struct { SubscriptionID string `json:"subscriptionID"` pagination.Page } +// SubscriptionAddonRepository defines operations for managing subscription addons. type SubscriptionAddonRepository interface { Create(ctx context.Context, namespace string, input CreateSubscriptionAddonRepositoryInput) (*models.NamespacedID, error) Get(ctx context.Context, id models.NamespacedID) (*SubscriptionAddon, error) List(ctx context.Context, namespace string, filter ListSubscriptionAddonRepositoryInput) (pagination.PagedResponse[SubscriptionAddon], error) }openmeter/subscription/addon/repo/transaction.go (1)
16-17: Potential future optimization for read-only transactions.Currently, each
HijackTxcall setsReadOnly: false. If any of these methods will eventually need read-only functionality (e.g., certain queries that only fetch data), consider allowing a configurable read-only option to reduce overhead and enforce constraints at the database level.Also applies to: 37-38, 58-59
openmeter/ent/db/subscriptionaddonquantity_delete.go (1)
72-81: Concurrency consideration for "delete one" scenario.When calling
Execon a single entity, if another concurrent process deletes the same entity, users can receive aNotFoundError. This behavior is expected and standard for Ent. Just be aware that if high concurrency is expected, you might want additional locking or an idempotent approach to avoid unexpected user-facing errors.openmeter/subscription/addon/repo/mapping.go (2)
16-34: Ensure non-nil checks on the passed entity.
MapSubscriptionAddonassumesentityis non-nil, but there's no explicit guard. If the caller passes a nil pointer, this could cause a panic. Depending on your usage, consider adding a quick nil check to produce a more explicit error message.
73-104: Validate the existence of addon rate cards.Line 98 checks if
arc == niland returns an error. This is a good validation step that prevents mapping an invalid rate card. If desired, you can add more context to the error message for easier debugging (e.g., including theentity.IDorentity.AddonRatecardID).openmeter/subscription/addon/service/service.go (1)
49-141:Createmethod logic is generally sound.
- Validates incoming data.
- Retrieves the add-on and subscription to ensure consistency.
- Handles single-instance constraints correctly.
- Uses a transaction for an atomic creation of the add-on, rate cards, and initial quantity.
One optional improvement could be to explicitly check whether a single-instance add-on is already attached to the subscription if that’s a business constraint (e.g., preventing duplicates).
openmeter/ent/db/subscriptionaddonquantity.go (1)
16-59: SubscriptionAddonQuantity struct
Defines core entity fields. Consider adding domain checks (e.g., forbidding negative quantities) at the model or hook level.openmeter/ent/db/subscriptionaddonratecard.go (2)
105-169: Ensure assignment logic remains consistent with future schema updates
TheassignValuesmethod uses a series of type checks tied to specific columns. If the columns are altered or new columns added, the switch-case structure may not match them correctly. Consider adding tests or validations that catch mismatches between schema definitions and this assignment logic.
210-239: Consider excluding sensitive data in string representation
TheString()method prints out most fields, includingmetadata. Ifmetadatacan contain sensitive or personally identifiable information (PII), you may want to redact or exclude it from the string to avoid accidental logging or exposure.openmeter/ent/schema/subscription_addon.go (2)
72-77: Allow future adjustments to quantity if desired
quantityis marked.Immutable(), preventing updates from the application. If the business logic requires adjusting quantities later, consider removingImmutable()or providing an update path.
110-118: Consider partial uniqueness if you allow soft deletes
SubscriptionAddonRateCarddefines a unique index on(namespace, id). If you rely ondeleted_atfor soft deletes, consider making this a partial unique index conditioned ondeleted_at IS NULLso a record can be re-created without a hard-deletion of the old record.openmeter/ent/db/subscriptionaddonquantity_create.go (2)
162-183: Check default fields coverage in tests.The
defaults()method sets fallback values forCreatedAt,UpdatedAt,ActiveFrom,Quantity, andID. These defaults are crucial for consistency. Make sure your tests confirm that unstated fields are properly assigned their default values.
226-247: Enhance error context in critical path.In
sqlSave, a constraint error is wrapped but not further annotated with specific field details. If debugging collisions or constraint violations becomes challenging, consider adding more context (e.g., the conflicting field name) in the resulting error message.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (2)
70-74: Clarify edge case handling for emptysubscription_addon_rate_card_id.If an empty string is passed inadvertently, the validator might fail, which is correct. Consider providing a more descriptive error message or an earlier check to guide developers before an actual DB constraint triggers.
155-186: Consider specialized validation or domain checks.This
checkmethod covers missing fields and string validations. If your domain requires more nuanced checks (e.g., referencing unique relationships or field dependencies), you could extend or refine these validations to enforce domain rules at creation time.openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
36-41: Chain multiple predicates carefully.Appending predicates in the
Wheremethod is standard, but ensure that the combination of filters (AND/OR logic) is explicitly correct for your domain queries.
42-46: Verify large query pagination performance.
LimitandOffsetcan handle large results. Ensure your database or indexing strategy can manage large queries without significant performance impact or memory overhead.
269-280: Review existence check logic for concurrency.The
Existmethod uses aFirstIDcheck under the hood. In high-concurrency scenarios, records may appear or disappear between the existence check and subsequent operations. If your domain logic is sensitive to race conditions, consider adding transaction-level locks or re-validation after this method.openmeter/ent/db/subscriptionaddonquantity_query.go (3)
20-32: Ensure clarity in struct usage and doc comments.
TheSubscriptionAddonQuantityQuerystruct organizes query configuration and chaining logic. It might be helpful to add more descriptive doc comments for each field to guide future maintainers on customizing or extending these queries.
87-98: Consider additional logging for debugging.
When an entity is not found, theFirst()method simply returns aNotFoundError. Logging the query predicates or context when an entity is missing could aid debugging in production environments.
312-407: Potential large result set consideration.
ThesqlAll()function fetches all matching records. If theWHEREconditions are broad, this could return very large datasets. Consider introducing pagination or chunked retrieval where necessary for performance.openmeter/ent/db/subscriptionaddon_update.go (4)
20-25: Document the update builder usage.
SubscriptionAddonUpdateaggregates hooks, mutation logic, and final queries. Adding a clear doc comment at the struct level guides developers on how to chain calls (e.g., setting fields, clearing edges) before callingSave().
150-161: Maintain transaction integrity on update.
Save()andSaveX()handle the final DB update. If you plan to enforce multi-entity updates in an atomic transaction, ensure upstream code wraps these calls in a proper transaction context to avoid partial updates.
195-322: Check error messages for clarity.
ThesqlSavefunction conditionally transforms certainsqlgraph.NotFoundErroror constraint errors into custom typed errors. Be sure these error messages are detailed enough for users to diagnose issues without diving into database logs.
324-330: Reuse common logic in single-entity updates.
SubscriptionAddonUpdateOneclosely mirrors the multi-entity update builder. If there’s a shared set of validation or defaulting logic, consider factoring it to a common helper to reduce duplication.openmeter/ent/db/subscriptionaddon/where.go (1)
433-442: Caution with multi-to-one edge conditions.
HasSubscription()sets up an M2O check. This is appropriate. Keep in mind that combined with other AND or OR predicates, performance might degrade if no suitable indexes exist.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
tools/migrate/migrations/atlas.sumis excluded by!**/*.sum
📒 Files selected for processing (107)
openmeter/ent/db/addon.go(3 hunks)openmeter/ent/db/addon/addon.go(3 hunks)openmeter/ent/db/addon/where.go(1 hunks)openmeter/ent/db/addon_create.go(3 hunks)openmeter/ent/db/addon_query.go(7 hunks)openmeter/ent/db/addon_update.go(7 hunks)openmeter/ent/db/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/addonratecard.go(6 hunks)openmeter/ent/db/addonratecard/where.go(2 hunks)openmeter/ent/db/addonratecard_create.go(7 hunks)openmeter/ent/db/addonratecard_query.go(8 hunks)openmeter/ent/db/addonratecard_update.go(9 hunks)openmeter/ent/db/client.go(15 hunks)openmeter/ent/db/ent.go(2 hunks)openmeter/ent/db/expose.go(1 hunks)openmeter/ent/db/hook/hook.go(1 hunks)openmeter/ent/db/migrate/schema.go(3 hunks)openmeter/ent/db/paginate.go(1 hunks)openmeter/ent/db/planratecard.go(3 hunks)openmeter/ent/db/planratecard/planratecard.go(3 hunks)openmeter/ent/db/planratecard/where.go(1 hunks)openmeter/ent/db/planratecard_create.go(4 hunks)openmeter/ent/db/planratecard_update.go(2 hunks)openmeter/ent/db/predicate/predicate.go(1 hunks)openmeter/ent/db/runtime.go(4 hunks)openmeter/ent/db/setorclear.go(3 hunks)openmeter/ent/db/subscription.go(3 hunks)openmeter/ent/db/subscription/subscription.go(4 hunks)openmeter/ent/db/subscription/where.go(1 hunks)openmeter/ent/db/subscription_create.go(3 hunks)openmeter/ent/db/subscription_query.go(8 hunks)openmeter/ent/db/subscription_update.go(7 hunks)openmeter/ent/db/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go(1 hunks)openmeter/ent/db/subscriptionaddon/where.go(1 hunks)openmeter/ent/db/subscriptionaddon_create.go(1 hunks)openmeter/ent/db/subscriptionaddon_delete.go(1 hunks)openmeter/ent/db/subscriptionaddon_query.go(1 hunks)openmeter/ent/db/subscriptionaddon_update.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity/where.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_create.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_query.go(1 hunks)openmeter/ent/db/subscriptionaddonquantity_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecard_update.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_create.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go(1 hunks)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go(1 hunks)openmeter/ent/db/subscriptionitem.go(3 hunks)openmeter/ent/db/subscriptionitem/subscriptionitem.go(4 hunks)openmeter/ent/db/subscriptionitem/where.go(1 hunks)openmeter/ent/db/subscriptionitem_create.go(3 hunks)openmeter/ent/db/subscriptionitem_query.go(7 hunks)openmeter/ent/db/subscriptionitem_update.go(7 hunks)openmeter/ent/db/tx.go(2 hunks)openmeter/ent/schema/addon.go(3 hunks)openmeter/ent/schema/productcatalog.go(1 hunks)openmeter/ent/schema/ratecard.go(1 hunks)openmeter/ent/schema/subscription.go(3 hunks)openmeter/ent/schema/subscription_addon.go(1 hunks)openmeter/productcatalog/addon/adapter/addon.go(4 hunks)openmeter/productcatalog/addon/adapter/mapping.go(3 hunks)openmeter/productcatalog/subscription/service/change_test.go(4 hunks)openmeter/productcatalog/subscription/service/migrate_test.go(4 hunks)openmeter/productcatalog/subscription/service/plan_test.go(3 hunks)openmeter/subscription/addon/README.md(1 hunks)openmeter/subscription/addon/addon.go(1 hunks)openmeter/subscription/addon/addonratecard.go(1 hunks)openmeter/subscription/addon/quantity.go(1 hunks)openmeter/subscription/addon/repo/mapping.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddon.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonquantity.go(1 hunks)openmeter/subscription/addon/repo/subscriptionaddonratecard.go(1 hunks)openmeter/subscription/addon/repo/transaction.go(1 hunks)openmeter/subscription/addon/repository.go(1 hunks)openmeter/subscription/addon/service.go(1 hunks)openmeter/subscription/addon/service/change_test.go(1 hunks)openmeter/subscription/addon/service/create_test.go(1 hunks)openmeter/subscription/addon/service/list_test.go(1 hunks)openmeter/subscription/addon/service/service.go(1 hunks)openmeter/subscription/patch/removeitem_test.go(1 hunks)openmeter/subscription/service/service_test.go(8 hunks)openmeter/subscription/service/sync_test.go(2 hunks)openmeter/subscription/testutils/addon.go(1 hunks)openmeter/subscription/testutils/compare.go(2 hunks)openmeter/subscription/testutils/feature.go(3 hunks)openmeter/subscription/testutils/plan.go(2 hunks)openmeter/subscription/testutils/ratecard.go(4 hunks)openmeter/subscription/testutils/service.go(3 hunks)openmeter/subscription/workflow/service/subscription_test.go(16 hunks)pkg/framework/entutils/mapping.go(1 hunks)test/customer/testenv.go(2 hunks)test/subscription/framework_test.go(2 hunks)tools/migrate/migrations/20250409142535_subscriptionaddon.down.sql(1 hunks)tools/migrate/migrations/20250409142535_subscriptionaddon.up.sql(1 hunks)
✅ Files skipped from review due to trivial changes (2)
- tools/migrate/migrations/20250409142535_subscriptionaddon.down.sql
- openmeter/ent/db/subscriptionaddonratecard/where.go
🚧 Files skipped from review as they are similar to previous changes (41)
- openmeter/subscription/testutils/plan.go
- openmeter/subscription/service/service_test.go
- openmeter/subscription/patch/removeitem_test.go
- openmeter/subscription/addon/README.md
- openmeter/productcatalog/addon/adapter/addon.go
- openmeter/ent/db/expose.go
- openmeter/subscription/addon/addonratecard.go
- openmeter/ent/db/addon/where.go
- openmeter/productcatalog/subscription/service/change_test.go
- test/customer/testenv.go
- test/subscription/framework_test.go
- openmeter/productcatalog/addon/adapter/mapping.go
- openmeter/productcatalog/subscription/service/migrate_test.go
- openmeter/subscription/addon/service/list_test.go
- pkg/framework/entutils/mapping.go
- openmeter/ent/db/addon_query.go
- openmeter/ent/db/addon.go
- openmeter/ent/db/subscription/subscription.go
- openmeter/ent/schema/subscription.go
- openmeter/subscription/addon/repo/subscriptionaddonquantity.go
- openmeter/subscription/service/sync_test.go
- openmeter/ent/db/subscriptionitem.go
- openmeter/productcatalog/subscription/service/plan_test.go
- openmeter/ent/db/ent.go
- openmeter/ent/db/addonratecard.go
- openmeter/ent/db/predicate/predicate.go
- openmeter/ent/db/subscription_create.go
- openmeter/ent/db/subscriptionaddonratecard_delete.go
- openmeter/ent/db/subscriptionitem_query.go
- openmeter/ent/schema/ratecard.go
- openmeter/ent/db/planratecard_update.go
- openmeter/ent/db/subscriptionitem/subscriptionitem.go
- openmeter/ent/db/subscriptionaddonratecarditemlink_delete.go
- openmeter/subscription/addon/quantity.go
- openmeter/ent/db/addon_update.go
- openmeter/ent/db/hook/hook.go
- openmeter/ent/db/addonratecard_create.go
- openmeter/ent/db/subscriptionaddon.go
- openmeter/ent/db/subscriptionaddonratecarditemlink.go
- openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go
- openmeter/ent/db/subscriptionaddon_query.go
🧰 Additional context used
🧠 Learnings (1)
openmeter/subscription/addon/service/change_test.go (1)
Learnt from: GAlexIHU
PR: openmeterio/openmeter#2626
File: openmeter/subscription/addon/service/change_test.go:23-92
Timestamp: 2025-04-08T11:02:14.464Z
Learning: The ChangeQuantity method in the subscription addon service allows setting ActiveFrom to a time in the past. No validation is needed to check if ActiveFrom is in the past.
🧬 Code Graph Analysis (54)
openmeter/subscription/workflow/service/subscription_test.go (8)
openmeter/subscription/testutils/service.go (1)
NewService(54-179)openmeter/productcatalog/feature/connector.go (1)
FeatureConnector(27-34)openmeter/subscription/testutils/db.go (1)
DBDeps(15-19)openmeter/subscription/testutils/plan.go (1)
GetExamplePlanInput(20-72)openmeter/customer/adapter.go (1)
CustomerAdapter(16-23)openmeter/subscription/workflow/service.go (2)
CreateSubscriptionWorkflowInput(17-21)Service(10-15)openmeter/subscription/addon/service.go (1)
Service(11-17)openmeter/subscription/service.go (1)
Service(10-31)
openmeter/ent/db/subscription/where.go (4)
openmeter/ent/db/predicate/predicate.go (2)
Subscription(216-216)SubscriptionAddon(219-219)openmeter/ent/db/subscription.go (2)
Subscription(20-54)Subscription(123-140)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/subscription/testutils/feature.go (2)
openmeter/productcatalog/feature/connector.go (2)
CreateFeatureInputs(17-24)FeatureConnector(27-34)openmeter/subscription/testutils/global.go (1)
ExampleNamespace(5-5)
openmeter/subscription/testutils/addon.go (6)
openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey(13-13)openmeter/subscription/testutils/global.go (2)
ISOMonth(7-7)ExampleNamespace(5-5)openmeter/productcatalog/effectiveperiod.go (1)
EffectivePeriod(18-24)openmeter/productcatalog/addon/service.go (1)
CreateAddonInput(98-101)pkg/models/model.go (1)
NamespacedModel(155-157)openmeter/productcatalog/addon.go (1)
AddonMeta(37-63)
openmeter/ent/db/addon_create.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/subscription/addon/addon.go (7)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)pkg/timeutil/timeline.go (1)
Timeline(42-44)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscription_query.go (3)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscription.go (2)
Subscription(20-54)Subscription(123-140)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/addon/addon.go (2)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Table(40-40)openmeter/ent/db/migrate/schema.go (1)
SubscriptionAddonsTable(1882-1912)
openmeter/ent/db/subscriptionitem_create.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)FieldID(18-18)
openmeter/ent/db/runtime.go (6)
openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
AddonIDValidator(103-103)SubscriptionIDValidator(105-105)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (4)
DefaultActiveFrom(76-76)DefaultQuantity(78-78)QuantityValidator(80-80)SubscriptionAddonIDValidator(82-82)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
SubscriptionAddonIDValidator(94-94)AddonRatecardIDValidator(96-96)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)
openmeter/ent/db/subscriptionitem/where.go (3)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionItem(231-231)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)FieldID(18-18)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)
openmeter/ent/db/tx.go (5)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/client.go (4)
SubscriptionAddonClient(6216-6218)SubscriptionAddonQuantityClient(6413-6415)SubscriptionAddonRateCardClient(6562-6564)SubscriptionAddonRateCardItemLinkClient(6743-6745)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/planratecard/where.go (2)
openmeter/ent/db/planratecard.go (2)
PlanRateCard(21-63)PlanRateCard(99-122)openmeter/ent/db/planratecard/planratecard.go (1)
FieldDiscounts(49-49)
openmeter/subscription/addon/repo/transaction.go (7)
openmeter/ent/db/tx.go (1)
Tx(15-104)openmeter/ent/db/client.go (2)
Driver(250-254)Client(63-147)pkg/framework/entutils/transaction.go (2)
NewTxDriver(47-52)TxDriver(76-88)openmeter/ent/db/expose.go (1)
NewTxClientFromRawConfig(78-172)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)
openmeter/subscription/addon/service.go (2)
openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
openmeter/subscription/addon/service/change_test.go (5)
openmeter/testutils/time.go (1)
GetRFC3339Time(10-17)openmeter/subscription/testutils/service.go (1)
SubscriptionDependencies(38-52)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (1)
GenericValidationError(145-147)
openmeter/subscription/addon/service/service.go (11)
openmeter/subscription/addon/repository.go (7)
SubscriptionAddonRepository(28-32)SubscriptionAddonRateCardRepository(41-43)SubscriptionAddonQuantityRepository(51-53)CreateSubscriptionAddonRepositoryInput(12-20)CreateSubscriptionAddonRateCardRepositoryInput(35-39)CreateSubscriptionAddonQuantityRepositoryInput(46-49)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/transaction/transaction.go (2)
Creator(18-20)Run(31-49)openmeter/subscription/addon/service.go (2)
Service(11-17)ListSubscriptionAddonsInput(19-23)openmeter/subscription/addon/addon.go (2)
CreateSubscriptionAddonInput(28-36)SubscriptionAddon(12-26)openmeter/productcatalog/addon/service.go (1)
GetAddonInput(211-224)pkg/models/error.go (2)
NewGenericValidationError(138-140)NewGenericConflictError(68-70)openmeter/subscription/subscriptionview.go (2)
SubscriptionPhaseView(71-75)SubscriptionItemView(99-105)pkg/models/metadata.go (1)
MetadataModel(26-28)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
openmeter/subscription/testutils/service.go (7)
openmeter/subscription/workflow/service.go (1)
Service(10-15)openmeter/subscription/addon/service/service.go (2)
NewService(41-47)Config(21-33)openmeter/subscription/service/service.go (1)
New(37-41)openmeter/subscription/addon/repo/subscriptionaddon.go (1)
NewSubscriptionAddonRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonratecard.go (1)
NewSubscriptionAddonRateCardRepo(23-27)openmeter/subscription/addon/repo/subscriptionaddonquantity.go (1)
NewSubscriptionAddonQuantityRepo(18-22)openmeter/subscription/testutils/addon.go (1)
NewTestAddonService(57-59)
openmeter/subscription/addon/repository.go (7)
pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/addonratecard_query.go (2)
openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)
openmeter/ent/db/subscriptionaddonquantity_delete.go (4)
openmeter/ent/db/ent.go (3)
IsConstraintError(361-367)ConstraintError(345-348)NotFoundError(278-280)openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42776-42794)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (3)
Table(34-34)FieldID(16-16)Label(14-14)
openmeter/ent/db/subscriptionaddon_delete.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41811-41835)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddon(219-219)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)FieldID(16-16)Label(14-14)
openmeter/ent/db/addonratecard/where.go (4)
openmeter/ent/db/predicate/predicate.go (2)
AddonRateCard(24-24)SubscriptionAddonRateCard(225-225)openmeter/ent/db/addonratecard/addonratecard.go (2)
FieldDiscounts(49-49)Table(61-61)openmeter/ent/db/subscriptionitem/subscriptionitem.go (2)
FieldDiscounts(60-60)Table(70-70)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (1)
Table(38-38)
openmeter/subscription/addon/repo/mapping.go (11)
openmeter/subscription/addon/addon.go (1)
SubscriptionAddon(12-26)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)pkg/models/model.go (1)
ManagedModel(107-113)pkg/models/metadata.go (1)
MetadataModel(26-28)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)pkg/timeutil/timeline.go (2)
NewTimeline(46-55)Timed(29-32)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)pkg/slicesx/map.go (1)
MapWithErr(23-47)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)
openmeter/subscription/addon/repo/subscriptionaddon.go (3)
openmeter/subscription/addon/repository.go (3)
SubscriptionAddonRepository(28-32)CreateSubscriptionAddonRepositoryInput(12-20)ListSubscriptionAddonRepositoryInput(22-26)pkg/framework/entutils/transaction.go (1)
TransactingRepo(199-221)openmeter/subscription/addon/repo/mapping.go (1)
MapSubscriptionAddon(17-64)
openmeter/subscription/testutils/ratecard.go (4)
openmeter/productcatalog/ratecard.go (3)
UsageBasedRateCard(315-321)FlatFeeRateCard(211-218)RateCardMeta(48-79)openmeter/subscription/testutils/global.go (1)
ISOMonth(7-7)openmeter/subscription/testutils/feature.go (1)
ExampleFeatureKey2(14-14)openmeter/productcatalog/price.go (1)
NewPriceFrom(342-364)
openmeter/ent/db/subscription_update.go (2)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (3)
Table(40-40)Columns(72-81)FieldID(16-16)
openmeter/ent/db/paginate.go (7)
openmeter/ent/db/subscriptionaddon_query.go (1)
SubscriptionAddonQuery(25-39)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonquantity_query.go (1)
SubscriptionAddonQuantityQuery(21-32)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonratecard_query.go (1)
SubscriptionAddonRateCardQuery(24-37)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (1)
SubscriptionAddonRateCardItemLinkQuery(22-34)
openmeter/ent/db/subscriptionitem_update.go (2)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionitem/subscriptionitem.go (4)
Table(70-70)SubscriptionAddonRateCardItemsTable(93-93)SubscriptionAddonRateCardItemsColumn(98-98)FieldID(18-18)
openmeter/subscription/addon/service/create_test.go (3)
openmeter/subscription/addon/addon.go (1)
CreateSubscriptionAddonInput(28-36)openmeter/subscription/addon/addonratecard.go (1)
CreateSubscriptionAddonRateCardInput(17-21)openmeter/subscription/addon/quantity.go (1)
CreateSubscriptionAddonQuantityInput(25-28)
openmeter/ent/db/addonratecard/addonratecard.go (2)
openmeter/ent/db/subscriptionitem/subscriptionitem.go (5)
FieldDiscounts(60-60)ByDiscounts(267-269)OrderOption(164-164)Table(70-70)FieldID(18-18)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
OrderOption(102-102)Table(38-38)FieldID(16-16)
openmeter/ent/db/subscriptionaddonquantity.go (5)
openmeter/ent/db/subscriptionaddonquantity/where.go (8)
ID(14-16)Namespace(69-71)CreatedAt(74-76)UpdatedAt(79-81)DeletedAt(84-86)ActiveFrom(89-91)Quantity(94-96)SubscriptionAddonID(99-101)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (9)
Label(14-14)FieldQuantity(28-28)FieldID(16-16)FieldNamespace(18-18)FieldSubscriptionAddonID(30-30)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)openmeter/ent/db/client.go (1)
NewSubscriptionAddonQuantityClient(6418-6420)openmeter/ent/db/subscriptionaddonquantity_update.go (1)
SubscriptionAddonQuantityUpdateOne(140-145)
openmeter/ent/db/subscriptionaddonratecard.go (4)
openmeter/ent/db/ent.go (3)
NotFoundError(278-280)NotLoadedError(324-326)Value(64-64)openmeter/ent/db/addonratecard/addonratecard.go (1)
Label(17-17)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (1)
Label(14-14)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (1)
Label(14-14)
openmeter/ent/db/addonratecard_update.go (5)
openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
ID(14-16)openmeter/ent/db/addonratecard/addonratecard.go (4)
Table(61-61)SubscriptionAddonRateCardsTable(77-77)SubscriptionAddonRateCardsColumn(82-82)FieldID(19-19)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
Table(38-38)FieldID(16-16)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
Table(32-32)FieldID(16-16)
openmeter/ent/schema/subscription_addon.go (7)
openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/subscription/addon/addonratecard.go (1)
SubscriptionAddonRateCard(8-15)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/subscription/addon/quantity.go (1)
SubscriptionAddonQuantity(11-17)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/addon.go (2)
Addon(18-54)Addon(86-105)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
openmeter/ent/db/addon/addon.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(90-97)Columns(71-87)ByID(140-142)OrderOption(137-137)ByNamespace(145-147)ByCreatedAt(150-152)ByUpdatedAt(155-157)ByDeletedAt(160-162)openmeter/ent/db/addonratecard/addonratecard.go (13)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscription/subscription.go (15)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(28-28)ValidColumn(111-118)Columns(93-108)ByID(147-149)OrderOption(144-144)ByNamespace(152-154)ByCreatedAt(157-159)ByUpdatedAt(162-164)ByDeletedAt(167-169)ByActiveFrom(172-174)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (13)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (16)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)ValidColumn(75-82)Columns(63-72)ByID(105-107)OrderOption(102-102)ByNamespace(110-112)ByCreatedAt(115-117)ByUpdatedAt(120-122)ByDeletedAt(125-127)BySubscriptionAddonID(130-132)BySubscriptionAddonField(140-144)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)openmeter/ent/db/subscriptionitem/subscriptionitem.go (15)
FieldID(18-18)FieldNamespace(20-20)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldActiveFrom(30-30)ValidColumn(128-135)Columns(102-125)ByID(167-169)OrderOption(164-164)ByNamespace(172-174)ByCreatedAt(177-179)ByUpdatedAt(182-184)ByDeletedAt(187-189)ByActiveFrom(192-194)
openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonRateCardItemLinkMutation(44426-44442)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)
openmeter/ent/db/subscriptionaddonratecard_update.go (5)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonRateCard(225-225)SubscriptionAddonRateCardItemLink(228-228)openmeter/ent/db/subscriptionaddonratecard/where.go (3)
ID(14-16)UpdatedAt(79-81)DeletedAt(84-86)openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (3)
ID(14-16)UpdatedAt(74-76)DeletedAt(79-81)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (3)
FieldID(16-16)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (3)
FieldID(16-16)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddonquantity_update.go (3)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonQuantityMutation(42776-42794)openmeter/ent/db/predicate/predicate.go (1)
SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/migrate/schema.go (3)
openmeter/ent/db/subscription/subscription.go (2)
Table(54-54)AddonsTable(84-84)openmeter/ent/db/subscriptionitem/subscriptionitem.go (1)
Table(70-70)openmeter/ent/db/addonratecard/addonratecard.go (1)
SubscriptionAddonRateCardsTable(77-77)
openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
openmeter/ent/db/addonratecard/addonratecard.go (14)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)ValidColumn(108-115)Columns(86-105)ByID(155-157)OrderOption(152-152)ByNamespace(160-162)ByCreatedAt(165-167)ByUpdatedAt(170-172)ByDeletedAt(175-177)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (14)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)ValidColumn(84-91)Columns(72-81)ByID(114-116)OrderOption(111-111)ByNamespace(119-121)ByCreatedAt(124-126)ByUpdatedAt(129-131)ByDeletedAt(134-136)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (16)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(30-30)ValidColumn(57-64)Columns(45-54)ByID(91-93)OrderOption(88-88)ByNamespace(96-98)ByCreatedAt(101-103)ByUpdatedAt(106-108)ByDeletedAt(111-113)BySubscriptionAddonID(126-128)BySubscriptionAddonField(131-135)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)ValidColumn(60-67)Columns(50-57)ByID(88-90)OrderOption(85-85)ByCreatedAt(93-95)ByUpdatedAt(98-100)ByDeletedAt(103-105)
openmeter/ent/db/subscriptionaddonratecard_query.go (5)
openmeter/ent/db/predicate/predicate.go (4)
SubscriptionAddonRateCard(225-225)SubscriptionAddon(219-219)SubscriptionAddonRateCardItemLink(228-228)AddonRateCard(24-24)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/addonratecard.go (2)
AddonRateCard(21-63)AddonRateCard(110-133)
openmeter/ent/db/subscriptionaddonquantity_create.go (1)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (20)
DefaultCreatedAt(70-70)DefaultUpdatedAt(72-72)DefaultActiveFrom(76-76)DefaultQuantity(78-78)DefaultID(84-84)NamespaceValidator(68-68)QuantityValidator(80-80)SubscriptionAddonIDValidator(82-82)Table(34-34)FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)SubscriptionAddonTable(36-36)Columns(45-54)SubscriptionAddonColumn(41-41)FieldSubscriptionAddonID(30-30)
openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (6)
ID(14-16)CreatedAt(69-71)UpdatedAt(74-76)SubscriptionAddonRateCardID(84-86)SubscriptionItemID(89-91)DeletedAt(79-81)openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (8)
SubscriptionAddonRateCardIDValidator(77-77)SubscriptionItemIDValidator(79-79)FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)
openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (3)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionitem.go (2)
SubscriptionItem(21-71)SubscriptionItem(129-154)
openmeter/ent/db/setorclear.go (7)
openmeter/ent/db/addonratecard_update.go (2)
AddonRateCardUpdate(24-28)AddonRateCardUpdateOne(575-580)openmeter/productcatalog/discount.go (1)
Discounts(346-346)openmeter/ent/db/planratecard_update.go (2)
PlanRateCardUpdate(23-27)PlanRateCardUpdateOne(493-498)openmeter/ent/db/subscriptionaddon_update.go (2)
SubscriptionAddonUpdate(21-25)SubscriptionAddonUpdateOne(325-330)openmeter/ent/db/subscriptionaddonquantity_update.go (2)
SubscriptionAddonQuantityUpdate(19-23)SubscriptionAddonQuantityUpdateOne(140-145)openmeter/ent/db/subscriptionaddonratecard_update.go (2)
SubscriptionAddonRateCardUpdate(20-24)SubscriptionAddonRateCardUpdateOne(243-248)openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (2)
SubscriptionAddonRateCardItemLinkUpdate(19-23)SubscriptionAddonRateCardItemLinkUpdateOne(143-148)
openmeter/ent/db/subscriptionaddon_update.go (5)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41811-41835)openmeter/ent/db/predicate/predicate.go (3)
SubscriptionAddon(219-219)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)
openmeter/ent/db/subscriptionaddon/where.go (4)
openmeter/ent/db/predicate/predicate.go (5)
SubscriptionAddon(219-219)Subscription(216-216)SubscriptionAddonRateCard(225-225)SubscriptionAddonQuantity(222-222)Addon(10-10)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (17)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldAddonID(28-28)FieldSubscriptionID(30-30)FieldMetadata(20-20)Table(40-40)SubscriptionTable(42-42)SubscriptionColumn(47-47)RateCardsTable(49-49)RateCardsColumn(54-54)QuantitiesTable(56-56)QuantitiesColumn(61-61)AddonTable(63-63)AddonColumn(68-68)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (6)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)Table(34-34)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (7)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)Table(38-38)
openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (11)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)FieldSubscriptionAddonRateCardID(24-24)FieldSubscriptionItemID(26-26)Table(32-32)SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)SubscriptionItemTable(41-41)SubscriptionItemColumn(46-46)
openmeter/ent/db/subscriptionaddonquantity_query.go (3)
openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (9)
OrderOption(88-88)Table(34-34)FieldID(16-16)SubscriptionAddonTable(36-36)SubscriptionAddonColumn(41-41)Label(14-14)ValidColumn(57-64)Columns(45-54)FieldSubscriptionAddonID(30-30)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddonquantity/where.go (3)
SubscriptionAddonID(99-101)IDIn(29-31)ID(14-16)
openmeter/ent/db/subscriptionaddonquantity/where.go (5)
openmeter/ent/db/predicate/predicate.go (2)
SubscriptionAddonQuantity(222-222)SubscriptionAddon(219-219)openmeter/ent/schema/subscription_addon.go (9)
SubscriptionAddonQuantity(60-62)SubscriptionAddonQuantity(64-70)SubscriptionAddonQuantity(72-78)SubscriptionAddonQuantity(80-84)SubscriptionAddonQuantity(86-95)SubscriptionAddon(15-17)SubscriptionAddon(19-26)SubscriptionAddon(28-33)SubscriptionAddon(35-58)openmeter/ent/db/addon/addon.go (6)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)Table(53-53)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (9)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldActiveFrom(26-26)FieldQuantity(28-28)FieldSubscriptionAddonID(30-30)Table(34-34)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (7)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldSubscriptionAddonID(28-28)Table(38-38)
openmeter/ent/db/subscriptionaddonratecard_create.go (4)
openmeter/ent/db/addonratecard/addonratecard.go (6)
FieldID(19-19)FieldNamespace(21-21)FieldCreatedAt(25-25)FieldUpdatedAt(27-27)FieldDeletedAt(29-29)FieldMetadata(23-23)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (6)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(22-22)FieldUpdatedAt(24-24)FieldDeletedAt(26-26)FieldMetadata(20-20)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (8)
FieldID(16-16)FieldNamespace(18-18)FieldCreatedAt(20-20)FieldUpdatedAt(22-22)FieldDeletedAt(24-24)FieldMetadata(26-26)FieldSubscriptionAddonID(28-28)FieldAddonRatecardID(30-30)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (4)
FieldID(16-16)FieldCreatedAt(18-18)FieldUpdatedAt(20-20)FieldDeletedAt(22-22)
openmeter/ent/db/subscriptionaddon_create.go (4)
openmeter/ent/db/mutation.go (1)
SubscriptionAddonMutation(41811-41835)openmeter/ent/db/subscriptionaddonratecard.go (2)
SubscriptionAddonRateCard(19-41)SubscriptionAddonRateCard(88-103)openmeter/ent/db/subscriptionaddonquantity.go (2)
SubscriptionAddonQuantity(17-39)SubscriptionAddonQuantity(62-77)openmeter/ent/db/subscriptionaddon.go (2)
SubscriptionAddon(19-41)SubscriptionAddon(99-114)
openmeter/ent/db/client.go (5)
openmeter/ent/db/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardItemLink(18-36)SubscriptionAddonRateCardItemLink(72-85)openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (8)
SubscriptionTable(42-42)SubscriptionColumn(47-47)RateCardsTable(49-49)RateCardsColumn(54-54)QuantitiesTable(56-56)QuantitiesColumn(61-61)AddonTable(63-63)AddonColumn(68-68)openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (2)
SubscriptionAddonTable(36-36)SubscriptionAddonColumn(41-41)openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (2)
SubscriptionAddonTable(40-40)SubscriptionAddonColumn(45-45)openmeter/ent/db/subscriptionaddonratecarditemlink/subscriptionaddonratecarditemlink.go (2)
SubscriptionAddonRateCardTable(34-34)SubscriptionAddonRateCardColumn(39-39)
⏰ Context from checks skipped due to timeout of 90000ms (4)
- GitHub Check: E2E
- GitHub Check: Developer environment
- GitHub Check: CI
- GitHub Check: Analyze (go)
🔇 Additional comments (236)
openmeter/ent/db/planratecard/where.go (2)
765-773: Properly implemented null-checking predicates for the 'discounts' field.These new functions provide a consistent way to check if the
discountsfield is null or not null, following the same pattern used for other nullable fields in this file. This is good for query flexibility when working with thePlanRateCardentity in the subscription add-ons feature.
774-974: Missing edge predicates for subscription addon rate cards.According to the PR summary, this file should also include two new functions:
HasSubscriptionAddonRateCards()andHasSubscriptionAddonRateCardsWith()to facilitate edge predicates related to "subscription_addon_rate_cards". These functions don't appear in the visible changes. Please verify that these functions are added elsewhere or add them to establish the necessary relationship between plan rate cards and subscription addon rate cards.If these functions are indeed missing, they should follow the pattern of other edge predicates in this file (like
HasPhase()andHasFeaturesWith()):// HasSubscriptionAddonRateCards applies the HasEdge predicate on the "subscription_addon_rate_cards" edge. func HasSubscriptionAddonRateCards() predicate.PlanRateCard { return predicate.PlanRateCard(func(s *sql.Selector) { step := sqlgraph.NewStep( sqlgraph.From(Table, FieldID), sqlgraph.Edge(sqlgraph.O2M, false, SubscriptionAddonRateCardsTable, SubscriptionAddonRateCardsColumn), ) sqlgraph.HasNeighbors(s, step) }) } // HasSubscriptionAddonRateCardsWith applies the HasEdge predicate on the "subscription_addon_rate_cards" edge with given conditions. func HasSubscriptionAddonRateCardsWith(preds ...predicate.SubscriptionAddonRateCard) predicate.PlanRateCard { return predicate.PlanRateCard(func(s *sql.Selector) { step := newSubscriptionAddonRateCardsStep() sqlgraph.HasNeighborsWith(s, step, func(s *sql.Selector) { for _, p := range preds { p(s) } }) }) }openmeter/subscription/workflow/service/subscription_test.go (7)
75-76: Function call simplification looks good.The refactoring of the test dependency setup looks cleaner. This change reflects the updated
NewServicefunction signature that now returns a singleSubscriptionDependenciesstruct instead of multiple values.
271-272: Consistent test setup pattern improves readability.The consistent pattern of retrieving dependencies with
NewServiceand then setting up the feature examples withCreateExampleFeaturesmakes the test setup more maintainable.
293-294: Simplified service references.Accessing services through the deps struct (
deps.SubscriptionServiceanddeps.WorkflowService) instead of a separate services variable improves code clarity and reduces the number of variables needed in the test.
464-465: Consistent naming convention across tests.The method name change from
CreateExampleFeaturetoCreateExampleFeaturessuggests creating multiple features at once, which is more appropriate for comprehensive testing scenarios.
707-708: Validates addon service integration.This test setup pattern is now consistently applied across all test cases, which is important as it creates the necessary dependencies for the new subscription addon service functionality being introduced in this PR.
862-863: Clean and efficient test dependency setup.The consistent dependency setup pattern across test functions demonstrates good test design principles - keeping setup logic centralized and reducing duplication.
1091-1092: Maintains backward compatibility.The refactoring successfully maintains existing test functionality while adapting to the new subscription addon service structure, ensuring tests remain valid with the new implementation.
openmeter/ent/schema/productcatalog.go (1)
132-140: Phase_id and feature_id fields properly align with edge definitionsThe added fields properly correspond to the edges defined in the
Edges()method (lines 145-157). Thephase_idis marked as required which matches theRequired()constraint on the corresponding edge, andfeature_idis optional which aligns with its edge definition.This maintains schema consistency between fields and relationships.
openmeter/ent/db/planratecard/planratecard.go (5)
48-49: Discounts field addition looks correct.The addition of the
FieldDiscountsconstant follows the same pattern as other field constants. According to the AI summary, this field was previously removed and is now being added back.
93-93: Discounts field correctly added to Columns slice.The
FieldDiscountsis properly added to theColumnsslice, ensuring it's included in database operations.
215-218: ByDiscounts function implementation looks correct.The
ByDiscountsfunction is implemented consistently with other ordering functions, using thesql.OrderByFieldmethod with the appropriate field constant.
1-1:Details
✅ Verification successful
Generated file warning: Ensure schema changes are made in source files.
This file is marked as generated by ent with a warning not to edit directly. The changes should be made to the schema definition files and then regenerated using the ent framework, rather than manually editing this file.
🏁 Script executed:
#!/bin/bash # Check for ent schema files that might define this entity echo "Looking for schema definition files..." find . -path "*/schema/*" -name "*.go" | grep -i "plan\|rate\|card"Length of output: 191
Do Not Edit This Generated File – Apply Schema Changes Instead
This file is auto-generated by the ent framework, as indicated by the header comment. Any modifications should be made in the source schema files rather than directly in this file. In this case, update the schema defined inopenmeter/ent/schema/ratecard.goand regenerate, instead of modifyingopenmeter/ent/db/planratecard/planratecard.go.
128-128:Details
❓ Verification inconclusive
Verify that Discounts ValueScanner is properly used.
I notice the
Discountsfield already exists in theValueScannerstruct, suggesting it was expected to exist in the schema. Ensure that this field is properly utilized in any code that reads/writes this entity.
🏁 Script executed:
#!/bin/bash # Check for usages of the Discounts field in assignValues method echo "Looking for assignValues method that should use the Discounts field..." grep -r "func (prc \*PlanRateCard) assignValues" --include="*.go" .Length of output: 333
Action Required: Confirm Discounts Field Usage in assignValues
The
Discountsfield is declared as afield.TypeValueScanner[*productcatalog.Discounts], and the correspondingassignValuesmethod is present inopenmeter/ent/db/planratecard/planratecard.go. However, it's not immediately clear from a grep of the method that this field is explicitly referenced during value assignment.
- Verify that the
assignValuesmethod (or any similar routines handling entity data) properly maps theDiscountsfield from the database schema.- If the mapping for
Discountsis intended to be handled implicitly (e.g., via reflective or automated assignments), kindly add a comment or test case that confirms its correct operation.Please take a closer look to ensure that both read and write operations fully incorporate this field.
openmeter/subscription/testutils/feature.go (2)
12-16: LGTM: Clean variable grouping and naming.The grouping of related variables and clear naming with sequential identifiers (test-feature-1, test-feature-2) follows good practices for test utils.
25-30: LGTM: Well-structured test fixture.The new ExampleFeature2 follows the same pattern as the existing test fixture, maintaining consistency in your test utilities.
openmeter/ent/db/setorclear.go (7)
2340-2366: Note the swapped functionality between SetOrClearDiscounts and SetOrClearFeatureID methodsSimilar to the AddonRateCardUpdate structs, the functionality of these methods has been swapped for PlanRateCardUpdate structs:
- SetOrClearDiscounts now handles discounts (previously handled feature IDs)
- SetOrClearFeatureID now handles feature IDs (previously handled discounts)
This change appears intentional but ensure dependent code has been updated accordingly.
2438-2450: Good addition of metadata handling for subscription addonsThese new methods properly implement the SetOrClearMetadata pattern for SubscriptionAddonUpdate and SubscriptionAddonUpdateOne structs, following the established pattern in the codebase.
2452-2464: Good implementation of timestamp handling for subscription addonsThe new SetOrClearDeletedAt methods provide soft-delete functionality for subscription addons, maintaining consistency with the pattern used throughout the codebase.
2466-2478: Good implementation of timestamp handling for subscription addon quantitiesThe new SetOrClearDeletedAt methods maintain consistent implementation of soft-delete functionality for subscription addon quantities.
2480-2506: Good implementation of metadata and timestamp handling for subscription addon rate cardsThe added methods correctly implement:
- SetOrClearDeletedAt for soft-delete functionality
- SetOrClearMetadata for consistent metadata management
Both follow the established pattern in the codebase.
2508-2520: Good implementation of timestamp handling for subscription addon rate card item linksThe new SetOrClearDeletedAt methods provide soft-delete functionality for subscription addon rate card item links, maintaining consistency with the pattern used throughout the codebase.
212-238:Details
❓ Verification inconclusive
Note the swapped functionality between SetOrClearDiscounts and SetOrClearFeatureID methods
The functionality of these methods has been swapped for the AddonRateCardUpdate structs:
- SetOrClearDiscounts now handles discounts (previously handled feature IDs)
- SetOrClearFeatureID now handles feature IDs (previously handled discounts)
This change appears intentional but ensure dependent code has been updated accordingly.
🏁 Script executed:
#!/bin/bash # Check for calls to these methods in the codebase to verify they've been updated echo "Checking for calls to SetOrClearDiscounts and SetOrClearFeatureID methods:" rg -A 1 "SetOrClearDiscounts|SetOrClearFeatureID" --type goLength of output: 2085
Attention: Verify Dependent Code for Swapped Functionality
The methods for handling discounts and feature IDs in
openmeter/ent/db/setorclear.gonow clearly reflect the intended swap:
SetOrClearDiscountsnow deals with discounts (callingClearDiscounts/SetDiscounts),SetOrClearFeatureIDnow deals with feature IDs (callingClearFeatureID/SetFeatureID).This updated behavior is applied for both the
AddonRateCardUpdate(and itsOnevariant) as well as the analogous methods forPlanRateCardUpdateandSubscriptionItemUpdate. Although the verification script only surfaced the method definitions, please ensure that all dependent or caller code has been updated to accommodate this intentional swap.openmeter/ent/db/subscriptionaddon/subscriptionaddon.go (2)
1-2: Auto-generated code disclaimer is appropriate.These lines indicate that the file is generated by Ent. Direct manual modifications in this section should be avoided to prevent overwriting.
93-95:Details
✅ Verification successful
Ensure
NamespaceValidatoris being utilized effectively.The
NamespaceValidatorhook exists but is not defined here. Confirm that it is properly implemented at the builder or schema layer to enforce namespace constraints and avoid passing unsafe values.Please verify usage with a quick search:
🏁 Script executed:
#!/bin/bash # Searching for namespace validator usage rg -A 5 "NamespaceValidator"Length of output: 71920
Rewritten Review Comment:
After verification, the
NamespaceValidatorinopenmeter/ent/db/subscriptionaddon/subscriptionaddon.gois correctly declared and its implementation is effectively provided and utilized. Its concrete assignment is done in the runtime layer (seeopenmeter/ent/db/runtime.go), and the validator is actively invoked in the create operation (for example, inopenmeter/ent/db/subscriptionaddon_create.go). No further modifications are necessary.openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go (4)
1-11: Auto-generated ent code notification.These lines indicate auto-generated code by Ent. Any manual updates here will be overwritten upon the next schema generation. If you need changes, apply them in the Ent schema definition instead.
12-60: Field and edge definitions look good.The constants and table references are correctly defined, matching Ent’s typical naming conventions and database schema patterns. The references to subscription add-ons, items, and addon ratecards are consistent with the rest of the codebase snippets provided.
62-82: Column list and “ValidColumn” approach.The approach of storing column names in a slice and validating them with “ValidColumn” is standard Ent practice. This is correct for ensuring that queries only reference valid columns.
101-186: Ordering options appear properly implemented.These ordering functions (ByID, ByNamespace, etc.) and steps (newSubscriptionAddonStep, newItemsStep, newAddonRatecardStep) follow standard Ent patterns, providing flexibility for sorting and relational traversal. If you need additional ordering (e.g., by metadata), you can add it by extending Ent’s “OrderOption” pattern.
openmeter/ent/db/tx.go (2)
83-90: Well-structured client field additions for subscription add-onsThese new client fields for subscription add-ons follow the established pattern in the
Txstruct and provide the necessary transaction support for the new subscription add-on functionality.
261-264: Properly initialized subscription add-on clientsThe initialization of the new subscription add-on client fields in the
initmethod maintains the existing pattern and ensures these clients are available during transactions.openmeter/subscription/testutils/addon.go (4)
15-22: Clear example rate card definitionThe
ExampleAddonRateCard1variable provides a well-structured test fixture for rate cards that maintains consistency with other test utilities.
24-51: Comprehensive test input generatorThe
GetExampleAddonInputfunction creates a complete test input with all necessary fields, making it easy to use in tests. Good use of thet.Helper()method to improve test failure reporting.
53-59: Simple and effective service wrapperThe
testAddonServicestruct and its constructor follow the decorator pattern to wrap the actual service, allowing for easier testing and additional functionality in tests.
61-78: Robust test addon creation helperThe
CreateExampleAddonmethod properly handles error scenarios and uses the test helper pattern consistently. It encapsulates the two-step process of creating and publishing an addon, making tests more concise.openmeter/ent/schema/addon.go (3)
59-62: Well-defined relationship with cascade deleteThe new edge to
SubscriptionAddonwith cascade delete properly establishes the relationship between addons and subscription addons, ensuring referential integrity when addons are deleted.
94-106: Elegant field reuse through compositionThe refactoring of the
Fieldsmethod to reuse fields fromRateCardimproves maintainability by reducing duplication. The comment about the ent/runtime.go bug provides useful context for why this approach was taken.
120-123: Consistent relationship with cascade deleteLike the addon edge, this new edge to
SubscriptionAddonRateCardwith cascade delete properly establishes the relationship between addon rate cards and subscription addon rate cards, maintaining referential integrity.openmeter/subscription/testutils/service.go (5)
17-18: Organized imports for new addon functionalityThe additions to the import section are well-organized, logically grouping related packages and maintaining the existing import structure.
Also applies to: 25-27
38-52: Comprehensive dependencies structureRenaming
ExposedServiceDepstoSubscriptionDependenciesbetter reflects its purpose, and the added fields for subscription addon services provide a complete set of dependencies for testing.
136-149: Well-structured addon service initializationThe addon repository and service initialization follows the same pattern as other services in the function, with proper error handling and dependency injection.
150-162: Clean subscription addon service setupThe subscription addon repositories and service are initialized with clear dependencies and a consistent approach, following the established patterns in the codebase.
164-178: Complete dependency return structureThe updated return statement includes all the necessary components, both existing and new, providing a comprehensive set of dependencies for testing subscription addons.
openmeter/ent/db/subscriptionaddonratecard_create.go (3)
21-26: Auto-generated builder struct looks standard.This builder struct follows the typical pattern from Ent, providing a flexible way to set fields before saving. The initialization logic, including hooks and conflict settings, appears correctly implemented.
167-181: Default field overrides.This block sets default values for fields like
CreatedAt,UpdatedAt, andID. This is a best practice for ensuring timestamps and IDs are always assigned—even if the caller forgets to set them. No issues found here.
224-245: Graceful handling of create operation with conflict checks.The
sqlSavemethod internally callssqlgraph.CreateNode, wrapping constraint errors toConstraintError. This is a standard approach in Ent for dealing with uniqueness or FK violations. Everything looks good.openmeter/ent/db/planratecard.go (2)
53-54: New Discounts field introduced.Adding the
Discountsfield aligns with the broader subscription system changes. Confirm that you have unit or integration tests to validate both presence and absence of discounts data.
349-352: Including Discounts in string representation.Displaying the
Discountsfield in theString()method is useful for debugging. However, watch out for large discount structures, as it can clutter logs.openmeter/subscription/testutils/compare.go (1)
12-12: Import alias for subscriptionaddon package.This import logically groups add-on functionality. The alias is clear and consistent.
openmeter/ent/db/subscription.go (4)
66-67: Correctly adds the Addons field to SubscriptionEdges structThis new field holds a slice of subscription addon pointers, enabling the relationship between subscriptions and their addons.
70-70: Properly updates the loadedTypes array sizeIncreased loadedTypes array size from 4 to 5 to accommodate the new "addons" edge, maintaining consistency with the edge-loading pattern.
113-120: Well-implemented AddonsOrErr methodThis method correctly follows the established pattern for edge retrieval methods, checking if the edge was loaded and returning either the addons or an appropriate error.
273-276: Properly implemented QueryAddons methodThis method provides a clean interface for querying the "addons" edge of the Subscription entity, following the established pattern for edge query methods.
openmeter/ent/db/subscriptionitem/where.go (2)
1278-1287: Correctly implemented HasSubscriptionAddonRateCardItems predicateThis function properly implements a predicate for checking the existence of edges on the "subscription_addon_rate_card_items" relationship, following the established pattern in the codebase.
1289-1299: Well-implemented HasSubscriptionAddonRateCardItemsWith predicateThis function correctly extends the functionality of the basic predicate by allowing additional filtering conditions, following the established pattern for complex edge predicates.
openmeter/ent/db/subscription/where.go (2)
891-900: Correctly implemented HasAddons predicateThis function properly implements a predicate for checking the existence of edges on the "addons" relationship, following the established pattern in the codebase.
902-912: Well-implemented HasAddonsWith predicateThis function correctly extends the functionality of the basic predicate by allowing additional filtering conditions, following the established pattern for complex edge predicates.
openmeter/ent/db/subscriptionitem_create.go (3)
17-17: Properly adds required importAdded the necessary import for the SubscriptionAddonRateCardItemLink entity.
285-298: Well-implemented AddSubscriptionAddonRateCardItems methodsThese methods correctly follow the established pattern for adding relationships during entity creation. The implementation handles both adding by IDs and by entity references.
591-606: Correctly updates createSpec for the new relationshipThis addition to the createSpec method properly handles the construction of an edge specification for the "subscription_addon_rate_card_items" relationship, ensuring that the relationships are established when a SubscriptionItem is created.
openmeter/ent/db/addon_create.go (2)
206-219: Implementation follows consistent patterns.The methods for adding subscription addons follow the same pattern as the existing methods for rate cards, which is good for maintainability.
444-459: Edge handling is implemented correctly.The edge specification for subscription addons is correctly implemented in the
createSpecmethod, following the same pattern as other edges.openmeter/ent/db/addonratecard/where.go (2)
765-773: Discount field predicates added correctly.The
DiscountsIsNilandDiscountsNotNilfunctions follow the same pattern as other field predicates in the file and provide necessary query capabilities for the discounts field.
961-982: Subscription addon rate card edge predicates implemented properly.The
HasSubscriptionAddonRateCardsandHasSubscriptionAddonRateCardsWithfunctions correctly implement edge predicates for the subscription addon rate cards relationship, following the consistent pattern used throughout the codebase.openmeter/ent/db/runtime.go (6)
41-44: New import statements align with the subscription addon feature.The added imports for subscription addon packages correctly introduce the necessary components for the new subscription addon functionality. These imports match the PR objectives to implement database schemas and types for subscription add-ons.
131-134: Added discounts descriptor for addonratecard schema.The addition of the discounts field descriptor follows the consistent pattern used throughout the file. This properly integrates discount functionality into addon rate cards, which is important for pricing flexibility in subscription addons.
135-136: Updated index for AddonID field descriptor.The index for AddonID descriptor has been correctly updated from 6 to 7 to account for the addition of the discounts field in the schema. This maintains proper field mapping in the generated code.
1158-1160: Added discounts descriptor for planratecard schema.The addition of the discounts field descriptor for planratecard follows the same pattern as the addonratecard changes, maintaining consistency throughout the codebase.
1162-1163: Updated index for PhaseID field descriptor.The index for PhaseID descriptor has been correctly updated from 6 to 7 to account for the addition of the discounts field in the schema, similar to the AddonID index update.
1231-1370: Comprehensive initialization for subscription addon entities.This extensive block adds all necessary initialization code for the new subscription addon entities, following the consistent pattern used throughout the file. It properly defines field descriptors, validators, and default values for all the new entity types.
The implementation covers:
- Namespace validation
- Created/Updated timestamp defaults
- ID generation
- Entity-specific validators like quantity validator and foreign key validators
The code is well-structured and follows the established patterns in the codebase.
openmeter/subscription/addon/repo/subscriptionaddonratecard.go (2)
17-27: Well-structured repository implementation.The repository is correctly implemented with a private struct that satisfies the public interface through type assertion on line 21. The constructor function follows the standard Go pattern for repository initialization.
29-80: Robust transaction handling in CreateMany method.The implementation uses a nested transaction approach with proper error handling. The method creates rate cards and their associated item links in a single transaction, ensuring atomicity of operations.
openmeter/subscription/testutils/ratecard.go (4)
16-17: Good practice: Extracted price amount as a constant.Extracting the example price amount into a shared constant improves code maintainability and consistency across test cases. This refactoring ensures that all examples use the same price value.
16-38: Changed ExampleRateCard1 from FlatFeeRateCard to UsageBasedRateCard.The type change from
FlatFeeRateCardtoUsageBasedRateCardis significant and aligns with the addition of subscription addon support. The associated field updates (such as changingBillingCadencefrom pointer to direct field) correctly reflect the different structure of a usage-based rate card.
53-75: Added example rate card specifically for addons.The new
ExampleRateCard3ForAddonsprovides a comprehensive example for testing subscription addon functionality. It includes all necessary metadata fields and uses the shared price amount constant for consistency.
93-94: Updated ExampleRateCardWithDiscounts to use the common price amount.Modifying the price amount to use the shared constant improves consistency across all example rate cards.
openmeter/ent/db/subscription_query.go (8)
21-21: Added import for the subscriptionaddon package.The import addition is necessary to support the new relationship between subscriptions and addons.
36-36: Added withAddons field to SubscriptionQuery struct.This field correctly follows the pattern used for other relationships in the query struct, enabling eager loading of related addon entities.
162-182: Implemented QueryAddons method for relationship traversal.The method correctly implements the chaining pattern for querying related entities, using the sqlgraph library to define the relationship between subscriptions and addons. The implementation matches the pattern used for other entity relationships.
380-380: Updated Clone method to include withAddons field.The Clone method has been properly updated to include the new withAddons field, ensuring that all query configuration is preserved when cloning.
431-440: Added WithAddons method for eager loading.The WithAddons method follows the established pattern for eager loading relationships, allowing for optional configuration of the addon query through functional options.
520-525: Updated loadedTypes array to include withAddons.The loadedTypes array correctly reflects the addition of the withAddons field, maintaining the relationship between array indices and field positions.
575-581: Added addon loading logic to sqlAll method.The sqlAll method has been updated to handle loading addons when requested, following the same pattern used for other relationships.
710-739: Implemented loadAddons method for eager loading.The loadAddons method correctly handles the loading of related addon entities, following the established pattern used for other relationships. It builds appropriate mappings between subscription IDs and addon entities, and assigns the loaded addons to the corresponding subscription nodes.
openmeter/subscription/addon/service/change_test.go (4)
20-42: Comprehensive negative quantity test.This subtest effectively verifies validation logic for negative quantities. The approach covers both the expected error and its content, ensuring alignment between the domain validation (
createInp.Validate()) and the service call (ChangeQuantity).
43-66: Thorough single-instance validation.This subtest ensures that a single-instance add-on cannot have a quantity greater than one. It cleanly verifies that the returned error is a
GenericValidationError, matching the domain rules.
68-92: Effective update scenario coverage.The subtest confirms that changing the quantity appends a new timestamped entry. It also checks that the latest quantity matches the updated value and timestamp, providing clear evidence of correct service behavior.
94-131: Well-structured setup helper.
createExampleSubscriptionAddoncentralizes subscription add-on creation for tests, reducing duplication. The function logic exhibits a clear flow: create subscription, create addon, then combine them, making the tests concise and maintainable.openmeter/ent/db/addon/addon.go (4)
50-51: Logical edge naming.Defining
EdgeSubscriptionAddonsmatches the existing naming convention for edges in this file, helping to keep the schema consistent.
61-68: Adequate table references.The new constants for the
subscription_addonstable and column maintain the same pattern used by other edges (e.g., ratecards). This preserves clarity and consistency.
223-235: Mirroring neighbor-based ordering.
BySubscriptionAddonsCountandBySubscriptionAddonsmirror the pattern used for ratecards ordering. This consistency allows predictable extension of query capabilities for add-on relationships.
243-249: Consistent graph step logic.
newSubscriptionAddonsStepcorrectly follows the established approach innewRatecardsStep, enabling neighbor-based graph operations for subscription addons without introducing special cases.openmeter/ent/db/paginate.go (4)
1596-1643: SubscriptionAddon pagination aligns with pattern.The
Paginatemethod forSubscriptionAddonQueryis consistent with existing pagination code. It resets offsets, counts total items, and retrieves the requested slice.
1644-1691: SubscriptionAddonQuantity pagination consistency.Similar to other entities,
SubscriptionAddonQuantityQuery.Paginateneatly handles limit/offset logic and total count retrieval. No issues spotted.
1692-1739: SubscriptionAddonRateCard pagination approach.The
SubscriptionAddonRateCardQuery.Paginatemethod follows the same robust pagination template, further unifying pagination across the codebase.
1740-1787: SubscriptionAddonRateCardItemLink pagination uniformity.Again, the method replicates the established pagination pattern, ensuring consistency. This uniform design reduces maintenance overhead.
openmeter/subscription/addon/service.go (3)
1-2: Consistent package naming.
The package name matches the folder path, maintaining clarity and preventing name collisions within the codebase.
3-9: Imports are minimal and relevant.
There are no apparent redundant imports, and all imported packages appear necessary for the functionality provided.
19-23: Well-defined input struct.
TheListSubscriptionAddonsInputstruct includes aSubscriptionIDfield plus pagination. This is a clear and concise design for filtering subscription addons.openmeter/subscription/addon/service/create_test.go (10)
26-64: Comprehensive invalid input test.
The test ensures that a zero quantity triggers a validation error prior to creation. This coverage is valuable and helps guard against improper usage of the API.
66-97: Appropriate handling when addon doesn't exist.
The test correctly checks for aGenericNotFoundErrorif the addon is missing. This behavior aligns with the domain requirement that referencing non-existent addons should yield a not-found error.
99-138: Subscription existence check.
Verifying that a non-existent subscription raises a not-found error is consistent with the domain model. The test is structured well and ensures controlled system behavior.
140-178: Rate card ownership validation.
Ensuring that the provided rate cards actually belong to the specified addon helps maintain data consistency. The test properly expects aGenericValidationErrorin the mismatch case.
223-308: Validation for referencing subscription items from different subscriptions.
Correctly capturesGenericConflictErrorusage. This prevents cross-subscription references that could cause billing inconsistencies.
310-351: Enforcing single-instance addon.
The test ensures an addon flagged as single-instance cannot have quantity > 1. This is a practical domain constraint.
353-359: TODO placeholders.
These tests are intentionally skipped, pending plan linking logic. Keeping them visible witht.Skip()is a good approach as a reminder.
361-414: Successful create-retrieve cycle.
The tests confirm that, once created, a subscription addon can be fetched and matches the initial state. This end-to-end coverage provides confidence in the creation and retrieval workflows.
417-437: Helper function for brewing example subscriptions.
createExampleSubscriptionis well structured and clarifies test setup, reducing duplication. It’s a standard approach to keep tests lean.
439-448: Test dependency injection.
withDepseffectively encapsulates DB setup/teardown, promoting test isolation, and preventing side effects from leaking. Good approach for integration-style testing.openmeter/ent/db/subscription_update.go (5)
18-18: New import for SubscriptionAddon.
Addingsubscriptionaddonis consistent with the newly introduced relationships. No issues here.
196-210: AddAddons methods.
These methods mirror common Ent patterns for adding edges in a one-to-many relationship. The naming and usage are consistent with standard Ent API conventions.
264-283: Clear and remove Addons.
These methods align with Ent’s approach to clearing or removing edges in a one-to-many relationship. Implementation is standard and looks correct.
498-542: Edge specification logic for Addons in SubscriptionUpdate.
The O2M edge logic properly handles cleared, removed, and newly added addon IDs. This ensures the SQL graph is accurately updated.
1056-1100: Edge specification logic for Addons in SubscriptionUpdateOne.
Same as above, the edge logic for single-entity updates ensures consistency across one-to-many relationships with addons.openmeter/subscription/addon/repository.go (3)
1-10: Package and imports are correctly organized.The package name
subscriptionaddonaligns with the directory structure, and the imports are properly organized with standard library imports first, followed by project-specific imports.
34-43: SubscriptionAddonRateCard repository interface and structure look good.The input struct and repository interface for SubscriptionAddonRateCard are well-designed with appropriate fields and methods.
45-53: SubscriptionAddonQuantity repository interface and structure look good.The input struct and repository interface for SubscriptionAddonQuantity are well-designed with appropriate fields and methods.
tools/migrate/migrations/20250409142535_subscriptionaddon.up.sql (4)
1-19: SubscriptionAddons table and indexes are well-designed.The table schema includes appropriate fields, constraints, and indexes. Foreign key relationships to
addonsandsubscriptionstables are properly established with cascade deletion.
19-37: SubscriptionAddonQuantities table and indexes are well-designed.The table schema includes appropriate fields with correct data types. The
quantityfield has a default value of 1, which seems reasonable. The foreign key relationship to thesubscription_addonstable is properly established.
38-59: SubscriptionAddonRateCards table and indexes are well-designed.The table schema includes appropriate fields and constraints. The foreign key relationships to
addon_rate_cardsandsubscription_addonstables are properly established.
60-79:Details
❓ Verification inconclusive
Verify the ON DELETE behavior for subscription_addon_rate_card_item_links.
I noticed that the foreign key constraint for
subscription_addon_rate_card_idusesON DELETE NO ACTIONwhile most other foreign keys in this migration useON DELETE CASCADE. This inconsistency might lead to orphaned records if a rate card is deleted.Please verify whether this inconsistency is intentional or if it should be changed to
ON DELETE CASCADEto maintain consistency with other foreign key constraints.
🏁 Script executed:
#!/bin/bash # Check if other foreign keys in the table use ON DELETE CASCADE grep -A 10 "FOREIGN KEY" tools/migrate/migrations/*subscriptionaddon.up.sql | grep "ON DELETE"Length of output: 1407
Action: Verify and Confirm the ON DELETE Behavior for Subscription Addon Rate Card Links
It was observed that within the migration file (
tools/migrate/migrations/20250409142535_subscriptionaddon.up.sql, lines 60–79), the foreign key constraint on"subscription_addon_rate_card_id"(constraint"subscription_addon_rate_card_item_links_subscription_addon_rate") is defined withON DELETE NO ACTION, whereas the other foreign key constraints in this migration consistently useON DELETE CASCADE. This inconsistency could potentially lead to orphaned records if a rate card is deleted.Please confirm whether this differing behavior is intentional. If not, consider updating the constraint to use
ON DELETE CASCADEfor consistency with the other foreign keys.openmeter/ent/db/subscriptionaddon_delete.go (2)
1-58: SubscriptionAddonDelete implementation follows Ent patterns correctly.The
SubscriptionAddonDeletebuilder provides methods for specifying deletion criteria and executing deletions. The implementation correctly handles error wrapping and follows the standard Ent pattern for deletion operations.
59-88: SubscriptionAddonDeleteOne implementation follows Ent patterns correctly.The
SubscriptionAddonDeleteOnebuilder correctly implements the deletion of a single entity, with proper error handling for both "not found" scenarios and other errors.openmeter/ent/db/addonratecard_query.go (5)
6-33: Updated imports and AddonRateCardQuery struct to support subscription addon rate cards.The changes correctly include the necessary imports and add the
withSubscriptionAddonRateCardsfield to theAddonRateCardQuerystruct to support loading related subscription addon rate cards.
114-134: QuerySubscriptionAddonRateCards method implementation looks good.The method properly chains queries on the "subscription_addon_rate_cards" edge, using the appropriate SQL graph configuration. The implementation follows the standard Ent pattern for edge traversal.
359-368: WithSubscriptionAddonRateCards eager-loading implementation looks good.The method correctly implements eager-loading for the "subscription_addon_rate_cards" edge, allowing for configuration of the query builder through optional function arguments.
444-495: Updated sqlAll method to handle loading subscription addon rate cards.The changes to the
sqlAllmethod correctly update the loaded types array and add logic to load subscription addon rate cards when requested.
560-589: loadSubscriptionAddonRateCards implementation looks good.The method correctly loads subscription addon rate cards for all addon rate cards in the result set, constructing appropriate foreign key mappings and handling errors properly.
openmeter/ent/db/subscriptionaddonquantity_delete.go (1)
15-20: Implementation aligns with Ent’s built-in patterns.The
SubscriptionAddonQuantityDeletestructs, methods, and not-found checks conform to typical Ent usage. The separation intoExecandExecXis a standard pattern, and error handling for constraint violations is handled properly.Also applies to: 59-60
openmeter/subscription/addon/repo/mapping.go (3)
36-46: Addon mapping is handled correctly.You correctly map
dbAdd.Name,dbAdd.Description, and calladdonrepo.FromAddonRowto handle further transformations. This approach is straightforward and consistent.
48-53: Timeline creation for quantities looks good.Using
timeutil.NewTimelinewith mapped quantities is an elegant way to maintain a chronological list of quantity changes. The logic here is concise and properly leverages thelo.Maputility.
113-129: Mapping logic for subscription addon quantities is clear.Reading
ActiveFromandQuantityfields into the domain model is straightforward, and the code respects theManagedModelfields for created/updated/deleted timestamps. The function is concise and correct.openmeter/ent/db/addonratecard/addonratecard.go (8)
48-49: NewFieldDiscountsdefinition looks good.
This aligns with the existing field naming conventions and provides a dedicated column for discounts. Ensure proper handling of this field in any related CRUD logic.
58-59: New edgeEdgeSubscriptionAddonRateCardsseems well-introduced.
The naming clearly reflects the relationship with subscription addon rate cards. Just confirm that the edge direction (O2M vs. M2O) and cardinality are correct in the surrounding schema code.
76-82: Table and column references for new subscription add-on rate cards are consistent.
All necessary constants for the table name, inverse table, and column are defined. They match the naming patterns in this package. No issues found.
102-102: Inclusion ofFieldDiscountsin the Columns array is correct.
Ensures queries can reference this column reliably.
224-227: Ordering bydiscountswithByDiscountsis correctly implemented.
The approach usingsql.OrderByField(FieldDiscounts, opts...).ToFunc()follows established ent patterns.
253-258:BySubscriptionAddonRateCardsCountordering is properly integrated.
Leveragessqlgraph.OrderByNeighborsCountto order by a neighbor relation count. This is consistent with other neighbor-based ordering.
260-265:BySubscriptionAddonRateCardsordering function is well-structured.
Allows sorting by neighboring terms on subscription add-on rate cards. No concerns identified.
280-286:newSubscriptionAddonRateCardsStep()implementation is coherent with ENT’s O2M edge structure.
No issues found with the step definition. Ensure it’s used correctly in higher-level queries.openmeter/subscription/addon/service/service.go (4)
1-47: Package setup, config struct, andNewServiceinitialization look straightforward.
No concurrency pitfalls seen. Dependencies are injected cleanly. The logger reference can help with better observability.
143-145:Getmethod is direct and efficient.
Delegates to the repository without extra overhead. The error handling is performed downstream.
147-154:Listmethod nicely wraps repository calls.
Input validation is performed early. The method properly returns a paginated response.
156-198:ChangeQuantitymethod has clear validation and concurrency boundaries.
- Checks single-instance limitation.
- Uses a transaction for atomic creation of the new quantity record.
- Returns the refreshed add-on.
If simultaneous updates are expected, consider heavier locking at the repository layer. Otherwise, this is acceptable.
openmeter/subscription/addon/repo/subscriptionaddon.go (5)
1-29: Repository struct and constructor.
Instantiation is clean, referencing the ent client. Matches the interface requirements forSubscriptionAddonRepository.
29-51:Createmethod effectively saves SubscriptionAddon entities.
- Wraps
cmd.Save(ctx)in a transaction for atomicity.- Returns a
NamespacedIDfor quick identification.
No issues found with error handling.
53-80:Getmethod uses a transacting repo and a helper query.
- Custom not-found error is correctly returned.
- Mapping logic is properly delegated to
MapSubscriptionAddon.
This flow is consistent and well-structured.
81-115:Listmethod with optional pagination.
- If no pagination is specified, it returns all matches.
- Otherwise, it efficiently paginates the response and maps the results.
This approach provides flexibility and is consistent with the typical pagination flow.
117-129:querySubscriptionAddonfunction properly preloads relationships.
Brings inAddon,Quantities, andRateCardsin one consistent query. Sorting theQuantitiesbyActiveFromandCreatedAtis logical.openmeter/ent/db/subscriptionitem_update.go (11)
17-17: Import statement updated.
No concerns. The import aligns with the usage in this file.
330-334: New edge method: AddSubscriptionAddonRateCardItemIDs
Function design looks consistent. Ensures the mutation receives the new IDs properly.
336-343: Additional method: AddSubscriptionAddonRateCardItems
Bridges to the ID-based method. Implementation is straightforward and follows ent patterns.
377-381: Method: ClearSubscriptionAddonRateCardItems
Clears the respective edge relationships. Implementation follows ent conventions with no issues.
383-396: Methods: RemoveSubscriptionAddonRateCardItemIDs, RemoveSubscriptionAddonRateCardItems
Implementation is consistent with ent's remove edge pattern.
651-695: SubscriptionAddonRateCardItems edge handling in sqlSave
Properly updates edges by clearing and adding relationships within the same transaction.
1010-1014: Single-entity AddSubscriptionAddonRateCardItemIDs
Mirrors the multi-entity logic. No issues found.
1016-1023: AddSubscriptionAddonRateCardItems
Wrapper method calling the ID-based variant. Implementation is correct.
1057-1061: ClearSubscriptionAddonRateCardItems for SubscriptionItemUpdateOne
Clears edges consistently. No concerns found.
1063-1076: RemoveSubscriptionAddonRateCardItemIDs, RemoveSubscriptionAddonRateCardItems
Follows ent's remove edge pattern. Implementation is correct.
1361-1405: Edge handling in sqlSave for SubscriptionItemUpdateOne
Ensures new edge relationships are properly managed. No issues.openmeter/ent/db/subscriptionaddonquantity.go (2)
1-15: File header
Auto-generated boilerplate. No issues found.
143-205: Value/Query/Update/Unwrap/String methods
The remaining methods for CRUD and string operations appear correct with no issues.openmeter/ent/db/planratecard_create.go (4)
162-166: Method: SetDiscounts in PlanRateCardCreate
Implementation aligns with other field setters. Looks good.
705-722: Manage discounts in PlanRateCardUpsert
Adds methods for setting, updating, and clearing the "discounts" field. Consistent with the existing pattern.
1009-1029: Discounts management for PlanRateCardUpsertOne
Proper approach for handling this field on single upsert.
1491-1511: Discounts handling for PlanRateCardUpsertBulk
Enables bulk management of the discounts field. No issues found.openmeter/ent/db/subscriptionaddonratecard.go (1)
87-103: Validate scanning defaults and handle unknown columns carefully
InscanValues, any columns not explicitly handled are assigned tosql.UnknownType. This can lead to silent issues if the schema changes or if a column is unexpectedly returned by queries. Consider logging or raising a warning for unrecognized columns to catch potential schema drift.openmeter/ent/db/migrate/schema.go (3)
1925-1954: Assess negative quantity usage
InSubscriptionAddonQuantities, aquantityfield defaults to 1, but the schema does not explicitly forbid negative values at the database level. If the application enforces non-negative quantities, confirm that the ENT validation (or application layer checks) is robust, and consider a DB-level constraint if you need absolute enforcement.
1966-2007: Confirm rate card deletion behavior
InSubscriptionAddonRateCardsTable, foreign keys toaddon_rate_cardsandsubscription_addonsare set to cascade on delete. Double-check that cascading deletions of rate cards or subscription addons matches your business needs, because it will remove all related subscription addon rate cards without further checks.
2009-2061: Validate logic for item links
SubscriptionAddonRateCardItemLinksTableenforces a unique index on(subscription_item_id, subscription_addon_rate_card_id)wheredeleted_at IS NULL. Verify that this aligns with the intended business rules, especially if you anticipate multiple item links to a single rate card under certain conditions.openmeter/ent/schema/subscription_addon.go (2)
35-57: Revisit edge cascade for addon’s relations
TheSubscriptionAddonedgesrate_cardsandquantitiesboth cascade on delete. Deleting a subscription addon will also remove all associated rate cards and quantities. Ensure this is the desired behavior, as it may lead to data loss if only a partial cleanup is intended.
145-171: Ensure naming clarity for preventing duplicate item links
The unique index on(subscription_item_id, subscription_addon_rate_card_id)wheredeleted_at IS NULLprevents duplicates. This is good, but confirm that the naming (subscription_item_id,subscription_addon_rate_card_id) is well-documented, as incorrect usage by developers could lead to silent unique violations.openmeter/ent/db/addonratecard_update.go (9)
18-18: Import usage looks good.
No issues found with this newly added import statement.
184-188: SetDiscounts implementation verified.
This setter is consistent with Ent’s pattern for setting optional fields. Everything looks good here.
190-194: ClearDiscounts method verified.
Properly clears the Discounts field by using the mutation’s clear method. This aligns with Ent’s practices.
254-258: Routine addition of SubscriptionAddonRateCard IDs.
The method properly delegates to the mutation. Typical Ent usage for adding edge IDs.
260-267: Adding SubscriptionAddonRateCards by entity references.
This approach—extracting IDs from entities—is standard in Ent. Looks good.
286-290: Clearing the SubscriptionAddonRateCards edge.
Consistent with how Ent handles edge clearing in a mutation. Good job.
292-296: Removing SubscriptionAddonRateCard IDs.
Logic for removing specific IDs from the mutation is in line with Ent’s typical pattern.
298-305: Removing SubscriptionAddonRateCards by entity references.
Implementation is correctly reusing the RemoveSubscriptionAddonRateCardIDs method. No issues found.
517-561:Details
✅ Verification successful
Edge specification logic for SubscriptionAddonRateCards.
The O2M relationship withaddonratecard.SubscriptionAddonRateCardsTableand columnaddonratecard.SubscriptionAddonRateCardsColumnappears correct. Consider verifying the consistency of foreign-key usage across the codebase to ensure the correct direction of the relationship.Here’s a script to confirm references to this column and table match this O2M convention:
🏁 Script executed:
#!/bin/bash # Searches for references to the SubscriptionAddonRateCardsTable and SubscriptionAddonRateCardsColumn in the codebase: rg -A 5 'SubscriptionAddonRateCardsTable' rg -A 5 'SubscriptionAddonRateCardsColumn'Length of output: 18055
Foreign-key usage verified for SubscriptionAddonRateCards edge.
The search confirms that the tableaddonratecard.SubscriptionAddonRateCardsTableand columnaddonratecard.SubscriptionAddonRateCardsColumnare used consistently across the codebase (e.g., inaddonratecard_create.go,addonratecard_update.go,client.go, and related schema definitions). No inconsistencies in the direction of the O2M relationship were found.openmeter/ent/db/subscriptionaddonratecarditemlink_update.go (9)
18-23: Definition of the SubscriptionAddonRateCardItemLinkUpdate struct.
The structure and embedded mutation fields align with Ent’s standard practice for update builders.
25-29: Where method for filtering.
The method simply appends predicates to the mutation. No concerns here.
31-55: Set/Clear DeletedAt methods.
These methods follow Ent’s approach for nullable time fields. Implementation is correct.
57-60: Accessing the underlying mutation object.
Exposing the mutation for extensibility matches common Ent patterns.
62-88: Save, SaveX, Exec, and ExecX methods.
These methods wrap thesqlSavecall with hooks and error handling. Standard approach in Ent.
90-96: Defaults method.
Automatically settingupdated_atif missing is consistent with typical update flows and best practices.
98-107: check method for required edges.
The logic that prevents clearing a required unique edge while also adding new IDs is correct and helps maintain data integrity.
109-140: sqlSave implementation for batch updates.
The specification ensures consistent field and edge updates; error handling uses Ent’s recommended pattern.
142-293: SubscriptionAddonRateCardItemLinkUpdateOne and associated methods.
All single-entity update methods match the batch update design. This structure is standard in Ent, ensuring consistent behavior.openmeter/ent/db/subscriptionaddonquantity/subscriptionaddonquantity.go (7)
12-42: Constants and table references.
Field definitions and edge references are properly enumerated. The schema labeling is typical for Ent.
44-64: Columns array and ValidColumn function.
The approach ensures queries can validate column usage. Implementation is straightforward and correct.
66-85: Validators and default value functions.
Including separate validators forNamespace,Quantity, andSubscriptionAddonIDis a best practice for data integrity. Defaults are clearly defined.
87-89: OrderOption type alias.
Defining an order option type for queries is consistent with Ent’s pattern for modular sorting.
90-129: Ordering methods ByID, ByNamespace, etc.
These functions are standard for sorting on individual fields via Ent. Implementation is correct.
130-135: BySubscriptionAddonField ordering.
Uses neighbor-based ordering vianewSubscriptionAddonStep. This advanced pattern is properly integrated.
136-142: newSubscriptionAddonStep function.
Configures an O2M step fromsubscription_addon_quantitiestosubscription_addonsthrough the foreign key. Looks accurate.openmeter/ent/db/subscriptionaddonquantity_update.go (1)
1-287: Well-structured ent-generated code.All methods for setting, clearing, and validating fields (e.g.,
updated_at,deleted_at) adhere to standard ent patterns, including the checks on clearing required edges. The default value assignment forupdated_atand thorough error handling (for not found and constraint errors) also appear robust. No concurrency or security issues are detected, and the design aligns with ent best practices for mutating database entities.openmeter/ent/db/subscriptionaddonratecard_update.go (1)
1-492: Thorough ent-generated update logic.This file effectively manages updates for batch and single-entity operations, covering field assignments, edge additions and removals, and handling for default timestamps. The checks for clearing required edges (e.g., subscription and addon_ratecard references) are correctly implemented. Error handling with graceful responses such as
NotFoundErrorandConstraintErroris also in place. Overall, no issues identified.openmeter/ent/db/subscriptionaddonratecard_query.go (1)
1-796: Correctly implemented ent-generated query builder.The query builder includes standard filtering (
Where), ordering, pagination (Limit,Offset), and eager loading of related edges (e.g.,SubscriptionAddon,Items,AddonRatecard). It provides robust methods for retrieving single or multiple nodes, handling edge cases like no match (NotFoundError) or multiple matches (NotSingularError). The grouped queries and field selection functionality also follow ent’s best practices for constructing queries. No issues found.openmeter/ent/db/subscriptionaddonquantity_create.go (2)
61-73: Confirm soft-delete logic consistency.
deleted_atis being set with a timestamp, implying a soft-delete strategy. Ensure that corresponding queries and validations handle this field correctly (e.g., filtering out soft-deleted records in normal operations or clarifying how "undeleting" is performed).
185-224: Validate concurrency scenarios in thecheckmethod.While the
checkmethod ensures required fields are set and valid, consider concurrency scenarios where multiple goroutines attempt to create the same entity (by the same ID, for instance). Confirm that the code handles collisions gracefully or that higher-level logic prevents duplicates.openmeter/ent/db/subscriptionaddonratecarditemlink_create.go (3)
57-68: Verify correct usage of soft-delete.Like in your other entities,
SetDeletedAtsuggests a soft-delete approach. Ensure consistent usage and be sure to document or test how these “deleted” records are queried or restored.
76-80: Validatesubscription_item_idsimilarly tosubscription_addon_rate_card_id.Ensure any domain constraints on
subscription_item_idare enforced in a similar manner. This keeps logic consistent and reduces possible edge-case omissions.
139-153: Confirm default ID generation strategy.The
defaults()method sets a default ID if none is provided. If you rely on externally generated IDs, ensure collisions or invalid formats are handled. Otherwise, an internally generated ID is typically safer.openmeter/ent/db/subscriptionaddonratecarditemlink_query.go (2)
67-87: Confirm relationship consistency in adjacency queries.
QuerySubscriptionAddonRateCardcreates a step fromsubscription_addon_rate_card_item_linktosubscription_addon_rate_card. Verify that the database constraints match these edges so dangling references are avoided or discovered early.
606-630: Approach locking with caution.
ForUpdateandForShareare dialect-specific locking mechanisms. Ensure the calling code is prepared for potential blocking or errors on databases that do not support them. Also verify that any read scenarios do not unintentionally hold locks longer than needed.openmeter/ent/db/subscriptionaddonquantity_query.go (4)
65-85: Validate edge configuration.
TheQuerySubscriptionAddon()method correctly configures an M2O relationship viasqlgraph.NewStep. Ensure that all related references to thesubscription_addontable align with the intended cardinality. If the schema changes in the future, consider updating this logic accordingly.
206-225: Double-check ID uniqueness assumptions.
TheIDs()method enforces a unique constraint if no explicitUnique(false)is provided. Confirm that making the query distinct by default aligns with your domain rules, especially if partial or cross-tenant queries are expected.
409-437: Check eager loading for large relationships.
loadSubscriptionAddon()is an eager-load mechanism that can lead to heavy queries if many rows match. If the relationship can grow large, ensure that usage scenarios won't cause performance bottlenecks.
529-540: Confirm row-level locking usage.
TheForUpdate()method correctly checks for Postgres before applying row-level locks. Verify that other supported database dialects either handle locking differently or gracefully ignore this method.openmeter/ent/db/subscriptionaddon_update.go (3)
71-84: Edge relationships managed correctly.
TheAddRateCardIDs()andAddRateCards()methods appear consistent with one-to-many relationships. Ensure you have unit tests that verify correct linking and unlinking of rate cards, particularly if the system expects partial updates.
176-182: Automatically updating timestamps is helpful.
Thedefaults()method sets the updated timestamp if not otherwise specified. That is a solid approach. Keep in mind to handle potential partial updates to only certain fields and whether updated timestamps should still be refreshed.
460-655: Comprehensive edge clearing and re-adding approach.
ThroughoutsqlSave(), edges forrate_cardsandquantitiescan be fully cleared before being re-added. This is a valid pattern. Just ensure that a rapid clear-and-re-add cycle will not cause undesired side effects in upstream services (e.g., events or triggers).openmeter/ent/db/subscriptionaddon/where.go (3)
1-11: Predicate constants and functions.
The file effectively exposes typed predicates (e.g.,ID,Namespace, etc.) for building queries. This is consistent with best practices for typed queries.
163-171: Addressing JSON or map fields.
MetadataIsNilandMetadataNotNilillustrate filtering for JSON fields. Verify that queries handle large JSON objects gracefully and that searching within structured JSON is handled in other predicates if needed.
525-538: Leverage combined logic operators.
TheAnd,Or, andNotfunctions are well-suited for complex queries. Double-check that each condition is thoroughly tested, ensuring that expected results are properly returned in edge cases.openmeter/ent/db/subscriptionaddonratecarditemlink/where.go (1)
1-413: Looks good—auto-generated Ent predicates.No issues found in this file. Each function consistently implements query predicates for all fields and edges of
SubscriptionAddonRateCardItemLink. Since this code is automatically generated, manual edits would be overwritten on subsequent code generations.openmeter/ent/db/subscriptionaddonquantity/where.go (1)
1-480: Looks good—auto-generated Ent predicates.No issues found in this file. Similar to the other where-predicates file, the generated functions systematically handle all relevant fields (e.g.,
Namespace,DeletedAt,Quantity) and edges forSubscriptionAddonQuantity. Manual changes are not advised, as they will be overwritten on regeneration.openmeter/ent/db/subscriptionaddon_create.go (1)
1-880: Looks good—auto-generated Ent creation logic.No immediate issues stand out. This file provides the standard create builder for
SubscriptionAddon, implementing field validation, default value logic, edge management, and conflict resolution. Everything appears consistent with Ent’s conventions.openmeter/ent/db/client.go (15)
51-54: Well-structured subscription addon package organizationThe new imports for subscription addon components are organized consistently with the existing package structure, maintaining a clear separation of concerns.
133-140: Clean integration of new client structuresThe SubscriptionAddon client structures follow a consistent pattern with the existing client structures, which promotes maintainability and readability.
191-194: Properly initialized client instancesThe initialization of the subscription addon clients is correctly implemented in the init method, ensuring these clients are available when the application starts.
323-326: Transaction support properly implementedThe subscription addon clients are correctly included in the transaction structure, ensuring that operations on these entities can participate in database transactions, which is essential for maintaining data consistency.
Also applies to: 382-385
427-429: Proper hook and interceptor registrationThe subscription addon clients are properly registered with hooks and interceptors, allowing for customization of behavior before and after database operations, which is a key feature of the ent framework.
Also applies to: 449-451
527-534: Complete mutation handlingAll necessary mutation cases for the subscription addon entities are properly implemented, ensuring that create, update, and delete operations will work correctly for these new entities.
670-684: Well-defined relationship between Addon and SubscriptionAddonThe QuerySubscriptionAddons method establishes a one-to-many relationship from Addon to SubscriptionAddon, which allows for proper navigation and querying of this relationship.
851-865: Proper relationship between AddonRateCard and SubscriptionAddonRateCardThe QuerySubscriptionAddonRateCards method correctly implements the one-to-many relationship from AddonRateCard to SubscriptionAddonRateCard, facilitating proper data access patterns.
6174-6188: Well-implemented relationship from Subscription to SubscriptionAddonThe QueryAddons method provides a clean way to access all add-ons associated with a subscription, which is essential for subscription management functionality.
6215-6410: Comprehensive SubscriptionAddonClient implementationThe SubscriptionAddonClient implementation follows best practices for the ent framework with properly defined CRUD operations, query builders, and relationship navigation methods.
6412-6559: Well-structured SubscriptionAddonQuantityClientThe SubscriptionAddonQuantityClient provides all necessary methods for working with subscription addon quantities, following consistent patterns with other clients in the codebase.
6561-6740: Thorough SubscriptionAddonRateCardClient implementationThe SubscriptionAddonRateCardClient includes comprehensive querying capabilities including the essential relationships to SubscriptionAddon, AddonRatecard, and the ability to navigate to rate card items.
6742-6905: Complete SubscriptionAddonRateCardItemLinkClient implementationThe SubscriptionAddonRateCardItemLinkClient correctly implements the relationship between rate cards and subscription items, which is crucial for applying the correct pricing to subscription items.
7063-7077: Properly implemented SubscriptionItem to SubscriptionAddonRateCardItemLink relationThe QuerySubscriptionAddonRateCardItems method enables navigation from a subscription item to its associated addon rate card links, completing the relationship chain needed for addon pricing.
7445-7446: Complete hooks and interceptors structure updateThe hooks and interceptors structures have been properly updated to include the new subscription addon entities, ensuring that custom behaviors can be applied to these entities.
Also applies to: 7458-7459
| fields := RateCard{}.Fields() // We have to use it like so due to some ent/runtime.go bug | ||
|
|
||
| fields = append(fields, | ||
| field.String("phase_id"). | ||
| NotEmpty(). | ||
| Comment("The phase identifier the ratecard is assigned to."), | ||
| field.String("feature_id"). | ||
| Optional(). | ||
| Nillable(). | ||
| Comment("The feature identifier the ratecard is related to."), | ||
| field.String("discounts"). | ||
| GoType(&productcatalog.Discounts{}). | ||
| ValueScanner(DiscountsValueScanner). | ||
| SchemaType(map[string]string{ | ||
| dialect.Postgres: "jsonb", | ||
| }). | ||
| Optional(). | ||
| Nillable(), | ||
| } | ||
| ) | ||
|
|
||
| return fields | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Code refactoring approach looks good but bug comment warrants attention
The approach to reuse fields from RateCard{} reduces code duplication and improves maintainability. However, the comment about "ent/runtime.go bug" suggests this implementation is a workaround rather than an ideal solution.
Consider documenting the specific bug in more detail or linking to an issue tracker reference to help future maintainers understand why this approach was necessary.
🏁 Script executed:
#!/bin/bash
# Search for other occurrences of similar workarounds in the codebase
echo "Searching for similar workarounds..."
rg "We have to use it like so due to some ent/runtime\.go bug" -g "*.go"
# Check if there's an existing issue for this bug
echo "Checking if RateCard is defined in the same package..."
fd "ratecard\.go" --type f -g "*.go"Length of output: 658
Action Required: Enhance Documentation for the "ent/runtime.go bug" Workaround
Your refactoring using RateCard{}.Fields() in openmeter/ent/schema/productcatalog.go is well done and nicely reduces duplication. However, the workaround comment—referencing an "ent/runtime.go bug"—remains ambiguous. We also noted a similar workaround in openmeter/ent/schema/addon.go. To improve maintainability, please consider either adding more details about the bug or linking to an external issue tracker where this bug is documented. This additional context will help future maintainers understand why the workaround is necessary.
| var ( | ||
| // NamespaceValidator is a validator for the "namespace" field. It is called by the builders before save. | ||
| NamespaceValidator func(string) error | ||
| // DefaultCreatedAt holds the default value on creation for the "created_at" field. | ||
| DefaultCreatedAt func() time.Time | ||
| // DefaultUpdatedAt holds the default value on creation for the "updated_at" field. | ||
| DefaultUpdatedAt func() time.Time | ||
| // UpdateDefaultUpdatedAt holds the default value on update for the "updated_at" field. | ||
| UpdateDefaultUpdatedAt func() time.Time | ||
| // SubscriptionAddonIDValidator is a validator for the "subscription_addon_id" field. It is called by the builders before save. | ||
| SubscriptionAddonIDValidator func(string) error | ||
| // AddonRatecardIDValidator is a validator for the "addon_ratecard_id" field. It is called by the builders before save. | ||
| AddonRatecardIDValidator func(string) error | ||
| // DefaultID holds the default value on creation for the "id" field. | ||
| DefaultID func() string | ||
| ) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Validators and defaults remain uninitialized.
The placeholders (e.g., NamespaceValidator, SubscriptionAddonIDValidator) and default hooks (e.g., DefaultCreatedAt) must be assigned in the ent builder if you need actual validations or time-stamp defaults. Otherwise, they will remain no-ops.
Please confirm that these validators and defaults are properly set in the schema or builder by running:
Ensure you see assignments in your Ent schema or builder files. If they are missing, consider defining them in the schema to avoid unvalidated fields.
🏁 Script executed:
#!/bin/bash
rg 'NamespaceValidator|SubscriptionAddonIDValidator|AddonRatecardIDValidator|DefaultCreatedAt|UpdateDefaultUpdatedAt|DefaultID' -A 3Length of output: 88689
Action Required: Initialize Validators and Defaults for SubscriptionAddonRateCard
The search confirms that for the type defined in openmeter/ent/db/subscriptionaddonratecard/subscriptionaddonratecard.go, the validator and default hook fields (such as NamespaceValidator, DefaultCreatedAt, DefaultUpdatedAt, UpdateDefaultUpdatedAt, SubscriptionAddonIDValidator, AddonRatecardIDValidator, and DefaultID) are declared but are not being assigned any concrete implementations. In contrast, similar entities (for example, in the addonratecard and subscription types) have their functions properly assigned within the runtime (typically in openmeter/ent/db/runtime.go).
Recommendations:
- Confirm whether these placeholders are intentionally left as no-ops.
- If validations or default values are required, assign the corresponding functions in the Ent builder (e.g., by adding assignments in the runtime configuration file) so that these hooks are properly initialized.
- Document your intent if leaving them uninitialized, to avoid confusion in future reviews.
| // SubscriptionAddonsColumns holds the columns for the "subscription_addons" table. | ||
| SubscriptionAddonsColumns = []*schema.Column{ | ||
| {Name: "id", Type: field.TypeString, Unique: true, SchemaType: map[string]string{"postgres": "char(26)"}}, | ||
| {Name: "namespace", Type: field.TypeString}, | ||
| {Name: "metadata", Type: field.TypeJSON, Nullable: true, SchemaType: map[string]string{"postgres": "jsonb"}}, | ||
| {Name: "created_at", Type: field.TypeTime}, | ||
| {Name: "updated_at", Type: field.TypeTime}, | ||
| {Name: "deleted_at", Type: field.TypeTime, Nullable: true}, | ||
| {Name: "addon_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, | ||
| {Name: "subscription_id", Type: field.TypeString, SchemaType: map[string]string{"postgres": "char(26)"}}, | ||
| } | ||
| // SubscriptionAddonsTable holds the schema information for the "subscription_addons" table. | ||
| SubscriptionAddonsTable = &schema.Table{ | ||
| Name: "subscription_addons", | ||
| Columns: SubscriptionAddonsColumns, | ||
| PrimaryKey: []*schema.Column{SubscriptionAddonsColumns[0]}, | ||
| ForeignKeys: []*schema.ForeignKey{ | ||
| { | ||
| Symbol: "subscription_addons_addons_subscription_addons", | ||
| Columns: []*schema.Column{SubscriptionAddonsColumns[6]}, | ||
| RefColumns: []*schema.Column{AddonsColumns[0]}, | ||
| OnDelete: schema.Cascade, | ||
| }, | ||
| { | ||
| Symbol: "subscription_addons_subscriptions_addons", | ||
| Columns: []*schema.Column{SubscriptionAddonsColumns[7]}, | ||
| RefColumns: []*schema.Column{SubscriptionsColumns[0]}, | ||
| OnDelete: schema.Cascade, | ||
| }, | ||
| }, | ||
| Indexes: []*schema.Index{ | ||
| { | ||
| Name: "subscriptionaddon_id", | ||
| Unique: true, | ||
| Columns: []*schema.Column{SubscriptionAddonsColumns[0]}, | ||
| }, | ||
| { | ||
| Name: "subscriptionaddon_namespace", | ||
| Unique: false, | ||
| Columns: []*schema.Column{SubscriptionAddonsColumns[1]}, | ||
| }, | ||
| }, | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Assess uniqueness constraints for SubscriptionAddons
Currently, only the primary key (id) is guaranteed unique, while (namespace, subscription_id, addon_id) isn’t enforced as unique. If you want to prevent the same addon from being added multiple times to the same subscription, consider adding a composite unique index on (namespace, subscription_id, addon_id) with a partial filter for deleted_at IS NULL.
| // IDEqualFold applies the EqualFold predicate on the ID field. | ||
| func IDEqualFold(id string) predicate.SubscriptionAddon { | ||
| return predicate.SubscriptionAddon(sql.FieldEqualFold(FieldID, id)) | ||
| } | ||
|
|
||
| // IDContainsFold applies the ContainsFold predicate on the ID field. | ||
| func IDContainsFold(id string) predicate.SubscriptionAddon { | ||
| return predicate.SubscriptionAddon(sql.FieldContainsFold(FieldID, id)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Careful with large string-based field queries.
IDEqualFold and IDContainsFold can lead to case-insensitive substring matching on large text fields. For performance, especially if IDs can be large or if these queries occur frequently, consider indexing or restricting usage.
Overview
subscription/addonpackageSummary by CodeRabbit
I'll craft concise release notes for this substantial update focusing on the key user-visible changes.
Release Notes: Subscription Add-ons Enhancement
New Features
Improvements
Changes
Compatibility