import { JoinerRelationship, JoinerServiceConfig } from "../joiner"; import { MedusaContainer } from "../common"; import { RepositoryService } from "../dal"; import { Logger } from "../logger"; import { ModuleProviderExports } from "./module-provider"; import { RemoteQueryGraph, RemoteQueryInput, RemoteQueryObjectConfig, RemoteQueryObjectFromStringResult } from "./remote-query-object-from-string"; export { RemoteQueryGraph, RemoteQueryInput, RemoteQueryObjectConfig, RemoteQueryObjectFromStringResult, }; export type Constructor = new (...args: any[]) => T | (new () => T); export * from "../common/medusa-container"; export * from "./medusa-internal-service"; export * from "./module-provider"; export * from "./remote-query"; export * from "./remote-query-entry-points"; export * from "./to-remote-query"; export type LogLevel = "query" | "schema" | "error" | "warn" | "info" | "log" | "migration"; export type LoggerOptions = boolean | "all" | LogLevel[]; export type CustomModuleDefinition = { key?: string; label?: string; isQueryable?: boolean; dependencies?: string[]; }; export type InternalModuleDeclaration = { scope: "internal"; dependencies?: string[]; definition?: CustomModuleDefinition; resolve?: string | ModuleExports; options?: Record; /** * 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; worker_mode?: "shared" | "worker" | "server"; }; export type ExternalModuleDeclaration = { scope: "external"; definition?: CustomModuleDefinition; server?: { type: "http"; url: string; keepAlive: boolean; }; options?: Record; /** * 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 type ModuleResolution = { resolutionPath: string | false; definition: ModuleDefinition; options?: Record; dependencies?: string[]; moduleDeclaration?: InternalModuleDeclaration | ExternalModuleDeclaration; moduleExports?: ModuleExports | ModuleProviderExports; }; export type ModuleDefinition = { key: string; defaultPackage: string | false; label: string; resolvePath?: string; isRequired?: boolean; isQueryable?: boolean; dependencies?: string[]; /** @internal only used in exceptional cases - relying on the shared contrainer breaks encapsulation */ __passSharedContainer?: boolean; defaultModuleDeclaration: InternalModuleDeclaration | ExternalModuleDeclaration; }; export type LinkModuleDefinition = { key: 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> = { container: MedusaContainer; options?: TOptions; logger?: Logger; dataLoaderOnly?: boolean; }; export type ModuleLoaderFunction = (options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration) => Promise; export type ModulesResponse = { module: string; resolution: string | false; }[]; export type LinkModulesExtraFields = Record; }>; /** * A link for two records of linked data models. * * The keys are the names of each module, and their value is an object that holds the ID of the linked data model's record. */ export type LinkDefinition = { [moduleName: string]: { [fieldName: string]: any; }; } & { data?: Record; }; export type ModuleJoinerConfig = Omit & { /** * GraphQL schema for the all module's available entities and fields */ schema?: string; relationships?: ModuleJoinerRelationship[]; extends?: { serviceName: string; entity?: string; fieldAlias?: Record; relationship: Omit; }[]; 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; /** * If true it expands a RemoteQuery property but doesn't create a pivot table */ isReadOnlyLink?: boolean; /** * Fields that will be part of the link record aside from the primary keys that can be updated * If not explicitly defined, this array will be populated by databaseConfig.extraFields */ extraDataFields?: string[]; 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?: LinkModulesExtraFields; }; }; export declare type ModuleJoinerRelationship = JoinerRelationship & { /** * If true, the link joiner will cascade deleting the relationship */ deleteCascade?: boolean; /** * The fields to be filterable by the Index module using query.index */ filterable?: string[]; /** * Allow multiple relationships to exist for this * entity */ hasMany?: boolean; }; export type ModuleExports> = { service: T; loaders?: ModuleLoaderFunction[]; runMigrations?(options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration): Promise; revertMigration?(options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration): Promise; generateMigration?(options: LoaderOptions, moduleDeclaration?: InternalModuleDeclaration): Promise; /** * Explicitly set the the true location of the module resources. * Can be used to re-export the module from a different location and specify its original location. */ discoveryPath?: string; }; 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 & { connection?: Record; }; debug?: boolean; pool?: Record; }; } export type ModuleServiceInitializeCustomDataLayerOptions = { manager?: any; repositories?: { [key: string]: Constructor; }; }; export type ModuleBootstrapDeclaration = InternalModuleDeclaration | ExternalModuleDeclaration; export interface IModuleService { /** * @ignore */ __joinerConfig?(): ModuleJoinerConfig; /** * @ignore */ __hooks?: { onApplicationStart?: () => Promise; onApplicationShutdown?: () => Promise; onApplicationPrepareShutdown?: () => Promise; }; } //# sourceMappingURL=index.d.ts.map