@ivfuture/ecomm-types
Advanced tools
Comparing version 1.0.1 to 1.1.0
export * as CacheTypes from "./cache"; | ||
export * as CommonTypes from "./common"; | ||
export * as DAL from "./dal"; | ||
export * as EventBusTypes from "./event-bus"; | ||
export * as FeatureFlagTypes from "./feature-flag"; | ||
export * as InventoryTypes from "./inventory"; | ||
export * as LoggerTypes from "./logger"; | ||
export * as ModulesSdkTypes from "./modules-sdk"; | ||
export * as PricingTypes from "./pricing"; | ||
export * as ProductTypes from "./product"; | ||
export * as ModulesSdkTypes from "./modules-sdk"; | ||
export * as SalesChannelTypes from "./sales-channel"; | ||
export * as SearchTypes from "./search"; | ||
export * as StockLocationTypes from "./stock-location"; | ||
export * as TransactionBaseTypes from "./transaction-base"; | ||
export * as DAL from "./dal"; | ||
export * as LoggerTypes from "./logger"; | ||
export * as WorkflowTypes from "./workflow"; |
@@ -26,14 +26,18 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LoggerTypes = exports.DAL = exports.TransactionBaseTypes = exports.StockLocationTypes = exports.SearchTypes = exports.ModulesSdkTypes = exports.ProductTypes = exports.InventoryTypes = exports.EventBusTypes = exports.CommonTypes = exports.CacheTypes = void 0; | ||
exports.WorkflowTypes = exports.TransactionBaseTypes = exports.StockLocationTypes = exports.SearchTypes = exports.SalesChannelTypes = exports.ProductTypes = exports.PricingTypes = exports.ModulesSdkTypes = exports.LoggerTypes = exports.InventoryTypes = exports.FeatureFlagTypes = exports.EventBusTypes = exports.DAL = exports.CommonTypes = exports.CacheTypes = void 0; | ||
exports.CacheTypes = __importStar(require("./cache")); | ||
exports.CommonTypes = __importStar(require("./common")); | ||
exports.DAL = __importStar(require("./dal")); | ||
exports.EventBusTypes = __importStar(require("./event-bus")); | ||
exports.FeatureFlagTypes = __importStar(require("./feature-flag")); | ||
exports.InventoryTypes = __importStar(require("./inventory")); | ||
exports.LoggerTypes = __importStar(require("./logger")); | ||
exports.ModulesSdkTypes = __importStar(require("./modules-sdk")); | ||
exports.PricingTypes = __importStar(require("./pricing")); | ||
exports.ProductTypes = __importStar(require("./product")); | ||
exports.ModulesSdkTypes = __importStar(require("./modules-sdk")); | ||
exports.SalesChannelTypes = __importStar(require("./sales-channel")); | ||
exports.SearchTypes = __importStar(require("./search")); | ||
exports.StockLocationTypes = __importStar(require("./stock-location")); | ||
exports.TransactionBaseTypes = __importStar(require("./transaction-base")); | ||
exports.DAL = __importStar(require("./dal")); | ||
exports.LoggerTypes = __importStar(require("./logger")); | ||
exports.WorkflowTypes = __importStar(require("./workflow")); | ||
//# sourceMappingURL=bundles.js.map |
@@ -7,6 +7,6 @@ import { FindManyOptions, FindOneOptions, FindOperator, FindOptionsSelect, FindOptionsWhere, OrderByCondition } from "typeorm"; | ||
*/ | ||
export declare type WithRequiredProperty<T, K extends keyof T> = T & { | ||
export type WithRequiredProperty<T, K extends keyof T> = T & { | ||
[Property in K]-?: T[Property]; | ||
}; | ||
export declare type PartialPick<T, K extends keyof T> = { | ||
export type PartialPick<T, K extends keyof T> = { | ||
[P in K]?: T[P]; | ||
@@ -22,7 +22,23 @@ }; | ||
} | ||
export declare type Writable<T> = { | ||
export type Writable<T> = { | ||
-readonly [key in keyof T]: T[key] | FindOperator<T[key]> | FindOperator<T[key][]> | FindOperator<string[]>; | ||
}; | ||
/** | ||
* @interface | ||
* | ||
* An object that is used to configure how an entity is retrieved from the database. It accepts as a typed parameter an `Entity` class, | ||
* which provides correct typing of field names in its properties. | ||
* | ||
* @prop select - An array of strings, each being attribute names of the entity to retrieve in the result. | ||
* @prop skip - A number indicating the number of records to skip before retrieving the results. | ||
* @prop take - A number indicating the number of records to return in the result. | ||
* @prop relations - An array of strings, each being relation names of the entity to retrieve in the result. | ||
* @prop order - | ||
* An object used to specify how to sort the returned records. Its keys are the names of attributes of the entity, and a key's value can either be `ASC` | ||
* to sort retrieved records in an ascending order, or `DESC` to sort retrieved records in a descending order. | ||
* @prop withDeleted - A boolean indicating whether deleted records should also be retrieved as part of the result. This only works if the entity extends the | ||
* `SoftDeletableEntity` class. | ||
*/ | ||
export interface FindConfig<Entity> { | ||
select?: (keyof Entity)[]; | ||
select?: (keyof Entity | string)[]; | ||
skip?: number; | ||
@@ -34,4 +50,5 @@ take?: number; | ||
}; | ||
withDeleted?: boolean; | ||
} | ||
export declare type ExtendedFindConfig<TEntity> = (Omit<FindOneOptions<TEntity>, "where" | "relations" | "select"> | Omit<FindManyOptions<TEntity>, "where" | "relations" | "select">) & { | ||
export type ExtendedFindConfig<TEntity> = (Omit<FindOneOptions<TEntity>, "where" | "relations" | "select"> | Omit<FindManyOptions<TEntity>, "where" | "relations" | "select">) & { | ||
select?: FindOptionsSelect<TEntity>; | ||
@@ -44,12 +61,12 @@ relations?: FindOptionsRelations<TEntity>; | ||
}; | ||
export declare type QuerySelector<TEntity> = Selector<TEntity> & { | ||
export type QuerySelector<TEntity> = Selector<TEntity> & { | ||
q?: string; | ||
}; | ||
export declare type TreeQuerySelector<TEntity> = QuerySelector<TEntity> & { | ||
export type TreeQuerySelector<TEntity> = QuerySelector<TEntity> & { | ||
include_descendants_tree?: boolean; | ||
}; | ||
export declare type Selector<TEntity> = { | ||
export type Selector<TEntity> = { | ||
[key in keyof TEntity]?: TEntity[key] | TEntity[key][] | DateComparisonOperator | StringComparisonOperator | NumericalComparisonOperator | FindOperator<TEntity[key][] | string | string[]>; | ||
}; | ||
export declare type TotalField = "shipping_total" | "discount_total" | "tax_total" | "refunded_total" | "total" | "subtotal" | "refundable_amount" | "gift_card_total" | "gift_card_tax_total"; | ||
export type TotalField = "shipping_total" | "discount_total" | "tax_total" | "refunded_total" | "total" | "subtotal" | "refundable_amount" | "gift_card_total" | "gift_card_tax_total"; | ||
export interface CustomFindOptions<TModel, InKeys extends keyof TModel> { | ||
@@ -64,3 +81,3 @@ select?: FindManyOptions<TModel>["select"]; | ||
} | ||
export declare type QueryConfig<TEntity extends BaseEntity> = { | ||
export type QueryConfig<TEntity extends BaseEntity> = { | ||
defaultFields?: (keyof TEntity | string)[]; | ||
@@ -73,3 +90,3 @@ defaultRelations?: string[]; | ||
}; | ||
export declare type RequestQueryFields = { | ||
export type RequestQueryFields = { | ||
expand?: string; | ||
@@ -81,3 +98,3 @@ fields?: string; | ||
}; | ||
export declare type PaginatedResponse = { | ||
export type PaginatedResponse = { | ||
limit: number; | ||
@@ -87,3 +104,3 @@ offset: number; | ||
}; | ||
export declare type DeleteResponse = { | ||
export type DeleteResponse = { | ||
id: string; | ||
@@ -90,0 +107,0 @@ object: string; |
import { RedisOptions } from "ioredis"; | ||
import { LoggerOptions } from "typeorm"; | ||
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "../modules-sdk"; | ||
declare type SessionOptions = { | ||
type SessionOptions = { | ||
name?: string; | ||
@@ -12,3 +12,3 @@ resave?: boolean; | ||
}; | ||
export declare type HttpCompressionOptions = { | ||
export type HttpCompressionOptions = { | ||
enabled?: boolean; | ||
@@ -19,3 +19,3 @@ level?: number; | ||
}; | ||
export declare type ProjectConfigOptions = { | ||
export type ProjectConfigOptions = { | ||
redis_url?: string; | ||
@@ -41,3 +41,3 @@ redis_prefix?: string; | ||
}; | ||
export declare type ConfigModule = { | ||
export type ConfigModule = { | ||
projectConfig: ProjectConfigOptions; | ||
@@ -44,0 +44,0 @@ featureFlags: Record<string, boolean | string>; |
import { AwilixContainer } from "awilix"; | ||
export declare type MedusaContainer = AwilixContainer & { | ||
export type MedusaContainer = AwilixContainer & { | ||
registerAdd: <T>(name: string, registration: T) => MedusaContainer; | ||
createScope: () => MedusaContainer; | ||
}; |
import { Dictionary, FilterQuery, Order } from "./utils"; | ||
export { FilterQuery } from "./utils"; | ||
/** | ||
* @interface | ||
* | ||
* An object used to allow specifying flexible queries with and/or conditions. | ||
* | ||
* @prop $and - An array of filters to apply on the entity, where each item in the array is joined with an "and" condition. | ||
* @prop $or - An array of filters to apply on the entity, where each item in the array is joined with an "or" condition. | ||
*/ | ||
export interface BaseFilterable<T> { | ||
$and?: T; | ||
$or?: T; | ||
$and?: (T | BaseFilterable<T>)[]; | ||
$or?: (T | BaseFilterable<T>)[]; | ||
} | ||
@@ -16,6 +24,7 @@ export interface OptionsQuery<T, P extends string = never> { | ||
} | ||
export declare type FindOptions<T = any> = { | ||
where: FilterQuery<T>; | ||
export type FindOptions<T = any> = { | ||
where: FilterQuery<T> & BaseFilterable<FilterQuery<T>>; | ||
options?: OptionsQuery<T, any>; | ||
}; | ||
export * from "./repository-service"; | ||
export * from "./entity"; |
@@ -18,2 +18,3 @@ "use strict"; | ||
__exportStar(require("./repository-service"), exports); | ||
__exportStar(require("./entity"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -0,3 +1,4 @@ | ||
import { RepositoryTransformOptions } from "../common"; | ||
import { Context } from "../shared-context"; | ||
import { FindOptions } from "./index"; | ||
import { RepositoryTransformOptions } from "../common"; | ||
/** | ||
@@ -8,5 +9,55 @@ * Data access layer (DAL) interface to implements for any repository service. | ||
*/ | ||
export interface RepositoryService<T = any> { | ||
find(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<T[]>; | ||
findAndCount(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions): Promise<[T[], number]>; | ||
interface BaseRepositoryService<T = any> { | ||
transaction<TManager = unknown>(task: (transactionManager: TManager) => Promise<any>, context?: { | ||
isolationLevel?: string; | ||
transaction?: TManager; | ||
enableNestedTransactions?: boolean; | ||
}): Promise<any>; | ||
getFreshManager<TManager = unknown>(): TManager; | ||
getActiveManager<TManager = unknown>(): TManager; | ||
serialize<TOutput extends object | object[]>(data: any, options?: any): Promise<TOutput>; | ||
} | ||
export interface RepositoryService<T = any> extends BaseRepositoryService<T> { | ||
find(options?: FindOptions<T>, context?: Context): Promise<T[]>; | ||
findAndCount(options?: FindOptions<T>, context?: Context): Promise<[T[], number]>; | ||
create(data: unknown[], context?: Context): Promise<T[]>; | ||
update(data: unknown[], context?: Context): Promise<T[]>; | ||
delete(ids: string[], context?: Context): Promise<void>; | ||
/** | ||
* Soft delete entities and cascade to related entities if configured. | ||
* | ||
* @param ids | ||
* @param context | ||
* | ||
* @returns [T[], Record<string, string[]>] the second value being the map of the entity names and ids that were soft deleted | ||
*/ | ||
softDelete(ids: string[], context?: Context): Promise<[T[], Record<string, unknown[]>]>; | ||
restore(ids: string[], context?: Context): Promise<[T[], Record<string, unknown[]>]>; | ||
} | ||
export interface TreeRepositoryService<T = any> extends BaseRepositoryService<T> { | ||
find(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions, context?: Context): Promise<T[]>; | ||
findAndCount(options?: FindOptions<T>, transformOptions?: RepositoryTransformOptions, context?: Context): Promise<[T[], number]>; | ||
create(data: unknown, context?: Context): Promise<T>; | ||
delete(id: string, context?: Context): Promise<void>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* An object that is used to specify an entity's related entities that should be soft-deleted when the main entity is soft-deleted. | ||
* | ||
* @prop returnLinkableKeys - An array of strings, each being the ID attribute names of the entity's relations. | ||
*/ | ||
export type SoftDeleteReturn<TReturnableLinkableKeys = string> = { | ||
returnLinkableKeys?: TReturnableLinkableKeys[]; | ||
}; | ||
/** | ||
* @interface | ||
* | ||
* An object that is used to specify an entity's related entities that should be restored when the main entity is restored. | ||
* | ||
* @prop returnLinkableKeys - An array of strings, each being the ID attribute names of the entity's relations. | ||
*/ | ||
export type RestoreReturn<TReturnableLinkableKeys = string> = { | ||
returnLinkableKeys?: TReturnableLinkableKeys[]; | ||
}; | ||
export {}; |
/// <reference types="node" /> | ||
export declare type Dictionary<T = any> = { | ||
export type Dictionary<T = any> = { | ||
[k: string]: T; | ||
}; | ||
declare type Query<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>; | ||
declare type ExpandScalar<T> = null | (T extends string ? string | RegExp : T extends Date ? Date | string : T); | ||
declare type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Buffer | { | ||
type Query<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>; | ||
type ExpandScalar<T> = null | (T extends string ? string | RegExp : T extends Date ? Date | string : T); | ||
type Scalar = boolean | number | string | bigint | symbol | Date | RegExp | Buffer | { | ||
toHexString(): string; | ||
}; | ||
declare type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T; | ||
type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T; | ||
declare const PrimaryKeyType: unique symbol; | ||
declare type Primary<T> = T extends { | ||
type Primary<T> = T extends { | ||
[PrimaryKeyType]?: infer PK; | ||
@@ -21,3 +21,3 @@ } ? ReadonlyPrimary<PK> : T extends { | ||
} ? ReadonlyPrimary<PK> : never; | ||
export declare type OperatorMap<T> = { | ||
export type OperatorMap<T> = { | ||
$and?: Query<T>[]; | ||
@@ -43,6 +43,6 @@ $or?: Query<T>[]; | ||
}; | ||
declare type FilterValue2<T> = T | ExpandScalar<T> | Primary<T>; | ||
declare type FilterValue<T> = OperatorMap<FilterValue2<T>> | FilterValue2<T> | FilterValue2<T>[] | null; | ||
declare type PrevLimit = [never, 1, 2, 3]; | ||
export declare type FilterQuery<T = any, Prev extends number = 3> = Prev extends never ? never : { | ||
type FilterValue2<T> = T | ExpandScalar<T> | Primary<T>; | ||
type FilterValue<T> = OperatorMap<FilterValue2<T>> | FilterValue2<T> | FilterValue2<T>[] | null; | ||
type PrevLimit = [never, 1, 2, 3]; | ||
export 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 { | ||
@@ -52,5 +52,5 @@ [x: number]: infer V; | ||
}; | ||
export declare type Order<T> = { | ||
export type Order<T> = { | ||
[key in keyof T]?: "ASC" | "DESC" | Order<T[key] extends Array<any> ? T[key][0] : T[key]>; | ||
}; | ||
export {}; |
@@ -1,11 +0,11 @@ | ||
export declare type Subscriber<T = unknown> = (data: T, eventName: string) => Promise<void>; | ||
export declare type SubscriberContext = { | ||
export type Subscriber<T = unknown> = (data: T, eventName: string) => Promise<void>; | ||
export type SubscriberContext = { | ||
subscriberId: string; | ||
}; | ||
export declare type SubscriberDescriptor = { | ||
export type SubscriberDescriptor = { | ||
id: string; | ||
subscriber: Subscriber; | ||
}; | ||
export declare type EventHandler<T = unknown> = (data: T, eventName: string) => Promise<void>; | ||
export declare type EmitData<T = unknown> = { | ||
export type EventHandler<T = unknown> = (data: T, eventName: string) => Promise<void>; | ||
export type EmitData<T = unknown> = { | ||
eventName: string; | ||
@@ -12,0 +12,0 @@ data: T; |
import { EmitData, Subscriber, SubscriberContext } from "./common"; | ||
export interface IEventBusModuleService { | ||
emit<T>(eventName: string, data: T, options: Record<string, unknown>): Promise<void>; | ||
emit<T>(eventName: string, data: T, options?: Record<string, unknown>): Promise<void>; | ||
emit<T>(data: EmitData<T>[]): Promise<void>; | ||
@@ -5,0 +5,0 @@ subscribe(eventName: string | symbol, subscriber: Subscriber, context?: SubscriberContext): this; |
@@ -0,10 +1,19 @@ | ||
export * from "./address"; | ||
export * from "./bundles"; | ||
export * from "./cache"; | ||
export * from "./cart"; | ||
export * from "./common"; | ||
export * from "./dal"; | ||
export * from "./event-bus"; | ||
export * from "./feature-flag"; | ||
export * from "./file-service"; | ||
export * from "./inventory"; | ||
export * from "./joiner"; | ||
export * from "./link-modules"; | ||
export * from "./logger"; | ||
export * from "./modules-sdk"; | ||
export * from "./pricing"; | ||
export * from "./product"; | ||
export * from "./product-category"; | ||
export * from "./sales-channel"; | ||
export * from "./search"; | ||
@@ -14,3 +23,2 @@ export * from "./shared-context"; | ||
export * from "./transaction-base"; | ||
export * from "./dal"; | ||
export * from "./logger"; | ||
export * from "./workflow"; |
@@ -17,11 +17,20 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./address"), exports); | ||
__exportStar(require("./bundles"), exports); | ||
__exportStar(require("./cache"), exports); | ||
__exportStar(require("./cart"), exports); | ||
__exportStar(require("./common"), exports); | ||
__exportStar(require("./dal"), exports); | ||
__exportStar(require("./event-bus"), exports); | ||
__exportStar(require("./feature-flag"), exports); | ||
__exportStar(require("./file-service"), exports); | ||
__exportStar(require("./inventory"), exports); | ||
__exportStar(require("./joiner"), exports); | ||
__exportStar(require("./link-modules"), exports); | ||
__exportStar(require("./logger"), exports); | ||
__exportStar(require("./modules-sdk"), exports); | ||
__exportStar(require("./pricing"), exports); | ||
__exportStar(require("./product"), exports); | ||
__exportStar(require("./product-category"), exports); | ||
__exportStar(require("./sales-channel"), exports); | ||
__exportStar(require("./search"), exports); | ||
@@ -31,4 +40,3 @@ __exportStar(require("./shared-context"), exports); | ||
__exportStar(require("./transaction-base"), exports); | ||
__exportStar(require("./dal"), exports); | ||
__exportStar(require("./logger"), exports); | ||
__exportStar(require("./workflow"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -64,3 +64,3 @@ import { NumericalComparisonOperator, StringComparisonOperator } from "../common"; | ||
*/ | ||
export declare type InventoryItemDTO = { | ||
export type InventoryItemDTO = { | ||
id: string; | ||
@@ -131,3 +131,3 @@ sku?: string | null; | ||
*/ | ||
export declare type ReservationItemDTO = { | ||
export type ReservationItemDTO = { | ||
id: string; | ||
@@ -184,3 +184,3 @@ location_id: string; | ||
*/ | ||
export declare type InventoryLevelDTO = { | ||
export type InventoryLevelDTO = { | ||
id: string; | ||
@@ -197,3 +197,3 @@ inventory_item_id: string; | ||
}; | ||
export declare type FilterableReservationItemProps = { | ||
export type FilterableReservationItemProps = { | ||
id?: string | string[]; | ||
@@ -208,3 +208,3 @@ type?: string | string[]; | ||
}; | ||
export declare type FilterableInventoryItemProps = { | ||
export type FilterableInventoryItemProps = { | ||
id?: string | string[]; | ||
@@ -218,19 +218,19 @@ location_id?: string | string[]; | ||
}; | ||
export declare type CreateInventoryItemInput = { | ||
sku?: string; | ||
origin_country?: string; | ||
mid_code?: string; | ||
material?: string; | ||
weight?: number; | ||
length?: number; | ||
height?: number; | ||
width?: number; | ||
title?: string; | ||
description?: string; | ||
thumbnail?: string; | ||
export type CreateInventoryItemInput = { | ||
sku?: string | null; | ||
origin_country?: string | null; | ||
mid_code?: string | null; | ||
material?: string | null; | ||
weight?: number | null; | ||
length?: number | null; | ||
height?: number | null; | ||
width?: number | null; | ||
title?: string | null; | ||
description?: string | null; | ||
thumbnail?: string | null; | ||
metadata?: Record<string, unknown> | null; | ||
hs_code?: string; | ||
hs_code?: string | null; | ||
requires_shipping?: boolean; | ||
}; | ||
export declare type CreateReservationItemInput = { | ||
export type CreateReservationItemInput = { | ||
line_item_id?: string; | ||
@@ -245,3 +245,3 @@ inventory_item_id: string; | ||
}; | ||
export declare type FilterableInventoryLevelProps = { | ||
export type FilterableInventoryLevelProps = { | ||
inventory_item_id?: string | string[]; | ||
@@ -253,3 +253,3 @@ location_id?: string | string[]; | ||
}; | ||
export declare type CreateInventoryLevelInput = { | ||
export type CreateInventoryLevelInput = { | ||
inventory_item_id: string; | ||
@@ -261,7 +261,11 @@ location_id: string; | ||
}; | ||
export declare type UpdateInventoryLevelInput = { | ||
export type UpdateInventoryLevelInput = { | ||
stocked_quantity?: number; | ||
incoming_quantity?: number; | ||
}; | ||
export declare type UpdateReservationItemInput = { | ||
export type BulkUpdateInventoryLevelInput = { | ||
inventory_item_id: string; | ||
location_id: string; | ||
} & UpdateInventoryLevelInput; | ||
export type UpdateReservationItemInput = { | ||
quantity?: number; | ||
@@ -272,3 +276,3 @@ location_id?: string; | ||
}; | ||
export declare type ReserveQuantityContext = { | ||
export type ReserveQuantityContext = { | ||
locationId?: string; | ||
@@ -275,0 +279,0 @@ lineItemId?: string; |
export * from "./common"; | ||
export * from "./inventory"; | ||
export * from "./service"; |
@@ -18,3 +18,3 @@ "use strict"; | ||
__exportStar(require("./common"), exports); | ||
__exportStar(require("./inventory"), exports); | ||
__exportStar(require("./service"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type JoinerRelationship = { | ||
export type JoinerRelationship = { | ||
alias: string; | ||
@@ -6,6 +6,40 @@ foreignKey: string; | ||
serviceName: string; | ||
/** | ||
* If true, the relationship is an internal service from the medusa core | ||
* TODO: Remove when there are no more "internal" services | ||
*/ | ||
isInternalService?: boolean; | ||
/** | ||
* In an inverted relationship the foreign key is on the other service and the primary key is on the current service | ||
*/ | ||
inverse?: boolean; | ||
/** | ||
* Force the relationship to return a list | ||
*/ | ||
isList?: boolean; | ||
/** | ||
* Extra arguments to pass to the remoteFetchData callback | ||
*/ | ||
args?: Record<string, any>; | ||
}; | ||
export interface JoinerServiceConfigAlias { | ||
name: string; | ||
/** | ||
* Extra arguments to pass to the remoteFetchData callback | ||
*/ | ||
args?: Record<string, any>; | ||
} | ||
export interface JoinerServiceConfig { | ||
serviceName: string; | ||
/** | ||
* Property name to use as entrypoint to the service | ||
*/ | ||
alias?: JoinerServiceConfigAlias | JoinerServiceConfigAlias[]; | ||
/** | ||
* alias for deeper nested relationships (e.g. { 'price': 'prices.calculated_price_set.amount' }) | ||
*/ | ||
fieldAlias?: Record<string, string | { | ||
path: string; | ||
forwardArgumentsOnPath: string[]; | ||
}>; | ||
primaryKeys: string[]; | ||
@@ -15,4 +49,8 @@ relationships?: JoinerRelationship[]; | ||
serviceName: string; | ||
resolve: JoinerRelationship; | ||
relationship: JoinerRelationship; | ||
}[]; | ||
/** | ||
* Extra arguments to pass to the remoteFetchData callback | ||
*/ | ||
args?: Record<string, any>; | ||
} | ||
@@ -22,6 +60,10 @@ export interface JoinerArgument { | ||
value?: any; | ||
field?: string; | ||
} | ||
export interface JoinerDirective { | ||
name: string; | ||
value?: any; | ||
} | ||
export interface RemoteJoinerQuery { | ||
service: string; | ||
service?: string; | ||
alias?: string; | ||
expands?: Array<{ | ||
@@ -31,6 +73,11 @@ property: string; | ||
args?: JoinerArgument[]; | ||
relationships?: JoinerRelationship[]; | ||
directives?: { | ||
[field: string]: JoinerDirective[]; | ||
}; | ||
}>; | ||
fields: string[]; | ||
args?: JoinerArgument[]; | ||
directives?: { | ||
[field: string]: JoinerDirective[]; | ||
}; | ||
} | ||
@@ -46,2 +93,4 @@ export interface RemoteNestedExpands { | ||
property: string; | ||
parent: string; | ||
parentConfig?: JoinerServiceConfig; | ||
serviceConfig: JoinerServiceConfig; | ||
@@ -48,0 +97,0 @@ fields: string[]; |
@@ -0,7 +1,9 @@ | ||
import { JoinerRelationship, JoinerServiceConfig } from "../joiner"; | ||
import { MedusaContainer } from "../common"; | ||
import { RepositoryService } from "../dal"; | ||
import { Logger } from "../logger"; | ||
export declare type Constructor<T> = new (...args: any[]) => T; | ||
export type Constructor<T> = new (...args: any[]) => T; | ||
export * from "../common/medusa-container"; | ||
export declare type LogLevel = "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"; | ||
export declare type LoggerOptions = boolean | "all" | LogLevel[]; | ||
export type LogLevel = "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"; | ||
export type LoggerOptions = boolean | "all" | LogLevel[]; | ||
export declare enum MODULE_SCOPE { | ||
@@ -15,11 +17,21 @@ INTERNAL = "internal", | ||
} | ||
export declare type InternalModuleDeclaration = { | ||
export type InternalModuleDeclaration = { | ||
scope: MODULE_SCOPE.INTERNAL; | ||
resources: MODULE_RESOURCE_TYPE; | ||
dependencies?: string[]; | ||
definition?: ModuleDefinition; | ||
resolve?: string; | ||
options?: Record<string, unknown>; | ||
/** | ||
* If multiple modules are registered with the same key, the alias can be used to differentiate them | ||
*/ | ||
alias?: string; | ||
/** | ||
* If the module is the main module for the key when multiple ones are registered | ||
*/ | ||
main?: boolean; | ||
}; | ||
export declare type ExternalModuleDeclaration = { | ||
export type ExternalModuleDeclaration = { | ||
scope: MODULE_SCOPE.EXTERNAL; | ||
definition?: ModuleDefinition; | ||
server?: { | ||
@@ -30,4 +42,13 @@ type: "http"; | ||
}; | ||
options?: Record<string, unknown>; | ||
/** | ||
* If multiple modules are registered with the same key, the alias can be used to differentiate them | ||
*/ | ||
alias?: string; | ||
/** | ||
* If the module is the main module for the key when multiple ones are registered | ||
*/ | ||
main?: boolean; | ||
}; | ||
export declare type ModuleResolution = { | ||
export type ModuleResolution = { | ||
resolutionPath: string | false; | ||
@@ -40,3 +61,3 @@ definition: ModuleDefinition; | ||
}; | ||
export declare type ModuleDefinition = { | ||
export type ModuleDefinition = { | ||
key: string; | ||
@@ -46,8 +67,33 @@ registrationName: string; | ||
label: string; | ||
/** | ||
* @deprecated property will be removed in future versions | ||
*/ | ||
canOverride?: boolean; | ||
/** | ||
* @deprecated property will be removed in future versions | ||
*/ | ||
isRequired?: boolean; | ||
isQueryable?: boolean; | ||
isLegacy?: boolean; | ||
dependencies?: string[]; | ||
defaultModuleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration; | ||
}; | ||
export declare type LoaderOptions<TOptions = Record<string, unknown>> = { | ||
export type LinkModuleDefinition = { | ||
key: string; | ||
registrationName: string; | ||
label: string; | ||
dependencies?: string[]; | ||
defaultModuleDeclaration: InternalModuleDeclaration; | ||
}; | ||
type ModuleDeclaration = ExternalModuleDeclaration | InternalModuleDeclaration; | ||
export type ModuleConfig = ModuleDeclaration & { | ||
module: string; | ||
path: string; | ||
definition: ModuleDefinition; | ||
}; | ||
export type LoadedModule = unknown & { | ||
__joinerConfig: ModuleJoinerConfig; | ||
__definition: ModuleDefinition; | ||
}; | ||
export type LoaderOptions<TOptions = Record<string, unknown>> = { | ||
container: MedusaContainer; | ||
@@ -57,8 +103,66 @@ options?: TOptions; | ||
}; | ||
export declare type ModuleLoaderFunction = (options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>; | ||
export declare type ModulesResponse = { | ||
export type ModuleLoaderFunction = (options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>; | ||
export type ModulesResponse = { | ||
module: string; | ||
resolution: string | false; | ||
}[]; | ||
export declare type ModuleExports = { | ||
export type ModuleJoinerConfig = Omit<JoinerServiceConfig, "serviceName" | "primaryKeys" | "relationships" | "extends"> & { | ||
/** | ||
* GraphQL schema for the all module's available entities and fields | ||
*/ | ||
schema?: string; | ||
relationships?: ModuleJoinerRelationship[]; | ||
extends?: { | ||
serviceName: string; | ||
fieldAlias?: Record<string, string | { | ||
path: string; | ||
forwardArgumentsOnPath: string[]; | ||
}>; | ||
relationship: ModuleJoinerRelationship; | ||
}[]; | ||
serviceName?: string; | ||
primaryKeys?: string[]; | ||
/** | ||
* If the module is a link module | ||
*/ | ||
isLink?: boolean; | ||
/** | ||
* Keys that can be used to link to other modules. e.g { product_id: "Product" } "Product" being the entity it refers to | ||
*/ | ||
linkableKeys?: Record<string, string>; | ||
/** | ||
* If true it expands a RemoteQuery property but doesn't create a pivot table | ||
*/ | ||
isReadOnlyLink?: boolean; | ||
databaseConfig?: { | ||
/** | ||
* Name of the pivot table. If not provided it is auto generated | ||
*/ | ||
tableName?: string; | ||
/** | ||
* Prefix for the id column. If not provided it is "link" | ||
*/ | ||
idPrefix?: string; | ||
extraFields?: Record<string, { | ||
type: "date" | "time" | "datetime" | "bigint" | "blob" | "uint8array" | "array" | "enumArray" | "enum" | "json" | "integer" | "smallint" | "tinyint" | "mediumint" | "float" | "double" | "boolean" | "decimal" | "string" | "uuid" | "text"; | ||
defaultValue?: string; | ||
nullable?: boolean; | ||
/** | ||
* Mikro-orm options for the column | ||
*/ | ||
options?: Record<string, unknown>; | ||
}>; | ||
}; | ||
}; | ||
export declare type ModuleJoinerRelationship = JoinerRelationship & { | ||
/** | ||
* If true, the relationship is an internal service from the medusa core TODO: Remove when there are no more "internal" services | ||
*/ | ||
isInternalService?: boolean; | ||
/** | ||
* If true, the link joiner will cascade deleting the relationship | ||
*/ | ||
deleteCascade?: boolean; | ||
}; | ||
export type ModuleExports = { | ||
service: Constructor<any>; | ||
@@ -71,1 +175,25 @@ loaders?: ModuleLoaderFunction[]; | ||
}; | ||
export interface ModuleServiceInitializeOptions { | ||
database: { | ||
/** | ||
* Forces to use a shared knex connection | ||
*/ | ||
connection?: any; | ||
clientUrl?: string; | ||
schema?: string; | ||
host?: string; | ||
port?: number; | ||
user?: string; | ||
password?: string; | ||
database?: string; | ||
driverOptions?: Record<string, unknown>; | ||
debug?: boolean; | ||
pool?: Record<string, unknown>; | ||
}; | ||
} | ||
export type ModuleServiceInitializeCustomDataLayerOptions = { | ||
manager?: any; | ||
repositories?: { | ||
[key: string]: Constructor<RepositoryService>; | ||
}; | ||
}; |
@@ -23,3 +23,3 @@ "use strict"; | ||
MODULE_SCOPE["EXTERNAL"] = "external"; | ||
})(MODULE_SCOPE = exports.MODULE_SCOPE || (exports.MODULE_SCOPE = {})); | ||
})(MODULE_SCOPE || (exports.MODULE_SCOPE = MODULE_SCOPE = {})); | ||
var MODULE_RESOURCE_TYPE; | ||
@@ -29,3 +29,3 @@ (function (MODULE_RESOURCE_TYPE) { | ||
MODULE_RESOURCE_TYPE["ISOLATED"] = "isolated"; | ||
})(MODULE_RESOURCE_TYPE = exports.MODULE_RESOURCE_TYPE || (exports.MODULE_RESOURCE_TYPE = {})); | ||
})(MODULE_RESOURCE_TYPE || (exports.MODULE_RESOURCE_TYPE = MODULE_RESOURCE_TYPE = {})); | ||
//# sourceMappingURL=index.js.map |
import { BaseFilterable } from "../dal"; | ||
import { OperatorMap } from "../dal/utils"; | ||
/** | ||
* @enum | ||
*/ | ||
export declare enum ProductStatus { | ||
@@ -10,3 +13,34 @@ DRAFT = "draft", | ||
/** | ||
* DTO in and out of the module (module API) | ||
* @interface | ||
* | ||
* A product's data. | ||
* @prop id - The ID of the product. | ||
* @prop title - The title of the product. | ||
* @prop handle - The handle of the product. The handle can be used to create slug URL paths. It can possibly be `null`. | ||
* @prop subtitle - The subttle of the product. It can possibly be `null`. | ||
* @prop description - The description of the product. It can possibly be `null`. | ||
* @prop is_giftcard - Whether the product is a gift card. | ||
* @prop status - The status of the product. Its value can be one of the values of the enum {@link ProductStatus}. | ||
* @prop thumbnail - The URL of the product's thumbnail. It can possibly be `null`. | ||
* @prop weight - The weight of the product. It can possibly be `null`. | ||
* @prop length - The length of the product. It can possibly be `null`. | ||
* @prop height - The height of the product. It can possibly be `null`. | ||
* @prop origin_country - The origin country of the product. It can possibly be `null`. | ||
* @prop hs_code - The HS Code of the product. It can possibly be `null`. | ||
* @prop mid_code - The MID Code of the product. It can possibly be `null`. | ||
* @prop material - The material of the product. It can possibly be `null`. | ||
* @prop collection - The associated product collection. It may only be available if the `collection` relation is expanded. | ||
* @prop categories -The associated product categories. It may only be available if the `categories` relation is expanded. | ||
* @prop type - The associated product type. It may only be available if the `type` relation is expanded. | ||
* @prop tags - The associated product tags. It may only be available if the `tags` relation is expanded. | ||
* @prop variants - The associated product variants. It may only be available if the `variants` relation is expanded. | ||
* @prop options - The associated product options. It may only be available if the `options` relation is expanded. | ||
* @prop images - The associated product images. It may only be available if the `images` relation is expanded. | ||
* @prop discountable - Whether the product can be discounted. | ||
* @prop external_id - | ||
* The ID of the product in an external system. This is useful if you're integrating the product with a third-party service and want to maintain | ||
* a reference to the ID in the integrated service. | ||
* @prop created_at - When the product was created. | ||
* @prop updated_at - When the product was updated. | ||
* @prop deleted_at - When the product was deleted. | ||
*/ | ||
@@ -22,2 +56,3 @@ export interface ProductDTO { | ||
thumbnail?: string | null; | ||
width?: number | null; | ||
weight?: number | null; | ||
@@ -36,2 +71,3 @@ length?: number | null; | ||
options: ProductOptionDTO[]; | ||
images: ProductImageDTO[]; | ||
discountable?: boolean; | ||
@@ -42,3 +78,35 @@ external_id?: string | null; | ||
deleted_at?: string | Date; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product variant's data. | ||
* | ||
* @prop id - The ID of the product variant. | ||
* @prop title - The tile of the product variant. | ||
* @prop sku - The SKU of the product variant. It can possibly be `null`. | ||
* @prop barcode - The barcode of the product variant. It can possibly be `null`. | ||
* @prop ean - The EAN of the product variant. It can possibly be `null`. | ||
* @prop upc - The UPC of the product variant. It can possibly be `null`. | ||
* @prop inventory_quantity - The inventory quantiy of the product variant. | ||
* @prop allow_backorder - Whether the product variant can be ordered when it's out of stock. | ||
* @prop manage_inventory - Whether the product variant's inventory should be managed by the core system. | ||
* @prop hs_code - The HS Code of the product variant. It can possibly be `null`. | ||
* @prop origin_country - The origin country of the product variant. It can possibly be `null`. | ||
* @prop mid_code - The MID Code of the product variant. It can possibly be `null`. | ||
* @prop material - The material of the product variant. It can possibly be `null`. | ||
* @prop weight - The weight of the product variant. It can possibly be `null`. | ||
* @prop length - The length of the product variant. It can possibly be `null`. | ||
* @prop height - The height of the product variant. It can possibly be `null`. | ||
* @prop width - The width of the product variant. It can possibly be `null`. | ||
* @prop options - The associated product options. It may only be available if the `options` relation is expanded. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop product - The associated product. It may only be available if the `product` relation is expanded. | ||
* @prop product_id - The ID of the associated product. | ||
* @prop variant_rank - The ranking of the variant among other variants associated with the product. It can possibly be `null`. | ||
* @prop created_at - When the product variant was created. | ||
* @prop updated_at - When the product variant was updated. | ||
* @prop deleted_at - When the product variant was deleted. | ||
*/ | ||
export interface ProductVariantDTO { | ||
@@ -65,2 +133,3 @@ id: string; | ||
product: ProductDTO; | ||
product_id: string; | ||
variant_rank?: number | null; | ||
@@ -71,2 +140,19 @@ created_at: string | Date; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product category's data. | ||
* | ||
* @prop id - The ID of the product category. | ||
* @prop name - The name of the product category. | ||
* @prop description - The description of the product category. | ||
* @prop handle - The handle of the product category. The handle can be used to create slug URL paths. | ||
* @prop is_active - Whether the product category is active. | ||
* @prop is_internal - Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers. | ||
* @prop rank - The ranking of the product category among sibling categories. | ||
* @prop parent_category - The associated parent category. It may only be available if the `parent_category` relation is expanded. | ||
* @prop category_children - The associated child categories. It may only be available if the `category_children` relation is expanded. | ||
* @prop created_at - When the product category was created. | ||
* @prop updated_at - When the product category was updated. | ||
*/ | ||
export interface ProductCategoryDTO { | ||
@@ -85,2 +171,56 @@ id: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product category to create. | ||
* | ||
* @prop name - The product category's name. | ||
* @prop handle - The product category's handle. | ||
* @prop is_active - Whether the product category is active. | ||
* @prop is_internal - Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers. | ||
* @prop rank - The ranking of the category among sibling categories. | ||
* @prop parent_category_id - The ID of the parent product category, if it has any. It may also be `null`. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface CreateProductCategoryDTO { | ||
name: string; | ||
handle?: string; | ||
is_active?: boolean; | ||
is_internal?: boolean; | ||
rank?: number; | ||
parent_category_id: string | null; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The data to update in a product category. | ||
* | ||
* @prop name - The name of the product category. | ||
* @prop handle - The handle of the product category. | ||
* @prop is_active - Whether the product category is active. | ||
* @prop is_internal - Whether the product category is internal. This can be used to only show the product category to admins and hide it from customers. | ||
* @prop rank - The ranking of the category among sibling categories. | ||
* @prop parent_category_id - The ID of the parent product category, if it has any. It may also be `null`. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface UpdateProductCategoryDTO { | ||
name?: string; | ||
handle?: string; | ||
is_active?: boolean; | ||
is_internal?: boolean; | ||
rank?: number; | ||
parent_category_id?: string | null; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product tag's data. | ||
* | ||
* @prop id - The ID of the product tag. | ||
* @prop value - The value of the product tag. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop products - The associated products. It may only be available if the `products` relation is expanded. | ||
*/ | ||
export interface ProductTagDTO { | ||
@@ -90,4 +230,16 @@ id: string; | ||
metadata?: Record<string, unknown> | null; | ||
products: ProductDTO[]; | ||
products?: ProductDTO[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product collection's data. | ||
* | ||
* @prop id - The ID of the product collection. | ||
* @prop title - The title of the product collection. | ||
* @prop handle - The handle of the product collection. The handle can be used to create slug URL paths. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop deleted_at - When the product collection was deleted. | ||
* @prop products - The associated products. It may only be available if the `products` relation is expanded. | ||
*/ | ||
export interface ProductCollectionDTO { | ||
@@ -99,3 +251,14 @@ id: string; | ||
deleted_at?: string | Date; | ||
products?: ProductDTO[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product type's data. | ||
* | ||
* @prop id - The ID of the product type. | ||
* @prop value - The value of the product type. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop deleted_at - When the product type was deleted. | ||
*/ | ||
export interface ProductTypeDTO { | ||
@@ -107,2 +270,15 @@ id: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product option's data. | ||
* | ||
* @prop id - The ID of the product option. | ||
* @prop title - The title of the product option. | ||
* @prop product - The associated product. It may only be available if the `product` relation is expanded. | ||
* @prop values - The associated product option values. It may only be available if the `values` relation is expanded. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop deleted_at - When the product option was deleted. | ||
* | ||
*/ | ||
export interface ProductOptionDTO { | ||
@@ -116,2 +292,30 @@ id: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The product image's data. | ||
* | ||
* @prop id - The ID of the product image. | ||
* @prop url - The URL of the product image. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop deleted_at - When the product image was deleted. | ||
*/ | ||
export interface ProductImageDTO { | ||
id: string; | ||
url: string; | ||
metadata?: Record<string, unknown> | null; | ||
deleted_at?: string | Date; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The product option value's data. | ||
* | ||
* @prop id - The ID of the product option value. | ||
* @prop value - The value of the product option value. | ||
* @prop option - The associated product option. It may only be available if the `option` relation is expanded. | ||
* @prop variant - The associated product variant. It may only be available if the `variant` relation is expanded. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
* @prop deleted_at - When the product option value was deleted. | ||
*/ | ||
export interface ProductOptionValueDTO { | ||
@@ -126,5 +330,15 @@ id: string; | ||
/** | ||
* Filters/Config (module API input filters and config) | ||
* @interface | ||
* | ||
* The filters to apply on retrieved products. | ||
* | ||
* @prop q - Search through the products' attributes, such as titles and descriptions, using this search term. | ||
* @prop handle - The handles to filter products by. | ||
* @prop id - The IDs to filter products by. | ||
* @prop tags - Filters on a product's tags. | ||
* @prop categories - Filters on a product's categories. | ||
* @prop collection_id - Filters a product by its associated collections. | ||
*/ | ||
export interface FilterableProductProps extends BaseFilterable<FilterableProductProps> { | ||
q?: string; | ||
handle?: string | string[]; | ||
@@ -137,5 +351,16 @@ id?: string | string[]; | ||
id?: string | string[] | OperatorMap<string>; | ||
is_internal?: boolean; | ||
is_active?: boolean; | ||
}; | ||
category_ids?: string | string[] | OperatorMap<string>; | ||
category_id?: string | string[] | OperatorMap<string>; | ||
collection_id?: string | string[] | OperatorMap<string>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product tags. | ||
* | ||
* @prop id - The IDs to filter product tags by. | ||
* @prop value - The value to filter product tags by. | ||
*/ | ||
export interface FilterableProductTagProps extends BaseFilterable<FilterableProductTagProps> { | ||
@@ -145,9 +370,55 @@ id?: string | string[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product types. | ||
* | ||
* @prop id - The IDs to filter product types by. | ||
* @prop value - The value to filter product types by. | ||
*/ | ||
export interface FilterableProductTypeProps extends BaseFilterable<FilterableProductTypeProps> { | ||
id?: string | string[]; | ||
value?: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product options. | ||
* | ||
* @prop id - The IDs to filter product options by. | ||
* @prop title - The titles to filter product options by. | ||
* @prop product_id - Filter the product options by their associated products' IDs. | ||
*/ | ||
export interface FilterableProductOptionProps extends BaseFilterable<FilterableProductOptionProps> { | ||
id?: string | string[]; | ||
title?: string; | ||
product_id?: string | string[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product collections. | ||
* | ||
* @prop id - The IDs to filter product collections by. | ||
* @prop title - The title to filter product collections by. | ||
*/ | ||
export interface FilterableProductCollectionProps extends BaseFilterable<FilterableProductCollectionProps> { | ||
id?: string | string[]; | ||
handle?: string | string[]; | ||
title?: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product variants. | ||
* | ||
* @prop id - The IDs to filter product variants by. | ||
* @prop sku - The SKUs to filter product variants by. | ||
* @prop product_id - Filter the product variants by their associated products' IDs. | ||
* @prop options - Filter product variants by their associated options. | ||
*/ | ||
export interface FilterableProductVariantProps extends BaseFilterable<FilterableProductVariantProps> { | ||
id?: string | string[]; | ||
sku?: string | string[]; | ||
product_id?: string | string[]; | ||
options?: { | ||
@@ -157,4 +428,18 @@ id?: string[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The filters to apply on retrieved product categories. | ||
* | ||
* @prop id - The IDs to filter product categories by. | ||
* @prop name - The names to filter product categories by. | ||
* @prop parent_category_id - Filter product categories by their parent category's ID. | ||
* @prop handle - The handles to filter product categories by. | ||
* @prop is_active - Filter product categories by whether they're active. | ||
* @prop is_internal - Filter product categories by whether they're internal. | ||
* @prop include_descendants_tree - Whether to include children of retrieved product categories. | ||
*/ | ||
export interface FilterableProductCategoryProps extends BaseFilterable<FilterableProductCategoryProps> { | ||
id?: string | string[]; | ||
name?: string | string[]; | ||
parent_category_id?: string | string[] | null; | ||
@@ -166,1 +451,431 @@ handle?: string | string[]; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product collection to create. | ||
* | ||
* @prop title - The product collection's title. | ||
* @prop handle - The product collection's handle. If not provided, the value of this attribute is set to the slug version of the title. | ||
* @prop products - The products to associate with the collection. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface CreateProductCollectionDTO { | ||
title: string; | ||
handle?: string; | ||
product_ids?: string[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The data to update in a product collection. The `id` is used to identify which product collection to update. | ||
* | ||
* @prop id - The ID of the product collection to update. | ||
* @prop value - The value of the product collection. | ||
* @prop title - The title of the product collection. | ||
* @prop handle - The handle of the product collection. | ||
* @prop product_ids - The IDs of the products to associate with the product collection. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface UpdateProductCollectionDTO { | ||
id: string; | ||
value?: string; | ||
title?: string; | ||
handle?: string; | ||
product_ids?: string[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product type to create. | ||
* | ||
* @prop id - The product type's ID. | ||
* @prop value - The product type's value. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface CreateProductTypeDTO { | ||
id?: string; | ||
value: string; | ||
metadata?: Record<string, unknown>; | ||
} | ||
export interface UpsertProductTypeDTO { | ||
id?: string; | ||
value: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The data to update in a product type. The `id` is used to identify which product type to update. | ||
* | ||
* @prop id - The ID of the product type to update. | ||
* @prop value - The new value of the product type. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface UpdateProductTypeDTO { | ||
id: string; | ||
value?: string; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product tag to create. | ||
* | ||
* @prop value - The value of the product tag. | ||
*/ | ||
export interface CreateProductTagDTO { | ||
value: string; | ||
} | ||
export interface UpsertProductTagDTO { | ||
id?: string; | ||
value: string; | ||
} | ||
/** | ||
* | ||
* @interface | ||
* | ||
* The data to update in a product tag. The `id` is used to identify which product tag to update. | ||
* | ||
* @prop id - The ID of the product tag to update. | ||
* @prop value - The value of the product tag. | ||
*/ | ||
export interface UpdateProductTagDTO { | ||
id: string; | ||
value?: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product option to create. | ||
* | ||
* @prop title - The product option's title. | ||
* @prop product_id - The ID of the associated product. | ||
*/ | ||
export interface CreateProductOptionDTO { | ||
title: string; | ||
product_id?: string; | ||
} | ||
export interface UpdateProductOptionDTO { | ||
id: string; | ||
title?: string; | ||
product_id?: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product variant option to create. | ||
* | ||
* @prop value - The value of a product variant option. | ||
*/ | ||
export interface CreateProductVariantOptionDTO { | ||
value: string; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product variant to create. | ||
* | ||
* @prop title - The tile of the product variant. | ||
* @prop sku - The SKU of the product variant. | ||
* @prop barcode - The barcode of the product variant. | ||
* @prop ean - The EAN of the product variant. | ||
* @prop upc - The UPC of the product variant. | ||
* @prop allow_backorder - Whether the product variant can be ordered when it's out of stock. | ||
* @prop inventory_quantity - The inventory quantiy of the product variant. | ||
* @prop manage_inventory - Whether the product variant's inventory should be managed by the core system. | ||
* @prop hs_code - The HS Code of the product variant. | ||
* @prop origin_country - The origin country of the product variant. | ||
* @prop mid_code - The MID Code of the product variant. | ||
* @prop material - The material of the product variant. | ||
* @prop weight - The weight of the product variant. | ||
* @prop length - The length of the product variant. | ||
* @prop height - The height of the product variant. | ||
* @prop width - The width of the product variant. | ||
* @prop options - The product variant options to create and associate with the product variant. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface CreateProductVariantDTO { | ||
title: string; | ||
sku?: string; | ||
barcode?: string; | ||
ean?: string; | ||
upc?: string; | ||
allow_backorder?: boolean; | ||
inventory_quantity?: number; | ||
manage_inventory?: boolean; | ||
hs_code?: string; | ||
origin_country?: string; | ||
mid_code?: string; | ||
material?: string; | ||
weight?: number; | ||
length?: number; | ||
height?: number; | ||
width?: number; | ||
options?: CreateProductVariantOptionDTO[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The data to update in a product variant. The `id` is used to identify which product variant to update. | ||
* | ||
* @prop id - The ID of the product variant to update. | ||
* @prop title - The tile of the product variant. | ||
* @prop sku - The SKU of the product variant. | ||
* @prop barcode - The barcode of the product variant. | ||
* @prop ean - The EAN of the product variant. | ||
* @prop upc - The UPC of the product variant. | ||
* @prop allow_backorder - Whether the product variant can be ordered when it's out of stock. | ||
* @prop inventory_quantity - The inventory quantiy of the product variant. | ||
* @prop manage_inventory - Whether the product variant's inventory should be managed by the core system. | ||
* @prop hs_code - The HS Code of the product variant. | ||
* @prop origin_country - The origin country of the product variant. | ||
* @prop mid_code - The MID Code of the product variant. | ||
* @prop material - The material of the product variant. | ||
* @prop weight - The weight of the product variant. | ||
* @prop length - The length of the product variant. | ||
* @prop height - The height of the product variant. | ||
* @prop width - The width of the product variant. | ||
* @prop options - The product variant options to create and associate with the product variant. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface UpdateProductVariantDTO { | ||
id: string; | ||
title?: string; | ||
sku?: string; | ||
barcode?: string; | ||
ean?: string; | ||
upc?: string; | ||
allow_backorder?: boolean; | ||
inventory_quantity?: number; | ||
manage_inventory?: boolean; | ||
hs_code?: string; | ||
origin_country?: string; | ||
mid_code?: string; | ||
material?: string; | ||
weight?: number; | ||
length?: number; | ||
height?: number; | ||
width?: number; | ||
options?: CreateProductVariantOptionDTO[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* A product to create. | ||
* | ||
* @prop title - The title of the product. | ||
* @prop subtitle - The subttle of the product. | ||
* @prop description - The description of the product. | ||
* @prop is_giftcard - Whether the product is a gift card. | ||
* @prop discountable - Whether the product can be discounted. | ||
* @prop images - | ||
* The product's images. If an array of strings is supplied, each string will be a URL and a `ProductImage` will be created | ||
* and associated with the product. If an array of objects is supplied, you can pass along the ID of an existing `ProductImage`. | ||
* @prop thumbnail - The URL of the product's thumbnail. | ||
* @prop handle - | ||
* The handle of the product. The handle can be used to create slug URL paths. | ||
* If not supplied, the value of the `handle` attribute of the product is set to the slug version of the `title` attribute. | ||
* @prop status - The status of the product. Its value can be one of the values of the enum {@link ProductStatus}. | ||
* @prop type - The product type to create and associate with the product. | ||
* @prop type_id - The product type to be associated with the product. | ||
* @prop collection_id - The product collection to be associated with the product. | ||
* @prop tags - The product tags to be created and associated with the product. | ||
* @prop categories - The product categories to associate with the product. | ||
* @prop options - The product options to be created and associated with the product. | ||
* @prop variants - The product variants to be created and associated with the product. | ||
* @prop width - The width of the product. | ||
* @prop height - The height of the product. | ||
* @prop length - The length of the product. | ||
* @prop weight - The weight of the product. | ||
* @prop origin_country - The origin country of the product. | ||
* @prop hs_code - The HS Code of the product. | ||
* @prop material - The material of the product. | ||
* @prop mid_code - The MID Code of the product. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface CreateProductDTO { | ||
title: string; | ||
subtitle?: string; | ||
description?: string; | ||
is_giftcard?: boolean; | ||
discountable?: boolean; | ||
images?: string[] | { | ||
id?: string; | ||
url: string; | ||
}[]; | ||
thumbnail?: string; | ||
handle?: string; | ||
status?: ProductStatus; | ||
type?: CreateProductTypeDTO; | ||
type_id?: string; | ||
collection_id?: string; | ||
tags?: CreateProductTagDTO[]; | ||
categories?: { | ||
id: string; | ||
}[]; | ||
options?: CreateProductOptionDTO[]; | ||
variants?: CreateProductVariantDTO[]; | ||
width?: number; | ||
height?: number; | ||
length?: number; | ||
weight?: number; | ||
origin_country?: string; | ||
hs_code?: string; | ||
material?: string; | ||
mid_code?: string; | ||
metadata?: Record<string, unknown>; | ||
} | ||
/** | ||
* @interface | ||
* | ||
* The data to update in a product. The `id` is used to identify which product to update. | ||
* | ||
* @prop id - The ID of the product to update. | ||
* @prop title - The title of the product. | ||
* @prop subtitle - The subttle of the product. | ||
* @prop description - The description of the product. | ||
* @prop is_giftcard - Whether the product is a gift card. | ||
* @prop discountable - Whether the product can be discounted. | ||
* @prop images - | ||
* The product's images. If an array of strings is supplied, each string will be a URL and a `ProductImage` will be created | ||
* and associated with the product. If an array of objects is supplied, you can pass along the ID of an existing `ProductImage`. | ||
* @prop thumbnail - The URL of the product's thumbnail. | ||
* @prop handle - | ||
* The handle of the product. The handle can be used to create slug URL paths. | ||
* If not supplied, the value of the `handle` attribute of the product is set to the slug version of the `title` attribute. | ||
* @prop status - The status of the product. Its value can be one of the values of the enum {@link ProductStatus}. | ||
* @prop type - The product type to create and associate with the product. | ||
* @prop type_id - The product type to be associated with the product. | ||
* @prop collection_id - The product collection to be associated with the product. | ||
* @prop tags - The product tags to be created and associated with the product. | ||
* @prop categories - The product categories to associate with the product. | ||
* @prop options - The product options to be created and associated with the product. | ||
* @prop variants - | ||
* The product variants to be created and associated with the product. You can also update existing product variants associated with the product. | ||
* @prop width - The width of the product. | ||
* @prop height - The height of the product. | ||
* @prop length - The length of the product. | ||
* @prop weight - The weight of the product. | ||
* @prop origin_country - The origin country of the product. | ||
* @prop hs_code - The HS Code of the product. | ||
* @prop material - The material of the product. | ||
* @prop mid_code - The MID Code of the product. | ||
* @prop metadata - Holds custom data in key-value pairs. | ||
*/ | ||
export interface UpdateProductDTO { | ||
id: string; | ||
title?: string; | ||
subtitle?: string; | ||
description?: string; | ||
is_giftcard?: boolean; | ||
discountable?: boolean; | ||
images?: string[] | { | ||
id?: string; | ||
url: string; | ||
}[]; | ||
thumbnail?: string; | ||
handle?: string; | ||
status?: ProductStatus; | ||
type?: CreateProductTypeDTO; | ||
type_id?: string | null; | ||
collection_id?: string | null; | ||
tags?: CreateProductTagDTO[]; | ||
categories?: { | ||
id: string; | ||
}[]; | ||
options?: CreateProductOptionDTO[]; | ||
variants?: (CreateProductVariantDTO | UpdateProductVariantDTO)[]; | ||
width?: number; | ||
height?: number; | ||
length?: number; | ||
weight?: number; | ||
origin_country?: string; | ||
hs_code?: string; | ||
material?: string; | ||
mid_code?: string; | ||
metadata?: Record<string, unknown>; | ||
} | ||
export interface CreateProductOnlyDTO { | ||
title: string; | ||
subtitle?: string; | ||
description?: string; | ||
is_giftcard?: boolean; | ||
discountable?: boolean; | ||
images?: { | ||
id?: string; | ||
url: string; | ||
}[]; | ||
thumbnail?: string; | ||
handle?: string; | ||
status?: ProductStatus; | ||
collection_id?: string; | ||
width?: number; | ||
height?: number; | ||
length?: number; | ||
weight?: number; | ||
origin_country?: string; | ||
hs_code?: string; | ||
material?: string; | ||
mid_code?: string; | ||
metadata?: Record<string, unknown>; | ||
tags?: { | ||
id: string; | ||
}[]; | ||
categories?: { | ||
id: string; | ||
}[]; | ||
type_id?: string; | ||
} | ||
export interface CreateProductVariantOnlyDTO { | ||
title: string; | ||
sku?: string; | ||
barcode?: string; | ||
ean?: string; | ||
upc?: string; | ||
allow_backorder?: boolean; | ||
inventory_quantity?: number; | ||
manage_inventory?: boolean; | ||
hs_code?: string; | ||
origin_country?: string; | ||
mid_code?: string; | ||
material?: string; | ||
weight?: number; | ||
length?: number; | ||
height?: number; | ||
width?: number; | ||
options?: (CreateProductVariantOptionDTO & { | ||
option: any; | ||
})[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
export interface UpdateProductVariantOnlyDTO { | ||
id: string; | ||
title?: string; | ||
sku?: string; | ||
barcode?: string; | ||
ean?: string; | ||
upc?: string; | ||
allow_backorder?: boolean; | ||
inventory_quantity?: number; | ||
manage_inventory?: boolean; | ||
hs_code?: string; | ||
origin_country?: string; | ||
mid_code?: string; | ||
material?: string; | ||
weight?: number; | ||
length?: number; | ||
height?: number; | ||
width?: number; | ||
options?: (CreateProductVariantOptionDTO & { | ||
option: any; | ||
})[]; | ||
metadata?: Record<string, unknown>; | ||
} | ||
export interface CreateProductOptionOnlyDTO { | ||
product_id?: string; | ||
product?: Record<any, any>; | ||
title: string; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ProductStatus = void 0; | ||
/** | ||
* @enum | ||
*/ | ||
var ProductStatus; | ||
@@ -10,3 +13,3 @@ (function (ProductStatus) { | ||
ProductStatus["REJECTED"] = "rejected"; | ||
})(ProductStatus = exports.ProductStatus || (exports.ProductStatus = {})); | ||
})(ProductStatus || (exports.ProductStatus = ProductStatus = {})); | ||
//# sourceMappingURL=common.js.map |
@@ -0,2 +1,2 @@ | ||
export * from "./common"; | ||
export * from "./service"; | ||
export * from "./common"; |
@@ -17,4 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./common"), exports); | ||
__exportStar(require("./service"), exports); | ||
__exportStar(require("./common"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,6 +0,4 @@ | ||
export * from "./index-types"; | ||
export * from "./interface"; | ||
export * from "./settings"; | ||
export * from "./variant-keys"; | ||
export declare type IndexSettings = { | ||
export type IndexSettings = { | ||
/** | ||
@@ -7,0 +5,0 @@ * Settings specific to the provider. E.g. `searchableAttributes`. |
@@ -17,6 +17,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./index-types"), exports); | ||
__exportStar(require("./interface"), exports); | ||
__exportStar(require("./settings"), exports); | ||
__exportStar(require("./variant-keys"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
export declare type IndexSettings = { | ||
export type IndexSettings = { | ||
/** | ||
@@ -3,0 +3,0 @@ * Settings specific to the provider. E.g. `searchableAttributes`. |
import { EntityManager } from "typeorm"; | ||
export declare type SharedContext = { | ||
export type SharedContext = { | ||
transactionManager?: EntityManager; | ||
manager?: EntityManager; | ||
}; | ||
/** | ||
* @internal The interface tag is used to ensure that the type is documented similar to interfaces. | ||
* @interface | ||
* | ||
* A shared context object that is used to share resources between the application and the module. | ||
* | ||
* @prop transactionManager - An instance of a transaction manager of type `TManager`, which is a typed parameter passed to the context to specify the type of the `transactionManager`. | ||
* @prop manager - An instance of a manager, typically an entity manager, of type `TManager`, which is a typed parameter passed to the context to specify the type of the `manager`. | ||
* @prop isolationLevel - A string indicating the isolation level of the context. Possible values are `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, or `SERIALIZABLE`. | ||
* @prop enableNestedTransactions - a boolean value indicating whether nested transactions are enabled. | ||
* @prop transactionId - a string indicating the ID of the current transaction. | ||
*/ | ||
export type Context<TManager = unknown> = { | ||
transactionManager?: TManager; | ||
manager?: TManager; | ||
isolationLevel?: string; | ||
enableNestedTransactions?: boolean; | ||
transactionId?: string; | ||
}; |
@@ -66,3 +66,3 @@ import { StringComparisonOperator } from "../common/common"; | ||
*/ | ||
export declare type StockLocationAddressDTO = { | ||
export type StockLocationAddressDTO = { | ||
id?: string; | ||
@@ -128,3 +128,3 @@ address_1: string; | ||
*/ | ||
export declare type StockLocationDTO = { | ||
export type StockLocationDTO = { | ||
id: string; | ||
@@ -148,6 +148,6 @@ name: string; | ||
*/ | ||
export declare type StockLocationExpandedDTO = StockLocationDTO & { | ||
export type StockLocationExpandedDTO = StockLocationDTO & { | ||
sales_channels?: any[]; | ||
}; | ||
export declare type FilterableStockLocationProps = { | ||
export type FilterableStockLocationProps = { | ||
id?: string | string[]; | ||
@@ -198,3 +198,3 @@ name?: string | string[] | StringComparisonOperator; | ||
*/ | ||
export declare type StockLocationAddressInput = { | ||
export type StockLocationAddressInput = { | ||
address_1: string; | ||
@@ -233,3 +233,3 @@ address_2?: string; | ||
*/ | ||
export declare type CreateStockLocationInput = { | ||
export type CreateStockLocationInput = { | ||
name: string; | ||
@@ -262,3 +262,3 @@ address_id?: string; | ||
*/ | ||
export declare type UpdateStockLocationInput = { | ||
export type UpdateStockLocationInput = { | ||
name?: string; | ||
@@ -265,0 +265,0 @@ address_id?: string; |
export * from "./common"; | ||
export * from "./stock-location"; | ||
export * from "./service"; |
@@ -18,3 +18,3 @@ "use strict"; | ||
__exportStar(require("./common"), exports); | ||
__exportStar(require("./stock-location"), exports); | ||
__exportStar(require("./service"), exports); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ivfuture/ecomm-types", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Medusa Types definition", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"repository": { | ||
@@ -23,9 +24,10 @@ "type": "git", | ||
"ioredis": "^5.2.5", | ||
"rimraf": "^5.0.1", | ||
"typeorm": "^0.3.16", | ||
"typescript": "^4.4.4", | ||
"typescript": "^5.1.6", | ||
"winston": "^3.8.2" | ||
}, | ||
"scripts": { | ||
"prepare": "cross-env NODE_ENV=production yarn run build", | ||
"build": "tsc --build", | ||
"prepublishOnly": "cross-env NODE_ENV=production tsc --build", | ||
"build": "rimraf dist && tsc --build", | ||
"watch": "tsc --build --watch", | ||
@@ -32,0 +34,0 @@ "test": "exit 0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
327883
202
8521
7
1