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

feat(order): module foundation #6399

Merged
merged 10 commits into from
Feb 15, 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/late-pillows-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/modules-sdk": patch
"@medusajs/types": patch
"@medusajs/utils": patch
---

Initial Order module implementation
4 changes: 2 additions & 2 deletions packages/fulfillment/src/models/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_address",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression

const fulfillmentDeletedAtIndexName = "IDX_fulfillment_address_deleted_at"
const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentDeletedAtIndexName,
tableName: "fulfillment_address",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

@Entity({ tableName: "fulfillment_address" })
export default class Address {
Expand Down
10 changes: 5 additions & 5 deletions packages/fulfillment/src/models/fulfillment-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
Expand All @@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import Fulfillment from "./fulfillment"

type FulfillmentItemOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -26,31 +26,31 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_item",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression

const lineItemIndexName = "IDX_fulfillment_item_line_item_id"
const lineItemIdIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentIdIndexName,
tableName: "fulfillment_item",
columns: "line_item_id",
where: "deleted_at IS NULL",
})
}).expression

const inventoryItemIndexName = "IDX_fulfillment_item_inventory_item_id"
const inventoryItemIdIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentIdIndexName,
tableName: "fulfillment_item",
columns: "inventory_item_id",
where: "deleted_at IS NULL",
})
}).expression

const fulfillmentItemDeletedAtIndexName = "IDX_fulfillment_item_deleted_at"
const fulfillmentItemDeletedAtIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentItemDeletedAtIndexName,
tableName: "fulfillment_item",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
6 changes: 3 additions & 3 deletions packages/fulfillment/src/models/fulfillment-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
Expand All @@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import Fulfillment from "./fulfillment"

type FulfillmentLabelOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -26,15 +26,15 @@ const fulfillmentIdIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_label",
columns: "fulfillment_id",
where: "deleted_at IS NULL",
})
}).expression

const deletedAtIndexName = "IDX_fulfillment_label_deleted_at"
const deletedAtIndexStatement = createPsqlIndexStatementHelper({
name: deletedAtIndexName,
tableName: "fulfillment_label",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
14 changes: 7 additions & 7 deletions packages/fulfillment/src/models/fulfillment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
Expand All @@ -17,12 +18,11 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"
import ServiceProvider from "./service-provider"
import Address from "./address"
import FulfillmentItem from "./fulfillment-item"
import FulfillmentLabel from "./fulfillment-label"
import ServiceProvider from "./service-provider"
import ShippingOption from "./shipping-option"

type FulfillmentOptionalProps = DAL.SoftDeletableEntityDateColumns

Expand All @@ -32,23 +32,23 @@ const fulfillmentDeletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

const fulfillmentProviderIdIndexName = "IDX_fulfillment_provider_id"
const fulfillmentProviderIdIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentProviderIdIndexName,
tableName: "fulfillment",
columns: "provider_id",
where: "deleted_at IS NULL",
})
}).expression

const fulfillmentLocationIdIndexName = "IDX_fulfillment_location_id"
const fulfillmentLocationIdIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentLocationIdIndexName,
tableName: "fulfillment",
columns: "location_id",
where: "deleted_at IS NULL",
})
}).expression

const fulfillmentShippingOptionIdIndexName =
"IDX_fulfillment_shipping_option_id"
Expand All @@ -58,7 +58,7 @@ const fulfillmentShippingOptionIdIndexStatement =
tableName: "fulfillment",
columns: "shipping_option_id",
where: "deleted_at IS NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
6 changes: 3 additions & 3 deletions packages/fulfillment/src/models/fullfilment-set.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Cascade,
Expand All @@ -17,7 +18,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ServiceZone from "./service-zone"

type FulfillmentSetOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -28,7 +28,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "fulfillment_set",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

const nameIndexName = "IDX_fulfillment_set_name_unique"
const nameIndexStatement = createPsqlIndexStatementHelper({
Expand All @@ -37,7 +37,7 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
columns: "name",
unique: true,
where: "deleted_at IS NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
12 changes: 6 additions & 6 deletions packages/fulfillment/src/models/geo-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
GeoZoneType,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
Expand All @@ -17,7 +18,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ServiceZone from "./service-zone"

type GeoZoneOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -28,39 +28,39 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "geo_zone",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

const countryCodeIndexName = "IDX_geo_zone_country_code"
const countryCodeIndexStatement = createPsqlIndexStatementHelper({
name: countryCodeIndexName,
tableName: "geo_zone",
columns: "country_code",
where: "deleted_at IS NULL",
})
}).expression

const provinceCodeIndexName = "IDX_geo_zone_province_code"
const provinceCodeIndexStatement = createPsqlIndexStatementHelper({
name: provinceCodeIndexName,
tableName: "geo_zone",
columns: "province_code",
where: "deleted_at IS NULL AND province_code IS NOT NULL",
})
}).expression

const cityIndexName = "IDX_geo_zone_city"
const cityIndexStatement = createPsqlIndexStatementHelper({
name: cityIndexName,
tableName: "geo_zone",
columns: "city",
where: "deleted_at IS NULL AND city IS NOT NULL",
})
}).expression

const serviceZoneIdIndexName = "IDX_geo_zone_service_zone_id"
const serviceZoneIdStatement = createPsqlIndexStatementHelper({
name: serviceZoneIdIndexName,
tableName: "geo_zone",
columns: "service_zone_id",
where: "deleted_at IS NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
4 changes: 2 additions & 2 deletions packages/fulfillment/src/models/service-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Collection,
Expand All @@ -16,7 +17,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"

type ServiceProviderOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -27,7 +27,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "service_provider",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
8 changes: 4 additions & 4 deletions packages/fulfillment/src/models/service-zone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Cascade,
Expand All @@ -18,7 +19,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import FulfillmentSet from "./fullfilment-set"
import GeoZone from "./geo-zone"
import ShippingOption from "./shipping-option"
Expand All @@ -31,7 +31,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "service_zone",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

const nameIndexName = "IDX_service_zone_name_unique"
const nameIndexStatement = createPsqlIndexStatementHelper({
Expand All @@ -40,15 +40,15 @@ const nameIndexStatement = createPsqlIndexStatementHelper({
columns: "name",
unique: true,
where: "deleted_at IS NULL",
})
}).expression

const fulfillmentSetIdIndexName = "IDX_service_zone_fulfillment_set_id"
const fulfillmentSetIdIndexStatement = createPsqlIndexStatementHelper({
name: fulfillmentSetIdIndexName,
tableName: "service_zone",
columns: "fulfillment_set_id",
where: "deleted_at IS NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
4 changes: 2 additions & 2 deletions packages/fulfillment/src/models/shipping-option-rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
Expand All @@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"

type ShippingOptionRuleOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -29,7 +29,7 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option_rule",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
6 changes: 3 additions & 3 deletions packages/fulfillment/src/models/shipping-option-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
generateEntityId,
} from "@medusajs/utils"

import { DAL } from "@medusajs/types"
import {
BeforeCreate,
Entity,
Expand All @@ -15,7 +16,6 @@ import {
PrimaryKey,
Property,
} from "@mikro-orm/core"
import { DAL } from "@medusajs/types"
import ShippingOption from "./shipping-option"

type ShippingOptionTypeOptionalProps = DAL.SoftDeletableEntityDateColumns
Expand All @@ -26,15 +26,15 @@ const deletedAtIndexStatement = createPsqlIndexStatementHelper({
tableName: "shipping_option_type",
columns: "deleted_at",
where: "deleted_at IS NOT NULL",
})
}).expression

const shippingOptionIdIndexName = "IDX_shipping_option_type_shipping_option_id"
const shippingOptionIdIndexStatement = createPsqlIndexStatementHelper({
name: shippingOptionIdIndexName,
tableName: "shipping_option_type",
columns: "shipping_option_id",
where: "deleted_at IS NULL",
})
}).expression

@Entity()
@Filter(DALUtils.mikroOrmSoftDeletableFilterOptions)
Expand Down
Loading
Loading