api-emulator 0.5.2 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -22
- package/dist/api.js +8 -8
- package/dist/api.js.map +1 -1
- package/dist/index.js +484 -97
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/external-plugin-adapter.ts","../src/plugin-manifest.ts","../src/plugin-lock.ts","../src/default-plugin-catalog.ts","../src/registry.ts","../src/commands/start.ts","../src/portless.ts","../src/base-url.ts","../src/service-runtime.ts","../src/commands/init.ts","../src/commands/list.ts","../src/commands/install.ts","../src/plugin-source-registry.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { startCommand } from \"./commands/start.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { listCommand } from \"./commands/list.js\";\nimport { installCommand } from \"./commands/install.js\";\n\ndeclare const PKG_VERSION: string;\nconst pkg = { version: PKG_VERSION };\n\nconst defaultPort = process.env.API_EMULATOR_PORT ?? process.env.EMULATE_PORT ?? process.env.PORT ?? \"4000\";\n\nconst program = new Command();\n\nprogram.name(\"api\").description(\"Local API emulators you can run, share, and extend with plugins\").version(pkg.version);\n\nprogram\n .command(\"start\", { isDefault: true })\n .description(\"Start the emulator server\")\n .option(\"-p, --port <port>\", \"Base port\", defaultPort)\n .option(\"-s, --service <services>\", \"Comma-separated services to enable\")\n .option(\"--seed <file>\", \"Path to seed config file\")\n .option(\"--base-url <url>\", \"Override advertised base URL (supports {service} template)\")\n .option(\"--portless\", \"Serve over HTTPS via portless (auto-registers aliases)\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .action(async (opts) => {\n const port = parseInt(opts.port, 10);\n if (Number.isNaN(port) || port < 1 || port > 65535) {\n console.error(`Invalid port: ${opts.port}`);\n process.exit(1);\n }\n await startCommand({\n port,\n service: opts.service,\n seed: opts.seed,\n baseUrl: opts.baseUrl,\n portless: opts.portless,\n plugin: opts.plugin,\n });\n });\n\nprogram\n .command(\"init\")\n .description(\"Generate a starter config file\")\n .option(\"-s, --service <service>\", \"Service to generate config for\", \"all\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .action(async (opts) => {\n await initCommand({ service: opts.service, plugin: opts.plugin });\n });\n\nprogram\n .command(\"list\")\n .alias(\"list-services\")\n .description(\"List available services\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .action(async (opts) => {\n await listCommand({ plugin: opts.plugin });\n });\n\nprogram\n .command(\"install <plugin>\")\n .description(\"Install a provider plugin by name\")\n .option(\"--package-manager <name>\", \"Package manager to use\")\n .option(\"--no-package-manager\", \"Only record the plugin in api-emulator.lock\")\n .action(async (plugin, opts) => {\n try {\n await installCommand(plugin, {\n packageManager: opts.packageManager === false ? false : opts.packageManager,\n });\n } catch (err) {\n console.error(err instanceof Error ? err.message : err);\n process.exit(1);\n }\n });\n\nprogram.parse();\n","import type { ServicePlugin, Store, AuthFallback, WebhookDispatcher } from \"@api-emulator/core\";\nimport { isAbsolute, resolve } from \"path\";\nimport { readPluginManifest, validatePluginManifest, type PluginManifest } from \"./plugin-manifest.js\";\nimport type { PluginModule } from \"./plugin-types.js\";\n\nexport interface ExternalPluginModule {\n plugin?: ServicePlugin;\n default?: ServicePlugin;\n seedFromConfig?(store: Store, baseUrl: string, config: unknown, webhooks?: WebhookDispatcher): void;\n label?: string;\n endpoints?: string;\n manifest?: PluginManifest;\n contract?: unknown;\n defaultFallback?(svcSeedConfig?: Record<string, unknown>): AuthFallback;\n initConfig?: Record<string, unknown>;\n}\n\nexport async function loadExternalPluginModule(specifier: string): Promise<PluginModule> {\n const modulePath = specifier.startsWith(\".\") || isAbsolute(specifier) ? resolve(specifier) : specifier;\n\n const mod = (await import(modulePath)) as ExternalPluginModule;\n const plugin = mod.plugin ?? mod.default;\n if (!plugin || typeof plugin.register !== \"function\" || typeof plugin.name !== \"string\") {\n throw new Error(`Plugin \"${specifier}\" must export a ServicePlugin (as \"plugin\" or default export)`);\n }\n\n const name = plugin.name;\n const manifest = validatePluginManifest(readPluginManifest(mod), name);\n return {\n name,\n label: manifest.label,\n endpoints: manifest.endpoints,\n manifest,\n async load() {\n return {\n plugin,\n seedFromConfig: mod.seedFromConfig,\n };\n },\n defaultFallback: mod.defaultFallback ?? (() => ({ login: \"admin\", id: 1, scopes: [] })),\n initConfig: manifest.initConfig,\n };\n}\n\nexport async function loadExternalPlugin(specifier: string): Promise<{ name: string; entry: PluginModule }> {\n const pluginModule = await loadExternalPluginModule(specifier);\n return { name: pluginModule.name, entry: pluginModule };\n}\n","import type { AuthFallback } from \"@api-emulator/core\";\n\nexport interface PluginManifest {\n name?: string;\n label?: string;\n endpoints?: string;\n initConfig?: Record<string, unknown>;\n contract?: unknown;\n compatibility?: {\n apiEmulator?: string;\n };\n}\n\ninterface LegacyManifestFields {\n label?: string;\n endpoints?: string;\n initConfig?: Record<string, unknown>;\n contract?: unknown;\n defaultFallback?(svcSeedConfig?: Record<string, unknown>): AuthFallback;\n}\n\nexport function readPluginManifest(mod: { manifest?: PluginManifest } & LegacyManifestFields): PluginManifest {\n return {\n label: mod.label,\n endpoints: mod.endpoints,\n initConfig: mod.initConfig,\n contract: mod.contract,\n ...mod.manifest,\n };\n}\n\nexport function validatePluginManifest(\n manifest: PluginManifest,\n pluginName: string,\n): Required<Pick<PluginManifest, \"label\" | \"endpoints\" | \"initConfig\">> &\n Omit<PluginManifest, \"label\" | \"endpoints\" | \"initConfig\"> {\n if (manifest.name && manifest.name !== pluginName) {\n throw new Error(`Plugin manifest name \"${manifest.name}\" does not match plugin name \"${pluginName}\"`);\n }\n\n return {\n ...manifest,\n label: manifest.label ?? `${pluginName} (external plugin)`,\n endpoints: manifest.endpoints ?? \"\",\n initConfig: manifest.initConfig ?? {},\n };\n}\n","import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\n\nexport const PLUGIN_LOCK_FILE = \"api-emulator.lock\";\n\nexport interface PluginLockEntry {\n name: string;\n source: \"registry\" | \"specifier\";\n specifier: string;\n sourceId?: string;\n packageName?: string;\n version?: string;\n}\n\nexport interface PluginLock {\n version: 1;\n plugins: Record<string, PluginLockEntry>;\n}\n\nexport function createEmptyPluginLock(): PluginLock {\n return { version: 1, plugins: {} };\n}\n\nexport function readPluginLock(cwd = process.cwd()): PluginLock {\n const path = resolve(cwd, PLUGIN_LOCK_FILE);\n if (!existsSync(path)) return createEmptyPluginLock();\n\n const parsed = JSON.parse(readFileSync(path, \"utf-8\")) as PluginLock;\n if (parsed.version !== 1 || typeof parsed.plugins !== \"object\" || parsed.plugins === null) {\n throw new Error(`Invalid ${PLUGIN_LOCK_FILE}`);\n }\n return parsed;\n}\n\nexport function writePluginLock(lock: PluginLock, cwd = process.cwd()): void {\n const sortedPlugins = Object.fromEntries(Object.entries(lock.plugins).sort(([a], [b]) => a.localeCompare(b)));\n const content = `${JSON.stringify({ version: 1, plugins: sortedPlugins }, null, 2)}\\n`;\n writeFileSync(resolve(cwd, PLUGIN_LOCK_FILE), content, \"utf-8\");\n}\n\nexport function getLockedPluginSpecifiers(cwd = process.cwd()): string[] {\n return Object.values(readPluginLock(cwd).plugins).map((entry) => entry.specifier);\n}\n","import type { PluginModule } from \"./plugin-types.js\";\n\nexport type ServiceName = string;\nexport const DEFAULT_PLUGIN_NAMES: readonly ServiceName[] = [];\nexport const SERVICE_NAMES: readonly ServiceName[] = DEFAULT_PLUGIN_NAMES;\nexport const DEFAULT_PLUGIN_REGISTRY: Record<ServiceName, PluginModule> = {};\n","import { loadExternalPluginModule } from \"./external-plugin-adapter.js\";\nimport { getLockedPluginSpecifiers } from \"./plugin-lock.js\";\nimport {\n DEFAULT_PLUGIN_REGISTRY,\n DEFAULT_PLUGIN_NAMES,\n SERVICE_NAMES,\n type ServiceName,\n} from \"./default-plugin-catalog.js\";\nimport type { PluginModule } from \"./plugin-types.js\";\nexport { DEFAULT_PLUGIN_REGISTRY, DEFAULT_PLUGIN_NAMES, SERVICE_NAMES, type ServiceName };\nexport type { LoadedPlugin, LoadedService, PluginModule, ServiceEntry } from \"./plugin-types.js\";\n\nexport interface ResolvePluginModulesOptions {\n includeInstalled?: boolean;\n}\n\nexport const DEFAULT_TOKENS = {\n tokens: {\n test_token_admin: {\n login: \"admin\",\n scopes: [\"repo\", \"user\", \"admin:org\", \"admin:repo_hook\"],\n },\n test_token_user1: {\n login: \"octocat\",\n scopes: [\"repo\", \"user\"],\n },\n },\n};\n\nexport async function resolvePluginModules(\n pluginSpecifiers: string[] = [],\n options: ResolvePluginModulesOptions = {},\n): Promise<Record<string, PluginModule>> {\n const installedSpecifiers = options.includeInstalled ? getLockedPluginSpecifiers() : [];\n const allSpecifiers = [...installedSpecifiers, ...pluginSpecifiers];\n const results = await Promise.all(allSpecifiers.map(loadExternalPluginModule));\n\n const externalEntries: Record<string, PluginModule> = {};\n for (const pluginModule of results) {\n if (pluginModule.name in DEFAULT_PLUGIN_REGISTRY) {\n throw new Error(`Plugin \"${pluginModule.name}\" conflicts with default plugin \"${pluginModule.name}\"`);\n }\n if (pluginModule.name in externalEntries) {\n throw new Error(`Duplicate plugin name \"${pluginModule.name}\"`);\n }\n externalEntries[pluginModule.name] = pluginModule;\n }\n\n return { ...DEFAULT_PLUGIN_REGISTRY, ...externalEntries };\n}\n\nexport const resolveServiceEntries = resolvePluginModules;\n\nexport function getDefaultPluginNames(): string[] {\n return [...DEFAULT_PLUGIN_NAMES];\n}\n","import { resolvePluginModules, getDefaultPluginNames, type LoadedPlugin, type PluginModule } from \"../registry.js\";\nimport { readFileSync, existsSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { parse as parseYaml } from \"yaml\";\nimport pc from \"picocolors\";\nimport { ensurePortless, registerAliases, removeAliases, portlessBaseUrl, type PortlessAlias } from \"../portless.js\";\nimport { resolveBaseUrl } from \"../base-url.js\";\nimport { createAuthTokens, createServiceRuntime, type RunningService, type SeedConfig } from \"../service-runtime.js\";\n\ndeclare const PKG_VERSION: string;\nconst pkg = { version: PKG_VERSION };\n\nexport interface StartOptions {\n port: number;\n service?: string;\n seed?: string;\n baseUrl?: string;\n portless?: boolean;\n plugin?: string;\n}\n\ninterface LoadResult {\n config: SeedConfig;\n source: string;\n}\n\nfunction loadSeedConfig(seedPath?: string): LoadResult | null {\n if (seedPath) {\n const fullPath = resolve(seedPath);\n if (!existsSync(fullPath)) {\n console.error(`Seed file not found: ${fullPath}`);\n process.exit(1);\n }\n const content = readFileSync(fullPath, \"utf-8\");\n try {\n const config = fullPath.endsWith(\".json\") ? JSON.parse(content) : parseYaml(content);\n return { config, source: seedPath };\n } catch (err) {\n console.error(`Failed to parse ${seedPath}: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n }\n\n const autoFiles = [\n \"api-emulator.config.yaml\",\n \"api-emulator.config.yml\",\n \"api-emulator.config.json\",\n \"emulate.config.yaml\",\n \"emulate.config.yml\",\n \"emulate.config.json\",\n \"service-emulator.config.yaml\",\n \"service-emulator.config.yml\",\n \"service-emulator.config.json\",\n ];\n\n for (const file of autoFiles) {\n const fullPath = resolve(file);\n if (existsSync(fullPath)) {\n const content = readFileSync(fullPath, \"utf-8\");\n try {\n const config = fullPath.endsWith(\".json\") ? JSON.parse(content) : parseYaml(content);\n return { config, source: file };\n } catch (err) {\n console.error(`Failed to parse ${file}: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n }\n }\n\n return null;\n}\n\nfunction inferServicesFromConfig(config: SeedConfig, availableServices: string[]): string[] | null {\n const found = availableServices.filter((k) => k in config);\n return found.length > 0 ? [...found] : null;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const { port: basePort } = options;\n\n if (options.portless && options.baseUrl) {\n console.error(\"--portless and --base-url are mutually exclusive.\");\n process.exit(1);\n }\n\n const loaded = loadSeedConfig(options.seed);\n const seedConfig = loaded?.config ?? null;\n const configSource = loaded?.source ?? null;\n\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n let allPluginModules: Record<string, PluginModule>;\n try {\n allPluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n } catch (err) {\n console.error(`Failed to load plugins: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n\n const defaultPlugins = getDefaultPluginNames();\n const externalServices = Object.keys(allPluginModules).filter((name) => !defaultPlugins.includes(name));\n\n let services: string[];\n if (options.service) {\n services = options.service.split(\",\").map((s) => s.trim());\n } else if (seedConfig) {\n services = inferServicesFromConfig(seedConfig, Object.keys(allPluginModules)) ?? [\n ...defaultPlugins,\n ...externalServices,\n ];\n } else {\n services = [...defaultPlugins, ...externalServices];\n }\n\n for (const svc of services) {\n if (!allPluginModules[svc]) {\n console.error(`Unknown service: ${svc}`);\n process.exit(1);\n }\n }\n\n const tokens = createAuthTokens(seedConfig);\n\n if (options.portless) {\n await ensurePortless();\n }\n\n interface PreparedService {\n svc: string;\n pluginModule: PluginModule;\n loadedPlugin: LoadedPlugin;\n svcSeedConfig: Record<string, unknown> | undefined;\n port: number;\n baseUrl: string;\n }\n\n const portlessAliases: PortlessAlias[] = [];\n const prepared: PreparedService[] = [];\n\n for (let i = 0; i < services.length; i++) {\n const svc = services[i];\n const pluginModule = allPluginModules[svc];\n const loadedPlugin = await pluginModule.load();\n\n const svcSeedConfig = seedConfig?.[svc] as Record<string, unknown> | undefined;\n const port = (svcSeedConfig?.port as number | undefined) ?? basePort + i;\n\n if (options.portless) {\n portlessAliases.push({ name: `${svc}.api-emulator`, port });\n }\n\n const seedBaseUrl =\n typeof svcSeedConfig?.baseUrl === \"string\" && svcSeedConfig.baseUrl.length > 0\n ? svcSeedConfig.baseUrl\n : undefined;\n const effectiveBaseUrl = options.portless ? portlessBaseUrl(svc) : options.baseUrl;\n const baseUrl = resolveBaseUrl({ service: svc, port, baseUrl: effectiveBaseUrl, seedBaseUrl });\n\n prepared.push({ svc, pluginModule, loadedPlugin, svcSeedConfig, port, baseUrl });\n }\n\n if (portlessAliases.length > 0) {\n registerAliases(portlessAliases);\n }\n\n const serviceUrls: Array<{ name: string; url: string }> = [];\n const runningServices: RunningService[] = [];\n\n for (const { svc, pluginModule, loadedPlugin, svcSeedConfig, port, baseUrl } of prepared) {\n serviceUrls.push({ name: svc, url: baseUrl });\n\n const running = createServiceRuntime({\n service: svc,\n pluginModule,\n loadedPlugin,\n port,\n baseUrl,\n tokens,\n seedConfig: svcSeedConfig,\n });\n runningServices.push(running);\n }\n\n printBanner(serviceUrls, tokens, configSource);\n\n const shutdown = () => {\n console.log(`\\n${pc.dim(\"Shutting down...\")}`);\n if (portlessAliases.length > 0) {\n removeAliases(portlessAliases);\n }\n for (const running of runningServices) {\n void running.close();\n }\n process.exit(0);\n };\n process.once(\"SIGINT\", shutdown);\n process.once(\"SIGTERM\", shutdown);\n}\n\nfunction printBanner(\n services: Array<{ name: string; url: string }>,\n tokens: Record<string, { login: string; id: number; scopes?: string[] }>,\n configSource: string | null,\n): void {\n const lines: string[] = [];\n lines.push(\"\");\n lines.push(` ${pc.bold(\"api-emulator\")} ${pc.dim(`v${pkg.version}`)}`);\n lines.push(\"\");\n\n const maxNameLen = Math.max(...services.map((s) => s.name.length));\n for (const { name, url } of services) {\n lines.push(` ${pc.cyan(name.padEnd(maxNameLen + 2))}${pc.bold(url)}`);\n }\n lines.push(\"\");\n\n const tokenEntries = Object.entries(tokens);\n if (tokenEntries.length > 0) {\n lines.push(` ${pc.dim(\"Tokens\")}`);\n for (const [token, user] of tokenEntries) {\n lines.push(` ${pc.dim(token)} ${pc.dim(\"->\")} ${user.login}`);\n }\n lines.push(\"\");\n }\n\n if (configSource) {\n lines.push(` ${pc.dim(\"Config:\")} ${configSource}`);\n } else {\n lines.push(\n ` ${pc.dim(\"Config:\")} defaults ${pc.dim(\"(run\")} npx -p api-emulator api init ${pc.dim(\"to customize)\")}`,\n );\n }\n lines.push(\"\");\n\n console.log(lines.join(\"\\n\"));\n}\n","import { execSync, spawnSync } from \"child_process\";\nimport { createInterface } from \"readline\";\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nfunction hasPortless(): boolean {\n const result = spawnSync(\"portless\", [\"--version\"], { stdio: \"ignore\" });\n return result.status === 0;\n}\n\nfunction promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n rl.question(question, (answer) => {\n rl.close();\n const normalized = answer.trim().toLowerCase();\n resolve(normalized === \"\" || normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\nfunction isProxyRunning(): boolean {\n const result = spawnSync(\"portless\", [\"list\"], { stdio: \"ignore\" });\n return result.status === 0;\n}\n\nexport async function ensurePortless(): Promise<void> {\n if (!hasPortless()) {\n if (!isInteractive()) {\n console.error(\"portless is required but not installed. Run: npm i -g portless\");\n process.exit(1);\n }\n\n const yes = await promptYesNo(\"portless is not installed. Install it now? (npm i -g portless) [Y/n] \");\n if (!yes) {\n console.error(\"Cannot continue without portless.\");\n process.exit(1);\n }\n\n try {\n execSync(\"npm i -g portless\", { stdio: \"inherit\" });\n } catch {\n console.error(\"Failed to install portless.\");\n process.exit(1);\n }\n\n if (!hasPortless()) {\n console.error(\"portless was installed but could not be found on PATH.\");\n process.exit(1);\n }\n }\n\n if (!isProxyRunning()) {\n console.error(\"portless proxy is not running. Start it with: portless proxy start\");\n process.exit(1);\n }\n}\n\nexport interface PortlessAlias {\n name: string;\n port: number;\n}\n\nexport function registerAliases(aliases: PortlessAlias[]): void {\n const registered: PortlessAlias[] = [];\n for (const { name, port } of aliases) {\n const result = spawnSync(\"portless\", [\"alias\", name, String(port), \"--force\"], {\n stdio: \"inherit\",\n });\n if (result.status !== 0) {\n if (registered.length > 0) {\n removeAliases(registered);\n }\n throw new Error(`Failed to register portless alias: ${name} -> ${port}`);\n }\n registered.push({ name, port });\n }\n}\n\nexport function removeAliases(aliases: PortlessAlias[]): void {\n for (const { name } of aliases) {\n const result = spawnSync(\"portless\", [\"alias\", \"--remove\", name], { stdio: \"ignore\" });\n if (result.status !== 0) {\n console.error(`Warning: failed to remove portless alias: ${name}`);\n }\n }\n}\n\nexport function portlessBaseUrl(serviceName: string): string {\n return `https://${serviceName}.api-emulator.localhost`;\n}\n","export interface ResolveBaseUrlOptions {\n service: string;\n port: number;\n baseUrl?: string;\n seedBaseUrl?: string;\n}\n\n/**\n * Fallback chain:\n * 1. Per-service baseUrl from seed config\n * 2. Explicit baseUrl (CLI flag or programmatic option)\n * 3. API_EMULATOR_BASE_URL env var (with {service} interpolation)\n * 4. EMULATE_BASE_URL env var for backward compatibility (with {service} interpolation)\n * 5. PORTLESS_URL env var (with {service} interpolation)\n * 6. http://localhost:<port>\n */\nexport function resolveBaseUrl(opts: ResolveBaseUrlOptions): string {\n if (opts.seedBaseUrl) {\n return opts.seedBaseUrl.replace(/\\{service\\}/g, opts.service);\n }\n if (opts.baseUrl) {\n return opts.baseUrl.replace(/\\{service\\}/g, opts.service);\n }\n const envBaseUrl = process.env.API_EMULATOR_BASE_URL ?? process.env.EMULATE_BASE_URL;\n if (envBaseUrl) {\n return envBaseUrl.replace(/\\{service\\}/g, opts.service);\n }\n const portlessUrl = process.env.PORTLESS_URL;\n if (portlessUrl) {\n return portlessUrl.replace(/\\{service\\}/g, opts.service);\n }\n return `http://localhost:${opts.port}`;\n}\n","import {\n createServer,\n createStoreFixture,\n fixtureStoreSnapshot,\n type AppKeyResolver,\n type FixtureInteraction,\n type FixtureSource,\n type Store,\n type StoreFixture,\n type StoreFixtureOptions,\n type StoreSnapshot,\n} from \"@api-emulator/core\";\nimport { serve } from \"@hono/node-server\";\nimport type { LoadedPlugin, PluginModule } from \"./registry.js\";\n\nexport interface SeedConfig {\n tokens?: Record<string, { login: string; scopes?: string[] }>;\n [service: string]: unknown;\n}\n\nexport type TokenMap = Record<string, { login: string; id: number; scopes?: string[] }>;\n\nexport interface ServiceRuntimeOptions {\n service: string;\n pluginModule: PluginModule;\n loadedPlugin: LoadedPlugin;\n port: number;\n baseUrl: string;\n tokens: TokenMap;\n seedConfig?: Record<string, unknown>;\n}\n\nexport interface RunningService {\n service: string;\n url: string;\n store: Store;\n snapshot(): StoreSnapshot;\n restore(fixture: FixtureSource): void;\n exportFixture(options?: StoreFixtureOptions): StoreFixture;\n resetToFixture(fixture: FixtureSource): void;\n reset(): void;\n close(): Promise<void>;\n}\n\nexport function createAuthTokens(seedConfig?: SeedConfig | null): TokenMap {\n const tokens: TokenMap = {};\n if (seedConfig?.tokens) {\n let tokenId = 100;\n for (const [token, user] of Object.entries(seedConfig.tokens)) {\n tokens[token] = { login: user.login, id: tokenId++, scopes: user.scopes };\n }\n } else {\n tokens[\"test_token_admin\"] = { login: \"admin\", id: 2, scopes: [\"repo\", \"user\", \"admin:org\", \"admin:repo_hook\"] };\n }\n return tokens;\n}\n\nexport function createServiceRuntime(options: ServiceRuntimeOptions): RunningService {\n const { service, pluginModule, loadedPlugin, port, baseUrl, tokens, seedConfig } = options;\n\n const resolverRef: { current?: AppKeyResolver } = {};\n const appKeyResolver: AppKeyResolver | undefined = loadedPlugin.createAppKeyResolver\n ? (appId) => resolverRef.current!(appId)\n : undefined;\n const fallbackUser = pluginModule.defaultFallback(seedConfig);\n\n const { app, store, webhooks } = createServer(loadedPlugin.plugin, {\n port,\n baseUrl,\n tokens,\n appKeyResolver,\n fallbackUser,\n });\n resolverRef.current = loadedPlugin.createAppKeyResolver?.(store);\n\n const seed = () => {\n loadedPlugin.plugin.seed?.(store, baseUrl);\n if (seedConfig && loadedPlugin.seedFromConfig) {\n loadedPlugin.seedFromConfig(store, baseUrl, seedConfig, webhooks);\n }\n };\n seed();\n\n const httpServer = serve({ fetch: app.fetch, port });\n\n return {\n service,\n url: baseUrl,\n store,\n snapshot() {\n return store.snapshot();\n },\n restore(fixture) {\n store.restore(fixtureStoreSnapshot(fixture));\n },\n exportFixture(options = {}) {\n const interactions = store.getData<FixtureInteraction[]>(\"api-emulator:interactions\");\n return createStoreFixture(service, store.snapshot(), {\n ...options,\n interactions: options.interactions ?? interactions,\n });\n },\n resetToFixture(fixture) {\n store.reset();\n store.restore(fixtureStoreSnapshot(fixture));\n },\n reset() {\n store.reset();\n seed();\n },\n close(): Promise<void> {\n return new Promise((resolve, reject) => {\n httpServer.close((err) => {\n if (err) reject(err);\n else resolve();\n });\n });\n },\n };\n}\n","import { writeFileSync, existsSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { stringify as yamlStringify } from \"yaml\";\nimport { DEFAULT_TOKENS, resolvePluginModules } from \"../registry.js\";\n\ninterface InitOptions {\n service: string;\n plugin?: string;\n}\n\nexport async function initCommand(options: InitOptions): Promise<void> {\n const filename = \"api-emulator.config.yaml\";\n const fullPath = resolve(filename);\n\n if (existsSync(fullPath)) {\n console.error(`Config file already exists: ${filename}`);\n process.exit(1);\n }\n\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n const pluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n const availableServices = Object.keys(pluginModules);\n\n let config: Record<string, unknown>;\n if (options.service === \"all\") {\n config = { ...DEFAULT_TOKENS };\n for (const name of availableServices) {\n Object.assign(config, pluginModules[name].initConfig);\n }\n } else {\n const pluginModule = pluginModules[options.service];\n if (!pluginModule) {\n console.error(`Unknown service: ${options.service}. Available: ${availableServices.join(\", \")}, all`);\n process.exit(1);\n }\n config = { ...DEFAULT_TOKENS, ...pluginModule.initConfig };\n }\n\n const content = yamlStringify(config);\n writeFileSync(fullPath, content, \"utf-8\");\n\n console.log(`Created ${filename}`);\n console.log(`\\nRun 'npx -p api-emulator api' to start the emulator.`);\n}\n","import { resolvePluginModules } from \"../registry.js\";\n\ninterface ListOptions {\n plugin?: string;\n}\n\nexport async function listCommand(options: ListOptions = {}): Promise<void> {\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n const pluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n\n console.log(\"\\nAvailable services:\\n\");\n for (const pluginModule of Object.values(pluginModules)) {\n console.log(` ${pluginModule.name.padEnd(10)}${pluginModule.label}`);\n console.log(` Endpoints: ${pluginModule.endpoints}`);\n console.log();\n }\n}\n","import { spawnSync } from \"child_process\";\nimport { existsSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { PLUGIN_LOCK_FILE, readPluginLock, writePluginLock } from \"../plugin-lock.js\";\nimport { resolvePluginSource } from \"../plugin-source-registry.js\";\n\nexport interface InstallOptions {\n packageManager?: string | false;\n}\n\nfunction detectPackageManager(): string {\n if (existsSync(resolve(\"bun.lock\")) || existsSync(resolve(\"bun.lockb\"))) return \"bun\";\n if (existsSync(resolve(\"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(resolve(\"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nfunction installPackage(packageManager: string, packageName: string): void {\n const args =\n packageManager === \"bun\"\n ? [\"add\", \"-D\", packageName]\n : packageManager === \"pnpm\"\n ? [\"add\", \"-D\", packageName]\n : packageManager === \"yarn\"\n ? [\"add\", \"-D\", packageName]\n : [\"install\", \"-D\", packageName];\n\n const result = spawnSync(packageManager, args, { stdio: \"inherit\" });\n if (result.error) {\n throw result.error;\n }\n if (result.status !== 0) {\n throw new Error(`${packageManager} ${args.join(\" \")} failed`);\n }\n}\n\nexport async function installCommand(name: string, options: InstallOptions = {}): Promise<void> {\n const source = resolvePluginSource(name);\n if (!source) {\n throw new Error(`Unknown plugin source: ${name}`);\n }\n\n const packageManager = options.packageManager === undefined ? detectPackageManager() : options.packageManager;\n if (packageManager && source.packageName) {\n installPackage(packageManager, source.packageName);\n } else if (packageManager && source.kind === \"package\" && !source.packageName) {\n throw new Error(`Plugin source \"${name}\" is a local package without a package name`);\n }\n\n const lock = readPluginLock();\n lock.plugins[source.name] = {\n name: source.name,\n source: source.kind === \"file\" ? \"specifier\" : \"registry\",\n sourceId: source.sourceId,\n packageName: source.packageName,\n specifier: packageManager && source.packageName ? source.packageName : source.specifier,\n version: \"latest\",\n };\n writePluginLock(lock);\n\n console.log(`Installed ${source.name} from ${source.sourceId}`);\n console.log(`Recorded plugin in ${PLUGIN_LOCK_FILE}`);\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\n\nexport type PluginSourceKind = \"package\" | \"file\";\n\nexport interface PluginSource {\n name: string;\n sourceId: string;\n kind: PluginSourceKind;\n specifier: string;\n description: string;\n packageName?: string;\n packageRoot?: string;\n}\n\nconst PLUGIN_SOURCES: Record<string, PluginSource> = {\n cloudflare: {\n name: \"cloudflare\",\n sourceId: \"public\",\n kind: \"package\",\n packageName: \"@api-emulator/cloudflare\",\n specifier: \"@api-emulator/cloudflare\",\n description: \"Workers-style bindings, D1, KV, R2, queues, durable objects, and service bindings\",\n },\n};\n\nconst DEFAULT_CATALOG_DIRS = [\"api-emulator-plugins\", \"api-emulator-internal\"];\nconst CATALOG_MANIFEST_FILES = [\"api-emulator.catalog.json\"];\nconst PLUGIN_ENTRY_FILES = [\"api-emulator.mjs\", \"api-emulator/index.mjs\"];\nconst PACKAGE_ENTRY_DIRS = [\"api-emulator\", \"trading-emulator\"];\n\nfunction candidateCatalogRoots(cwd = process.cwd()): string[] {\n const envRoots =\n process.env.API_EMULATOR_PLUGIN_CATALOGS?.split(\",\")\n .map((value) => value.trim())\n .filter(Boolean) ?? [];\n const roots = [...envRoots];\n let current = resolve(cwd);\n for (;;) {\n for (const dir of DEFAULT_CATALOG_DIRS) {\n roots.push(join(current, dir));\n roots.push(join(dirname(current), dir));\n }\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return [...new Set(roots.map((root) => resolve(root)))];\n}\n\nfunction sourceIdForRoot(root: string): string {\n const base = root.split(/[\\\\/]/).pop() ?? \"local\";\n if (base === \"api-emulator-plugins\") return \"public\";\n if (base === \"api-emulator-internal\") return \"internal\";\n return base;\n}\n\nfunction packageEntrySpecifier(packageRoot: string, pkg: { exports?: unknown; main?: string }): string {\n if (typeof pkg.exports === \"string\") return resolve(packageRoot, pkg.exports);\n if (\n typeof pkg.exports === \"object\" &&\n pkg.exports !== null &&\n \".\" in pkg.exports &&\n typeof pkg.exports[\".\"] === \"string\"\n ) {\n return resolve(packageRoot, pkg.exports[\".\"]);\n }\n if (\n typeof pkg.exports === \"object\" &&\n pkg.exports !== null &&\n \".\" in pkg.exports &&\n typeof pkg.exports[\".\"] === \"object\" &&\n pkg.exports[\".\"] !== null &&\n \"import\" in pkg.exports[\".\"] &&\n typeof pkg.exports[\".\"].import === \"string\"\n ) {\n return resolve(packageRoot, pkg.exports[\".\"].import);\n }\n if (typeof pkg.main === \"string\") return resolve(packageRoot, pkg.main);\n return packageRoot;\n}\n\ninterface CatalogManifest {\n plugins?: Record<\n string,\n {\n kind?: PluginSourceKind;\n specifier: string;\n description?: string;\n packageName?: string;\n }\n >;\n}\n\nfunction discoverManifest(root: string, sourceId: string): PluginSource[] {\n const sources: PluginSource[] = [];\n for (const manifestFile of CATALOG_MANIFEST_FILES) {\n const manifestPath = join(root, manifestFile);\n if (!existsSync(manifestPath)) continue;\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf-8\")) as CatalogManifest;\n for (const [name, entry] of Object.entries(manifest.plugins ?? {})) {\n sources.push({\n name,\n sourceId,\n kind: entry.kind ?? (entry.packageName ? \"package\" : \"file\"),\n packageName: entry.packageName,\n specifier: entry.specifier.startsWith(\".\") ? resolve(root, entry.specifier) : entry.specifier,\n description: entry.description ?? `${name} plugin from ${sourceId} catalog`,\n });\n }\n }\n return sources;\n}\n\nfunction discoverCatalog(root: string): PluginSource[] {\n if (!existsSync(root) || !statSync(root).isDirectory()) return [];\n\n const sourceId = sourceIdForRoot(root);\n const sources: PluginSource[] = discoverManifest(root, sourceId);\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n const name = entry.name.slice(1);\n const pluginRoot = join(root, entry.name);\n\n for (const entryFile of PLUGIN_ENTRY_FILES) {\n const specifier = join(pluginRoot, entryFile);\n if (existsSync(specifier)) {\n sources.push({\n name,\n sourceId,\n kind: \"file\",\n specifier,\n description: `${name} plugin from ${sourceId} catalog`,\n });\n break;\n }\n }\n\n for (const entryDir of PACKAGE_ENTRY_DIRS) {\n const packageRoot = join(pluginRoot, entryDir);\n const packageJsonPath = join(packageRoot, \"package.json\");\n if (!existsSync(packageJsonPath)) continue;\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n name?: string;\n description?: string;\n main?: string;\n };\n sources.push({\n name,\n sourceId,\n kind: \"package\",\n packageName: pkg.name,\n packageRoot,\n specifier: packageEntrySpecifier(packageRoot, pkg),\n description: pkg.description ?? `${name} package from ${sourceId} catalog`,\n });\n break;\n }\n }\n return sources;\n}\n\nfunction pluginSources(): Record<string, PluginSource> {\n const sources = { ...PLUGIN_SOURCES };\n for (const root of candidateCatalogRoots()) {\n for (const source of discoverCatalog(root)) {\n sources[source.name] ??= source;\n }\n }\n return sources;\n}\n\nexport function listPluginSources(): PluginSource[] {\n return Object.values(pluginSources());\n}\n\nexport function resolvePluginSource(name: string): PluginSource | null {\n return pluginSources()[name] ?? null;\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACCxB,SAAS,YAAY,eAAe;;;ACoB7B,SAAS,mBAAmB,KAA2E;AAC5G,SAAO;AAAA,IACL,OAAO,IAAI;AAAA,IACX,WAAW,IAAI;AAAA,IACf,YAAY,IAAI;AAAA,IAChB,UAAU,IAAI;AAAA,IACd,GAAG,IAAI;AAAA,EACT;AACF;AAEO,SAAS,uBACd,UACA,YAE2D;AAC3D,MAAI,SAAS,QAAQ,SAAS,SAAS,YAAY;AACjD,UAAM,IAAI,MAAM,yBAAyB,SAAS,IAAI,iCAAiC,UAAU,GAAG;AAAA,EACtG;AAEA,SAAO;AAAA,IACL,GA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AK,CAAC;AAAA,EAChB;AACF,CAAC;AAEH,QAAQ,MAAM;","names":["resolve","readFileSync","existsSync","resolve","resolve","options","resolve","resolve","existsSync","readFileSync","writeFileSync","existsSync","resolve","resolve","existsSync","writeFileSync","spawnSync","existsSync","resolve","existsSync","readFileSync","resolve","pkg","existsSync","resolve","spawnSync","pkg"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/external-plugin-adapter.ts","../src/plugin-manifest.ts","../src/plugin-lock.ts","../src/default-plugin-catalog.ts","../src/registry.ts","../src/commands/start.ts","../src/portless.ts","../src/base-url.ts","../src/service-runtime.ts","../src/cli-notifier.ts","../src/commands/init.ts","../src/generated-manifest.ts","../src/commands/list.ts","../src/commands/install.ts","../src/plugin-source-registry.ts","../src/commands/validate-plugin.ts","../src/commands/plugin.ts"],"sourcesContent":["import { Command } from \"commander\";\nimport { startCommand } from \"./commands/start.js\";\nimport { initCommand } from \"./commands/init.js\";\nimport { listCommand } from \"./commands/list.js\";\nimport { installCommand } from \"./commands/install.js\";\nimport { validatePluginCommand } from \"./commands/validate-plugin.js\";\nimport { pluginCreateCommand } from \"./commands/plugin.js\";\nimport { notifyIfRequested } from \"./cli-notifier.js\";\n\ndeclare const PKG_VERSION: string;\nconst pkg = { version: PKG_VERSION };\n\nconst defaultPort = process.env.API_EMULATOR_PORT ?? process.env.PORT ?? \"4000\";\n\nconst program = new Command();\n\nprogram\n .name(\"api\")\n .description(\"Local API emulators you can run, share, and extend with plugins\")\n .version(pkg.version)\n .option(\"--notify\", \"Show a macOS notification for useful command milestones\");\n\nfunction notifyOption(command: Command): Command {\n return command.option(\"--notify\", \"Show a macOS notification for useful command milestones\");\n}\n\nfunction wantsNotify(command: Command, opts: { notify?: boolean }): boolean {\n return Boolean(opts.notify ?? command.optsWithGlobals<{ notify?: boolean }>().notify);\n}\n\nfunction wantsStartNotify(opts: { notify?: boolean }): boolean {\n return opts.notify !== false;\n}\n\nfunction formatDuration(ms: number): string {\n if (ms < 1000) return `${ms}ms`;\n return `${(ms / 1000).toFixed(1)}s`;\n}\n\nasync function runCommandWithNotification(label: string, enabled: boolean, fn: () => Promise<void>): Promise<void> {\n const startedAt = Date.now();\n try {\n await fn();\n notifyIfRequested({\n enabled,\n title: \"api-emulator\",\n message: `${label} finished in ${formatDuration(Date.now() - startedAt)}`,\n });\n } catch (err) {\n notifyIfRequested({\n enabled,\n title: \"api-emulator\",\n message: `${label} failed after ${formatDuration(Date.now() - startedAt)}`,\n });\n console.error(err instanceof Error ? err.message : err);\n process.exit(1);\n }\n}\n\nnotifyOption(\n program\n .command(\"start\", { isDefault: true })\n .description(\"Start the emulator server\")\n .option(\"-p, --port <port>\", \"Base port\", defaultPort)\n .option(\"-s, --service <services>\", \"Comma-separated services to enable\")\n .option(\"--seed <file>\", \"Path to seed config file\")\n .option(\"--base-url <url>\", \"Override advertised base URL (supports {service} template)\")\n .option(\"--portless\", \"Serve over HTTPS via portless (auto-registers aliases)\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .option(\"--no-notify\", \"Disable the macOS notification when the emulator server is ready\"),\n).action(async (opts) => {\n const port = parseInt(opts.port, 10);\n if (Number.isNaN(port) || port < 1 || port > 65535) {\n console.error(`Invalid port: ${opts.port}`);\n process.exit(1);\n }\n await startCommand({\n port,\n service: opts.service,\n seed: opts.seed,\n baseUrl: opts.baseUrl,\n portless: opts.portless,\n plugin: opts.plugin,\n notify: wantsStartNotify(opts),\n });\n});\n\nnotifyOption(\n program\n .command(\"init\")\n .description(\"Generate a starter config file\")\n .option(\"-s, --service <service>\", \"Service to generate config for\", \"all\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .option(\"--agents <targets>\", \"Install agent skills for agents,user-agents,claude,codex,cursor,windsurf\")\n .option(\"--skills-only\", \"Only install agent skills\")\n .option(\"--yes\", \"Overwrite generated files that changed\")\n .option(\"--non-interactive\", \"Use defaults suitable for agents and CI\"),\n).action(async (opts, command) => {\n await runCommandWithNotification(\"init\", wantsNotify(command, opts), async () => {\n await initCommand({\n service: opts.service,\n plugin: opts.plugin,\n agents: opts.agents,\n skillsOnly: opts.skillsOnly,\n yes: opts.yes,\n nonInteractive: opts.nonInteractive,\n });\n });\n});\n\nfunction addPluginCreateCommand(command: Command): void {\n notifyOption(\n command\n .command(\"create <name>\")\n .description(\"Scaffold a provider clone\")\n .option(\"--dir <dir>\", \"Directory to create the clone in\")\n .option(\"--fidelity <level>\", \"Initial fidelity level\", \"stub\")\n .option(\"--yes\", \"Overwrite generated files that changed\"),\n ).action(async (name, opts, actionCommand) => {\n await runCommandWithNotification(\"plugin create\", wantsNotify(actionCommand, opts), async () => {\n await pluginCreateCommand(name, {\n dir: opts.dir,\n fidelity: opts.fidelity,\n yes: opts.yes,\n });\n });\n });\n}\n\nconst plugin = program.command(\"plugin\").description(\"Create and manage provider plugins\");\naddPluginCreateCommand(plugin);\n\nconst clone = program.command(\"clone\").description(\"Create and manage provider clones\");\naddPluginCreateCommand(clone);\n\nprogram\n .command(\"list\")\n .alias(\"list-services\")\n .description(\"List available services\")\n .option(\"--plugin <plugins>\", \"Comma-separated external plugin paths or package names\")\n .action(async (opts) => {\n await listCommand({ plugin: opts.plugin });\n });\n\nnotifyOption(\n program\n .command(\"install <plugin>\")\n .description(\"Install a provider plugin by name\")\n .option(\"--package-manager <name>\", \"Package manager to use\")\n .option(\"--no-package-manager\", \"Only record the plugin in api-emulator.lock\"),\n).action(async (plugin, opts, command) => {\n await runCommandWithNotification(\"install\", wantsNotify(command, opts), async () => {\n await installCommand(plugin, {\n packageManager: opts.packageManager === false ? false : opts.packageManager,\n });\n });\n});\n\nnotifyOption(\n program\n .command(\"validate-plugin <plugin>\")\n .description(\"Validate a provider plugin by name, path, or package\")\n .option(\"--skip-build\", \"Skip entrypoint build validation\")\n .option(\"--skip-load\", \"Skip runtime module loading validation\"),\n).action(async (plugin, opts, command) => {\n await runCommandWithNotification(\"validate-plugin\", wantsNotify(command, opts), async () => {\n await validatePluginCommand(plugin, {\n skipBuild: opts.skipBuild,\n skipLoad: opts.skipLoad,\n });\n });\n});\n\nprogram.parse();\n","import type { ServicePlugin, Store, AuthFallback, WebhookDispatcher } from \"@api-emulator/core\";\nimport { isAbsolute, resolve } from \"path\";\nimport {\n formatPluginFidelity,\n readPluginManifest,\n validatePluginManifest,\n type PluginManifest,\n} from \"./plugin-manifest.js\";\nimport type { PluginModule } from \"./plugin-types.js\";\n\nexport interface ExternalPluginModule {\n plugin?: ServicePlugin;\n default?: ServicePlugin;\n seedFromConfig?(store: Store, baseUrl: string, config: unknown, webhooks?: WebhookDispatcher): void;\n manifest?: PluginManifest;\n defaultFallback?(svcSeedConfig?: Record<string, unknown>): AuthFallback;\n}\n\nexport async function loadExternalPluginModule(specifier: string): Promise<PluginModule> {\n const modulePath = specifier.startsWith(\".\") || isAbsolute(specifier) ? resolve(specifier) : specifier;\n\n const mod = (await import(modulePath)) as ExternalPluginModule;\n const plugin = mod.plugin ?? mod.default;\n if (!plugin || typeof plugin.register !== \"function\" || typeof plugin.name !== \"string\") {\n throw new Error(`Plugin \"${specifier}\" must export a ServicePlugin (as \"plugin\" or default export)`);\n }\n\n const name = plugin.name;\n const manifest = validatePluginManifest(readPluginManifest(mod), name);\n return {\n name,\n label: manifest.label,\n endpoints: manifest.endpoints,\n fidelity: formatPluginFidelity(manifest.fidelity),\n manifest,\n async load() {\n return {\n plugin,\n seedFromConfig: mod.seedFromConfig,\n };\n },\n defaultFallback: mod.defaultFallback ?? (() => ({ login: \"admin\", id: 1, scopes: [] })),\n initConfig: manifest.initConfig,\n };\n}\n\nexport async function loadExternalPlugin(specifier: string): Promise<{ name: string; entry: PluginModule }> {\n const pluginModule = await loadExternalPluginModule(specifier);\n return { name: pluginModule.name, entry: pluginModule };\n}\n","export interface PluginManifest {\n name?: string;\n label?: string;\n endpoints?: string;\n fidelity?: string | PluginFidelity;\n initConfig?: Record<string, unknown>;\n contract?: unknown;\n}\n\nexport interface PluginFidelity {\n level: string;\n endpoints?: string[];\n seedableResources?: string[];\n smoke?: string;\n notes?: string;\n}\n\nexport function formatPluginFidelity(fidelity: PluginManifest[\"fidelity\"]): string {\n if (!fidelity) return \"unrated\";\n if (typeof fidelity === \"string\") return fidelity;\n return fidelity.level;\n}\n\nexport function readPluginManifest(mod: { manifest?: PluginManifest }): PluginManifest {\n return mod.manifest ?? {};\n}\n\nexport function validatePluginManifest(\n manifest: PluginManifest,\n pluginName: string,\n): Required<Pick<PluginManifest, \"label\" | \"endpoints\" | \"initConfig\">> &\n Omit<PluginManifest, \"label\" | \"endpoints\" | \"initConfig\"> {\n if (manifest.name && manifest.name !== pluginName) {\n throw new Error(`Plugin manifest name \"${manifest.name}\" does not match plugin name \"${pluginName}\"`);\n }\n\n return {\n ...manifest,\n label: manifest.label ?? `${pluginName} (external plugin)`,\n endpoints: manifest.endpoints ?? \"\",\n initConfig: manifest.initConfig ?? {},\n };\n}\n","import { existsSync, readFileSync, writeFileSync } from \"fs\";\nimport { resolve } from \"path\";\n\nexport const PLUGIN_LOCK_FILE = \"api-emulator.lock\";\n\nexport interface PluginLockEntry {\n name: string;\n source: \"registry\" | \"specifier\";\n specifier: string;\n sourceId?: string;\n packageName?: string;\n version?: string;\n}\n\nexport interface PluginLock {\n version: 1;\n plugins: Record<string, PluginLockEntry>;\n}\n\nexport function createEmptyPluginLock(): PluginLock {\n return { version: 1, plugins: {} };\n}\n\nexport function readPluginLock(cwd = process.cwd()): PluginLock {\n const path = resolve(cwd, PLUGIN_LOCK_FILE);\n if (!existsSync(path)) return createEmptyPluginLock();\n\n const parsed = JSON.parse(readFileSync(path, \"utf-8\")) as PluginLock;\n if (parsed.version !== 1 || typeof parsed.plugins !== \"object\" || parsed.plugins === null) {\n throw new Error(`Invalid ${PLUGIN_LOCK_FILE}`);\n }\n return parsed;\n}\n\nexport function writePluginLock(lock: PluginLock, cwd = process.cwd()): void {\n const sortedPlugins = Object.fromEntries(Object.entries(lock.plugins).sort(([a], [b]) => a.localeCompare(b)));\n const content = `${JSON.stringify({ version: 1, plugins: sortedPlugins }, null, 2)}\\n`;\n writeFileSync(resolve(cwd, PLUGIN_LOCK_FILE), content, \"utf-8\");\n}\n\nexport function getLockedPluginSpecifiers(cwd = process.cwd()): string[] {\n return Object.values(readPluginLock(cwd).plugins).map((entry) => entry.specifier);\n}\n","import type { PluginModule } from \"./plugin-types.js\";\n\nexport type ServiceName = string;\nexport const DEFAULT_PLUGIN_NAMES: readonly ServiceName[] = [];\nexport const SERVICE_NAMES: readonly ServiceName[] = DEFAULT_PLUGIN_NAMES;\nexport const DEFAULT_PLUGIN_REGISTRY: Record<ServiceName, PluginModule> = {};\n","import { loadExternalPluginModule } from \"./external-plugin-adapter.js\";\nimport { getLockedPluginSpecifiers } from \"./plugin-lock.js\";\nimport {\n DEFAULT_PLUGIN_REGISTRY,\n DEFAULT_PLUGIN_NAMES,\n SERVICE_NAMES,\n type ServiceName,\n} from \"./default-plugin-catalog.js\";\nimport type { PluginModule } from \"./plugin-types.js\";\nexport { DEFAULT_PLUGIN_REGISTRY, DEFAULT_PLUGIN_NAMES, SERVICE_NAMES, type ServiceName };\nexport type { LoadedPlugin, LoadedService, PluginModule, ServiceEntry } from \"./plugin-types.js\";\n\nexport interface ResolvePluginModulesOptions {\n includeInstalled?: boolean;\n}\n\nexport const DEFAULT_TOKENS = {\n tokens: {\n test_token_admin: {\n login: \"admin\",\n scopes: [\"repo\", \"user\", \"admin:org\", \"admin:repo_hook\"],\n },\n test_token_user1: {\n login: \"octocat\",\n scopes: [\"repo\", \"user\"],\n },\n },\n};\n\nexport async function resolvePluginModules(\n pluginSpecifiers: string[] = [],\n options: ResolvePluginModulesOptions = {},\n): Promise<Record<string, PluginModule>> {\n const installedSpecifiers = options.includeInstalled ? getLockedPluginSpecifiers() : [];\n const allSpecifiers = [...installedSpecifiers, ...pluginSpecifiers];\n const results = await Promise.all(allSpecifiers.map(loadExternalPluginModule));\n\n const externalEntries: Record<string, PluginModule> = {};\n for (const pluginModule of results) {\n if (pluginModule.name in DEFAULT_PLUGIN_REGISTRY) {\n throw new Error(`Plugin \"${pluginModule.name}\" conflicts with default plugin \"${pluginModule.name}\"`);\n }\n if (pluginModule.name in externalEntries) {\n throw new Error(`Duplicate plugin name \"${pluginModule.name}\"`);\n }\n externalEntries[pluginModule.name] = pluginModule;\n }\n\n return { ...DEFAULT_PLUGIN_REGISTRY, ...externalEntries };\n}\n\nexport const resolveServiceEntries = resolvePluginModules;\n\nexport function getDefaultPluginNames(): string[] {\n return [...DEFAULT_PLUGIN_NAMES];\n}\n","import { resolvePluginModules, getDefaultPluginNames, type LoadedPlugin, type PluginModule } from \"../registry.js\";\nimport { readFileSync, existsSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { parse as parseYaml } from \"yaml\";\nimport pc from \"picocolors\";\nimport { ensurePortless, registerAliases, removeAliases, portlessBaseUrl, type PortlessAlias } from \"../portless.js\";\nimport { resolveBaseUrl } from \"../base-url.js\";\nimport { createAuthTokens, createServiceRuntime, type RunningService, type SeedConfig } from \"../service-runtime.js\";\nimport { notifyIfRequested } from \"../cli-notifier.js\";\n\ndeclare const PKG_VERSION: string;\nconst pkg = { version: PKG_VERSION };\n\nexport interface StartOptions {\n port: number;\n service?: string;\n seed?: string;\n baseUrl?: string;\n portless?: boolean;\n plugin?: string;\n notify?: boolean;\n}\n\ninterface LoadResult {\n config: SeedConfig;\n source: string;\n}\n\nfunction loadSeedConfig(seedPath?: string): LoadResult | null {\n if (seedPath) {\n const fullPath = resolve(seedPath);\n if (!existsSync(fullPath)) {\n console.error(`Seed file not found: ${fullPath}`);\n process.exit(1);\n }\n const content = readFileSync(fullPath, \"utf-8\");\n try {\n const config = fullPath.endsWith(\".json\") ? JSON.parse(content) : parseYaml(content);\n return { config, source: seedPath };\n } catch (err) {\n console.error(`Failed to parse ${seedPath}: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n }\n\n const autoFiles = [\"api-emulator.config.yaml\", \"api-emulator.config.yml\", \"api-emulator.config.json\"];\n\n for (const file of autoFiles) {\n const fullPath = resolve(file);\n if (existsSync(fullPath)) {\n const content = readFileSync(fullPath, \"utf-8\");\n try {\n const config = fullPath.endsWith(\".json\") ? JSON.parse(content) : parseYaml(content);\n return { config, source: file };\n } catch (err) {\n console.error(`Failed to parse ${file}: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n }\n }\n\n return null;\n}\n\nfunction inferServicesFromConfig(config: SeedConfig, availableServices: string[]): string[] | null {\n const found = availableServices.filter((k) => k in config);\n return found.length > 0 ? [...found] : null;\n}\n\nexport async function startCommand(options: StartOptions): Promise<void> {\n const { port: basePort } = options;\n\n if (options.portless && options.baseUrl) {\n console.error(\"--portless and --base-url are mutually exclusive.\");\n process.exit(1);\n }\n\n const loaded = loadSeedConfig(options.seed);\n const seedConfig = loaded?.config ?? null;\n const configSource = loaded?.source ?? null;\n\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n let allPluginModules: Record<string, PluginModule>;\n try {\n allPluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n } catch (err) {\n console.error(`Failed to load plugins: ${err instanceof Error ? err.message : err}`);\n process.exit(1);\n }\n\n const defaultPlugins = getDefaultPluginNames();\n const externalServices = Object.keys(allPluginModules).filter((name) => !defaultPlugins.includes(name));\n\n let services: string[];\n if (options.service) {\n services = options.service.split(\",\").map((s) => s.trim());\n } else if (seedConfig) {\n services = inferServicesFromConfig(seedConfig, Object.keys(allPluginModules)) ?? [\n ...defaultPlugins,\n ...externalServices,\n ];\n } else {\n services = [...defaultPlugins, ...externalServices];\n }\n\n for (const svc of services) {\n if (!allPluginModules[svc]) {\n console.error(`Unknown service: ${svc}`);\n process.exit(1);\n }\n }\n\n const tokens = createAuthTokens(seedConfig);\n\n if (options.portless) {\n await ensurePortless();\n }\n\n interface PreparedService {\n svc: string;\n pluginModule: PluginModule;\n loadedPlugin: LoadedPlugin;\n svcSeedConfig: Record<string, unknown> | undefined;\n port: number;\n }\n\n const portlessAliases: PortlessAlias[] = [];\n const prepared: PreparedService[] = [];\n\n for (let i = 0; i < services.length; i++) {\n const svc = services[i];\n const pluginModule = allPluginModules[svc];\n const loadedPlugin = await pluginModule.load();\n\n const svcSeedConfig = seedConfig?.[svc] as Record<string, unknown> | undefined;\n const port = (svcSeedConfig?.port as number | undefined) ?? basePort + i;\n\n if (options.portless) {\n portlessAliases.push({ name: `${svc}.api-emulator`, port });\n }\n\n prepared.push({ svc, pluginModule, loadedPlugin, svcSeedConfig, port });\n }\n\n if (portlessAliases.length > 0) {\n registerAliases(portlessAliases);\n }\n\n const serviceUrls: Array<{ name: string; url: string }> = [];\n const runningServices: RunningService[] = [];\n\n for (const { svc, pluginModule, loadedPlugin, svcSeedConfig, port } of prepared) {\n const seedBaseUrl =\n typeof svcSeedConfig?.baseUrl === \"string\" && svcSeedConfig.baseUrl.length > 0\n ? svcSeedConfig.baseUrl\n : undefined;\n const effectiveBaseUrl = options.portless ? portlessBaseUrl(svc) : options.baseUrl;\n const baseUrl = resolveBaseUrl({ service: svc, port, baseUrl: effectiveBaseUrl, seedBaseUrl });\n\n serviceUrls.push({ name: svc, url: baseUrl });\n\n const running = createServiceRuntime({\n service: svc,\n pluginModule,\n loadedPlugin,\n port,\n baseUrl,\n tokens,\n seedConfig: svcSeedConfig,\n });\n runningServices.push(running);\n }\n\n printBanner(serviceUrls, tokens, configSource);\n notifyIfRequested({\n enabled: options.notify,\n title: \"api-emulator\",\n message: `Server started with ${serviceUrls.length} service${serviceUrls.length === 1 ? \"\" : \"s\"}`,\n });\n\n const shutdown = () => {\n console.log(`\\n${pc.dim(\"Shutting down...\")}`);\n if (portlessAliases.length > 0) {\n removeAliases(portlessAliases);\n }\n for (const running of runningServices) {\n void running.close();\n }\n process.exit(0);\n };\n process.once(\"SIGINT\", shutdown);\n process.once(\"SIGTERM\", shutdown);\n}\n\nfunction printBanner(\n services: Array<{ name: string; url: string }>,\n tokens: Record<string, { login: string; id: number; scopes?: string[] }>,\n configSource: string | null,\n): void {\n const lines: string[] = [];\n lines.push(\"\");\n lines.push(` ${pc.bold(\"api-emulator\")} ${pc.dim(`v${pkg.version}`)}`);\n lines.push(\"\");\n\n const maxNameLen = Math.max(...services.map((s) => s.name.length));\n for (const { name, url } of services) {\n lines.push(` ${pc.cyan(name.padEnd(maxNameLen + 2))}${pc.bold(url)}`);\n }\n lines.push(\"\");\n\n const tokenEntries = Object.entries(tokens);\n if (tokenEntries.length > 0) {\n lines.push(` ${pc.dim(\"Tokens\")}`);\n for (const [token, user] of tokenEntries) {\n lines.push(` ${pc.dim(token)} ${pc.dim(\"->\")} ${user.login}`);\n }\n lines.push(\"\");\n }\n\n if (configSource) {\n lines.push(` ${pc.dim(\"Config:\")} ${configSource}`);\n } else {\n lines.push(\n ` ${pc.dim(\"Config:\")} defaults ${pc.dim(\"(run\")} npx -p api-emulator api init ${pc.dim(\"to customize)\")}`,\n );\n }\n lines.push(\"\");\n\n console.log(lines.join(\"\\n\"));\n}\n","import { execSync, spawnSync } from \"child_process\";\nimport { Socket } from \"net\";\nimport { createInterface } from \"readline\";\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nfunction hasPortless(): boolean {\n const result = spawnSync(\"portless\", [\"--version\"], { stdio: \"ignore\" });\n return result.status === 0;\n}\n\nfunction promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({ input: process.stdin, output: process.stdout });\n rl.question(question, (answer) => {\n rl.close();\n const normalized = answer.trim().toLowerCase();\n resolve(normalized === \"\" || normalized === \"y\" || normalized === \"yes\");\n });\n });\n}\n\nfunction portlessUrl(name: string): string | null {\n const result = spawnSync(\"portless\", [\"get\", name], { encoding: \"utf-8\" });\n if (result.status !== 0) return null;\n\n const url = result.stdout.trim();\n return url.length > 0 ? url : null;\n}\n\nasync function canConnect(port: number): Promise<boolean> {\n return new Promise((resolve) => {\n const socket = new Socket();\n const done = (ok: boolean) => {\n socket.destroy();\n resolve(ok);\n };\n socket.setTimeout(500);\n socket.once(\"connect\", () => done(true));\n socket.once(\"error\", () => done(false));\n socket.once(\"timeout\", () => done(false));\n socket.connect(port, \"127.0.0.1\");\n });\n}\n\nasync function isProxyRunning(): Promise<boolean> {\n const url = portlessUrl(\"api-emulator-probe\");\n if (!url) return false;\n\n try {\n const parsed = new URL(url);\n const port = parsed.port ? Number(parsed.port) : parsed.protocol === \"http:\" ? 80 : 443;\n return await canConnect(port);\n } catch {\n return false;\n }\n}\n\nconst portlessInstallCommand = \"bun add --global portless\";\n\nexport async function ensurePortless(): Promise<void> {\n if (!hasPortless()) {\n if (!isInteractive()) {\n console.error(`portless is required but not installed. Run: ${portlessInstallCommand}`);\n process.exit(1);\n }\n\n const yes = await promptYesNo(`portless is not installed. Install it now? (${portlessInstallCommand}) [Y/n] `);\n if (!yes) {\n console.error(\"Cannot continue without portless.\");\n process.exit(1);\n }\n\n try {\n execSync(portlessInstallCommand, { stdio: \"inherit\" });\n } catch {\n console.error(\"Failed to install portless.\");\n process.exit(1);\n }\n\n if (!hasPortless()) {\n console.error(\"portless was installed but could not be found on PATH.\");\n process.exit(1);\n }\n }\n\n if (!(await isProxyRunning())) {\n console.error(\"portless proxy is not running. Start it with: portless proxy start\");\n process.exit(1);\n }\n}\n\nexport interface PortlessAlias {\n name: string;\n port: number;\n}\n\nexport function registerAliases(aliases: PortlessAlias[]): void {\n const registered: PortlessAlias[] = [];\n for (const { name, port } of aliases) {\n const result = spawnSync(\"portless\", [\"alias\", name, String(port), \"--force\"], {\n stdio: \"inherit\",\n });\n if (result.status !== 0) {\n if (registered.length > 0) {\n removeAliases(registered);\n }\n throw new Error(`Failed to register portless alias: ${name} -> ${port}`);\n }\n registered.push({ name, port });\n }\n}\n\nexport function removeAliases(aliases: PortlessAlias[]): void {\n for (const { name } of aliases) {\n const result = spawnSync(\"portless\", [\"alias\", \"--remove\", name], { stdio: \"ignore\" });\n if (result.status !== 0) {\n console.error(`Warning: failed to remove portless alias: ${name}`);\n }\n }\n}\n\nexport function portlessBaseUrl(serviceName: string): string {\n return portlessUrl(`${serviceName}.api-emulator`) ?? `https://${serviceName}.api-emulator.localhost`;\n}\n","export interface ResolveBaseUrlOptions {\n service: string;\n port: number;\n baseUrl?: string;\n seedBaseUrl?: string;\n}\n\n/**\n * Fallback chain:\n * 1. Per-service baseUrl from seed config\n * 2. Explicit baseUrl (CLI flag or programmatic option)\n * 3. API_EMULATOR_BASE_URL env var (with {service} interpolation)\n * 4. PORTLESS_URL env var (with {service} interpolation)\n * 5. http://localhost:<port>\n */\nexport function resolveBaseUrl(opts: ResolveBaseUrlOptions): string {\n if (opts.seedBaseUrl) {\n return opts.seedBaseUrl.replace(/\\{service\\}/g, opts.service);\n }\n if (opts.baseUrl) {\n return opts.baseUrl.replace(/\\{service\\}/g, opts.service);\n }\n const envBaseUrl = process.env.API_EMULATOR_BASE_URL;\n if (envBaseUrl) {\n return envBaseUrl.replace(/\\{service\\}/g, opts.service);\n }\n const portlessUrl = process.env.PORTLESS_URL;\n if (portlessUrl) {\n return portlessUrl.replace(/\\{service\\}/g, opts.service);\n }\n return `http://localhost:${opts.port}`;\n}\n","import {\n createServer,\n createStoreFixture,\n fixtureStoreSnapshot,\n type AppKeyResolver,\n type FixtureInteraction,\n type FixtureSource,\n type Store,\n type StoreFixture,\n type StoreFixtureOptions,\n type StoreSnapshot,\n} from \"@api-emulator/core\";\nimport { serve } from \"@hono/node-server\";\nimport type { LoadedPlugin, PluginModule } from \"./registry.js\";\n\nexport interface SeedConfig {\n tokens?: Record<string, { login: string; scopes?: string[] }>;\n [service: string]: unknown;\n}\n\nexport type TokenMap = Record<string, { login: string; id: number; scopes?: string[] }>;\n\nexport interface ServiceRuntimeOptions {\n service: string;\n pluginModule: PluginModule;\n loadedPlugin: LoadedPlugin;\n port: number;\n baseUrl: string;\n tokens: TokenMap;\n seedConfig?: Record<string, unknown>;\n}\n\nexport interface RunningService {\n service: string;\n url: string;\n store: Store;\n snapshot(): StoreSnapshot;\n restore(fixture: FixtureSource): void;\n exportFixture(options?: StoreFixtureOptions): StoreFixture;\n resetToFixture(fixture: FixtureSource): void;\n reset(): void;\n close(): Promise<void>;\n}\n\nexport function createAuthTokens(seedConfig?: SeedConfig | null): TokenMap {\n const tokens: TokenMap = {};\n if (seedConfig?.tokens) {\n let tokenId = 100;\n for (const [token, user] of Object.entries(seedConfig.tokens)) {\n tokens[token] = { login: user.login, id: tokenId++, scopes: user.scopes };\n }\n } else {\n tokens[\"test_token_admin\"] = { login: \"admin\", id: 2, scopes: [\"repo\", \"user\", \"admin:org\", \"admin:repo_hook\"] };\n }\n return tokens;\n}\n\nexport function createServiceRuntime(options: ServiceRuntimeOptions): RunningService {\n const { service, pluginModule, loadedPlugin, port, baseUrl, tokens, seedConfig } = options;\n\n const resolverRef: { current?: AppKeyResolver } = {};\n const appKeyResolver: AppKeyResolver | undefined = loadedPlugin.createAppKeyResolver\n ? (appId) => resolverRef.current!(appId)\n : undefined;\n const fallbackUser = pluginModule.defaultFallback(seedConfig);\n\n const { app, store, webhooks } = createServer(loadedPlugin.plugin, {\n port,\n baseUrl,\n tokens,\n appKeyResolver,\n fallbackUser,\n });\n resolverRef.current = loadedPlugin.createAppKeyResolver?.(store);\n\n const seed = () => {\n loadedPlugin.plugin.seed?.(store, baseUrl);\n if (seedConfig && loadedPlugin.seedFromConfig) {\n loadedPlugin.seedFromConfig(store, baseUrl, seedConfig, webhooks);\n }\n };\n seed();\n\n const httpServer = serve({ fetch: app.fetch, port });\n\n return {\n service,\n url: baseUrl,\n store,\n snapshot() {\n return store.snapshot();\n },\n restore(fixture) {\n store.restore(fixtureStoreSnapshot(fixture));\n },\n exportFixture(options = {}) {\n const interactions = store.getData<FixtureInteraction[]>(\"api-emulator:interactions\");\n return createStoreFixture(service, store.snapshot(), {\n ...options,\n interactions: options.interactions ?? interactions,\n });\n },\n resetToFixture(fixture) {\n store.reset();\n store.restore(fixtureStoreSnapshot(fixture));\n },\n reset() {\n store.reset();\n seed();\n },\n close(): Promise<void> {\n return new Promise((resolve, reject) => {\n httpServer.close((err) => {\n if (err) reject(err);\n else resolve();\n });\n });\n },\n };\n}\n","import { spawn } from \"child_process\";\nimport { platform } from \"os\";\n\nexport interface NotificationOptions {\n enabled?: boolean;\n title: string;\n message: string;\n}\n\nexport function escapeAppleScript(value: string): string {\n return value.replace(/\\\\/g, \"\\\\\\\\\").replace(/\"/g, '\\\\\"');\n}\n\nexport function appleScriptNotification({ title, message }: Omit<NotificationOptions, \"enabled\">): string {\n return `display notification \"${escapeAppleScript(message)}\" with title \"${escapeAppleScript(title)}\"`;\n}\n\nexport function notifyIfRequested(options: NotificationOptions): void {\n if (!options.enabled || platform() !== \"darwin\") return;\n\n const child = spawn(\"/usr/bin/osascript\", [\"-e\", appleScriptNotification(options)], {\n detached: true,\n stdio: \"ignore\",\n });\n child.unref();\n}\n","import { writeFileSync, existsSync } from \"fs\";\nimport { homedir } from \"os\";\nimport { resolve } from \"path\";\nimport { stringify as yamlStringify } from \"yaml\";\nimport { writeGeneratedFile } from \"../generated-manifest.js\";\nimport { DEFAULT_TOKENS, resolvePluginModules } from \"../registry.js\";\n\ninterface InitOptions {\n service: string;\n plugin?: string;\n agents?: string;\n skillsOnly?: boolean;\n yes?: boolean;\n nonInteractive?: boolean;\n}\n\nconst AGENT_SKILL_DIRS: Record<string, string> = {\n agents: \".agents/skills\",\n claude: \".claude/skills\",\n codex: \".codex/skills\",\n cursor: \".cursor/skills\",\n factory: \".agents/skills\",\n global: `${homedir()}/.agents/skills`,\n \"user-agents\": `${homedir()}/.agents/skills`,\n windsurf: \".windsurf/skills\",\n};\n\nfunction parseAgentTargets(input?: string, nonInteractive?: boolean): string[] {\n const values =\n input\n ?.split(\",\")\n .map((value) => value.trim())\n .filter(Boolean) ?? [];\n if (values.length > 0) return values;\n return nonInteractive ? [\"agents\"] : [\"agents\"];\n}\n\nfunction pluginAuthoringSkill(): string {\n return `---\nname: api-emulator-plugin-authoring\ndescription: Create, validate, and install api-emulator provider plugins.\n---\n\n# API Emulator Plugin Authoring\n\nUse this skill when adding or validating a provider plugin for api-emulator.\n\n## Workflow\n\n1. Create a provider clone scaffold with \\`npx -p api-emulator api clone create <provider>\\`.\n2. Add provider-shaped routes, deterministic seed state, and manifest fidelity metadata.\n3. Run \\`npx -p api-emulator api validate-plugin <provider>\\`.\n4. Run the relevant smoke or test command before calling the plugin done.\n\n## Safety\n\n- Never call production APIs from smoke tests.\n- Use dummy credentials and temporary CLI homes.\n- Prefer documented base URL overrides before patching SDKs or CLIs.\n`;\n}\n\nfunction runtimeSkill(): string {\n return `---\nname: api-emulator-runtime\ndescription: Run api-emulator locally with configured provider plugins.\n---\n\n# API Emulator Runtime\n\nUse this skill when running local API replacements for development or tests.\n\n## Commands\n\n- \\`npx -p api-emulator api list\\`\n- \\`npx -p api-emulator api init\\`\n- \\`npx -p api-emulator api install <plugin>\\`\n- \\`npx -p api-emulator api clone create <provider>\\`\n- \\`npx -p api-emulator api --service <service>\\`\n\nKeep seed data deterministic and reset emulator state between tests.\n`;\n}\n\nfunction installAgentSkills(options: Pick<InitOptions, \"agents\" | \"yes\" | \"nonInteractive\">): void {\n for (const target of parseAgentTargets(options.agents, options.nonInteractive)) {\n const dir = AGENT_SKILL_DIRS[target];\n if (!dir) {\n throw new Error(`Unknown agent target: ${target}. Available: ${Object.keys(AGENT_SKILL_DIRS).join(\", \")}`);\n }\n writeGeneratedFile(`${dir}/api-emulator-plugin-authoring/SKILL.md`, pluginAuthoringSkill(), {\n source: \"api init\",\n yes: options.yes,\n });\n writeGeneratedFile(`${dir}/api-emulator-runtime/SKILL.md`, runtimeSkill(), {\n source: \"api init\",\n yes: options.yes,\n });\n }\n}\n\nexport async function initCommand(options: InitOptions): Promise<void> {\n if (options.agents || options.skillsOnly) {\n installAgentSkills(options);\n console.log(\"Installed api-emulator agent skills\");\n }\n\n if (options.skillsOnly) return;\n\n const filename = \"api-emulator.config.yaml\";\n const fullPath = resolve(filename);\n\n if (existsSync(fullPath)) {\n console.error(`Config file already exists: ${filename}`);\n process.exit(1);\n }\n\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n const pluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n const availableServices = Object.keys(pluginModules);\n\n let config: Record<string, unknown>;\n if (options.service === \"all\") {\n config = { ...DEFAULT_TOKENS };\n for (const name of availableServices) {\n Object.assign(config, pluginModules[name].initConfig);\n }\n } else {\n const pluginModule = pluginModules[options.service];\n if (!pluginModule) {\n console.error(`Unknown service: ${options.service}. Available: ${availableServices.join(\", \")}, all`);\n process.exit(1);\n }\n config = { ...DEFAULT_TOKENS, ...pluginModule.initConfig };\n }\n\n const content = yamlStringify(config);\n writeFileSync(fullPath, content, \"utf-8\");\n\n console.log(`Created ${filename}`);\n console.log(`\\nRun 'npx -p api-emulator api' to start the emulator.`);\n}\n","import { createHash } from \"crypto\";\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"fs\";\nimport { dirname, resolve } from \"path\";\n\nexport const GENERATED_MANIFEST_FILE = \".api-emulator/manifest.json\";\n\nexport interface GeneratedManifest {\n version: 1;\n files: Record<\n string,\n {\n checksum: string;\n source: string;\n }\n >;\n}\n\nexport interface WriteGeneratedFileOptions {\n source: string;\n yes?: boolean;\n cwd?: string;\n}\n\nexport function checksum(content: string): string {\n return createHash(\"sha256\").update(content).digest(\"hex\");\n}\n\nexport function readGeneratedManifest(cwd = process.cwd()): GeneratedManifest {\n const path = resolve(cwd, GENERATED_MANIFEST_FILE);\n if (!existsSync(path)) return { version: 1, files: {} };\n\n const parsed = JSON.parse(readFileSync(path, \"utf-8\")) as GeneratedManifest;\n if (parsed.version !== 1 || typeof parsed.files !== \"object\" || parsed.files === null) {\n throw new Error(`Invalid ${GENERATED_MANIFEST_FILE}`);\n }\n return parsed;\n}\n\nexport function writeGeneratedManifest(manifest: GeneratedManifest, cwd = process.cwd()): void {\n const path = resolve(cwd, GENERATED_MANIFEST_FILE);\n mkdirSync(dirname(path), { recursive: true });\n const files = Object.fromEntries(Object.entries(manifest.files).sort(([a], [b]) => a.localeCompare(b)));\n writeFileSync(path, `${JSON.stringify({ version: 1, files }, null, 2)}\\n`, \"utf-8\");\n}\n\nexport function writeGeneratedFile(relativePath: string, content: string, options: WriteGeneratedFileOptions): void {\n const cwd = options.cwd ?? process.cwd();\n const path = resolve(cwd, relativePath);\n const manifest = readGeneratedManifest(cwd);\n const existing = manifest.files[relativePath];\n\n if (existsSync(path)) {\n const current = readFileSync(path, \"utf-8\");\n if (current === content) {\n manifest.files[relativePath] = { checksum: checksum(content), source: options.source };\n writeGeneratedManifest(manifest, cwd);\n return;\n }\n if (!options.yes && (!existing || existing.checksum !== checksum(current))) {\n throw new Error(`Refusing to overwrite user-edited file: ${relativePath}. Re-run with --yes to overwrite.`);\n }\n }\n\n mkdirSync(dirname(path), { recursive: true });\n writeFileSync(path, content, \"utf-8\");\n manifest.files[relativePath] = { checksum: checksum(content), source: options.source };\n writeGeneratedManifest(manifest, cwd);\n}\n","import { resolvePluginModules } from \"../registry.js\";\n\ninterface ListOptions {\n plugin?: string;\n}\n\nexport async function listCommand(options: ListOptions = {}): Promise<void> {\n const pluginSpecifiers =\n options.plugin\n ?.split(\",\")\n .map((s) => s.trim())\n .filter(Boolean) ?? [];\n const pluginModules = await resolvePluginModules(pluginSpecifiers, { includeInstalled: true });\n\n console.log(\"\\nAvailable services:\\n\");\n for (const pluginModule of Object.values(pluginModules)) {\n console.log(` ${pluginModule.name.padEnd(10)}${pluginModule.label}`);\n console.log(` Endpoints: ${pluginModule.endpoints}`);\n console.log(` Fidelity: ${pluginModule.fidelity}`);\n console.log();\n }\n}\n","import { spawnSync } from \"child_process\";\nimport { existsSync } from \"fs\";\nimport { resolve } from \"path\";\nimport { PLUGIN_LOCK_FILE, readPluginLock, writePluginLock } from \"../plugin-lock.js\";\nimport { resolvePluginSource } from \"../plugin-source-registry.js\";\n\nexport interface InstallOptions {\n packageManager?: string | false;\n}\n\nfunction detectPackageManager(): string {\n if (existsSync(resolve(\"bun.lock\")) || existsSync(resolve(\"bun.lockb\"))) return \"bun\";\n if (existsSync(resolve(\"pnpm-lock.yaml\"))) return \"pnpm\";\n if (existsSync(resolve(\"yarn.lock\"))) return \"yarn\";\n return \"npm\";\n}\n\nfunction installPackage(packageManager: string, packageName: string): void {\n const args =\n packageManager === \"bun\"\n ? [\"add\", \"-D\", packageName]\n : packageManager === \"pnpm\"\n ? [\"add\", \"-D\", packageName]\n : packageManager === \"yarn\"\n ? [\"add\", \"-D\", packageName]\n : [\"install\", \"-D\", packageName];\n\n const result = spawnSync(packageManager, args, { stdio: \"inherit\" });\n if (result.error) {\n throw result.error;\n }\n if (result.status !== 0) {\n throw new Error(`${packageManager} ${args.join(\" \")} failed`);\n }\n}\n\nexport async function installCommand(name: string, options: InstallOptions = {}): Promise<void> {\n const source = resolvePluginSource(name);\n if (!source) {\n throw new Error(`Unknown plugin source: ${name}`);\n }\n\n const packageManager = options.packageManager === undefined ? detectPackageManager() : options.packageManager;\n if (packageManager && source.packageName) {\n installPackage(packageManager, source.packageName);\n } else if (packageManager && source.kind === \"package\" && !source.packageName) {\n throw new Error(`Plugin source \"${name}\" is a local package without a package name`);\n }\n\n const lock = readPluginLock();\n lock.plugins[source.name] = {\n name: source.name,\n source: source.kind === \"file\" ? \"specifier\" : \"registry\",\n sourceId: source.sourceId,\n packageName: source.packageName,\n specifier: packageManager && source.packageName ? source.packageName : source.specifier,\n version: \"latest\",\n };\n writePluginLock(lock);\n\n console.log(`Installed ${source.name} from ${source.sourceId}`);\n console.log(`Recorded plugin in ${PLUGIN_LOCK_FILE}`);\n}\n","import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\n\nexport type PluginSourceKind = \"package\" | \"file\";\n\nexport interface PluginSource {\n name: string;\n sourceId: string;\n kind: PluginSourceKind;\n specifier: string;\n description: string;\n packageName?: string;\n packageRoot?: string;\n}\n\nconst PLUGIN_SOURCES: Record<string, PluginSource> = {\n cloudflare: {\n name: \"cloudflare\",\n sourceId: \"public\",\n kind: \"package\",\n packageName: \"@api-emulator/cloudflare\",\n specifier: \"@api-emulator/cloudflare\",\n description: \"Workers-style bindings, D1, KV, R2, queues, durable objects, and service bindings\",\n },\n};\n\nconst DEFAULT_CATALOG_DIRS = [\"api-emulator-plugins\", \"api-emulator-internal\"];\nconst CATALOG_MANIFEST_FILES = [\"api-emulator.catalog.json\"];\nconst PLUGIN_ENTRY_FILES = [\"api-emulator.mjs\", \"api-emulator/index.mjs\"];\nconst PACKAGE_ENTRY_DIRS = [\"api-emulator\", \"trading-emulator\"];\n\nfunction candidateCatalogRoots(cwd = process.cwd()): string[] {\n const envRoots =\n process.env.API_EMULATOR_PLUGIN_CATALOGS?.split(\",\")\n .map((value) => value.trim())\n .filter(Boolean) ?? [];\n const roots = [...envRoots];\n let current = resolve(cwd);\n for (;;) {\n for (const dir of DEFAULT_CATALOG_DIRS) {\n roots.push(join(current, dir));\n roots.push(join(dirname(current), dir));\n }\n const parent = dirname(current);\n if (parent === current) break;\n current = parent;\n }\n return [...new Set(roots.map((root) => resolve(root)))];\n}\n\nfunction sourceIdForRoot(root: string): string {\n const base = root.split(/[\\\\/]/).pop() ?? \"local\";\n if (base === \"api-emulator-plugins\") return \"public\";\n if (base === \"api-emulator-internal\") return \"internal\";\n return base;\n}\n\nfunction packageEntrySpecifier(packageRoot: string, pkg: { exports?: unknown; main?: string }): string {\n if (typeof pkg.exports === \"string\") return resolve(packageRoot, pkg.exports);\n if (\n typeof pkg.exports === \"object\" &&\n pkg.exports !== null &&\n \".\" in pkg.exports &&\n typeof pkg.exports[\".\"] === \"string\"\n ) {\n return resolve(packageRoot, pkg.exports[\".\"]);\n }\n if (\n typeof pkg.exports === \"object\" &&\n pkg.exports !== null &&\n \".\" in pkg.exports &&\n typeof pkg.exports[\".\"] === \"object\" &&\n pkg.exports[\".\"] !== null &&\n \"import\" in pkg.exports[\".\"] &&\n typeof pkg.exports[\".\"].import === \"string\"\n ) {\n return resolve(packageRoot, pkg.exports[\".\"].import);\n }\n if (typeof pkg.main === \"string\") return resolve(packageRoot, pkg.main);\n return packageRoot;\n}\n\ninterface CatalogManifest {\n plugins?: Record<\n string,\n {\n kind?: PluginSourceKind;\n specifier: string;\n description?: string;\n packageName?: string;\n }\n >;\n}\n\nfunction discoverManifest(root: string, sourceId: string): PluginSource[] {\n const sources: PluginSource[] = [];\n for (const manifestFile of CATALOG_MANIFEST_FILES) {\n const manifestPath = join(root, manifestFile);\n if (!existsSync(manifestPath)) continue;\n const manifest = JSON.parse(readFileSync(manifestPath, \"utf-8\")) as CatalogManifest;\n for (const [name, entry] of Object.entries(manifest.plugins ?? {})) {\n sources.push({\n name,\n sourceId,\n kind: entry.kind ?? (entry.packageName ? \"package\" : \"file\"),\n packageName: entry.packageName,\n specifier: entry.specifier.startsWith(\".\") ? resolve(root, entry.specifier) : entry.specifier,\n description: entry.description ?? `${name} plugin from ${sourceId} catalog`,\n });\n }\n }\n return sources;\n}\n\nfunction discoverCatalog(root: string): PluginSource[] {\n if (!existsSync(root) || !statSync(root).isDirectory()) return [];\n\n const sourceId = sourceIdForRoot(root);\n const sources: PluginSource[] = discoverManifest(root, sourceId);\n for (const entry of readdirSync(root, { withFileTypes: true })) {\n if (!entry.isDirectory() || !entry.name.startsWith(\"@\")) continue;\n const name = entry.name.slice(1);\n const pluginRoot = join(root, entry.name);\n\n for (const entryDir of PACKAGE_ENTRY_DIRS) {\n const packageRoot = join(pluginRoot, entryDir);\n const packageJsonPath = join(packageRoot, \"package.json\");\n if (!existsSync(packageJsonPath)) continue;\n const pkg = JSON.parse(readFileSync(packageJsonPath, \"utf-8\")) as {\n name?: string;\n description?: string;\n main?: string;\n };\n sources.push({\n name,\n sourceId,\n kind: \"package\",\n packageName: pkg.name,\n packageRoot,\n specifier: packageEntrySpecifier(packageRoot, pkg),\n description: pkg.description ?? `${name} package from ${sourceId} catalog`,\n });\n break;\n }\n\n for (const entryFile of PLUGIN_ENTRY_FILES) {\n const specifier = join(pluginRoot, entryFile);\n if (existsSync(specifier)) {\n sources.push({\n name,\n sourceId,\n kind: \"file\",\n specifier,\n description: `${name} plugin from ${sourceId} catalog`,\n });\n break;\n }\n }\n }\n return sources;\n}\n\nfunction pluginSources(): Record<string, PluginSource> {\n const sources = { ...PLUGIN_SOURCES };\n for (const root of candidateCatalogRoots()) {\n for (const source of discoverCatalog(root)) {\n sources[source.name] ??= source;\n }\n }\n return sources;\n}\n\nexport function listPluginSources(): PluginSource[] {\n return Object.values(pluginSources());\n}\n\nexport function resolvePluginSource(name: string): PluginSource | null {\n return pluginSources()[name] ?? null;\n}\n","import { existsSync, mkdtempSync, rmSync } from \"fs\";\nimport { tmpdir } from \"os\";\nimport { basename, extname, isAbsolute, join, resolve } from \"path\";\nimport { spawnSync } from \"child_process\";\nimport { loadExternalPluginModule } from \"../external-plugin-adapter.js\";\nimport { resolvePluginSource, type PluginSource } from \"../plugin-source-registry.js\";\n\nexport interface ValidatePluginOptions {\n skipBuild?: boolean;\n skipLoad?: boolean;\n}\n\nfunction resolveSource(input: string): PluginSource {\n const source = resolvePluginSource(input);\n if (source) return source;\n\n const specifier = input.startsWith(\".\") || isAbsolute(input) ? resolve(input) : input;\n return {\n name: basename(input).replace(/\\.[^.]+$/, \"\"),\n sourceId: \"specifier\",\n kind: \"file\",\n specifier,\n description: `${input} plugin specifier`,\n };\n}\n\nfunction assertLocalFile(path: string): void {\n if ((path.startsWith(\".\") || isAbsolute(path)) && !existsSync(resolve(path))) {\n throw new Error(`Plugin entry does not exist: ${path}`);\n }\n}\n\nfunction canBuild(specifier: string): boolean {\n return [\".ts\", \".tsx\", \".js\", \".mjs\"].includes(extname(specifier));\n}\n\nfunction buildEntry(specifier: string): void {\n if (!canBuild(specifier)) return;\n const outdir = mkdtempSync(join(tmpdir(), \"api-emulator-plugin-validate-\"));\n try {\n const result = spawnSync(\"bun\", [\"build\", specifier, \"--packages\", \"external\", \"--outdir\", outdir], {\n stdio: \"pipe\",\n encoding: \"utf-8\",\n });\n if (result.error) {\n if ((result.error as NodeJS.ErrnoException).code === \"ENOENT\") {\n console.log(\" build: skipped (bun not found)\");\n return;\n }\n throw result.error;\n }\n if (result.status !== 0) {\n throw new Error((result.stderr || result.stdout || \"Plugin build failed\").trim());\n }\n console.log(\" build: ok\");\n } finally {\n rmSync(outdir, { recursive: true, force: true });\n }\n}\n\nasync function loadPlugin(specifier: string, expectedName: string): Promise<void> {\n const module = await loadExternalPluginModule(specifier);\n if (module.name !== expectedName) {\n throw new Error(`Plugin exported name \"${module.name}\" does not match requested plugin \"${expectedName}\"`);\n }\n await module.load();\n console.log(\" load: ok\");\n}\n\nexport async function validatePluginCommand(input: string, options: ValidatePluginOptions = {}): Promise<void> {\n const source = resolveSource(input);\n\n console.log(`Validating ${source.name} from ${source.sourceId}`);\n console.log(` specifier: ${source.specifier}`);\n if (source.packageName) console.log(` package: ${source.packageName}`);\n\n assertLocalFile(source.specifier);\n console.log(\" entry: ok\");\n\n if (!options.skipBuild) {\n buildEntry(source.specifier);\n }\n\n if (options.skipLoad) {\n console.log(\" load: skipped\");\n } else {\n await loadPlugin(source.specifier, source.name);\n }\n\n console.log(`Plugin ${source.name} is valid`);\n}\n","import { existsSync, readFileSync } from \"fs\";\nimport { join } from \"path\";\nimport { writeGeneratedFile } from \"../generated-manifest.js\";\n\nexport interface PluginCreateOptions {\n dir?: string;\n fidelity?: string;\n yes?: boolean;\n}\n\nfunction normalizePluginName(input: string): string {\n const name = input.trim().replace(/^@/, \"\");\n if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) {\n throw new Error(\"Plugin names must use lowercase letters, numbers, and hyphens\");\n }\n return name;\n}\n\nfunction pluginEntry(name: string, fidelity: string): string {\n return `export const manifest = {\n name: \"${name}\",\n label: \"${name} API emulator\",\n endpoints: \"GET /health\",\n fidelity: {\n level: \"${fidelity}\",\n endpoints: [\"GET /health\"],\n seedableResources: [],\n smoke: \"not-started\",\n },\n initConfig: {\n ${JSON.stringify(name)}: {},\n },\n};\n\nexport const plugin = {\n name: \"${name}\",\n register(app) {\n app.get(\"/health\", (c) => c.json({ ok: true, service: \"${name}\" }));\n },\n};\n`;\n}\n\nfunction catalogContent(name: string, specifier: string, description: string): string {\n const catalogPath = \"api-emulator.catalog.json\";\n const catalog = existsSync(catalogPath)\n ? (JSON.parse(readFileSync(catalogPath, \"utf-8\")) as { plugins?: Record<string, unknown> })\n : {};\n catalog.plugins ??= {};\n catalog.plugins[name] = {\n kind: \"file\",\n specifier,\n description,\n };\n return `${JSON.stringify(catalog, null, 2)}\\n`;\n}\n\nexport async function pluginCreateCommand(input: string, options: PluginCreateOptions = {}): Promise<void> {\n const name = normalizePluginName(input);\n const pluginDir = options.dir ?? `@${name}`;\n const entryPath = join(pluginDir, \"api-emulator.mjs\");\n const catalogSpecifier = `./${entryPath}`;\n\n writeGeneratedFile(entryPath, pluginEntry(name, options.fidelity ?? \"stub\"), {\n source: \"api clone create\",\n yes: options.yes,\n });\n writeGeneratedFile(\n \"api-emulator.catalog.json\",\n catalogContent(name, catalogSpecifier, `${name} API emulator plugin`),\n {\n source: \"api clone create\",\n yes: options.yes,\n },\n );\n\n console.log(`Created ${entryPath}`);\n console.log(`Recorded ${name} in api-emulator.catalog.json`);\n console.log(`Run 'npx -p api-emulator api validate-plugin ${name}' to check the clone.`);\n}\n"],"mappings":";AAAA,SAAS,eAAe;;;ACCxB,SAAS,YAAY,eAAe;;;ACgB7B,SAAS,qBAAqB,UAA8C;AACjF,MAAI,CAAC,SAAU,QAAO;AACtB,MAAI,OAAO,aAAa,SAAU,QAAO;AACzC,SAAO,SAAS;AAClB;AAEO,SAAS,mBAAmB,KAAoD;AACrF,SAAO,IAAI,YAAY,CAAC;AAC1B;AAEO,SAAS,uBACd,UACA,YAE2D;AAC3D,MAAI,SAAS,QAAQ,SAAS,SAAS,YAAY;AACjD,UAAM,IAA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;AACtB,QAAM,YAAY,EAAE,QAAQ,KAAK,OAAO,CAAC;AAC3C,CAAC;AAEH;AAAA,EACE,QACG,QAAQ,kBAAkB,EAC1B,YAAY,mCAAmC,EAC/C,OAAO,4BAA4B,wBAAwB,EAC3D,OAAO,wBAAwB,6CAA6C;AACjF,EAAE,OAAO,OAAOC,SAAQ,MAAM,YAAY;AACxC,QAAM,2BAA2B,WAAW,YAAY,SAAS,IAAI,GAAG,YAAY;AAClF,UAAM,eAAeA,SAAQ;AAAA,MAC3B,gBAAgB,KAAK,mBAAmB,QAAQ,QAAQ,KAAK;AAAA,IAC/D,CAAC;AAAA,EACH,CAAC;AACH,CAAC;AAED;AAAA,EACE,QACG,QAAQ,0BAA0B,EAClC,YAAY,sDAAsD,EAClE,OAAO,gBAAgB,kCAAkC,EACzD,OAAO,eAAe,wCAAwC;AACnE,EAAE,OAAO,OAAOA,SAAQ,MAAM,YAAY;AACxC,QAAM,2BAA2B,mBAAmB,YAAY,SAAS,IAAI,GAAG,YAAY;AAC1F,UAAM,sBAAsBA,SAAQ;AAAA,MAClC,WAAW,KAAK;AAAA,MAChB,UAAU,KAAK;AAAA,IACjB,CAAC;AAAA,EACH,CAAC;AACH,CAAC;AAED,QAAQ,MAAM;","names":["plugin","resolve","readFileSync","existsSync","resolve","resolve","portlessUrl","options","resolve","resolve","existsSync","readFileSync","writeFileSync","existsSync","resolve","existsSync","readFileSync","writeFileSync","resolve","resolve","existsSync","writeFileSync","spawnSync","existsSync","resolve","existsSync","readFileSync","dirname","resolve","pkg","existsSync","resolve","spawnSync","existsSync","isAbsolute","join","resolve","spawnSync","isAbsolute","resolve","existsSync","join","spawnSync","existsSync","readFileSync","join","existsSync","readFileSync","join","pkg","plugin"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "api-emulator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Local API emulators you can run, share, and extend with plugins",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@hono/node-server": "^1",
|
|
58
|
-
"@api-emulator/core": "0.
|
|
58
|
+
"@api-emulator/core": "0.7.0",
|
|
59
59
|
"commander": "^14",
|
|
60
60
|
"picocolors": "^1.1.1",
|
|
61
61
|
"yaml": "^2"
|