-
Notifications
You must be signed in to change notification settings - Fork 0
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
[pull] develop from medusajs:develop #8
Conversation
…10673) * fix(core-flows): refresh payment collections upon shipping changes * chore: fix spec
* docs: support generating sidebar items with tags * small fix * fix dependencies * test * test fix * test fix * test fix * test fix * another fix * revert change * fix for resources
**What** - Allow to provide `foreignKeyName` option for hasOne and belongsTo relationships - `model.hasOne(() => OtherEntity, { foreignKey: true, foreignKeyName: 'other_entity_something_id' })` - The above will also output a generated type that takes into consideration the custom fk name 🔽 - Update types to account for defined custom foreign key name - Fix joiner config linkable generation to account for custom linkable keys that provide a public API for their model but are not part of the list of the models included in the MedusaService - This was supposed to be handled correctly but the implementation was not considering that custom linkable keys could reference models not part of the one provided to medusa service - Migrate fulfillment module to DML - Fix has one with fk behaviour and hooks (the relation should be assigned but not the fk) - Fix has one belongsTo hooks (the relation should be assigned but not the fk) - Fix hasOneWithFk and belongsTo non persisted fk to be selectable - Allow to define `belongsTo` without other side definition for `ManyToOne` with no counter part defined - Meaning that if a user defined `belongsTo` on one side andnot mapped by and no counter part on the other entity it will be considered as a `ManyToOne` - `orphanRemoval` on `OneToOne` have been removed, this means that when assigning a new object relation to an entity, the previous one gets deconected but not deleted automatically. This prevent removing data un volountarely **NOTE** As per our convention here are some information to keep in mind **HasOne <> BelongsTo** Define `OneToOne`, The foreign key is owned by the belongs to and the relation needs to be provided to cascade if wanted **HasMany <> BelongsTo** Define `OneToMane` <> `ManyToOne`, the foreign key is owned by the many to one and for those relation no cascade will be performed, the foreign key must be provided. For the `HasMany` the cascade is available **HasOne (with FK)** Will act similarly to belongs to with **HasOne <> BelongsTo** Co-authored-by: Carlos R. L. Rodrigues <[email protected]>
Reviewer's Guide by SourceryThis pull request refactors the Fulfillment module to use the DML (Data Modeling Language) for defining entities and relationships. It also introduces a number of improvements to the existing functionality, including support for custom foreign keys in relationships, improved handling of foreign key assignments, and a more robust implementation of cascading deletes. Additionally, it includes updates to the cart workflows to refresh payment collections when shipping methods are changed, and fixes an issue with updating collections with products. Sequence diagram for adding shipping method to cartsequenceDiagram
participant Client
participant Cart
participant ShippingOption
participant PaymentCollection
Client->>Cart: addShippingMethod
Cart->>ShippingOption: validateShippingOption
Cart->>Cart: removeExistingShippingMethod
Cart->>Cart: addNewShippingMethod
Cart->>Cart: refreshCartItems
Note over Cart: Updated to use refreshCartItems workflow
Cart->>PaymentCollection: refresh
Note over PaymentCollection: Payment collection refreshed after shipping change
Entity relationship diagram for the Fulfillment moduleerDiagram
FULFILLMENT ||--o{ FULFILLMENT_ITEM : contains
FULFILLMENT ||--o| FULFILLMENT_ADDRESS : has
FULFILLMENT ||--o{ FULFILLMENT_LABEL : has
FULFILLMENT }|--|| FULFILLMENT_PROVIDER : provided_by
FULFILLMENT }o--|| SHIPPING_OPTION : uses
SERVICE_ZONE ||--o{ GEO_ZONE : contains
SERVICE_ZONE }|--|| FULFILLMENT_SET : belongs_to
SERVICE_ZONE ||--o{ SHIPPING_OPTION : offers
SHIPPING_OPTION ||--o{ SHIPPING_OPTION_RULE : has
SHIPPING_OPTION ||--|| SHIPPING_OPTION_TYPE : has
SHIPPING_OPTION }o--|| SHIPPING_PROFILE : belongs_to
Class diagram showing the updated Fulfillment module entitiesclassDiagram
class Fulfillment {
+id: string
+location_id: string
+packed_at: Date
+shipped_at: Date
+delivered_at: Date
+canceled_at: Date
+data: Record
+requires_shipping: boolean
}
class FulfillmentItem {
+id: string
+title: string
+sku: string
+barcode: string
+quantity: BigNumber
+line_item_id: string
+inventory_item_id: string
}
class ServiceZone {
+id: string
+name: string
+metadata: Record
}
class GeoZone {
+id: string
+type: GeoZoneType
+country_code: string
+province_code: string
+city: string
+postal_expression: Record
}
class ShippingOption {
+id: string
+name: string
+price_type: ShippingOptionPriceType
+data: Record
+metadata: Record
}
Fulfillment "1" -- "*" FulfillmentItem
ServiceZone "1" -- "*" GeoZone
ServiceZone "1" -- "*" ShippingOption
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 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 (
|
See Commits and Changes for more details.
Created by pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )
Summary by Sourcery
Refactor models to use DML.
New Features:
belongsTo
andhasOne
relations.Tests: