@medusajs/types
Advanced tools
Comparing version 1.8.7-snapshot-20230522200557 to 1.8.7-snapshot-20230524100957
@@ -87,2 +87,4 @@ import { FindManyOptions, FindOneOptions, FindOperator, FindOptionsSelect, FindOptionsWhere, OrderByCondition } from "typeorm"; | ||
} | ||
export interface RepositoryTransformOptions { | ||
} | ||
export interface DateComparisonOperator { | ||
@@ -99,2 +101,5 @@ lt?: Date; | ||
lte?: string; | ||
contains?: string; | ||
starts_with?: string; | ||
ends_with?: string; | ||
} | ||
@@ -101,0 +106,0 @@ export interface NumericalComparisonOperator { |
@@ -6,5 +6,2 @@ /// <reference types="node" /> | ||
declare type Query<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>; | ||
declare type EntityProps<T> = { | ||
-readonly [K in keyof T as ExcludeFunctions<T, K>]?: T[K]; | ||
}; | ||
declare type ExpandScalar<T> = null | (T extends string ? string | RegExp : T extends Date ? Date | string : T); | ||
@@ -14,3 +11,2 @@ declare type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Buffer | { | ||
}; | ||
declare type ExcludeFunctions<T, K extends keyof T> = T[K] extends Function ? never : K extends symbol ? never : K; | ||
declare type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T; | ||
@@ -50,7 +46,8 @@ declare const PrimaryKeyType: unique symbol; | ||
declare type FilterValue<T> = OperatorMap<FilterValue2<T>> | FilterValue2<T> | FilterValue2<T>[] | null; | ||
declare type ExpandObject<T> = T extends object ? T extends Scalar ? never : { | ||
-readonly [K in keyof T as ExcludeFunctions<T, K>]?: Query<any> | FilterValue<any> | null; | ||
} : never; | ||
declare type ObjectQuery<T> = ExpandObject<T> & OperatorMap<T>; | ||
export declare type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T>>> | NonNullable<EntityProps<T> & OperatorMap<T>> | FilterQuery<T>[]; | ||
declare type PrevLimit = [never, 1, 2, 3]; | ||
export declare type FilterQuery<T = any, Prev extends number = 3> = Prev extends never ? never : { | ||
[Key in keyof T]?: T[Key] extends boolean | number | string | bigint | symbol | Date ? T[Key] | OperatorMap<T[Key]> : T[Key] extends infer U ? U extends { | ||
[x: number]: infer V; | ||
} ? V extends object ? FilterQuery<Partial<V>, PrevLimit[Prev]> : never : never : never; | ||
}; | ||
declare type Order<T> = { | ||
@@ -68,3 +65,3 @@ [key in keyof T]?: "ASC" | "DESC" | Order<T[key] extends Array<any> ? T[key][0] : T[key]>; | ||
} | ||
export declare type FindOptions<T> = { | ||
export declare type FindOptions<T = any> = { | ||
where: FilterQuery<T>; | ||
@@ -71,0 +68,0 @@ options?: OptionsQuery<T, any>; |
import { FindOptions } from "./index"; | ||
import { RepositoryTransformOptions } from "../common"; | ||
/** | ||
@@ -7,5 +8,5 @@ * Data access layer (DAL) interface to implements for any repository service. | ||
*/ | ||
export interface RepositoryService<S = any> { | ||
find<T = S>(options?: FindOptions<T>): Promise<T[]>; | ||
findAndCount<T = S>(options?: FindOptions<T>): Promise<[T[], number]>; | ||
export interface RepositoryService<T = any> { | ||
find(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<T[]>; | ||
findAndCount(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<[T[], number]>; | ||
} |
@@ -8,2 +8,3 @@ export * from "./bundles"; | ||
export * from "./product"; | ||
export * from "./product-category"; | ||
export * from "./search"; | ||
@@ -10,0 +11,0 @@ export * from "./shared-context"; |
@@ -24,2 +24,3 @@ "use strict"; | ||
__exportStar(require("./product"), exports); | ||
__exportStar(require("./product-category"), exports); | ||
__exportStar(require("./search"), exports); | ||
@@ -26,0 +27,0 @@ __exportStar(require("./shared-context"), exports); |
@@ -200,3 +200,3 @@ import { NumericalComparisonOperator, StringComparisonOperator } from "../common"; | ||
location_id?: string | string[]; | ||
description?: string; | ||
description?: string | StringComparisonOperator; | ||
created_by?: string | string[]; | ||
@@ -203,0 +203,0 @@ quantity?: number | NumericalComparisonOperator; |
@@ -64,2 +64,5 @@ import { OperatorMap } from "../dal"; | ||
} | ||
export interface ProductCategoryDTO { | ||
id: string; | ||
} | ||
export interface ProductTagDTO { | ||
@@ -97,6 +100,5 @@ id: string; | ||
categories?: { | ||
id?: { | ||
[Operator in keyof OperatorMap<any>]: string[]; | ||
} | string[]; | ||
id?: string | OperatorMap<string>; | ||
}; | ||
category_ids?: string | OperatorMap<string>; | ||
} | ||
@@ -118,1 +120,9 @@ export interface FilterableProductTagProps { | ||
} | ||
export interface FilterableProductCategoryProps { | ||
id?: string | string[]; | ||
parent_category_id?: string | string[] | null; | ||
handle?: string | string[]; | ||
is_active?: boolean; | ||
is_internal?: boolean; | ||
include_descendants_tree?: boolean; | ||
} |
import { FilterableProductCollectionProps, FilterableProductProps, FilterableProductTagProps, FilterableProductVariantProps, ProductCollectionDTO, ProductDTO, ProductTagDTO, ProductVariantDTO } from "./common"; | ||
import { FindConfig } from "../common"; | ||
import { SharedContext } from "../shared-context"; | ||
export interface IProductService { | ||
list<T = unknown>(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<T[]>; | ||
listAndCount<T = unknown>(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<[T[], number]>; | ||
listTags<T = unknown>(filter: FilterableProductTagProps, config?: FindConfig<ProductVariantDTO>, context?: SharedContext): Promise<T[]>; | ||
listVariants<T = unknown>(filter: FilterableProductVariantProps, config?: FindConfig<ProductTagDTO>, context?: SharedContext): Promise<T[]>; | ||
listCollections<T = unknown>(filter: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, context?: SharedContext): Promise<T[]>; | ||
export interface IProductService<TProduct = any, TProductVariant = any, TProductTag = any, TProductCollection = any> { | ||
list(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<ProductDTO[]>; | ||
listAndCount(filter: FilterableProductProps, config?: FindConfig<ProductDTO>, context?: SharedContext): Promise<[ProductDTO[], number]>; | ||
listTags(filter: FilterableProductTagProps, config?: FindConfig<ProductVariantDTO>, context?: SharedContext): Promise<ProductTagDTO[]>; | ||
listVariants(filter: FilterableProductVariantProps, config?: FindConfig<ProductTagDTO>, context?: SharedContext): Promise<ProductVariantDTO[]>; | ||
listCollections(filter: FilterableProductCollectionProps, config?: FindConfig<ProductCollectionDTO>, context?: SharedContext): Promise<ProductCollectionDTO[]>; | ||
} |
{ | ||
"name": "@medusajs/types", | ||
"version": "1.8.7-snapshot-20230522200557", | ||
"version": "1.8.7-snapshot-20230524100957", | ||
"description": "Medusa Types definition", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
66466
103
1563