Skip to content
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

chore(utils): Update base repository to infer primary keys and support composite #6062

Merged
merged 6 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/cyan-countries-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/authentication": patch
"@medusajs/pricing": patch
"@medusajs/utils": patch
---

chore(utils): Update base repository to infer primary keys and support composite
7 changes: 6 additions & 1 deletion packages/authentication/src/repositories/auth-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export class AuthProviderRepository extends DALUtils.mikroOrmBaseRepositoryFacto
{
create: RepositoryTypes.CreateAuthProviderDTO
}
>(AuthProvider, "provider") {
>(AuthProvider) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async update(
data: RepositoryTypes.UpdateAuthProviderDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/authentication/src/repositories/auth-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import { SqlEntityManager } from "@mikro-orm/postgresql"
export class AuthUserRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
AuthUser
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: RepositoryTypes.CreateAuthUserDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/cart/src/repositories/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class AddressRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: CreateAddressDTO
}
>(Address) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async update(
data: { address: Address; update: UpdateAddressDTO }[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/cart/src/repositories/cart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class CartRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: CreateCartDTO
}
>(Cart) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async update(
data: { cart: Cart; update: UpdateCartDTO }[],
context: Context = {}
Expand Down
7 changes: 6 additions & 1 deletion packages/pricing/src/repositories/currency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class CurrencyRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: RepositoryTypes.CreateCurrencyDTO
update: RepositoryTypes.UpdateCurrencyDTO
}
>(Currency, "code") {}
>(Currency) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/pricing/src/repositories/money-amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class MoneyAmountRepository extends DALUtils.mikroOrmBaseRepositoryFactor
create: RepositoryTypes.CreateMoneyAmountDTO
update: RepositoryTypes.UpdateMoneyAmountDTO
}
>(MoneyAmount) {}
>(MoneyAmount) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
5 changes: 5 additions & 0 deletions packages/pricing/src/repositories/price-list-rule-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class PriceListRuleValueRepository extends DALUtils.mikroOrmBaseRepositor
update: RepositoryTypes.UpdatePriceListRuleValueDTO
}
>(PriceListRuleValue) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: RepositoryTypes.CreatePriceListRuleValueDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/pricing/src/repositories/price-list-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { RepositoryTypes } from "@types"
export class PriceListRuleRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
PriceListRule
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: RepositoryTypes.CreatePriceListRuleDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/pricing/src/repositories/price-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { RepositoryTypes } from "@types"
export class PriceListRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
PriceList
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: RepositoryTypes.CreatePriceListDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/pricing/src/repositories/price-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class PriceRuleRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
update: RepositoryTypes.UpdatePriceRuleDTO
}
>(PriceRule) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: RepositoryTypes.CreatePriceRuleDTO[],
context: Context = {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class PriceSetMoneyAmountRulesRepository extends DALUtils.mikroOrmBaseRep
create: RepositoryTypes.CreatePriceSetMoneyAmountRulesDTO
update: RepositoryTypes.UpdatePriceSetMoneyAmountRulesDTO
}
>(PriceSetMoneyAmountRules) {}
>(PriceSetMoneyAmountRules) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class PriceSetMoneyAmountRepository extends DALUtils.mikroOrmBaseReposito
create: RepositoryTypes.CreatePriceSetMoneyAmountDTO
update: RepositoryTypes.UpdatePriceSetMoneyAmountDTO
}
>(PriceSetMoneyAmount) {}
>(PriceSetMoneyAmount) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/pricing/src/repositories/price-set-rule-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class PriceSetRuleTypeRepository extends DALUtils.mikroOrmBaseRepositoryF
create: RepositoryTypes.CreatePriceSetRuleTypeDTO
update: RepositoryTypes.UpdatePriceSetRuleTypeDTO
}
>(PriceSetRuleType) {}
>(PriceSetRuleType) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/pricing/src/repositories/price-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ export class PriceSetRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: RepositoryTypes.CreatePriceSetDTO
update: RepositoryTypes.UpdatePriceSetDTO
}
>(PriceSet) {}
>(PriceSet) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/pricing/src/repositories/rule-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export class RuleTypeRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: RepositoryTypes.CreateRuleTypeDTO
update: RepositoryTypes.UpdateRuleTypeDTO
}
>(RuleType) {}
>(RuleType) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ type CreateProductCollection = ProductTypes.CreateProductCollectionDTO & {
export class ProductCollectionRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
ProductCollection
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: CreateProductCollection[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { DALUtils } from "@medusajs/utils"
export class ProductImageRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
Image
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async upsert(urls: string[], context: Context = {}): Promise<Image[]> {
const manager = this.getActiveManager<SqlEntityManager>(context)

Expand Down
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-option-value.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import { SqlEntityManager } from "@mikro-orm/postgresql"
export class ProductOptionValueRepository extends DALUtils.mikroOrmBaseRepositoryFactory(
ProductOptionValue
) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async upsert(
optionValues: (UpdateProductOptionValueDTO | CreateProductOptionValueDTO)[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ export class ProductOptionRepository extends DALUtils.mikroOrmBaseRepositoryFact
update: ProductTypes.UpdateProductOptionDTO
}
>(ProductOption) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async create(
data: ProductTypes.CreateProductOptionDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-tag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export class ProductTagRepository extends DALUtils.mikroOrmBaseRepositoryFactory
update: UpdateProductTagDTO
}
>(ProductTag) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async upsert(
tags: UpsertProductTagDTO[],
context: Context = {}
Expand Down
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export class ProductTypeRepository extends DALUtils.mikroOrmBaseRepositoryFactor
update: UpdateProductTypeDTO
}
>(ProductType) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async upsert(
types: CreateProductTypeDTO[],
context: Context = {}
Expand Down
7 changes: 6 additions & 1 deletion packages/product/src/repositories/product-variant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ export class ProductVariantRepository extends DALUtils.mikroOrmBaseRepositoryFac
"id"
>
}
>(ProductVariant) {}
>(ProductVariant) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
5 changes: 5 additions & 0 deletions packages/product/src/repositories/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export class ProductRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: WithRequiredProperty<ProductTypes.CreateProductOnlyDTO, "status">
}
>(Product) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}

async find(
findOptions: DAL.FindOptions<Product & { q?: string }> = { where: {} },
context: Context = {}
Expand Down
7 changes: 6 additions & 1 deletion packages/promotion/src/repositories/application-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export class ApplicationMethodRepository extends DALUtils.mikroOrmBaseRepository
create: CreateApplicationMethodDTO
update: UpdateApplicationMethodDTO
}
>(ApplicationMethod) {}
>(ApplicationMethod) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@ export class PromotionRuleValueRepository extends DALUtils.mikroOrmBaseRepositor
create: CreatePromotionRuleValueDTO
update: UpdatePromotionRuleValueDTO
}
>(PromotionRuleValue) {}
>(PromotionRuleValue) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/promotion/src/repositories/promotion-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export class PromotionRuleRepository extends DALUtils.mikroOrmBaseRepositoryFact
create: CreatePromotionRuleDTO
update: UpdatePromotionRuleDTO
}
>(PromotionRule) {}
>(PromotionRule) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
7 changes: 6 additions & 1 deletion packages/promotion/src/repositories/promotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ export class PromotionRepository extends DALUtils.mikroOrmBaseRepositoryFactory<
create: CreatePromotionDTO
Update: UpdatePromotionDTO
}
>(Promotion) {}
>(Promotion) {
constructor(...args: any[]) {
// @ts-ignore
super(...arguments)
}
}
Loading