fix: remote query types (#12712)
* fix: remote query types * fix: breaking types * Create eleven-falcons-return.md
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/modules-sdk": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: remote query types
|
||||||
@@ -155,7 +155,7 @@ export class Query {
|
|||||||
queryOptions: RemoteQueryInput<TEntry>,
|
queryOptions: RemoteQueryInput<TEntry>,
|
||||||
options?: RemoteJoinerOptions
|
options?: RemoteJoinerOptions
|
||||||
): Promise<GraphResultSet<TEntry>> {
|
): Promise<GraphResultSet<TEntry>> {
|
||||||
const normalizedQuery = toRemoteQuery<TEntry>(
|
const normalizedQuery = toRemoteQuery(
|
||||||
queryOptions,
|
queryOptions,
|
||||||
this.#remoteQuery.getEntitiesMap()
|
this.#remoteQuery.getEntitiesMap()
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import {
|
import {
|
||||||
RemoteQueryEntryPoints,
|
|
||||||
RemoteQueryFilters,
|
RemoteQueryFilters,
|
||||||
RemoteQueryGraph,
|
RemoteQueryGraph,
|
||||||
RemoteQueryInput,
|
RemoteQueryInput,
|
||||||
@@ -31,7 +30,7 @@ const ARGUMENTS = "__args"
|
|||||||
|
|
||||||
export function toRemoteQuery<const TEntity extends string>(
|
export function toRemoteQuery<const TEntity extends string>(
|
||||||
config: {
|
config: {
|
||||||
entity: TEntity | keyof RemoteQueryEntryPoints
|
entity: TEntity
|
||||||
fields: RemoteQueryInput<TEntity>["fields"]
|
fields: RemoteQueryInput<TEntity>["fields"]
|
||||||
filters?: RemoteQueryFilters<TEntity>
|
filters?: RemoteQueryFilters<TEntity>
|
||||||
pagination?: Partial<RemoteQueryInput<TEntity>["pagination"]>
|
pagination?: Partial<RemoteQueryInput<TEntity>["pagination"]>
|
||||||
|
|||||||
@@ -25,57 +25,102 @@ export type RemoteQueryObjectFromStringResult<
|
|||||||
__value: object
|
__value: object
|
||||||
}
|
}
|
||||||
|
|
||||||
export type RemoteQueryInput<TEntry extends string> = {
|
export type RemoteQueryInput<TEntry extends string> =
|
||||||
/**
|
TEntry extends keyof RemoteQueryEntryPoints
|
||||||
* The name of the entity to retrieve. For example, `product`.
|
? {
|
||||||
*/
|
/**
|
||||||
entity: TEntry | keyof RemoteQueryEntryPoints
|
* The name of the entity to retrieve. For example, `product`.
|
||||||
/**
|
*/
|
||||||
* The fields and relations to retrieve in the entity.
|
entity: TEntry
|
||||||
*/
|
/**
|
||||||
fields: ObjectToRemoteQueryFields<
|
* The fields and relations to retrieve in the entity.
|
||||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
*/
|
||||||
> extends never
|
fields: ObjectToRemoteQueryFields<
|
||||||
? string[]
|
RemoteQueryEntryPoints[TEntry]
|
||||||
:
|
> extends never
|
||||||
| ObjectToRemoteQueryFields<
|
? string[]
|
||||||
RemoteQueryEntryPoints[TEntry & keyof RemoteQueryEntryPoints]
|
:
|
||||||
>[]
|
| ObjectToRemoteQueryFields<RemoteQueryEntryPoints[TEntry]>[]
|
||||||
| string[]
|
| string[]
|
||||||
/**
|
/**
|
||||||
* Pagination configurations for the returned list of items.
|
* Pagination configurations for the returned list of items.
|
||||||
*/
|
*/
|
||||||
pagination?: {
|
pagination?: {
|
||||||
/**
|
/**
|
||||||
* The number of items to skip before retrieving the returned items.
|
* The number of items to skip before retrieving the returned items.
|
||||||
*/
|
*/
|
||||||
skip?: number
|
skip?: number
|
||||||
/**
|
/**
|
||||||
* The maximum number of items to return.
|
* The maximum number of items to return.
|
||||||
*/
|
*/
|
||||||
take?: number
|
take?: number
|
||||||
/**
|
/**
|
||||||
* Sort by field names in ascending or descending order.
|
* Sort by field names in ascending or descending order.
|
||||||
*/
|
*/
|
||||||
order?: IndexOrderBy<TEntry>
|
order?: IndexOrderBy<TEntry>
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Filters to apply on the retrieved items.
|
* Filters to apply on the retrieved items.
|
||||||
*/
|
*/
|
||||||
filters?: RemoteQueryFilters<TEntry>
|
filters?: RemoteQueryFilters<TEntry>
|
||||||
/**
|
/**
|
||||||
* Apply a query context on the retrieved data. For example, to retrieve product prices for a certain context.
|
* Apply a query context on the retrieved data. For example, to retrieve product prices for a certain context.
|
||||||
*/
|
*/
|
||||||
context?: QueryContextType
|
context?: QueryContextType
|
||||||
/**
|
/**
|
||||||
* Apply a `withDeleted` flag on the retrieved data to retrieve soft deleted items.
|
* Apply a `withDeleted` flag on the retrieved data to retrieve soft deleted items.
|
||||||
*/
|
*/
|
||||||
withDeleted?: boolean
|
withDeleted?: boolean
|
||||||
/**
|
/**
|
||||||
* Strategy will be send to the entry module called method
|
* Strategy will be send to the entry module called method
|
||||||
*/
|
*/
|
||||||
strategy?: "joined" | "select-in"
|
strategy?: "joined" | "select-in"
|
||||||
}
|
}
|
||||||
|
: {
|
||||||
|
/**
|
||||||
|
* The name of the entity to retrieve. For example, `product`.
|
||||||
|
*/
|
||||||
|
entity: TEntry
|
||||||
|
/**
|
||||||
|
* The fields and relations to retrieve in the entity.
|
||||||
|
*/
|
||||||
|
fields: ObjectToRemoteQueryFields<any> extends never
|
||||||
|
? string[]
|
||||||
|
: ObjectToRemoteQueryFields<any>[] | string[]
|
||||||
|
/**
|
||||||
|
* Pagination configurations for the returned list of items.
|
||||||
|
*/
|
||||||
|
pagination?: {
|
||||||
|
/**
|
||||||
|
* The number of items to skip before retrieving the returned items.
|
||||||
|
*/
|
||||||
|
skip?: number
|
||||||
|
/**
|
||||||
|
* The maximum number of items to return.
|
||||||
|
*/
|
||||||
|
take?: number
|
||||||
|
/**
|
||||||
|
* Sort by field names in ascending or descending order.
|
||||||
|
*/
|
||||||
|
order?: IndexOrderBy<TEntry>
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Filters to apply on the retrieved items.
|
||||||
|
*/
|
||||||
|
filters?: RemoteQueryFilters<TEntry>
|
||||||
|
/**
|
||||||
|
* Apply a query context on the retrieved data. For example, to retrieve product prices for a certain context.
|
||||||
|
*/
|
||||||
|
context?: QueryContextType
|
||||||
|
/**
|
||||||
|
* Apply a `withDeleted` flag on the retrieved data to retrieve soft deleted items.
|
||||||
|
*/
|
||||||
|
withDeleted?: boolean
|
||||||
|
/**
|
||||||
|
* Strategy will be send to the entry module called method
|
||||||
|
*/
|
||||||
|
strategy?: "joined" | "select-in"
|
||||||
|
}
|
||||||
|
|
||||||
export type RemoteQueryGraph<TEntry extends string> = {
|
export type RemoteQueryGraph<TEntry extends string> = {
|
||||||
__TConfig: RemoteQueryObjectConfig<TEntry>
|
__TConfig: RemoteQueryObjectConfig<TEntry>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ type ExtractFiltersOperators<
|
|||||||
? never
|
? never
|
||||||
: Key extends ExcludedProps
|
: Key extends ExcludedProps
|
||||||
? never
|
? never
|
||||||
: T[Key] extends string | number | boolean | Date
|
: NonNullable<T[Key]> extends string | number | boolean | Date
|
||||||
? T[Key] | T[Key][] | OperatorMap<T[Key] | T[Key][]>
|
? T[Key] | T[Key][] | OperatorMap<T[Key] | T[Key][]>
|
||||||
: T[Key] extends Array<infer R>
|
: T[Key] extends Array<infer R>
|
||||||
? TypeOnly<R> extends { __typename: any }
|
? TypeOnly<R> extends { __typename: any }
|
||||||
|
|||||||
Reference in New Issue
Block a user