UNPKG

@launchql/core

Version:
151 lines (150 loc) 5.09 kB
import { LaunchQLOptions, LaunchQLWorkspaceConfig } from '@launchql/types'; import { PgConfig } from 'pg-env'; import { ExtensionInfo } from '../../files'; import { ModuleMap } from '../../modules/modules'; import { PackageAnalysisResult, RenameOptions } from '../../files/types'; export declare enum PackageContext { Outside = "outside", Workspace = "workspace-root", Module = "module", ModuleInsideWorkspace = "module-in-workspace" } export interface InitModuleOptions { name: string; description: string; author: string; extensions: string[]; branch?: string; templateRepo?: string; templatePath?: string; cacheTtlMs?: number; noTty?: boolean; toolName?: string; answers?: Record<string, any>; } export declare class LaunchQLPackage { cwd: string; workspacePath?: string; modulePath?: string; config?: LaunchQLWorkspaceConfig; allowedDirs: string[]; allowedParentDirs: string[]; private _moduleMap?; private _moduleInfo?; constructor(cwd?: string); resetCwd(cwd: string): void; private resolveSqitchPath; private loadConfigSync; private loadAllowedDirs; private loadAllowedParentDirs; isInsideAllowedDirs(cwd: string): boolean; isParentOfAllowedDirs(cwd: string): boolean; private createModuleDirectory; ensureModule(): void; ensureWorkspace(): void; getContext(): PackageContext; isInWorkspace(): boolean; isInModule(): boolean; getWorkspacePath(): string | undefined; getModulePath(): string | undefined; clearCache(): void; getModules(): Promise<LaunchQLPackage[]>; /** * List all modules by parsing .control files in the workspace directory. * Handles naming collisions by preferring the shortest path. */ listModules(): ModuleMap; getModuleMap(): ModuleMap; getAvailableModules(): string[]; getModuleProject(name: string): LaunchQLPackage; getModuleInfo(): ExtensionInfo; getModuleName(): string; getRequiredModules(): string[]; setModuleDependencies(modules: string[]): void; private validateModuleDependencies; private initModuleSqitch; initModule(options: InitModuleOptions): Promise<void>; getLatestChange(moduleName: string): string; getLatestChangeAndVersion(moduleName: string): { change: string; version: string; }; getModuleExtensions(): { resolved: string[]; external: string[]; }; getModuleDependencies(moduleName: string): { native: string[]; modules: string[]; }; getModuleDependencyChanges(moduleName: string): { native: string[]; modules: { name: string; latest: string; version: string; }[]; }; getModulePlan(): string; getModuleControlFile(): string; getModuleMakefile(): string; getModuleSQL(): string; generateModulePlan(options: { uri?: string; includePackages?: boolean; includeTags?: boolean; }): string; writeModulePlan(options: { uri?: string; includePackages?: boolean; includeTags?: boolean; }): void; /** * Add a tag to the current module's plan file */ addTag(tagName: string, changeName?: string, comment?: string): void; /** * Add a change to the current module's plan file and create SQL files */ addChange(changeName: string, dependencies?: string[], comment?: string): void; /** * Add change to the current module (internal helper) */ private addChangeToModule; /** * Create deploy/revert/verify SQL files for a change */ private createSqlFiles; publishToDist(distFolder?: string): void; /** * Installs an extension npm package into the local skitch extensions directory, * and automatically adds it to the current module’s package.json dependencies. */ installModules(...pkgstrs: string[]): Promise<void>; /** * Get the set of modules that have been deployed to the database */ private getDeployedModules; resolveWorkspaceExtensionDependencies(opts?: { filterDeployed?: boolean; pgConfig?: PgConfig; }): Promise<{ resolved: string[]; external: string[]; }>; private parsePackageTarget; deploy(opts: LaunchQLOptions, target?: string, recursive?: boolean): Promise<void>; /** * Reverts database changes for modules. Unlike verify operations, revert operations * modify database state and must ensure dependent modules are reverted before their * dependencies to prevent database constraint violations. */ revert(opts: LaunchQLOptions, target?: string, recursive?: boolean): Promise<void>; verify(opts: LaunchQLOptions, target?: string, recursive?: boolean): Promise<void>; removeFromPlan(toChange: string): Promise<void>; analyzeModule(): PackageAnalysisResult; renameModule(newName: string, opts?: RenameOptions): { changed: string[]; warnings: string[]; }; }