chore: Fix merge conflicts with master
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
chores(medusa): Improve draft order creation perf flow
|
||||||
@@ -3917,7 +3917,7 @@ Then, in your `.env` file add the API key you created earlier as well as the sen
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
SENDGRID_API_KEY=<API_KEY>
|
SENDGRID_API_KEY=<API_KEY>
|
||||||
SENDGRID_FROM=<YOUR_SEND_FROM>
|
SENDGRID_FROM=<SEND_FROM_EMAIL>
|
||||||
```
|
```
|
||||||
|
|
||||||
Make sure to replace the `<API_KEY>` with the SendGrid API key and the `<SEND_FROM_EMAIL>` with the email you’re using in SendGrid as the single sender.
|
Make sure to replace the `<API_KEY>` with the SendGrid API key and the `<SEND_FROM_EMAIL>` with the email you’re using in SendGrid as the single sender.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ addHowToData: true
|
|||||||
|
|
||||||
In this document, you’ll learn how to create a [Migration](overview.md) using [Typeorm](https://typeorm.io) on your Medusa server.
|
In this document, you’ll learn how to create a [Migration](overview.md) using [Typeorm](https://typeorm.io) on your Medusa server.
|
||||||
|
|
||||||
## Create Migration File
|
## Step 1: Create Migration File
|
||||||
|
|
||||||
To create a migration that makes changes to your Medusa schema, run the following command:
|
To create a migration that makes changes to your Medusa schema, run the following command:
|
||||||
|
|
||||||
@@ -19,15 +19,62 @@ This will create the migration file in the path you specify. You can use this wi
|
|||||||
|
|
||||||
The migration file must be inside the `src/migrations` directory. When you run the build command, it will be transpiled into the directory `dist/migrations`. The `migrations run` command can only pick up migrations under the `dist/migrations` directory on a Medusa server. This applies to migrations created in a Medusa server, and not in a Medusa plugin. For plugins, check out the [Plugin's Structure section](../plugins/create.md).
|
The migration file must be inside the `src/migrations` directory. When you run the build command, it will be transpiled into the directory `dist/migrations`. The `migrations run` command can only pick up migrations under the `dist/migrations` directory on a Medusa server. This applies to migrations created in a Medusa server, and not in a Medusa plugin. For plugins, check out the [Plugin's Structure section](../plugins/create.md).
|
||||||
|
|
||||||
:::tip
|
<details>
|
||||||
|
<summary>Generating Migrations for Entities</summary>
|
||||||
|
|
||||||
You can alternatively use Typeorm's `generate` command to generate a Migration file from existing database tables, which requires setting up a data source in Typeorm. Check out Typeorm's documentation to learn [how to create a data source](https://typeorm.io/data-source#creating-a-new-datasource), then use the [generate command](https://typeorm.io/using-cli#generate-a-migration-from-existing-table-schema).
|
You can alternatively use Typeorm's `generate` command to generate a Migration file from existing entity classes. As Medusa uses v0.2.45 of Typeorm, you have to create a `ormconfig.json` first before using the `generate` command.
|
||||||
|
|
||||||
|
:::note
|
||||||
|
|
||||||
|
Typeorm will be updated to the latest version in v1.8.0 of Medusa.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
For example, create the file `ormconfig.json` in the root of your Medusa server with the following content:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "postgres",
|
||||||
|
"host": "localhost",
|
||||||
|
"port": 5432,
|
||||||
|
"username": "<YOUR_DB_USERNAME>",
|
||||||
|
"password": "<YOUR_DB_PASSWORD>",
|
||||||
|
"database": "<YOUR_DB_NAME>",
|
||||||
|
"synchronize": true,
|
||||||
|
"logging": false,
|
||||||
|
"entities": [
|
||||||
|
"dist/models/**/*.js"
|
||||||
|
],
|
||||||
|
"migrations": [
|
||||||
|
"dist/migrations/**/*.js"
|
||||||
|
],
|
||||||
|
"cli": {
|
||||||
|
"entitiesDir": "src/models",
|
||||||
|
"migrationsDir": "src/migrations"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Make sure to replace `<YOUR_DB_USERNAME>`, `<YOUR_DB_PASSWORD>`, and `<YOUR_DB_NAME>` with the necessary values for your database connection.
|
||||||
|
|
||||||
|
Then, after creating your entity, run the `build` command:
|
||||||
|
|
||||||
|
```bash npm2yarn
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
|
|
||||||
|
Finally, run the following command to generate a Migration for your new entity:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npx typeorm@0.2.45 migration:generate -n PostCreate
|
||||||
|
```
|
||||||
|
|
||||||
|
Where `PostCreate` is just an example of the name of the migration to generate. The migration will then be generated in `src/migrations/<TIMESTAMP>-PostCreate.ts`. You can then skip to step 3 of this guide.
|
||||||
|
</details>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Write Migration File
|
## Step 2: Write Migration File
|
||||||
|
|
||||||
The migration file contains the necessary commands to create the database columns, foreign keys, and more.
|
The migration file contains the necessary commands to create the database columns, foreign keys, and more.
|
||||||
|
|
||||||
@@ -35,7 +82,7 @@ You can learn more about writing the migration file in You can learn more about
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Build Files
|
## Step 3: Build Files
|
||||||
|
|
||||||
Before you can run the migrations you need to run the build command to transpile the TypeScript files to JavaScript files:
|
Before you can run the migrations you need to run the build command to transpile the TypeScript files to JavaScript files:
|
||||||
|
|
||||||
@@ -45,7 +92,7 @@ npm run build
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Run Migration
|
## Step 4: Run Migration
|
||||||
|
|
||||||
The last step is to run the migration with the command detailed earlier
|
The last step is to run the migration with the command detailed earlier
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 8
|
sidebar_position: 9
|
||||||
description: 'Actions Required for v.1.3.0'
|
description: 'Actions Required for v.1.3.0'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 7
|
sidebar_position: 8
|
||||||
description: 'Actions Required for v.1.3.0'
|
description: 'Actions Required for v.1.3.0'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 6
|
sidebar_position: 7
|
||||||
description: 'Actions Required for v.1.3.0'
|
description: 'Actions Required for v.1.3.0'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 5
|
sidebar_position: 6
|
||||||
description: 'Actions Required for v.1.6.1'
|
description: 'Actions Required for v.1.6.1'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 4
|
sidebar_position: 5
|
||||||
description: 'Actions Required for v.1.7.0'
|
description: 'Actions Required for v.1.7.0'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 3
|
sidebar_position: 4
|
||||||
description: 'Actions Required for v.1.7.1'
|
description: 'Actions Required for v.1.7.1'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 1
|
||||||
|
description: 'Actions Required for v.1.7.12'
|
||||||
|
---
|
||||||
|
|
||||||
|
# v1.7.12
|
||||||
|
|
||||||
|
Version 1.7.12 of Medusa introduces some database schema changes which require running the migrations command.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
This release contains a migration to ensure that the `product_variant_inventory` table is in its correct state. This is due to a mistake in a previous version where a column name was renamed in an already released migration. This could lead to errors if the migration was applied before the renaming of the column.
|
||||||
|
|
||||||
|
## Actions Required
|
||||||
|
|
||||||
|
### Run Migrations
|
||||||
|
|
||||||
|
After updating your Medusa server and before running it, run the following command to run the latest migrations:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
medusa migrations run
|
||||||
|
```
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 2
|
sidebar_position: 3
|
||||||
description: 'Actions Required for v.1.7.3'
|
description: 'Actions Required for v.1.7.3'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 1
|
sidebar_position: 2
|
||||||
description: 'Actions Required for v.1.7.6'
|
description: 'Actions Required for v.1.7.6'
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
# @medusajs/inventory
|
# @medusajs/inventory
|
||||||
|
|
||||||
|
## 1.0.9
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- Updated dependencies [[`ce577f269`](https://github.com/medusajs/medusa/commit/ce577f2696aa2181bef8f3096b1a639feabe2714), [`aa0d1f321`](https://github.com/medusajs/medusa/commit/aa0d1f32153f82c6219efe5cfc08862db5e5a129), [`9f508c8bd`](https://github.com/medusajs/medusa/commit/9f508c8bd8bee63677504cc8b86f1643579945d8)]:
|
||||||
|
- @medusajs/medusa@1.7.12
|
||||||
|
|
||||||
## 1.0.8
|
## 1.0.8
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@medusajs/inventory",
|
"name": "@medusajs/inventory",
|
||||||
"version": "1.0.8",
|
"version": "1.0.9",
|
||||||
"description": "Inventory Module for Medusa",
|
"description": "Inventory Module for Medusa",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"test:unit": "jest --passWithNoTests"
|
"test:unit": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@medusajs/medusa": "1.7.11",
|
"@medusajs/medusa": "1.7.12",
|
||||||
"typeorm": "^0.3.11"
|
"typeorm": "^0.3.11"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,15 @@
|
|||||||
# Change Log
|
# Change Log
|
||||||
|
|
||||||
|
## 1.7.12
|
||||||
|
|
||||||
|
### Patch Changes
|
||||||
|
|
||||||
|
- [#3394](https://github.com/medusajs/medusa/pull/3394) [`ce577f269`](https://github.com/medusajs/medusa/commit/ce577f2696aa2181bef8f3096b1a639feabe2714) Thanks [@olivermrbl](https://github.com/olivermrbl)! - feat(medusa): Add global job options for events
|
||||||
|
|
||||||
|
- [#3388](https://github.com/medusajs/medusa/pull/3388) [`aa0d1f321`](https://github.com/medusajs/medusa/commit/aa0d1f32153f82c6219efe5cfc08862db5e5a129) Thanks [@olivermrbl](https://github.com/olivermrbl)! - fix(medusa): Remove default job age option from EventBus
|
||||||
|
|
||||||
|
- [#3384](https://github.com/medusajs/medusa/pull/3384) [`9f508c8bd`](https://github.com/medusajs/medusa/commit/9f508c8bd8bee63677504cc8b86f1643579945d8) Thanks [@pKorsholm](https://github.com/pKorsholm)! - Fix(medusa): Column naming on migrations
|
||||||
|
|
||||||
## 1.7.11
|
## 1.7.11
|
||||||
|
|
||||||
### Patch Changes
|
### Patch Changes
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@medusajs/medusa",
|
"name": "@medusajs/medusa",
|
||||||
"version": "1.7.11",
|
"version": "1.7.12",
|
||||||
"description": "E-commerce for JAMstack",
|
"description": "E-commerce for JAMstack",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"bin": "./cli.js",
|
"bin": "./cli.js",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ export class multiLocation1671711415179 implements MigrationInterface {
|
|||||||
`CREATE INDEX "IDX_c2203162ca946a71aeb98390b0" ON "sales_channel_location" ("location_id") `
|
`CREATE INDEX "IDX_c2203162ca946a71aeb98390b0" ON "sales_channel_location" ("location_id") `
|
||||||
)
|
)
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE TABLE "product_variant_inventory_item" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "inventory_item_id" text NOT NULL, "variant_id" text NOT NULL, "required_quantity" integer NOT NULL DEFAULT '1', CONSTRAINT "UQ_c9be7c1b11a1a729eb51d1b6bca" UNIQUE ("variant_id", "inventory_item_id"), CONSTRAINT "PK_9a1188b8d36f4d198303b4f7efa" PRIMARY KEY ("id"))`
|
`CREATE TABLE "product_variant_inventory_item" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "inventory_item_id" text NOT NULL, "variant_id" text NOT NULL, "quantity" integer NOT NULL DEFAULT '1', CONSTRAINT "UQ_c9be7c1b11a1a729eb51d1b6bca" UNIQUE ("variant_id", "inventory_item_id"), CONSTRAINT "PK_9a1188b8d36f4d198303b4f7efa" PRIMARY KEY ("id"))`
|
||||||
)
|
)
|
||||||
await queryRunner.query(
|
await queryRunner.query(
|
||||||
`CREATE INDEX "IDX_c74e8c2835094a37dead376a3b" ON "product_variant_inventory_item" ("inventory_item_id") `
|
`CREATE INDEX "IDX_c74e8c2835094a37dead376a3b" ON "product_variant_inventory_item" ("inventory_item_id") `
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm"
|
||||||
|
|
||||||
|
export class ensureRequiredQuantity1678093365811 implements MigrationInterface {
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`
|
||||||
|
DO
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
ALTER TABLE product_variant_inventory_item
|
||||||
|
RENAME COLUMN quantity TO required_quantity;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN undefined_column THEN
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`
|
||||||
|
DO
|
||||||
|
$$
|
||||||
|
BEGIN
|
||||||
|
ALTER TABLE product_variant_inventory_item
|
||||||
|
RENAME COLUMN required_quantity TO quantity;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN undefined_column THEN
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
`)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import CustomShippingOptionService from "../custom-shipping-option"
|
|
||||||
import { MockManager, MockRepository } from "medusa-test-utils"
|
import { MockManager, MockRepository } from "medusa-test-utils"
|
||||||
|
import CustomShippingOptionService from "../custom-shipping-option"
|
||||||
|
|
||||||
describe("CustomShippingOptionService", () => {
|
describe("CustomShippingOptionService", () => {
|
||||||
describe("list", () => {
|
describe("list", () => {
|
||||||
@@ -118,19 +118,17 @@ describe("CustomShippingOptionService", () => {
|
|||||||
cart_id: "test-cso-cart",
|
cart_id: "test-cso-cart",
|
||||||
shipping_option_id: "test-so",
|
shipping_option_id: "test-so",
|
||||||
price: 30,
|
price: 30,
|
||||||
metadata: undefined,
|
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
expect(customShippingOptionRepository.save).toHaveBeenCalledTimes(1)
|
expect(customShippingOptionRepository.save).toHaveBeenCalledTimes(1)
|
||||||
expect(customShippingOptionRepository.save).toHaveBeenCalledWith({
|
expect(customShippingOptionRepository.save).toHaveBeenCalledWith({
|
||||||
id: "test-cso",
|
|
||||||
0: {
|
0: {
|
||||||
cart_id: "test-cso-cart",
|
cart_id: "test-cso-cart",
|
||||||
shipping_option_id: "test-so",
|
shipping_option_id: "test-so",
|
||||||
price: 30,
|
price: 30,
|
||||||
metadata: undefined,
|
|
||||||
},
|
},
|
||||||
|
id: "test-cso",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -141,6 +141,149 @@ describe("EventBusService", () => {
|
|||||||
expect(eventBus.queue_.add).toHaveBeenCalled()
|
expect(eventBus.queue_.add).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe("successfully adds job to queue with local options", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
jest.resetAllMocks()
|
||||||
|
const stagedJobRepository = MockRepository({
|
||||||
|
find: () => Promise.resolve([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus = new EventBusService({
|
||||||
|
logger: loggerMock,
|
||||||
|
manager: MockManager,
|
||||||
|
stagedJobRepository,
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus.queue_.add.mockImplementationOnce(() => "hi")
|
||||||
|
|
||||||
|
job = eventBus.emit(
|
||||||
|
"eventName",
|
||||||
|
{ hi: "1234" },
|
||||||
|
{ removeOnComplete: 100 }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
afterAll(async () => {
|
||||||
|
await eventBus.stopEnqueuer()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("calls queue.add", () => {
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalled()
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalledWith(
|
||||||
|
{ eventName: "eventName", data: { hi: "1234" } },
|
||||||
|
{ removeOnComplete: 100 }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("successfully adds job to queue with global options", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
jest.resetAllMocks()
|
||||||
|
const stagedJobRepository = MockRepository({
|
||||||
|
find: () => Promise.resolve([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus = new EventBusService(
|
||||||
|
{
|
||||||
|
logger: loggerMock,
|
||||||
|
manager: MockManager,
|
||||||
|
stagedJobRepository,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
projectConfig: { event_options: { removeOnComplete: 10 } },
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
eventBus.queue_.add.mockImplementationOnce(() => "hi")
|
||||||
|
|
||||||
|
job = eventBus.emit("eventName", { hi: "1234" })
|
||||||
|
})
|
||||||
|
afterAll(async () => {
|
||||||
|
await eventBus.stopEnqueuer()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("calls queue.add", () => {
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalled()
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalledWith(
|
||||||
|
{ eventName: "eventName", data: { hi: "1234" } },
|
||||||
|
{ removeOnComplete: 10, attempts: 1 }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("successfully adds job to queue with default options", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
jest.resetAllMocks()
|
||||||
|
const stagedJobRepository = MockRepository({
|
||||||
|
find: () => Promise.resolve([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus = new EventBusService({
|
||||||
|
logger: loggerMock,
|
||||||
|
manager: MockManager,
|
||||||
|
stagedJobRepository,
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus.queue_.add.mockImplementationOnce(() => "hi")
|
||||||
|
|
||||||
|
job = eventBus.emit("eventName", { hi: "1234" })
|
||||||
|
})
|
||||||
|
afterAll(async () => {
|
||||||
|
await eventBus.stopEnqueuer()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("calls queue.add", () => {
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalled()
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalledWith(
|
||||||
|
{ eventName: "eventName", data: { hi: "1234" } },
|
||||||
|
{ removeOnComplete: true, attempts: 1 }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe("successfully adds job to queue with local options and global options merged", () => {
|
||||||
|
beforeAll(() => {
|
||||||
|
jest.resetAllMocks()
|
||||||
|
const stagedJobRepository = MockRepository({
|
||||||
|
find: () => Promise.resolve([]),
|
||||||
|
})
|
||||||
|
|
||||||
|
eventBus = new EventBusService(
|
||||||
|
{
|
||||||
|
logger: loggerMock,
|
||||||
|
manager: MockManager,
|
||||||
|
stagedJobRepository,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
projectConfig: { event_options: { removeOnComplete: 10 } },
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
eventBus.queue_.add.mockImplementationOnce(() => "hi")
|
||||||
|
|
||||||
|
job = eventBus.emit(
|
||||||
|
"eventName",
|
||||||
|
{ hi: "1234" },
|
||||||
|
{ attempts: 10, delay: 1000, backoff: { type: "exponential" } }
|
||||||
|
)
|
||||||
|
})
|
||||||
|
afterAll(async () => {
|
||||||
|
await eventBus.stopEnqueuer()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("calls queue.add", () => {
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalled()
|
||||||
|
expect(eventBus.queue_.add).toHaveBeenCalledWith(
|
||||||
|
{ eventName: "eventName", data: { hi: "1234" } },
|
||||||
|
{
|
||||||
|
removeOnComplete: 10, // global option
|
||||||
|
attempts: 10, // local option
|
||||||
|
delay: 1000, // local option
|
||||||
|
backoff: { type: "exponential" }, // local option
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("worker", () => {
|
describe("worker", () => {
|
||||||
|
|||||||
@@ -1,6 +1,26 @@
|
|||||||
import { isEmpty, isEqual } from "lodash"
|
import { isEmpty, isEqual } from "lodash"
|
||||||
import { isDefined, MedusaError } from "medusa-core-utils"
|
import { isDefined, MedusaError } from "medusa-core-utils"
|
||||||
import { DeepPartial, EntityManager, In, IsNull, Not } from "typeorm"
|
import { DeepPartial, EntityManager, In, IsNull, Not } from "typeorm"
|
||||||
|
import {
|
||||||
|
CustomerService,
|
||||||
|
CustomShippingOptionService,
|
||||||
|
DiscountService,
|
||||||
|
EventBusService,
|
||||||
|
GiftCardService,
|
||||||
|
LineItemAdjustmentService,
|
||||||
|
LineItemService,
|
||||||
|
NewTotalsService,
|
||||||
|
PaymentProviderService,
|
||||||
|
ProductService,
|
||||||
|
ProductVariantInventoryService,
|
||||||
|
ProductVariantService,
|
||||||
|
RegionService,
|
||||||
|
SalesChannelService,
|
||||||
|
ShippingOptionService,
|
||||||
|
StoreService,
|
||||||
|
TaxProviderService,
|
||||||
|
TotalsService,
|
||||||
|
} from "."
|
||||||
import { IPriceSelectionStrategy, TransactionBaseService } from "../interfaces"
|
import { IPriceSelectionStrategy, TransactionBaseService } from "../interfaces"
|
||||||
import SalesChannelFeatureFlag from "../loaders/feature-flags/sales-channels"
|
import SalesChannelFeatureFlag from "../loaders/feature-flags/sales-channels"
|
||||||
import {
|
import {
|
||||||
@@ -36,30 +56,10 @@ import {
|
|||||||
TotalField,
|
TotalField,
|
||||||
WithRequiredProperty,
|
WithRequiredProperty,
|
||||||
} from "../types/common"
|
} from "../types/common"
|
||||||
|
import { PaymentSessionInput } from "../types/payment"
|
||||||
import { buildQuery, isString, setMetadata } from "../utils"
|
import { buildQuery, isString, setMetadata } from "../utils"
|
||||||
import { FlagRouter } from "../utils/flag-router"
|
import { FlagRouter } from "../utils/flag-router"
|
||||||
import { validateEmail } from "../utils/is-email"
|
import { validateEmail } from "../utils/is-email"
|
||||||
import { PaymentSessionInput } from "../types/payment"
|
|
||||||
import {
|
|
||||||
CustomerService,
|
|
||||||
CustomShippingOptionService,
|
|
||||||
DiscountService,
|
|
||||||
EventBusService,
|
|
||||||
GiftCardService,
|
|
||||||
LineItemAdjustmentService,
|
|
||||||
LineItemService,
|
|
||||||
NewTotalsService,
|
|
||||||
PaymentProviderService,
|
|
||||||
ProductService,
|
|
||||||
ProductVariantInventoryService,
|
|
||||||
ProductVariantService,
|
|
||||||
RegionService,
|
|
||||||
SalesChannelService,
|
|
||||||
ShippingOptionService,
|
|
||||||
StoreService,
|
|
||||||
TaxProviderService,
|
|
||||||
TotalsService,
|
|
||||||
} from "."
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { MedusaError } from "medusa-core-utils"
|
import { MedusaError } from "medusa-core-utils"
|
||||||
import { EntityManager } from "typeorm"
|
import { DeepPartial, EntityManager } from "typeorm"
|
||||||
import { TransactionBaseService } from "../interfaces"
|
import { TransactionBaseService } from "../interfaces"
|
||||||
import { CustomShippingOption } from "../models"
|
import { CustomShippingOption } from "../models"
|
||||||
import { CustomShippingOptionRepository } from "../repositories/custom-shipping-option"
|
import { CustomShippingOptionRepository } from "../repositories/custom-shipping-option"
|
||||||
import { FindConfig, Selector } from "../types/common"
|
import { FindConfig, Selector } from "../types/common"
|
||||||
import { CreateCustomShippingOptionInput } from "../types/shipping-options"
|
import { CreateCustomShippingOptionInput } from "../types/shipping-options"
|
||||||
import { buildQuery } from "../utils"
|
import { buildQuery } from "../utils"
|
||||||
import { DeepPartial } from "typeorm/common/DeepPartial"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
@@ -87,7 +86,6 @@ class CustomShippingOptionService extends TransactionBaseService {
|
|||||||
const customShippingOptionRepo = this.activeManager_.withRepository(
|
const customShippingOptionRepo = this.activeManager_.withRepository(
|
||||||
this.customShippingOptionRepository_
|
this.customShippingOptionRepository_
|
||||||
)
|
)
|
||||||
|
|
||||||
const data_ = (
|
const data_ = (
|
||||||
Array.isArray(data) ? data : [data]
|
Array.isArray(data) ? data : [data]
|
||||||
) as DeepPartial<CustomShippingOption>[]
|
) as DeepPartial<CustomShippingOption>[]
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { OrderRepository } from "../repositories/order"
|
|||||||
import { PaymentRepository } from "../repositories/payment"
|
import { PaymentRepository } from "../repositories/payment"
|
||||||
import { FindConfig } from "../types/common"
|
import { FindConfig } from "../types/common"
|
||||||
import { DraftOrderCreateProps } from "../types/draft-orders"
|
import { DraftOrderCreateProps } from "../types/draft-orders"
|
||||||
|
import { GenerateInputData } from "../types/line-item"
|
||||||
import { buildQuery } from "../utils"
|
import { buildQuery } from "../utils"
|
||||||
import CartService from "./cart"
|
import CartService from "./cart"
|
||||||
import CustomShippingOptionService from "./custom-shipping-option"
|
import CustomShippingOptionService from "./custom-shipping-option"
|
||||||
@@ -28,7 +29,6 @@ import EventBusService from "./event-bus"
|
|||||||
import LineItemService from "./line-item"
|
import LineItemService from "./line-item"
|
||||||
import ProductVariantService from "./product-variant"
|
import ProductVariantService from "./product-variant"
|
||||||
import ShippingOptionService from "./shipping-option"
|
import ShippingOptionService from "./shipping-option"
|
||||||
import { GenerateInputData } from "../types/line-item"
|
|
||||||
|
|
||||||
type InjectedDependencies = {
|
type InjectedDependencies = {
|
||||||
manager: EntityManager
|
manager: EntityManager
|
||||||
@@ -352,7 +352,7 @@ class DraftOrderService extends TransactionBaseService {
|
|||||||
cart_id: createdCart.id,
|
cart_id: createdCart.id,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
itemsToCreate.push(...toCreate)
|
promises.push(lineItemServiceTx.create(toCreate))
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom line items can be added to a draft order
|
// custom line items can be added to a draft order
|
||||||
|
|||||||
@@ -49,8 +49,6 @@ export type EmitOptions = {
|
|||||||
}
|
}
|
||||||
} & JobOptions
|
} & JobOptions
|
||||||
|
|
||||||
const COMPLETED_JOB_TTL = 10000
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can keep track of multiple subscribers to different events and run the
|
* Can keep track of multiple subscribers to different events and run the
|
||||||
* subscribers when events happen. Events will run asynchronously.
|
* subscribers when events happen. Events will run asynchronously.
|
||||||
@@ -227,10 +225,15 @@ export default class EventBusService {
|
|||||||
data: T,
|
data: T,
|
||||||
options: Record<string, unknown> & EmitOptions = { attempts: 1 }
|
options: Record<string, unknown> & EmitOptions = { attempts: 1 }
|
||||||
): Promise<StagedJob | void> {
|
): Promise<StagedJob | void> {
|
||||||
|
const globalEventOptions = this.config_?.projectConfig?.event_options ?? {}
|
||||||
|
|
||||||
|
// The order of precedence for job options is:
|
||||||
|
// 1. local options
|
||||||
|
// 2. global options
|
||||||
|
// 3. default options
|
||||||
const opts: EmitOptions = {
|
const opts: EmitOptions = {
|
||||||
removeOnComplete: {
|
removeOnComplete: true,
|
||||||
age: COMPLETED_JOB_TTL,
|
...globalEventOptions,
|
||||||
},
|
|
||||||
...options,
|
...options,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import { Request } from "express"
|
|||||||
import { LoggerOptions } from "typeorm"
|
import { LoggerOptions } from "typeorm"
|
||||||
import { Logger as _Logger } from "winston"
|
import { Logger as _Logger } from "winston"
|
||||||
import { Customer, User } from "../models"
|
import { Customer, User } from "../models"
|
||||||
|
import { EmitOptions } from "../services/event-bus"
|
||||||
import { FindConfig, RequestQueryFields } from "./common"
|
import { FindConfig, RequestQueryFields } from "./common"
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
@@ -58,6 +59,25 @@ export type ConfigModule = {
|
|||||||
projectConfig: {
|
projectConfig: {
|
||||||
redis_url?: string
|
redis_url?: string
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global options passed to all `EventBusService.emit` in the core as well as your own emitters. The options are forwarded to Bull's `Queue.add` method.
|
||||||
|
*
|
||||||
|
* The global options can be overridden by passing options to `EventBusService.emit` directly.
|
||||||
|
*
|
||||||
|
* Note: This will be deprecated as we move to Event Bus module in 1.8
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Example
|
||||||
|
* ```js
|
||||||
|
* {
|
||||||
|
* removeOnComplete: { age: 10 },
|
||||||
|
* }
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @see https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queueadd
|
||||||
|
*/
|
||||||
|
event_options?: Record<string, unknown> & EmitOptions
|
||||||
|
|
||||||
session_options?: SessionOptions
|
session_options?: SessionOptions
|
||||||
|
|
||||||
jwt_secret?: string
|
jwt_secret?: string
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"id":"https://github.com/medusajs/medusa/releases/tag/v1.7.11","content":"v1.7.11 is out","isCloseable":true}
|
{}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
current_branch=$(git branch --show-current)
|
||||||
|
|
||||||
|
if [[ "$VERCEL_DEPLOY_BRANCHES" == *"$current_branch"* ]]; then
|
||||||
|
echo "Branch allowed to deploy"
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
echo "Branch not allowed to deploy"
|
||||||
|
exit 0;
|
||||||
|
fi
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
{
|
||||||
|
"redirects": [
|
||||||
|
{
|
||||||
|
"source": "/api",
|
||||||
|
"destination": "/api/store"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/store/auth/(.*)",
|
||||||
|
"destination": "/api/store/#tag/Auth"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/store/cart/(.*)",
|
||||||
|
"destination": "/api/store/#tag/Cart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/store/collection/(.*)",
|
||||||
|
"destination": "/api/store/#tag/Collection"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/store/product/(.*)",
|
||||||
|
"destination": "/api/store/#tag/Product"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/admin/auth/(.*)",
|
||||||
|
"destination": "/api/admin/#tag/Auth"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/api/admin/users/(.*)",
|
||||||
|
"destination": "/api/admin/#tag/User"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/headless-ecommerce-store-with-gatsby-contentful-medusa",
|
||||||
|
"destination": "/add-plugins/contentful"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/deploying-on-heroku",
|
||||||
|
"destination": "/deployments/server/deploying-on-heroku"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/admin/introduction",
|
||||||
|
"destination": "/admin/quickstart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/admin/quickstart/quick-start",
|
||||||
|
"destination": "/admin/quickstart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/admin/quickstart",
|
||||||
|
"destination": "/admin/quickstart"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/quickstart/starters/nextjs-medusa-starter",
|
||||||
|
"destination": "/starters/nextjs-medusa-starter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/quickstart/starters/gatsby-medusa-starter",
|
||||||
|
"destination": "/starters/gatsby-medusa-starter"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/create-medusa-app",
|
||||||
|
"destination": "/usage/create-medusa-app"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/guides/plugins",
|
||||||
|
"destination": "/advanced/backend/plugins/overview"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/deploying-admin-on-netlify",
|
||||||
|
"destination": "/deployments/admin/deploying-on-netlify"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/deploying-on-digital-ocean/",
|
||||||
|
"destination": "/deployments/server/deploying-on-digital-ocean"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/how-to/deploying-on-qovery/",
|
||||||
|
"destination": "/deployments/server/deploying-on-qovery"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/guides/fulfillment-api",
|
||||||
|
"destination": "/advanced/backend/shipping/add-fulfillment-provider"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/guides/checkouts",
|
||||||
|
"destination": "/advanced/storefront/how-to-implement-checkout-flow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/guides/checkouts",
|
||||||
|
"destination": "/advanced/storefront/how-to-implement-checkout-flow"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-7-3",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-7-3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-7-1",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-7-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-7-0",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-7-0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-6-1",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-6-1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-3-8",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-3-8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-3-6",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-3-6"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"source": "/advanced/backend/upgrade-guides/1-3-0",
|
||||||
|
"destination": "/advanced/backend/upgrade-guides/medusa-core/1-3-0"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -5734,7 +5734,7 @@ __metadata:
|
|||||||
typeorm: ^0.3.11
|
typeorm: ^0.3.11
|
||||||
typescript: ^4.4.4
|
typescript: ^4.4.4
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
"@medusajs/medusa": 1.7.11
|
"@medusajs/medusa": 1.7.12
|
||||||
typeorm: ^0.3.11
|
typeorm: ^0.3.11
|
||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|||||||
Reference in New Issue
Block a user