Skip to content

Commit

Permalink
lint content
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Oct 3, 2024
1 parent b7712ff commit d1bcf12
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@ import { faker } from "@faker-js/faker"
import {
ContainerRegistrationKeys,
Modules,
ProductStatus
} from "@medusajs/framework/utils";
ProductStatus,
} from "@medusajs/framework/utils"
import {
createInventoryLevelsWorkflow,
createProductsWorkflow
} from "@medusajs/medusa/core-flows";
createProductsWorkflow,
} from "@medusajs/medusa/core-flows"

export default async function seedDummyProducts ({
container
export default async function seedDummyProducts({
container,
}: ExecArgs) {
const salesChannelModuleService = container.resolve(
Modules.SALES_CHANNEL
);
)
const logger = container.resolve(
ContainerRegistrationKeys.LOGGER
)
const query = container.resolve(
ContainerRegistrationKeys.QUERY
)

let defaultSalesChannel = await salesChannelModuleService
const defaultSalesChannel = await salesChannelModuleService
.listSalesChannels({
name: "Default Sales Channel",
});
})

const sizeOptions = ["S", "M", "L", "XL"];
const colorOptions = ["Black", "White"];
const sizeOptions = ["S", "M", "L", "XL"]
const colorOptions = ["Black", "White"]
const currency_code = "eur"
const productsNum = 50

Expand All @@ -85,7 +85,7 @@ Next, replace the `TODO` with the following:

```ts title="src/scripts/demo-products.ts"
const productsData = new Array(productsNum).fill(0).map((_, index) => {
const title = faker.commerce.product() + '_' + index
const title = faker.commerce.product() + "_" + index
return {
title,
is_giftcard: true,
Expand All @@ -104,12 +104,12 @@ const productsData = new Array(productsNum).fill(0).map((_, index) => {
images: [
{
url: faker.image.urlPlaceholder({
text: title
text: title,
}),
},
{
url: faker.image.urlPlaceholder({
text: title
text: title,
}),
},
],
Expand Down Expand Up @@ -142,7 +142,7 @@ Then, replace the new `TODO` with the following:
```ts title="src/scripts/demo-products.ts"
const { result: products } = await createProductsWorkflow(container).run({
input: {
products: productsData
products: productsData,
},
})

Expand All @@ -156,16 +156,16 @@ You create the generated products using the `createProductsWorkflow` imported pr
Only thing left is to create inventory levels for the products. So, replace the last `TODO` with the following:

```ts title="src/scripts/demo-products.ts"
logger.info("Seeding inventory levels.");
logger.info("Seeding inventory levels.")

const { data: stockLocations } = await query.graph({
entity: "stock_location",
fields: ["id"]
fields: ["id"],
})

const { data: inventoryItems } = await query.graph({
entity: 'inventory_item',
fields: ['id']
entity: "inventory_item",
fields: ["id"],
})

const inventoryLevels = inventoryItems.map((inventoryItem) => ({
Expand All @@ -176,11 +176,11 @@ const inventoryLevels = inventoryItems.map((inventoryItem) => ({

await createInventoryLevelsWorkflow(container).run({
input: {
inventory_levels: inventoryLevels
inventory_levels: inventoryLevels,
},
})

logger.info("Finished seeding inventory levels data.");
logger.info("Finished seeding inventory levels data.")
```

You use Query to retrieve the stock location, to use the first location in the application, and the inventory items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ export default defineLink(
extraColumns: {
metadata: {
type: "json",
}
}
}
},
},
},
}
)
```
Expand Down Expand Up @@ -94,16 +94,16 @@ Learn more about the remote link, how to resolve it, and its methods in [this ch
```ts
await remoteLink.create({
[Modules.PRODUCT]: {
product_id: "123"
product_id: "123",
},
HELLO_MODULE: {
my_custom_id: "321"
my_custom_id: "321",
},
data: {
metadata: {
test: true
}
}
test: true,
},
},
})
```

Expand Down Expand Up @@ -138,8 +138,8 @@ const { data } = await query.graph({
entity: productHelloLink.entryPoint,
fields: ["metadata", "product.*", "my_custom.*"],
filters: {
product_id: "prod_123"
}
product_id: "prod_123",
},
})
```

Expand All @@ -160,15 +160,15 @@ For example:
```ts
await remoteLink.create({
[Modules.PRODUCT]: {
product_id: "123"
product_id: "123",
},
HELLO_MODULE: {
my_custom_id: "321"
my_custom_id: "321",
},
data: {
metadata: {
test: false
}
}
test: false,
},
},
})
```
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const methodsHighlight = [
// other imports...
import {
InjectManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"

class HelloModuleService {
Expand Down Expand Up @@ -99,7 +99,7 @@ export const opHighlights = [
import {
InjectManager,
InjectTransactionManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@mikro-orm/knex"
Expand All @@ -118,10 +118,10 @@ class HelloModuleService {
await transactionManager.nativeUpdate(
"my_custom",
{
id: input.id
id: input.id,
},
{
name: input.name
name: input.name,
}
)

Expand Down Expand Up @@ -307,7 +307,7 @@ export const repoHighlights = [
import {
InjectManager,
InjectTransactionManager,
MedusaContext
MedusaContext,
} from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@mikro-orm/knex"
Expand All @@ -327,10 +327,10 @@ class HelloModuleService {
await transactionManager.nativeUpdate(
"my_custom",
{
id: input.id
id: input.id,
},
{
name: input.name
name: input.name,
}
)

Expand All @@ -342,7 +342,7 @@ class HelloModuleService {
return updatedRecord
},
{
transaction: sharedContext.transactionManager
transaction: sharedContext.transactionManager,
}
)
}
Expand Down Expand Up @@ -397,7 +397,7 @@ class HelloModuleService {
// ...
},
{
transaction: sharedContext.transactionManager
transaction: sharedContext.transactionManager,
}
)
}
Expand Down Expand Up @@ -430,7 +430,7 @@ class HelloModuleService {
// ...
},
{
isolationLevel: IsolationLevel.READ_COMMITTED
isolationLevel: IsolationLevel.READ_COMMITTED,
}
)
}
Expand All @@ -456,7 +456,7 @@ class HelloModuleService {
// ...
},
{
enableNestedTransactions: false
enableNestedTransactions: false,
}
)
}
Expand Down

0 comments on commit d1bcf12

Please sign in to comment.