UNPKG

storyblok

Version:
323 lines (302 loc) 8.31 kB
declare const regionCodes: readonly ["eu", "us", "cn", "ca", "ap"]; type RegionCode = typeof regionCodes[number]; /** * Interface representing the default options for a CLI command. */ interface CommandOptions { /** * Indicates whether verbose output is enabled. */ verbose: boolean; } /** * Interface representing the options for the `components pull` command. */ interface PullComponentsOptions extends CommandOptions { /** * The filename to save the file as. * Defaults to `components`. The file will be saved as `<filename>.<space>.json`. * @default `components */ filename?: string; /** * The suffix to add to the filename. * Defaults to the space ID. * @default space */ suffix?: string; /** * Indicates whether to save each component to a separate file. * @default false */ separateFiles?: boolean; } interface PushComponentsOptions extends CommandOptions { /** * The glob pattern filter to apply to components before pushing. * Matching components and all their dependencies (groups, tags, other components) * will be collected and pushed together. * @default `.*` */ filter?: string; /** * Indicates whether to save each component to a separate file. * @default false */ separateFiles?: boolean; /** * The source space id. */ from?: string; /** * Suffix to add to the component name. */ suffix?: string; } interface MigrationsGenerateOptions extends CommandOptions { suffix?: string; } interface MigrationsRunOptions extends CommandOptions { dryRun?: boolean; filter?: string; /** * The source space id to read migration files from. */ from?: string; query?: string; startsWith?: string; publish?: 'all' | 'published' | 'published-with-changes'; } /** * Options for the datasources delete command. */ interface DeleteDatasourceOptions { /** * The datasource id to delete by, if provided. If not set, the command will delete by name. */ id?: string; /** * If true, skip confirmation prompt (for CI or automation) */ force?: boolean; } /** * Interface representing the options for the `datasources pull` command. */ interface PullDatasourcesOptions extends CommandOptions { /** * The filename to save the file as. * Defaults to `DEFAULT_DATASOURCES_FILENAME`. The file will be saved as `<filename>.<space>.json`. * @default DEFAULT_DATASOURCES_FILENAME */ filename?: string; /** * The suffix to add to the filename. * Defaults to the space ID. * @default space */ suffix?: string; /** * Indicates whether to save each datasource to a separate file. * @default false */ separateFiles?: boolean; } interface PushDatasourcesOptions extends CommandOptions { /** * The glob pattern filter to apply to datasources before pushing. * @default `.*` */ filter?: string; /** * Indicates whether to save each component to a separate file. * @default false */ separateFiles?: boolean; /** * The source space id. */ from?: string; /** * Suffix to add to the component name. */ suffix?: string; } type MigrationsRollbackOptions = CommandOptions; interface GenerateTypesOptions { separateFiles?: boolean; strict?: boolean; typePrefix?: string; typeSuffix?: string; filename?: string; path?: string; suffix?: string; customFieldsParser?: string; compilerOptions?: string; } /** * Interface representing the options for the `pull-languages` command. */ interface PullLanguagesOptions extends CommandOptions { /** * The path to save the languages file to. * Defaults to `.storyblok/languages`. * @default `.storyblok/languages` */ path?: string; /** * The space ID. * @required true */ space: string; /** * The filename to save the file as. * Defaults to `DEFAULT_LANGUAGES_FILENAME`. The file will be saved as `<filename>.<space>.json`. * @default DEFAULT_LANGUAGES_FILENAME */ filename?: string; /** * The suffix to add to the filename. * Defaults to the space ID. * @default space */ suffix?: string; } interface PullAssetsOptions extends CommandOptions { dryRun?: boolean; query?: string; assetToken?: string; } interface PushAssetsOptions extends CommandOptions { from?: string; data?: string; shortFilename?: string; folder?: string; cleanup?: boolean; updateStories?: boolean; assetToken?: string; dryRun?: boolean; } interface PullStoriesOptions extends CommandOptions { dryRun?: boolean; query?: string; startsWith?: string; } interface PushStoriesOptions extends CommandOptions { from?: string; dryRun?: boolean; publish?: string; cleanup?: boolean; } interface PruneLogsOptions extends CommandOptions { keep: number; } interface PruneReportsOptions extends CommandOptions { keep: number; } /** * Makes all properties in T optional recursively */ type DeepPartial<T> = T extends object ? { [P in keyof T]?: DeepPartial<T[P]>; } : T; interface ApiConfig { maxRetries: number; maxConcurrency: number; } interface LogConsoleConfig { enabled: boolean; level: string; } interface LogFileConfig { enabled: boolean; level: string; maxFiles: number; } interface LogConfig { console: LogConsoleConfig; file: LogFileConfig; } interface ReportConfig { enabled: boolean; maxFiles: number; } interface UiConfig { enabled: boolean; } interface GlobalConfig { region?: RegionCode; space?: number | string; path?: string; api: ApiConfig; log: LogConfig; report: ReportConfig; ui: UiConfig; verbose: boolean; } type StripCommandOption<T> = T extends CommandOptions ? Omit<T, keyof CommandOptions> : T; type CommandConfig<T> = Partial<StripCommandOption<T>>; interface SharedConfigOptions { space?: number | string; path?: string; } interface CommandOptionsMap { components: { pull: PullComponentsOptions; push: PushComponentsOptions; }; datasources: { pull: PullDatasourcesOptions; push: PushDatasourcesOptions; delete: DeleteDatasourceOptions; }; migrations: { generate: MigrationsGenerateOptions; run: MigrationsRunOptions; rollback: MigrationsRollbackOptions; }; types: { generate: GenerateTypesOptions; }; languages: { pull: PullLanguagesOptions; }; assets: { pull: PullAssetsOptions; push: PushAssetsOptions; }; stories: { pull: PullStoriesOptions; push: PushStoriesOptions; }; logs: { list: Record<string, never>; prune: PruneLogsOptions; }; reports: { list: Record<string, never>; prune: PruneReportsOptions; }; } type SubcommandConfig<T> = SharedConfigOptions & CommandConfig<T>; type ModuleConfig<Subs extends Record<string, any>> = SharedConfigOptions & { [K in keyof Subs]?: SubcommandConfig<Subs[K]>; }; type ModulesConfig = { [K in keyof CommandOptionsMap]?: ModuleConfig<CommandOptionsMap[K]>; }; type ComponentsModuleConfig = ModulesConfig['components']; type DatasourcesModuleConfig = ModulesConfig['datasources']; type MigrationsModuleConfig = ModulesConfig['migrations']; type TypesModuleConfig = ModulesConfig['types']; type LanguagesModuleConfig = ModulesConfig['languages']; type AssetsModuleConfig = ModulesConfig['assets']; type StoriesModuleConfig = ModulesConfig['stories']; type LogsModuleConfig = ModulesConfig['logs']; type ReportsModuleConfig = ModulesConfig['reports']; interface StoryblokConfig extends DeepPartial<GlobalConfig> { modules?: ModulesConfig; } declare function defineConfig<T extends StoryblokConfig>(config: T): T; export { defineConfig }; export type { AssetsModuleConfig, ComponentsModuleConfig, DatasourcesModuleConfig, LanguagesModuleConfig, LogsModuleConfig, MigrationsModuleConfig, ModulesConfig, ReportsModuleConfig, StoriesModuleConfig, StoryblokConfig, TypesModuleConfig };