feat: Application types generation from project GQL schema's (#8995)
This commit is contained in:
1 parent
ac30a989f4
commit
2c5e72d141
92 files changed
+5129
-443
No files matched your search
+81
-9
@@ -3,9 +3,9 @@ import { FulfillmentSetDTO, IFulfillmentModuleService } from "@medusajs/types"
|
||||
import { Module, Modules } from "@medusajs/utils"
|
||||
import { FulfillmentModuleService, FulfillmentProviderService } from "@services"
|
||||
import {
|
||||
SuiteOptions,
|
||||
initModules,
|
||||
moduleIntegrationTestRunner,
|
||||
SuiteOptions,
|
||||
} from "medusa-test-utils"
|
||||
import { resolve } from "path"
|
||||
import { createFullDataStructure } from "../../__fixtures__"
|
||||
@@ -109,10 +109,18 @@ moduleIntegrationTestRunner({
|
||||
}).linkable
|
||||
|
||||
expect(Object.keys(linkable)).toEqual([
|
||||
"fulfillment",
|
||||
"fulfillmentAddress",
|
||||
"fulfillmentItem",
|
||||
"fulfillmentLabel",
|
||||
"fulfillmentProvider",
|
||||
"fulfillmentSet",
|
||||
"shippingOption",
|
||||
"fulfillment",
|
||||
"geoZone",
|
||||
"serviceZone",
|
||||
"shippingOptionRule",
|
||||
"shippingOptionType",
|
||||
"shippingOption",
|
||||
"shippingProfile",
|
||||
])
|
||||
|
||||
Object.keys(linkable).forEach((key) => {
|
||||
@@ -120,12 +128,36 @@ moduleIntegrationTestRunner({
|
||||
})
|
||||
|
||||
expect(linkable).toEqual({
|
||||
fulfillment: {
|
||||
fulfillmentAddress: {
|
||||
id: {
|
||||
linkable: "fulfillment_id",
|
||||
linkable: "fulfillment_address_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillment",
|
||||
field: "fulfillmentAddress",
|
||||
},
|
||||
},
|
||||
fulfillmentItem: {
|
||||
id: {
|
||||
linkable: "fulfillment_item_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentItem",
|
||||
},
|
||||
},
|
||||
fulfillmentLabel: {
|
||||
id: {
|
||||
linkable: "fulfillment_label_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentLabel",
|
||||
},
|
||||
},
|
||||
fulfillmentProvider: {
|
||||
id: {
|
||||
linkable: "fulfillment_provider_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "fulfillmentProvider",
|
||||
},
|
||||
},
|
||||
fulfillmentSet: {
|
||||
@@ -136,12 +168,28 @@ moduleIntegrationTestRunner({
|
||||
field: "fulfillmentSet",
|
||||
},
|
||||
},
|
||||
shippingOption: {
|
||||
fulfillment: {
|
||||
id: {
|
||||
linkable: "shipping_option_id",
|
||||
linkable: "fulfillment_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOption",
|
||||
field: "fulfillment",
|
||||
},
|
||||
},
|
||||
geoZone: {
|
||||
id: {
|
||||
linkable: "geo_zone_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "geoZone",
|
||||
},
|
||||
},
|
||||
serviceZone: {
|
||||
id: {
|
||||
linkable: "service_zone_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "serviceZone",
|
||||
},
|
||||
},
|
||||
shippingOptionRule: {
|
||||
@@ -152,6 +200,30 @@ moduleIntegrationTestRunner({
|
||||
field: "shippingOptionRule",
|
||||
},
|
||||
},
|
||||
shippingOptionType: {
|
||||
id: {
|
||||
linkable: "shipping_option_type_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOptionType",
|
||||
},
|
||||
},
|
||||
shippingOption: {
|
||||
id: {
|
||||
linkable: "shipping_option_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingOption",
|
||||
},
|
||||
},
|
||||
shippingProfile: {
|
||||
id: {
|
||||
linkable: "shipping_profile_id",
|
||||
primaryKey: "id",
|
||||
serviceName: "fulfillment",
|
||||
field: "shippingProfile",
|
||||
},
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
import { defineJoinerConfig, Modules } from "@medusajs/utils"
|
||||
import {
|
||||
Fulfillment,
|
||||
FulfillmentProvider,
|
||||
FulfillmentSet,
|
||||
ShippingOption,
|
||||
ShippingOptionRule,
|
||||
} from "@models"
|
||||
import { default as schema } from "./schema"
|
||||
|
||||
export const joinerConfig = defineJoinerConfig(Modules.FULFILLMENT, {
|
||||
schema,
|
||||
linkableKeys: {
|
||||
fulfillment_id: Fulfillment.name,
|
||||
fulfillment_set_id: FulfillmentSet.name,
|
||||
shipping_option_id: ShippingOption.name,
|
||||
shipping_option_rule_id: ShippingOptionRule.name,
|
||||
fulfillment_provider_id: FulfillmentProvider.name,
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,167 @@
|
||||
export default `
|
||||
enum GeoZoneType {
|
||||
country
|
||||
province
|
||||
city
|
||||
zip
|
||||
}
|
||||
|
||||
enum ShippingOptionPriceType {
|
||||
calculated
|
||||
flat
|
||||
}
|
||||
|
||||
type FulfillmentItem {
|
||||
id: ID!
|
||||
title: String!
|
||||
quantity: Int!
|
||||
sku: String!
|
||||
barcode: String!
|
||||
line_item_id: String
|
||||
inventory_item_id: String
|
||||
fulfillment_id: String!
|
||||
fulfillment: Fulfillment!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type FulfillmentLabel {
|
||||
id: ID!
|
||||
tracking_number: String!
|
||||
tracking_url: String!
|
||||
label_url: String!
|
||||
fulfillment_id: String!
|
||||
fulfillment: Fulfillment!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type FulfillmentProvider {
|
||||
id: ID!
|
||||
name: String!
|
||||
metadata: JSON
|
||||
shipping_options: [ShippingOption!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type FulfillmentSet {
|
||||
id: ID!
|
||||
name: String!
|
||||
type: String!
|
||||
metadata: JSON
|
||||
service_zones: [ServiceZone!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type Fulfillment {
|
||||
id: ID!
|
||||
location_id: String!
|
||||
packed_at: DateTime
|
||||
shipped_at: DateTime
|
||||
delivered_at: DateTime
|
||||
canceled_at: DateTime
|
||||
marked_shipped_by: String
|
||||
created_by: String
|
||||
data: JSON
|
||||
provider_id: String!
|
||||
shipping_option_id: String
|
||||
metadata: JSON
|
||||
shipping_option: ShippingOption
|
||||
provider: FulfillmentProvider!
|
||||
delivery_address: FulfillmentAddress!
|
||||
items: [FulfillmentItem!]!
|
||||
labels: [FulfillmentLabel!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type GeoZone {
|
||||
id: ID!
|
||||
type: GeoZoneType!
|
||||
country_code: String!
|
||||
province_code: String
|
||||
city: String
|
||||
postal_expression: JSON
|
||||
metadata: JSON
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type ServiceZone {
|
||||
id: ID!
|
||||
name: String!
|
||||
metadata: JSON
|
||||
fulfillment_set: FulfillmentSet!
|
||||
fulfillment_set_id: String!
|
||||
geo_zones: [GeoZone!]!
|
||||
shipping_options: [ShippingOption!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type ShippingOptionRule {
|
||||
id: ID!
|
||||
attribute: String!
|
||||
operator: String!
|
||||
value: JSON
|
||||
shipping_option_id: String!
|
||||
shipping_option: ShippingOption!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type ShippingOptionType {
|
||||
id: ID!
|
||||
label: String!
|
||||
description: String!
|
||||
code: String!
|
||||
shipping_option_id: String!
|
||||
shipping_option: ShippingOption!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type ShippingOption {
|
||||
id: ID!
|
||||
name: String!
|
||||
price_type: ShippingOptionPriceType!
|
||||
service_zone_id: String!
|
||||
shipping_profile_id: String!
|
||||
provider_id: String!
|
||||
shipping_option_type_id: String
|
||||
data: JSON
|
||||
metadata: JSON
|
||||
service_zone: ServiceZone!
|
||||
shipping_profile: ShippingProfile!
|
||||
fulfillment_provider: FulfillmentProvider!
|
||||
type: ShippingOptionType!
|
||||
rules: [ShippingOptionRule!]!
|
||||
fulfillments: [Fulfillment!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
type ShippingProfile {
|
||||
id: ID!
|
||||
name: String!
|
||||
type: String!
|
||||
metadata: JSON
|
||||
shipping_options: [ShippingOption!]!
|
||||
created_at: DateTime!
|
||||
updated_at: DateTime!
|
||||
deleted_at: DateTime
|
||||
}
|
||||
|
||||
`
|
||||
Reference in new issue
Block a user