import type { TObject } from "@sinclair/typebox"; import type { MessageV1 } from "../json-schema/old-v1-message/schemaV1.js"; import type { ProjectSettings } from "../json-schema/settings.js"; import type { Bundle, Message, NewBundle, NewMessage, NewVariant, Variant } from "../database/schema.js"; import type { ExportFile, ImportFile } from "../project/api.js"; export type InlangPlugin | unknown = unknown> = { /** * @deprecated Use `key` instead. */ id?: string; /** * The key of the plugin. */ key: string; settingsSchema?: TObject; /** * @deprecated Use `importFiles` instead. */ loadMessages?: (args: { settings: ProjectSettings; nodeishFs: NodeFsPromisesSubsetLegacy; }) => Promise | MessageV1[]; /** * @deprecated Use `exportFiles` instead. */ saveMessages?: (args: { messages: MessageV1[]; settings: ProjectSettings; nodeishFs: NodeFsPromisesSubsetLegacy; }) => Promise | void; /** * Files that should be imported by the inlang SDK. * * - `metadata` is optional and can be used to store additional information * that is accessible in `importFiles` via `toBeImportedMetadata`. See * https://github.com/opral/inlang/issues/218 for more info. * */ toBeImportedFiles?: (args: { settings: ProjectSettings & ExternalSettings; }) => MaybePromise; }>>; importFiles?: (args: { files: ImportFile[]; settings: ProjectSettings & ExternalSettings; }) => MaybePromise<{ bundles: BundleImport[]; messages: MessageImport[]; variants: VariantImport[]; }>; exportFiles?: (args: { bundles: Bundle[]; messages: Message[]; variants: Variant[]; settings: ProjectSettings & ExternalSettings; }) => MaybePromise>; /** * @deprecated Use the `meta` field instead. */ addCustomApi?: (args: { settings: ProjectSettings & ExternalSettings; }) => Record; /** * Define app-specific APIs under a `meta` field. * * @example * meta: { * "app.inlang.ide-extension": { * documentPaths: ["*.json"] * } * } */ meta?: Record>; }; /** * Exposing only a subset to ease mapping of fs functions. * * https://github.com/opral/inlang/issues/136 */ export type NodeFsPromisesSubsetLegacy = { readFile: ((path: string) => Promise) | ((path: string, options?: { encoding: "utf-8"; }) => Promise); readdir: (path: string) => Promise; writeFile: (path: string, data: ArrayBuffer | string) => Promise; mkdir: (path: string) => Promise; }; /** * A to be imported bundle. */ export type BundleImport = NewBundle; /** * A to be imported message. * * The `id` property is omitted because it is generated by the SDK. */ export type MessageImport = Omit & { /** * If the id is not provided, the SDK will generate one. */ id?: string; }; /** * A to be imported variant. * * - The `id` and `messageId` properties are omitted because they are generated by the SDK. * - The `bundleId` and `locale` properties are added to the import variant to match the variant * with a message. */ export type VariantImport = (NewVariant & { /** * If the id is not provided, the SDK will generate one. */ id: string; /** * If the messageId is not provided, the SDK will match the variant * with a message based on the `messageBundleId` and `messageLocale` properties. */ messageId: string; /** * Required to match the variant with a message in case the `id` and `messageId` are undefined. */ messageBundleId?: undefined; /** * Required to match the variant with a message in case the `id` and `messageId` are undefined. */ messageLocale?: undefined; }) | (Omit & { /** * If the id is not provided, the SDK will generate one. */ id?: undefined; /** * If the messageId is not provided, the SDK will match the variant * with a message based on the `messageBundleId` and `messageLocale` properties. */ messageId?: undefined; /** * Required to match the variant with a message in case the `id` and `messageId` are undefined. */ messageBundleId: string; /** * Required to match the variant with a message in case the `id` and `messageId` are undefined. */ messageLocale: string; }); type MaybePromise = T | Promise; export {}; //# sourceMappingURL=schema.d.ts.map