Skip to content

Commit

Permalink
Merge branch 'develop' into feat/promotion-dml
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Dec 6, 2024
2 parents 6b11eae + 0a077d4 commit 882c6a5
Show file tree
Hide file tree
Showing 41 changed files with 1,050 additions and 742 deletions.
7 changes: 7 additions & 0 deletions .changeset/clean-paws-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/workflow-engine-inmemory": patch
"@medusajs/workflow-engine-redis": patch
"@medusajs/utils": patch
---

chore(workflow-engine): Migrate to DML
5 changes: 5 additions & 0 deletions .changeset/gold-birds-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/store": patch
---

refactor: migrate store module to DML
5 changes: 5 additions & 0 deletions .changeset/green-pants-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/utils": patch
---

fix: avoid optional fields on graphql generated types
5 changes: 5 additions & 0 deletions .changeset/heavy-peaches-sniff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---

fix(dashboard): Prevent sending off empty string as handle for product category
5 changes: 5 additions & 0 deletions .changeset/silly-waves-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/locking-postgres": patch
---

chore: locking-postgres provider to DML
5 changes: 5 additions & 0 deletions .changeset/thick-cars-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/framework": patch
---

fix(framework): add missing query type argument in request types
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from "../../../../../components/modals"
import { KeyboundForm } from "../../../../../components/utilities/keybound-form"
import { useCreateProductCategory } from "../../../../../hooks/api/categories"
import { transformNullableFormData } from "../../../../../lib/form-helpers"
import { CreateCategoryDetails } from "./create-category-details"
import { CreateCategoryNesting } from "./create-category-nesting"
import { CreateCategoryDetailsSchema, CreateCategorySchema } from "./schema"
Expand Down Expand Up @@ -79,13 +80,15 @@ export const CreateCategoryForm = ({
const { mutateAsync, isPending } = useCreateProductCategory()

const handleSubmit = form.handleSubmit((data) => {
const { visibility, status, parent_category_id, rank, ...rest } = data
const { visibility, status, parent_category_id, rank, name, ...rest } = data
const parsedData = transformNullableFormData(rest, false)

setShouldFreeze(true)

mutateAsync(
{
...rest,
name: name,
...parsedData,
parent_category_id: parent_category_id ?? undefined,
rank: rank ?? undefined,
is_active: status === "active",
Expand Down
7 changes: 4 additions & 3 deletions packages/core/framework/src/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ export interface PublishableKeyContext {
sales_channel_ids: string[]
}

export interface AuthenticatedMedusaRequest<Body = never>
extends MedusaRequest<Body> {
export interface AuthenticatedMedusaRequest<Body = unknown, QueryFields = Record<string, unknown>>
extends MedusaRequest<Body, QueryFields> {
auth_context: AuthContext
publishable_key_context?: PublishableKeyContext
}

export interface MedusaStoreRequest<Body = never> extends MedusaRequest<Body> {
export interface MedusaStoreRequest<Body = unknown, QueryFields = Record<string, unknown>>
extends MedusaRequest<Body, QueryFields> {
auth_context?: AuthContext
publishable_key_context: PublishableKeyContext
}
Expand Down
19 changes: 12 additions & 7 deletions packages/core/js-sdk/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ const normalizeRequest = (
body = JSON.stringify(body)
}

// "credentials" is not supported in some environments (eg. on the backend), and it might throw an exception if the field is set.
const isFetchCredentialsSupported = "credentials" in Request.prototype

// Oftentimes the server will be on a different origin, so we want to default to include
// Note that the cookie's SameSite attribute takes precedence over this setting.
const credentials =
config.auth?.type === "session"
? config.auth?.fetchCredentials || "include"
: "omit"

return {
...init,
headers,
// TODO: Setting this to "include" poses some security risks, as it will send cookies to any domain. We should consider making this configurable.
credentials: isFetchCredentialsSupported
? config.auth?.type === "session"
? "include"
: "omit"
: undefined,
credentials: isFetchCredentialsSupported ? credentials : undefined,
...(body ? { body: body as RequestInit["body"] } : {}),
} as RequestInit
}
Expand Down Expand Up @@ -231,7 +234,9 @@ export class Client {
let normalizedInput: RequestInfo | URL = input
if (input instanceof URL || typeof input === "string") {
const baseUrl = new URL(this.config.baseUrl)
const fullPath = `${baseUrl.pathname.replace(/\/$/, '')}/${input.toString().replace(/^\//, '')}`
const fullPath = `${baseUrl.pathname.replace(/\/$/, "")}/${input
.toString()
.replace(/^\//, "")}`
normalizedInput = new URL(fullPath, baseUrl.origin)
if (init?.query) {
const params = Object.fromEntries(
Expand Down
1 change: 1 addition & 0 deletions packages/core/js-sdk/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Config = {
type?: "jwt" | "session"
jwtTokenStorageKey?: string
jwtTokenStorageMethod?: "local" | "session" | "memory" | "nostore"
fetchCredentials?: "include" | "omit" | "same-origin"
}
logger?: Logger
debug?: boolean
Expand Down
Loading

0 comments on commit 882c6a5

Please sign in to comment.