medusa-plugin-tolgee
Version:
Medusa V2 Plugin to easily add translations to your models with Tolgee
47 lines (46 loc) • 1.53 kB
TypeScript
import { TolgeeAdminOptions, SupportedModels, ModelDTO } from "../../common";
import { AxiosCacheInstance } from "axios-cache-interceptor";
import { Logger } from "@medusajs/medusa";
export type TolgeeModuleConfig = {
projectId: string;
apiKey: string;
baseURL: string;
ttl?: number;
rateLimit?: {
maxRequests?: number;
perMilliseconds?: number;
};
batchingDelayMilliseconds?: number;
keys?: {
[key in SupportedModels]?: string[];
};
tags?: {
[key in SupportedModels]?: string[];
};
};
type TolgeeModuleConfigInternal = Omit<TolgeeModuleConfig, "keys"> & {
keys: Required<TolgeeModuleConfig["keys"]>;
};
declare class TolgeeModuleService {
protected readonly client_: AxiosCacheInstance;
protected readonly logger: Logger;
protected readonly options_: TolgeeModuleConfigInternal;
constructor({ tolgeeClient, logger }: {
tolgeeClient: AxiosCacheInstance;
logger: Logger;
}, options: TolgeeModuleConfig);
getOptions(): Promise<TolgeeAdminOptions>;
getModelKeyNames(id: string): Promise<any>;
list(filter: {
id: string | string[];
context?: {
country_code: string;
};
}): Promise<{}[]>;
private getNormalizedData;
private createNewKeyWithTranslation;
createModelTranslations(models: ModelDTO[], type: SupportedModels): Promise<string[]>;
private getNamespaceKeys;
deleteTranslation(id: string): Promise<void>;
}
export default TolgeeModuleService;