@revenexx/integrations-node-devkit 0.2.0 → 0.2.1
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/dist/chunk-UBYGZFB7.js +1263 -0
- package/dist/chunk-UBYGZFB7.js.map +1 -0
- package/dist/cli.cjs +2038 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +798 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +1331 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +360 -0
- package/dist/index.d.ts +360 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/testing/index.cjs +215 -0
- package/dist/testing/index.cjs.map +1 -0
- package/dist/testing/index.d.cts +194 -0
- package/dist/testing/index.d.ts +194 -0
- package/dist/testing/index.js +179 -0
- package/dist/testing/index.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../node_modules/tsup/assets/cjs_shims.js","../src/env.ts","../src/errors.ts","../src/loader.ts","../src/persistence.ts","../src/store.ts","../src/resolve.ts","../src/server.ts","../src/http.ts","../src/projections.ts"],"sourcesContent":["/**\n * `@revenexx/integrations-node-devkit` — local development kit for Revenexx\n * integration node packages. Dev/CI only; never bundled into a node package.\n *\n * Two surfaces:\n * - `@revenexx/integrations-node-devkit` → the mock-API preview server (this entry)\n * - `@revenexx/integrations-node-devkit/testing` → the unit-testing harness\n */\n\nimport { readFileSync } from 'node:fs';\n\n// Read from package.json rather than hardcoded, so the released version can\n// never drift from what `integrations-devkit --version` prints. `../` resolves\n// to the package root from both `src/` and the bundled `dist/`. The CJS build\n// needs tsup's `shims: true` for `import.meta.url`.\nconst manifestUrl = new URL('../package.json', import.meta.url);\nexport const DEVKIT_VERSION: string = JSON.parse(readFileSync(manifestUrl, 'utf8')).version;\n\nexport {\n ENV_FILE_MIN_NODE,\n type EnvFileChoice,\n loadEnvFile,\n type LoadEnvFileOptions,\n nodeOwnedEnvFlag,\n resolveEnvFile,\n} from './env.js';\nexport { DevApiError } from './errors.js';\nexport {\n ensureTsxRegistered,\n importFresh,\n type LoadedPackage,\n loadPackageFromEntry,\n resolveExports,\n} from './loader.js';\nexport {\n applySeeds,\n type CredentialSeed,\n type DevSeeds,\n interpolateEnv,\n loadSeedsFromDir,\n loadState,\n saveState,\n type SecretSeed,\n type WorkflowSeed,\n} from './persistence.js';\nexport {\n buildOAuthAuthorizeUrl,\n exchangeOAuthCode,\n findCredential,\n findCredentialType,\n findNode,\n nodeVersions,\n type ResolveNodeConfigInput,\n type ResolveNodeConfigResult,\n resolveCredentialInstance,\n resolveNodeConfig,\n testCredentialConfig,\n testCredentialInstance,\n type ValidateNodeConfigInput,\n type ValidateNodeConfigResult,\n validateNodeConfig,\n} from './resolve.js';\nexport {\n createDevServer,\n createRequestListener,\n type DevServerDeps,\n} from './server.js';\nexport {\n type CredentialRecord,\n DEV_TENANT_ID,\n DevStore,\n type DevStoreSnapshot,\n type SecretRecord,\n STORE_SCHEMA_VERSION,\n type TriggerRecord,\n type WorkflowRecord,\n} from './store.js';\n","// Shim globals in cjs bundle\n// There's a weird bug that esbuild will always inject importMetaUrl\n// if we export it as `const importMetaUrl = ... __filename ...`\n// But using a function will not cause this issue\n\nconst getImportMetaUrl = () => \n typeof document === \"undefined\" \n ? new URL(`file:${__filename}`).href \n : (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT') \n ? document.currentScript.src \n : new URL(\"main.js\", document.baseURI).href;\n\nexport const importMetaUrl = /* @__PURE__ */ getImportMetaUrl()\n","import { existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\n/**\n * `.env` loading for the CLI.\n *\n * Seeds reference secrets as `${VAR}` and {@link interpolateEnv} resolves those\n * from `process.env`, so without this the documented workflow — commit the\n * reference, keep the value in `.env` — only worked if the developer exported\n * the variables by hand.\n *\n * Loading happens before option parsing, because the CLI reads `PORT` for its\n * default port; a `.env` that sets `PORT` would otherwise be read too late.\n *\n * `process.loadEnvFile` deliberately does not overwrite variables that are\n * already set, so a shell-provided value always beats the file:\n *\n * REVENEXX_DEV_API_KEY=… npm run preview\n *\n * The flag is `--env`, *not* `--env-file`: Node reserves `--env-file` and\n * `--env-file-if-exists` and acts on them wherever they appear, including after\n * the script path. `node cli.js --env-file missing` therefore dies inside Node\n * with exit code 9 before this module is ever reached, so the devkit cannot own\n * that name. {@link nodeOwnedEnvFlag} spots the mistake and explains it.\n */\n\n/** Minimum Node version shipping `process.loadEnvFile`. */\nexport const ENV_FILE_MIN_NODE = '20.12';\n\n/** Flags Node itself consumes, positionally, and which the devkit must not reuse. */\nconst NODE_OWNED_FLAGS = ['--env-file', '--env-file-if-exists'];\n\nexport interface EnvFileChoice {\n /** Absolute path to load, or `null` when `--no-env` disabled loading. */\n path: string | null;\n /** True when the file was named with `--env` rather than defaulted to. */\n explicit: boolean;\n}\n\n/**\n * Returns the Node-owned env flag present in `argv`, if any. Node has already\n * acted on it by the time the CLI runs — this exists only so the CLI can say so\n * instead of leaving the user wondering why `--env-file` behaved oddly.\n */\nexport function nodeOwnedEnvFlag(argv: string[]): string | null {\n return NODE_OWNED_FLAGS.find(flag => argv.includes(flag) || argv.some(arg => arg.startsWith(`${flag}=`))) ?? null;\n}\n\n/** Decides which env file to load. Pure — touches neither disk nor `process.env`. */\nexport function resolveEnvFile(argv: string[], cwd: string = process.cwd()): EnvFileChoice {\n if (argv.includes('--no-env')) {\n return { path: null, explicit: false };\n }\n const flag = argv.indexOf('--env');\n if (flag === -1) {\n return { path: resolve(cwd, '.env'), explicit: false };\n }\n const value = argv[flag + 1];\n if (!value || value.startsWith('-')) {\n throw new Error('--env requires a path.');\n }\n return { path: resolve(cwd, value), explicit: true };\n}\n\nexport interface LoadEnvFileOptions {\n cwd?: string;\n warn?: (message: string) => void;\n}\n\n/**\n * Loads the env file chosen by {@link resolveEnvFile} into `process.env` and\n * returns its path, or `null` when nothing was loaded.\n *\n * A missing *default* `.env` is fine — most packages do not have one. A file\n * asked for by name and missing is an error: ignoring it would hide a typo and\n * resurface much later as a puzzling `Seed references ${X}` failure.\n */\nexport function loadEnvFile(argv: string[], options: LoadEnvFileOptions = {}): string | null {\n const { cwd = process.cwd(), warn = (message: string) => console.warn(message) } = options;\n\n const nodeFlag = nodeOwnedEnvFlag(argv);\n if (nodeFlag) {\n warn(`Note: ${nodeFlag} is a Node flag and Node has already applied it. The devkit's own flag is --env <path>.`);\n }\n\n const { path, explicit } = resolveEnvFile(argv, cwd);\n if (!path) {\n return null;\n }\n if (!existsSync(path)) {\n if (explicit) {\n throw new Error(`--env: ${path} does not exist.`);\n }\n return null;\n }\n // npm's `engines` field is advisory, so an old runtime reaches this far.\n if (typeof process.loadEnvFile !== 'function') {\n warn(`Ignoring ${path}: env-file support needs Node >= ${ENV_FILE_MIN_NODE} (running ${process.version}).`);\n return null;\n }\n\n process.loadEnvFile(path);\n return path;\n}\n","/**\n * An error that maps to an HTTP status + JSON body in the mock API, mirroring\n * Laravel's `{message}` / `{message, errors}` envelopes.\n */\nexport class DevApiError extends Error {\n constructor(\n public readonly status: number,\n message: string,\n public readonly errors?: Record<string, string[]>,\n ) {\n super(message);\n this.name = 'DevApiError';\n }\n}\n","import { pathToFileURL } from 'node:url';\nimport { buildManifest, type ICredential, type INode, type ITemplateDescription, type NodeManifest } from '@revenexx/integrations-node-sdk';\n\n/**\n * A node package loaded into the dev process: its live `NODES` / `CREDENTIALS`\n * / `TEMPLATES` instances (so author-time resolvers, `test`, and `resolve` can\n * be invoked in-process — no bundle, no sandbox) plus the derived manifest the\n * mock API serves.\n */\nexport interface LoadedPackage {\n nodes: INode[];\n credentials: ICredential[];\n templates: ITemplateDescription[];\n manifest: NodeManifest;\n}\n\ninterface PackageExports {\n NODES?: unknown;\n CREDENTIALS?: unknown;\n TEMPLATES?: unknown;\n}\n\n/**\n * Validates a package's module exports and builds a {@link LoadedPackage}.\n * Mirrors the checks in the SDK's `rvnxx-nodes manifest` CLI so the dev loop\n * and the build produce identical manifests.\n */\nexport function resolveExports(mod: PackageExports): LoadedPackage {\n if (!Array.isArray(mod.NODES)) {\n throw new Error('Package entry does not export a `NODES` array. Export `NODES: INode[]`.');\n }\n if (mod.CREDENTIALS !== undefined && !Array.isArray(mod.CREDENTIALS)) {\n throw new Error('Package entry exports `CREDENTIALS` but it is not an array.');\n }\n if (mod.TEMPLATES !== undefined && !Array.isArray(mod.TEMPLATES)) {\n throw new Error('Package entry exports `TEMPLATES` but it is not an array.');\n }\n\n const nodes = mod.NODES as INode[];\n const credentials = (mod.CREDENTIALS as ICredential[] | undefined) ?? [];\n const templates = (mod.TEMPLATES as ITemplateDescription[] | undefined) ?? [];\n\n return {\n nodes,\n credentials,\n templates,\n manifest: buildManifest(nodes, credentials, templates),\n };\n}\n\nlet tsxRegistered = false;\n\n/**\n * Registers the `tsx` ESM loader once per process so `import()` can load\n * TypeScript sources directly. Idempotent.\n */\nexport async function ensureTsxRegistered(): Promise<void> {\n if (tsxRegistered) {\n return;\n }\n const { register } = await import('tsx/esm/api');\n register();\n tsxRegistered = true;\n}\n\n/** Imports a module by path, registering tsx first for TypeScript sources. */\nexport async function importFresh<T = unknown>(entryPath: string): Promise<T> {\n if (/\\.[cm]?tsx?$/.test(entryPath)) {\n await ensureTsxRegistered();\n }\n const href = `${pathToFileURL(entryPath).href}?t=${Date.now()}`;\n return (await import(href)) as T;\n}\n\n/**\n * Imports a package entry and resolves its exports. Supports TypeScript\n * sources directly (via `tsx`) so the preview runs against the developer's\n * live `src/`, not a built artifact. A cache-busting query is appended so\n * repeated calls (hot-reload) re-evaluate the module.\n */\nexport async function loadPackageFromEntry(entryPath: string): Promise<LoadedPackage> {\n return resolveExports(await importFresh<PackageExports>(entryPath));\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { importFresh } from './loader.js';\nimport { type DevStore, type DevStoreSnapshot, STORE_SCHEMA_VERSION } from './store.js';\n\n/**\n * Layered persistence for the preview session:\n * 1. committed seeds (this module's {@link applySeeds}) — the durable base,\n * with `${ENV_VAR}` references interpolated from the environment;\n * 2. `.revenexx-dev/state.json` overlay ({@link loadState}/{@link saveState}) —\n * interactive session state, versioned and disposable.\n */\n\nexport interface CredentialSeed {\n credentialTypeSlug: string;\n name: string;\n config: Record<string, unknown>;\n /** Stable id so workflows can reference the credential across restarts. */\n id?: string;\n status?: string;\n durableCreds?: Record<string, unknown> | null;\n}\n\nexport interface SecretSeed {\n key: string;\n value: string;\n}\n\nexport interface WorkflowSeed {\n name: string;\n definition: Record<string, unknown>;\n}\n\nexport interface DevSeeds {\n credentials?: CredentialSeed[];\n secrets?: SecretSeed[];\n workflows?: WorkflowSeed[];\n}\n\nconst ENV_REF = /\\$\\{([A-Z0-9_]+)\\}/g;\n\n/**\n * Recursively replaces `${ENV_VAR}` references in string values from `env`.\n * Throws a clear error when a referenced variable is unset so a developer\n * knows to add it to their `.env` — keeping secrets out of committed seeds.\n */\nexport function interpolateEnv<T>(value: T, env: NodeJS.ProcessEnv = process.env): T {\n if (typeof value === 'string') {\n return value.replace(ENV_REF, (_match, name: string) => {\n const resolved = env[name];\n if (resolved === undefined) {\n throw new Error(`Seed references \\${${name}} but that environment variable is not set (add it to your .env).`);\n }\n return resolved;\n }) as unknown as T;\n }\n if (Array.isArray(value)) {\n return value.map(item => interpolateEnv(item, env)) as unknown as T;\n }\n if (value && typeof value === 'object') {\n const out: Record<string, unknown> = {};\n for (const [key, val] of Object.entries(value)) {\n out[key] = interpolateEnv(val, env);\n }\n return out as T;\n }\n return value;\n}\n\n/** Applies committed seeds to the store (env-interpolated). */\nexport function applySeeds(store: DevStore, seeds: DevSeeds, env: NodeJS.ProcessEnv = process.env): void {\n for (const secret of seeds.secrets ?? []) {\n const { key, value } = interpolateEnv(secret, env);\n store.setSecret(key, value);\n }\n for (const credential of seeds.credentials ?? []) {\n const resolved = interpolateEnv(credential, env);\n store.createCredential({\n credentialTypeSlug: resolved.credentialTypeSlug,\n name: resolved.name,\n config: resolved.config,\n id: resolved.id,\n status: resolved.status,\n durableCreds: resolved.durableCreds ?? null,\n });\n }\n for (const workflow of seeds.workflows ?? []) {\n store.createWorkflow(interpolateEnv(workflow, env));\n }\n}\n\n/**\n * Reads a persisted session snapshot. Returns `null` (and warns) when the file\n * is absent or its `schemaVersion` no longer matches — the overlay is\n * disposable, so a mismatch is discarded rather than migrated.\n */\nexport function loadState(file: string, log: (msg: string) => void = console.warn): DevStoreSnapshot | null {\n if (!existsSync(file)) {\n return null;\n }\n let parsed: DevStoreSnapshot;\n try {\n parsed = JSON.parse(readFileSync(file, 'utf-8')) as DevStoreSnapshot;\n } catch {\n log(`Ignoring ${file}: not valid JSON.`);\n return null;\n }\n if (parsed.schemaVersion !== STORE_SCHEMA_VERSION) {\n log(`Ignoring ${file}: schemaVersion ${parsed.schemaVersion} != ${STORE_SCHEMA_VERSION} (discarded, seeds are the source of truth).`);\n return null;\n }\n return parsed;\n}\n\nexport function saveState(file: string, snapshot: DevStoreSnapshot): void {\n mkdirSync(dirname(file), { recursive: true });\n writeFileSync(file, JSON.stringify(snapshot, null, 2), 'utf-8');\n}\n\nconst SEED_ENTRY_CANDIDATES = ['index.ts', 'index.mjs', 'index.js', 'seeds.ts', 'seeds.js'];\n\n/**\n * Loads committed seeds from a directory (default `dev/seeds`). Resolves the\n * first present entry file and reads its `default` or named `seeds` export.\n * Returns empty seeds when no seed directory/entry exists.\n */\nexport async function loadSeedsFromDir(dir: string): Promise<DevSeeds> {\n for (const candidate of SEED_ENTRY_CANDIDATES) {\n const path = resolve(dir, candidate);\n if (existsSync(path)) {\n const mod = await importFresh<{ default?: DevSeeds; seeds?: DevSeeds }>(path);\n return mod.default ?? mod.seeds ?? {};\n }\n }\n return {};\n}\n","import { randomUUID } from 'node:crypto';\n\n/**\n * In-memory data store backing the mock Integrations API. Holds the tenant-\n * scoped resources a developer creates in the preview (credentials, secrets,\n * workflows, triggers). Serializable so a session can be persisted to and\n * rehydrated from `.revenexx-dev/state.json`.\n */\n\nexport const DEV_TENANT_ID = 'dev-tenant';\n\nexport interface CredentialRecord {\n id: string;\n tenantId: string;\n credentialTypeSlug: string;\n name: string;\n status: string;\n /** Full user-entered config, including secret fields (never sent to the UI verbatim). */\n config: Record<string, unknown>;\n /** System-managed long-lived secrets (e.g. an OAuth refresh token). */\n durableCreds: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface SecretRecord {\n key: string;\n value: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface WorkflowRecord {\n id: number;\n name: string;\n definition: Record<string, unknown>;\n buildStatus: string;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface TriggerRecord {\n id: string;\n workflowId: number;\n type: string;\n name: string | null;\n config: Record<string, unknown>;\n active: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface DevStoreSnapshot {\n schemaVersion: number;\n credentials: CredentialRecord[];\n secrets: SecretRecord[];\n workflows: WorkflowRecord[];\n triggers: TriggerRecord[];\n nextWorkflowId: number;\n}\n\nexport const STORE_SCHEMA_VERSION = 1;\n\nfunction now(): string {\n return new Date().toISOString();\n}\n\nexport class DevStore {\n private credentials = new Map<string, CredentialRecord>();\n private secrets = new Map<string, SecretRecord>();\n private workflows = new Map<number, WorkflowRecord>();\n private triggers = new Map<string, TriggerRecord>();\n private nextWorkflowId = 1;\n\n /**\n * @param onChange fired after any mutation so a caller (the CLI) can persist\n * the session to `.revenexx-dev/state.json`.\n */\n constructor(private onChange?: () => void) {}\n\n /** (Re)wire the post-mutation callback — e.g. attach it only after seeding. */\n setOnMutation(onChange: (() => void) | undefined): void {\n this.onChange = onChange;\n }\n\n private touch(): void {\n this.onChange?.();\n }\n\n // ------------------------------------------------------------- credentials\n\n listCredentials(typeSlug?: string): CredentialRecord[] {\n const all = [...this.credentials.values()];\n return typeSlug ? all.filter(c => c.credentialTypeSlug === typeSlug) : all;\n }\n\n getCredential(id: string): CredentialRecord | undefined {\n return this.credentials.get(id);\n }\n\n createCredential(input: {\n credentialTypeSlug: string;\n name: string;\n config: Record<string, unknown>;\n status?: string;\n /** Stable id — pass to keep a seeded credential's id fixed across restarts. */\n id?: string;\n durableCreds?: Record<string, unknown> | null;\n }): CredentialRecord {\n const ts = now();\n const record: CredentialRecord = {\n id: input.id ?? randomUUID(),\n tenantId: DEV_TENANT_ID,\n credentialTypeSlug: input.credentialTypeSlug,\n name: input.name,\n status: input.status ?? 'active',\n config: input.config,\n durableCreds: input.durableCreds ?? null,\n createdAt: ts,\n updatedAt: ts,\n };\n this.credentials.set(record.id, record);\n this.touch();\n return record;\n }\n\n updateCredential(id: string, patch: Partial<Pick<CredentialRecord, 'name' | 'config' | 'status' | 'durableCreds'>>): CredentialRecord | undefined {\n const record = this.credentials.get(id);\n if (!record) {\n return undefined;\n }\n if (patch.name !== undefined) {\n record.name = patch.name;\n }\n if (patch.config !== undefined) {\n record.config = patch.config;\n }\n if (patch.status !== undefined) {\n record.status = patch.status;\n }\n if (patch.durableCreds !== undefined) {\n record.durableCreds = patch.durableCreds;\n }\n record.updatedAt = now();\n this.touch();\n return record;\n }\n\n deleteCredential(id: string): boolean {\n const deleted = this.credentials.delete(id);\n if (deleted) {\n this.touch();\n }\n return deleted;\n }\n\n // ----------------------------------------------------------------- secrets\n\n listSecrets(): SecretRecord[] {\n return [...this.secrets.values()];\n }\n\n getSecret(key: string): SecretRecord | undefined {\n return this.secrets.get(key);\n }\n\n setSecret(key: string, value: string): SecretRecord {\n const existing = this.secrets.get(key);\n const ts = now();\n const record: SecretRecord = {\n key,\n value,\n createdAt: existing?.createdAt ?? ts,\n updatedAt: ts,\n };\n this.secrets.set(key, record);\n this.touch();\n return record;\n }\n\n deleteSecret(key: string): boolean {\n const deleted = this.secrets.delete(key);\n if (deleted) {\n this.touch();\n }\n return deleted;\n }\n\n // --------------------------------------------------------------- workflows\n\n listWorkflows(): WorkflowRecord[] {\n return [...this.workflows.values()];\n }\n\n getWorkflow(id: number): WorkflowRecord | undefined {\n return this.workflows.get(id);\n }\n\n createWorkflow(input: { name: string; definition: Record<string, unknown> }): WorkflowRecord {\n const ts = now();\n const record: WorkflowRecord = {\n id: this.nextWorkflowId++,\n name: input.name,\n definition: input.definition,\n buildStatus: 'ready',\n createdAt: ts,\n updatedAt: ts,\n };\n this.workflows.set(record.id, record);\n this.touch();\n return record;\n }\n\n updateWorkflow(id: number, patch: Partial<Pick<WorkflowRecord, 'name' | 'definition' | 'buildStatus'>>): WorkflowRecord | undefined {\n const record = this.workflows.get(id);\n if (!record) {\n return undefined;\n }\n Object.assign(record, patch, { updatedAt: now() });\n this.touch();\n return record;\n }\n\n deleteWorkflow(id: number): boolean {\n for (const trigger of this.triggers.values()) {\n if (trigger.workflowId === id) {\n this.triggers.delete(trigger.id);\n }\n }\n const deleted = this.workflows.delete(id);\n if (deleted) {\n this.touch();\n }\n return deleted;\n }\n\n // ---------------------------------------------------------------- triggers\n\n listTriggers(workflowId: number): TriggerRecord[] {\n return [...this.triggers.values()].filter(t => t.workflowId === workflowId);\n }\n\n getTrigger(id: string): TriggerRecord | undefined {\n return this.triggers.get(id);\n }\n\n createTrigger(input: {\n workflowId: number;\n type: string;\n name?: string | null;\n config?: Record<string, unknown>;\n active?: boolean;\n id?: string;\n }): TriggerRecord {\n const ts = now();\n const record: TriggerRecord = {\n id: input.id ?? randomUUID(),\n workflowId: input.workflowId,\n type: input.type,\n name: input.name ?? null,\n config: input.config ?? {},\n active: input.active ?? true,\n createdAt: ts,\n updatedAt: ts,\n };\n this.triggers.set(record.id, record);\n this.touch();\n return record;\n }\n\n replaceTrigger(id: string, input: { type: string; name?: string | null; config?: Record<string, unknown>; active?: boolean }): TriggerRecord | undefined {\n const record = this.triggers.get(id);\n if (!record) {\n return undefined;\n }\n record.type = input.type;\n record.name = input.name ?? null;\n record.config = input.config ?? {};\n record.active = input.active ?? true;\n record.updatedAt = now();\n this.touch();\n return record;\n }\n\n deleteTrigger(id: string): boolean {\n const deleted = this.triggers.delete(id);\n if (deleted) {\n this.touch();\n }\n return deleted;\n }\n\n // ------------------------------------------------------------- persistence\n\n toSnapshot(): DevStoreSnapshot {\n return {\n schemaVersion: STORE_SCHEMA_VERSION,\n credentials: [...this.credentials.values()],\n secrets: [...this.secrets.values()],\n workflows: [...this.workflows.values()],\n triggers: [...this.triggers.values()],\n nextWorkflowId: this.nextWorkflowId,\n };\n }\n\n loadSnapshot(snapshot: DevStoreSnapshot): void {\n this.credentials = new Map(snapshot.credentials.map(c => [c.id, c]));\n this.secrets = new Map(snapshot.secrets.map(s => [s.key, s]));\n this.workflows = new Map(snapshot.workflows.map(w => [w.id, w]));\n this.triggers = new Map(snapshot.triggers.map(t => [t.id, t]));\n this.nextWorkflowId = snapshot.nextWorkflowId ?? Math.max(0, ...snapshot.workflows.map(w => w.id)) + 1;\n }\n\n /**\n * Overlays a snapshot on top of the current contents (upsert by id/key), used\n * to layer the persisted `.revenexx-dev/state.json` session over the freshly\n * applied committed seeds. State entries win over seed entries with the same\n * id/key; seed-only entries are preserved.\n */\n mergeSnapshot(snapshot: DevStoreSnapshot): void {\n for (const c of snapshot.credentials) {\n this.credentials.set(c.id, c);\n }\n for (const s of snapshot.secrets) {\n this.secrets.set(s.key, s);\n }\n for (const w of snapshot.workflows) {\n this.workflows.set(w.id, w);\n }\n for (const t of snapshot.triggers) {\n this.triggers.set(t.id, t);\n }\n this.nextWorkflowId = Math.max(this.nextWorkflowId, snapshot.nextWorkflowId ?? 0, ...snapshot.workflows.map(w => w.id + 1));\n }\n}\n","import {\n type IConfigField,\n type IConfigOption,\n type ICredential,\n type ICredentialContext,\n type ICredentialDescription,\n type ICredentialResolveResult,\n type ICredentialTestResult,\n type INode,\n type INodeAuthorContext,\n type IOutputPort,\n isOAuthAuthorizeCredential,\n} from '@revenexx/integrations-node-sdk';\nimport { DevApiError } from './errors.js';\nimport type { LoadedPackage } from './loader.js';\nimport type { DevStore } from './store.js';\n\n/**\n * The fidelity centre of the mock API: instead of the production sandbox +\n * content-addressed bundle, the developer's live node/credential instances are\n * invoked directly in-process. Author-time resolvers, credential `test`, and\n * `resolve` run exactly as the developer wrote them. The PO-145 grant/security\n * model is intentionally omitted — this is dev-only.\n */\n\nconst noopLogger = {\n info() {},\n warn() {},\n error() {},\n};\n\nfunction compareSemver(a: string, b: string): number {\n const pa = a.split('.').map(n => Number.parseInt(n, 10) || 0);\n const pb = b.split('.').map(n => Number.parseInt(n, 10) || 0);\n for (let i = 0; i < 3; i++) {\n const diff = (pa[i] ?? 0) - (pb[i] ?? 0);\n if (diff !== 0) {\n return diff;\n }\n }\n return 0;\n}\n\nexport function nodeVersions(loaded: LoadedPackage, slug: string): string[] {\n return loaded.nodes\n .filter(n => n.description.slug === slug)\n .map(n => n.description.version)\n .sort((a, b) => compareSemver(b, a));\n}\n\nexport function findNode(loaded: LoadedPackage, slug: string, version?: string): INode {\n const matches = loaded.nodes.filter(n => n.description.slug === slug);\n if (matches.length === 0) {\n throw new DevApiError(404, `Node '${slug}' not found.`);\n }\n if (!version || version === 'latest') {\n return [...matches].sort((a, b) => compareSemver(b.description.version, a.description.version))[0]!;\n }\n const exact = matches.find(n => n.description.version === version);\n if (!exact) {\n throw new DevApiError(404, `Node '${slug}' has no version '${version}'.`);\n }\n return exact;\n}\n\nexport function findCredential(loaded: LoadedPackage, slug: string): ICredential {\n const cred = loaded.credentials.find(c => c.description.slug === slug);\n if (!cred) {\n throw new DevApiError(404, `Credential type '${slug}' not found.`);\n }\n return cred;\n}\n\nexport function findCredentialType(loaded: LoadedPackage, slug: string): ICredentialDescription {\n return findCredential(loaded, slug).description;\n}\n\nfunction credentialContext(store: DevStore, credentialId?: string): ICredentialContext {\n return {\n signal: new AbortController().signal,\n logger: noopLogger,\n persistDurableCreds: credentialId\n ? async (durableCreds: Record<string, unknown>) => {\n store.updateCredential(credentialId, { durableCreds });\n }\n : undefined,\n };\n}\n\n/** Resolves a credential instance's access data by running its real `resolve`. */\nexport async function resolveCredentialInstance(loaded: LoadedPackage, store: DevStore, credentialId: string): Promise<ICredentialResolveResult> {\n const instance = store.getCredential(credentialId);\n if (!instance) {\n throw new DevApiError(404, `Credential instance '${credentialId}' not found.`);\n }\n const cred = findCredential(loaded, instance.credentialTypeSlug);\n const ctx = credentialContext(store, credentialId);\n return cred.resolve(ctx, instance.config, instance.durableCreds);\n}\n\nfunction authorContext(loaded: LoadedPackage, store: DevStore, config: Record<string, unknown>, locale?: string): INodeAuthorContext {\n return {\n signal: new AbortController().signal,\n logger: noopLogger,\n config,\n secrets: {\n async get(key: string): Promise<string> {\n const secret = store.getSecret(key);\n if (!secret) {\n throw new DevApiError(404, `Secret '${key}' not found.`);\n }\n return secret.value;\n },\n },\n credentials: {\n async get(id: string): Promise<Record<string, unknown>> {\n return (await resolveCredentialInstance(loaded, store, id)).credentials;\n },\n },\n locale,\n };\n}\n\nexport interface ResolveNodeConfigInput {\n slug: string;\n version?: string;\n /** `\"*\"` (all), `\"outputs\"`, or a specific config field key. */\n target: string;\n config: Record<string, unknown>;\n locale?: string;\n}\n\nexport interface ResolveNodeConfigResult {\n options?: IConfigOption[];\n fields?: IConfigField[];\n outputs?: IOutputPort[];\n}\n\n/**\n * Runs a node's author-time resolvers for the requested `target`, mirroring\n * the server's `config:resolve` semantics.\n */\nexport async function resolveNodeConfig(loaded: LoadedPackage, store: DevStore, input: ResolveNodeConfigInput): Promise<ResolveNodeConfigResult> {\n const node = findNode(loaded, input.slug, input.version);\n const ctx = authorContext(loaded, store, input.config ?? {}, input.locale);\n\n try {\n if (input.target === 'outputs') {\n if (!node.resolveOutputs) {\n return { outputs: [] };\n }\n return { outputs: await node.resolveOutputs(ctx) };\n }\n\n if (input.target === '*') {\n const result: ResolveNodeConfigResult = {};\n if (node.resolveConfigSchema) {\n result.fields = await node.resolveConfigSchema(ctx);\n }\n if (node.resolveOutputs) {\n result.outputs = await node.resolveOutputs(ctx);\n }\n return result;\n }\n\n // A specific config field key.\n const field = node.description.config?.find(f => f.key === input.target);\n if (field?.type === 'dynamic-schema') {\n if (!node.resolveConfigSchema) {\n return { fields: [] };\n }\n return { fields: await node.resolveConfigSchema(ctx) };\n }\n if (!node.loadOptions) {\n return { options: [] };\n }\n return { options: await node.loadOptions(ctx, input.target) };\n } catch (err) {\n if (err instanceof DevApiError) {\n throw err;\n }\n throw new DevApiError(502, `Node resolve failed: ${(err as Error).message}`);\n }\n}\n\nexport interface ValidateNodeConfigInput {\n slug: string;\n version?: string;\n config: Record<string, unknown>;\n locale?: string;\n}\n\nexport interface ValidateNodeConfigResult {\n valid: boolean;\n /** Config field key → human-readable messages. Empty object when valid. */\n errors: Record<string, string[]>;\n}\n\n/** True when a value counts as \"provided\" (mirrors the UI's `isResolvableValue`). */\nfunction isProvided(value: unknown): boolean {\n if (value === undefined || value === null) {\n return false;\n }\n if (typeof value === 'string') {\n return value.trim().length > 0;\n }\n if (Array.isArray(value)) {\n return value.length > 0;\n }\n return true;\n}\n\n/** An expression placeholder (`${{…}}` / leading `=`) is \"set\" but not statically checkable. */\nfunction isExpression(value: unknown): boolean {\n return typeof value === 'string' && (value.startsWith('=') || value.includes('${{'));\n}\n\n/** Applies one field's static rules to `value`, pushing messages under `field.key`. */\nfunction validateField(field: IConfigField, value: unknown, errors: Record<string, string[]>): void {\n const push = (msg: string): void => {\n (errors[field.key] ??= []).push(msg);\n };\n const provided = isProvided(value);\n if (field.required && !provided) {\n push('This field is required.');\n return;\n }\n if (!provided || isExpression(value)) {\n // Optional-and-empty, or an expression the mock cannot evaluate — skip type/rules.\n return;\n }\n\n switch (field.type) {\n case 'string':\n case 'secret-ref':\n case 'expression':\n if (typeof value !== 'string') {\n push('Expected a string.');\n }\n break;\n case 'number':\n if (typeof value !== 'number' || Number.isNaN(value)) {\n push('Expected a number.');\n }\n break;\n case 'boolean':\n if (typeof value !== 'boolean') {\n push('Expected a boolean.');\n }\n break;\n case 'select':\n // Dynamic options are only known after resolve — can't check membership here.\n if (!field.dynamic && field.options && !field.options.some(o => o.value === value)) {\n push('Not one of the allowed options.');\n }\n break;\n case 'multiselect':\n if (!Array.isArray(value)) {\n push('Expected an array.');\n } else if (!field.dynamic && field.options) {\n const allowed = new Set(field.options.map(o => o.value));\n for (const v of value) {\n if (!allowed.has(v as string | number | boolean)) {\n push(`Value '${String(v)}' is not an allowed option.`);\n }\n }\n }\n break;\n case 'array':\n if (!Array.isArray(value)) {\n push('Expected an array.');\n }\n break;\n case 'object':\n if (typeof value !== 'object' || Array.isArray(value)) {\n push('Expected an object.');\n }\n break;\n // credentials-ref / dynamic-schema carry no scalar type check here.\n }\n\n const v = field.validation;\n if (v) {\n if (typeof value === 'string') {\n if (v.pattern !== undefined && !new RegExp(v.pattern).test(value)) {\n push(`Does not match pattern ${v.pattern}.`);\n }\n if (v.minLength !== undefined && value.length < v.minLength) {\n push(`Must be at least ${v.minLength} characters.`);\n }\n if (v.maxLength !== undefined && value.length > v.maxLength) {\n push(`Must be at most ${v.maxLength} characters.`);\n }\n }\n if (typeof value === 'number') {\n if (v.min !== undefined && value < v.min) {\n push(`Must be >= ${v.min}.`);\n }\n if (v.max !== undefined && value > v.max) {\n push(`Must be <= ${v.max}.`);\n }\n }\n if (Array.isArray(value)) {\n if (v.minLength !== undefined && value.length < v.minLength) {\n push(`Must have at least ${v.minLength} items.`);\n }\n if (v.maxLength !== undefined && value.length > v.maxLength) {\n push(`Must have at most ${v.maxLength} items.`);\n }\n }\n }\n}\n\n/**\n * Validates a submitted node `config` against the field rules in its manifest\n * (`required`, `IConfigValidation`, types, static options). For `dynamic-schema`\n * fields the resolved child schema is fetched and its rules applied to the\n * flattened keys. Deep cross-field validation is intentionally out of scope\n * (the production service does that on save); this mirrors the mock's\n * \"light, schema-based\" fidelity. Unknown extra keys are ignored.\n */\nexport async function validateNodeConfig(loaded: LoadedPackage, store: DevStore, input: ValidateNodeConfigInput): Promise<ValidateNodeConfigResult> {\n const node = findNode(loaded, input.slug, input.version);\n const config = input.config ?? {};\n const errors: Record<string, string[]> = {};\n const fields = node.description.config ?? [];\n\n for (const field of fields) {\n if (field.type === 'dynamic-schema') {\n continue; // resolved child fields are validated below\n }\n validateField(field, config[field.key], errors);\n }\n\n if (fields.some(f => f.type === 'dynamic-schema') && node.resolveConfigSchema) {\n const ctx = authorContext(loaded, store, config, input.locale);\n let children: IConfigField[];\n try {\n children = await node.resolveConfigSchema(ctx);\n } catch (err) {\n if (err instanceof DevApiError) {\n throw err;\n }\n throw new DevApiError(502, `Node resolve failed: ${(err as Error).message}`);\n }\n for (const child of children) {\n validateField(child, config[child.key], errors);\n }\n }\n\n return { valid: Object.keys(errors).length === 0, errors };\n}\n\n/** Runs a credential type's `test` against inline (unsaved) config. */\nexport async function testCredentialConfig(loaded: LoadedPackage, store: DevStore, typeSlug: string, config: Record<string, unknown>): Promise<ICredentialTestResult> {\n const cred = findCredential(loaded, typeSlug);\n return cred.test(credentialContext(store), config);\n}\n\n/** Runs `test` against a saved credential instance's stored config. */\nexport async function testCredentialInstance(loaded: LoadedPackage, store: DevStore, credentialId: string): Promise<ICredentialTestResult> {\n const instance = store.getCredential(credentialId);\n if (!instance) {\n throw new DevApiError(404, `Credential instance '${credentialId}' not found.`);\n }\n const cred = findCredential(loaded, instance.credentialTypeSlug);\n return cred.test(credentialContext(store, credentialId), instance.config);\n}\n\nexport async function buildOAuthAuthorizeUrl(\n loaded: LoadedPackage,\n store: DevStore,\n credentialId: string,\n params: { redirectUri: string; state: string },\n): Promise<{ authorizeUrl: string; codeVerifier?: string }> {\n const instance = store.getCredential(credentialId);\n if (!instance) {\n throw new DevApiError(404, `Credential instance '${credentialId}' not found.`);\n }\n const cred = findCredential(loaded, instance.credentialTypeSlug);\n if (!isOAuthAuthorizeCredential(cred)) {\n throw new DevApiError(422, `Credential type '${instance.credentialTypeSlug}' is not a 3-legged OAuth type.`);\n }\n return cred.buildAuthorizeUrl(credentialContext(store, credentialId), instance.config, params);\n}\n\nexport async function exchangeOAuthCode(\n loaded: LoadedPackage,\n store: DevStore,\n credentialId: string,\n params: { code: string; redirectUri: string; codeVerifier?: string },\n): Promise<{ durableCreds: Record<string, unknown> }> {\n const instance = store.getCredential(credentialId);\n if (!instance) {\n throw new DevApiError(404, `Credential instance '${credentialId}' not found.`);\n }\n const cred = findCredential(loaded, instance.credentialTypeSlug);\n if (!isOAuthAuthorizeCredential(cred)) {\n throw new DevApiError(422, `Credential type '${instance.credentialTypeSlug}' is not a 3-legged OAuth type.`);\n }\n const out = await cred.exchangeCode(credentialContext(store, credentialId), instance.config, params);\n store.updateCredential(credentialId, { durableCreds: out.durableCreds, status: 'active' });\n return out;\n}\n","import http from 'node:http';\nimport { DevApiError } from './errors.js';\nimport { readJson, sendError, sendJson } from './http.js';\nimport type { LoadedPackage } from './loader.js';\nimport { credentialInstanceToApi, credentialTypeToApi, nodeToApi, secretToApi, templateFullToApi, templateSummaryToApi, triggerToApi, workflowToApi } from './projections.js';\nimport {\n buildOAuthAuthorizeUrl,\n exchangeOAuthCode,\n findCredential,\n findCredentialType,\n nodeVersions,\n resolveNodeConfig,\n testCredentialConfig,\n testCredentialInstance,\n validateNodeConfig,\n} from './resolve.js';\nimport { DEV_TENANT_ID, type DevStore } from './store.js';\n\nexport interface DevServerDeps {\n /** Returns the currently-loaded package; a function so hot-reload can swap it. */\n getPackage(): LoadedPackage;\n store: DevStore;\n /** JSON schemas served at `/schemas/{domain}[/{version}]`, keyed by `domain` and `domain/version`. */\n schemas?: Record<string, unknown>;\n}\n\nconst SEGMENT = (s: string | undefined): string => decodeURIComponent(s ?? '');\n\n/** Builds the `(req, res)` request listener implementing the mock `/api/v1` surface. */\nexport function createRequestListener(deps: DevServerDeps): http.RequestListener {\n return (req, res) => {\n handle(req, res, deps).catch(err => sendError(res, err));\n };\n}\n\nexport function createDevServer(deps: DevServerDeps): http.Server {\n return http.createServer(createRequestListener(deps));\n}\n\nasync function handle(req: http.IncomingMessage, res: http.ServerResponse, deps: DevServerDeps): Promise<void> {\n const method = (req.method ?? 'GET').toUpperCase();\n if (method === 'OPTIONS') {\n sendJson(res, 204, {});\n return;\n }\n\n const url = new URL(req.url ?? '/', 'http://localhost');\n let pathname = url.pathname;\n if (pathname.startsWith('/api/v1')) {\n pathname = pathname.slice('/api/v1'.length);\n }\n const seg = pathname.split('/').filter(Boolean).map(SEGMENT);\n const loaded = deps.getPackage();\n const store = deps.store;\n\n switch (seg[0]) {\n case undefined:\n case 'health':\n return void sendJson(res, 200, { status: 'ok' });\n\n case 'me':\n return void sendJson(res, 200, {\n id: 'dev-user',\n name: 'Dev User',\n email: 'dev@revenexx.test',\n tenant_id: DEV_TENANT_ID,\n });\n\n case 'schemas':\n return handleSchemas(res, deps, seg);\n\n case 'nodes':\n return handleNodes(req, res, method, loaded, store, seg);\n\n case 'credential-types':\n return handleCredentialTypes(res, loaded, seg);\n\n case 'credentials':\n return handleCredentials(req, res, method, loaded, store, seg, url);\n\n case 'secrets':\n return handleSecrets(req, res, method, store, seg);\n\n case 'templates':\n return handleTemplates(req, res, method, loaded, store, seg);\n\n case 'workflows':\n return handleWorkflows(req, res, method, store, seg);\n\n default:\n return void sendJson(res, 404, { message: `No route for /${seg.join('/')}` });\n }\n}\n\n// --------------------------------------------------------------------- schemas\n\nfunction handleSchemas(res: http.ServerResponse, deps: DevServerDeps, seg: string[]): void {\n const domain = seg[1];\n const version = seg[2];\n if (!domain) {\n throw new DevApiError(404, 'Schema domain required.');\n }\n const schemas = deps.schemas ?? {};\n const schema = (version && schemas[`${domain}/${version}`]) || schemas[domain];\n if (!schema) {\n throw new DevApiError(404, `No schema for '${domain}${version ? `/${version}` : ''}'. Vendor it into assets/schemas.`);\n }\n sendJson(res, 200, schema);\n}\n\n// ----------------------------------------------------------------------- nodes\n\nasync function handleNodes(req: http.IncomingMessage, res: http.ServerResponse, method: string, loaded: LoadedPackage, store: DevStore, seg: string[]): Promise<void> {\n // GET /nodes\n if (seg.length === 1 && method === 'GET') {\n return void sendJson(res, 200, { data: loaded.manifest.nodes.map(nodeToApi) });\n }\n const slug = seg[1];\n if (!slug) {\n throw new DevApiError(404, 'Node slug required.');\n }\n\n // GET /nodes/{slug}/versions\n if (seg[2] === 'versions' && method === 'GET') {\n const versions = nodeVersions(loaded, slug);\n if (versions.length === 0) {\n throw new DevApiError(404, `Node '${slug}' not found.`);\n }\n return void sendJson(res, 200, { data: versions });\n }\n\n const version = seg[2];\n if (!version) {\n throw new DevApiError(404, 'Node version required.');\n }\n\n // POST /nodes/{slug}/{version}/config:resolve\n if (seg[3] === 'config:resolve' && method === 'POST') {\n const body = await readJson<{ target?: string; config?: Record<string, unknown>; locale?: string }>(req);\n if (!body.target) {\n throw new DevApiError(422, 'Field `target` is required.', { target: ['The target field is required.'] });\n }\n const result = await resolveNodeConfig(loaded, store, {\n slug,\n version,\n target: body.target,\n config: body.config ?? {},\n locale: body.locale,\n });\n return void sendJson(res, 200, result);\n }\n\n // POST /nodes/{slug}/{version}/config:validate\n if (seg[3] === 'config:validate' && method === 'POST') {\n const body = await readJson<{ config?: Record<string, unknown>; locale?: string }>(req);\n const result = await validateNodeConfig(loaded, store, {\n slug,\n version,\n config: body.config ?? {},\n locale: body.locale,\n });\n // 200 even when invalid — the `{ valid, errors }` body carries the verdict.\n return void sendJson(res, 200, result);\n }\n\n // GET /nodes/{slug}/{version}\n if (seg.length === 3 && method === 'GET') {\n const node = loaded.manifest.nodes.find(n => n.slug === slug && (version === 'latest' || n.version === version));\n if (!node) {\n throw new DevApiError(404, `Node '${slug}@${version}' not found.`);\n }\n return void sendJson(res, 200, nodeToApi(node));\n }\n\n throw new DevApiError(404, `No route for nodes/${seg.slice(1).join('/')}`);\n}\n\n// ------------------------------------------------------------- credential-types\n\nfunction handleCredentialTypes(res: http.ServerResponse, loaded: LoadedPackage, seg: string[]): void {\n if (seg.length === 1) {\n return void sendJson(res, 200, {\n data: (loaded.manifest.credentials ?? []).map(credentialTypeToApi),\n });\n }\n const slug = seg[1]!;\n const type = findCredentialType(loaded, slug); // throws 404\n sendJson(res, 200, { data: credentialTypeToApi(type) });\n}\n\n// ----------------------------------------------------------------- credentials\n\nasync function handleCredentials(req: http.IncomingMessage, res: http.ServerResponse, method: string, loaded: LoadedPackage, store: DevStore, seg: string[], url: URL): Promise<void> {\n const typeOf = (slug: string) => {\n try {\n return findCredentialType(loaded, slug);\n } catch {\n return undefined;\n }\n };\n\n // Collection-level routes.\n if (seg.length === 1) {\n if (method === 'GET') {\n const filter = url.searchParams.get('type') ?? undefined;\n const data = store.listCredentials(filter).map(c => credentialInstanceToApi(c, typeOf(c.credentialTypeSlug)));\n return void sendJson(res, 200, { data });\n }\n if (method === 'POST') {\n const body = await readJson<{ credential_type_slug?: string; name?: string; config?: Record<string, unknown> }>(req);\n if (!body.credential_type_slug || !body.name) {\n throw new DevApiError(422, 'Fields `credential_type_slug` and `name` are required.');\n }\n findCredential(loaded, body.credential_type_slug); // 404 if unknown type\n const record = store.createCredential({\n credentialTypeSlug: body.credential_type_slug,\n name: body.name,\n config: body.config ?? {},\n });\n return void sendJson(res, 201, credentialInstanceToApi(record, typeOf(record.credentialTypeSlug)));\n }\n }\n\n // POST /credentials/test (inline, unsaved)\n if (seg[1] === 'test' && method === 'POST') {\n const body = await readJson<{ credential_type_slug?: string; config?: Record<string, unknown> }>(req);\n if (!body.credential_type_slug) {\n throw new DevApiError(422, 'Field `credential_type_slug` is required.');\n }\n const result = await testCredentialConfig(loaded, store, body.credential_type_slug, body.config ?? {});\n return void sendJson(res, 200, result);\n }\n\n // GET /credentials/oauth/callback\n if (seg[1] === 'oauth' && seg[2] === 'callback' && method === 'GET') {\n const code = url.searchParams.get('code');\n const state = url.searchParams.get('state');\n if (!code || !state) {\n throw new DevApiError(422, 'OAuth callback requires `code` and `state`.');\n }\n // The state carries the credential id in the dev flow (see authorize-url below).\n const credentialId = state;\n const redirectUri = `${url.origin}/api/v1/credentials/oauth/callback`;\n await exchangeOAuthCode(loaded, store, credentialId, { code, redirectUri });\n return void sendJson(res, 200, { status: 'connected', credential_id: credentialId });\n }\n\n const id = seg[1];\n if (!id) {\n throw new DevApiError(404, 'Credential id required.');\n }\n\n // POST /credentials/{id}/test\n if (seg[2] === 'test' && method === 'POST') {\n const result = await testCredentialInstance(loaded, store, id);\n return void sendJson(res, 200, result);\n }\n\n // POST /credentials/{id}/oauth/authorize-url\n if (seg[2] === 'oauth' && seg[3] === 'authorize-url' && method === 'POST') {\n const redirectUri = 'http://localhost/api/v1/credentials/oauth/callback';\n // Dev flow: carry the credential id in `state` so the callback can find it.\n const result = await buildOAuthAuthorizeUrl(loaded, store, id, { redirectUri, state: id });\n return void sendJson(res, 200, { authorize_url: result.authorizeUrl });\n }\n\n // Item-level routes.\n if (seg.length === 2) {\n const record = store.getCredential(id);\n if (method === 'GET') {\n if (!record) {\n throw new DevApiError(404, `Credential '${id}' not found.`);\n }\n return void sendJson(res, 200, credentialInstanceToApi(record, typeOf(record.credentialTypeSlug)));\n }\n if (method === 'PATCH') {\n if (!record) {\n throw new DevApiError(404, `Credential '${id}' not found.`);\n }\n const body = await readJson<{ name?: string; config?: Record<string, unknown> }>(req);\n const updated = store.updateCredential(id, { name: body.name, config: body.config });\n return void sendJson(res, 200, credentialInstanceToApi(updated!, typeOf(updated!.credentialTypeSlug)));\n }\n if (method === 'DELETE') {\n store.deleteCredential(id);\n return void sendJson(res, 200, { deleted: true });\n }\n }\n\n throw new DevApiError(404, `No route for credentials/${seg.slice(1).join('/')}`);\n}\n\n// --------------------------------------------------------------------- secrets\n\nasync function handleSecrets(req: http.IncomingMessage, res: http.ServerResponse, method: string, store: DevStore, seg: string[]): Promise<void> {\n if (seg.length === 1) {\n if (method === 'GET') {\n return void sendJson(res, 200, { data: store.listSecrets().map(secretToApi) });\n }\n if (method === 'POST') {\n const body = await readJson<{ key?: string; value?: string }>(req);\n if (!body.key || body.value === undefined) {\n throw new DevApiError(422, 'Fields `key` and `value` are required.');\n }\n const record = store.setSecret(body.key, body.value);\n return void sendJson(res, 201, secretToApi(record));\n }\n }\n const key = seg[1];\n if (key) {\n if (method === 'PATCH') {\n const body = await readJson<{ value?: string }>(req);\n if (body.value === undefined) {\n throw new DevApiError(422, 'Field `value` is required.');\n }\n return void sendJson(res, 200, secretToApi(store.setSecret(key, body.value)));\n }\n if (method === 'DELETE') {\n store.deleteSecret(key);\n return void sendJson(res, 200, { deleted: true });\n }\n }\n throw new DevApiError(404, `No route for secrets/${seg.slice(1).join('/')}`);\n}\n\n// ------------------------------------------------------------------- templates\n\nasync function handleTemplates(req: http.IncomingMessage, res: http.ServerResponse, method: string, loaded: LoadedPackage, store: DevStore, seg: string[]): Promise<void> {\n const templates = loaded.manifest.templates ?? [];\n if (seg.length === 1 && method === 'GET') {\n return void sendJson(res, 200, { data: templates.map(templateSummaryToApi) });\n }\n const slug = seg[1];\n const template = templates.find(t => t.slug === slug);\n if (!template) {\n throw new DevApiError(404, `Template '${slug}' not found.`);\n }\n if (seg.length === 2 && method === 'GET') {\n return void sendJson(res, 200, templateFullToApi(template));\n }\n if (seg[2] === 'requirements' && method === 'GET') {\n // Best-effort: surface the credential types referenced by the template blob.\n return void sendJson(res, 200, { data: { credentials: [], secrets: [] } });\n }\n if (seg[2] === 'instantiate' && method === 'POST') {\n const body = await readJson<{ name?: string }>(req);\n const workflow = store.createWorkflow({\n name: body.name ?? String(template.name),\n definition: template.definition,\n });\n for (const trigger of template.triggers ?? []) {\n store.createTrigger({\n workflowId: workflow.id,\n type: trigger.type,\n name: trigger.name ?? null,\n config: trigger.config ?? {},\n active: trigger.active ?? true,\n id: trigger.handle,\n });\n }\n return void sendJson(res, 201, workflowToApi(workflow));\n }\n throw new DevApiError(404, `No route for templates/${seg.slice(1).join('/')}`);\n}\n\n// ------------------------------------------------------------------- workflows\n\nasync function handleWorkflows(req: http.IncomingMessage, res: http.ServerResponse, method: string, store: DevStore, seg: string[]): Promise<void> {\n if (seg.length === 1) {\n if (method === 'GET') {\n return void sendJson(res, 200, { data: store.listWorkflows().map(workflowToApi) });\n }\n if (method === 'POST') {\n const body = await readJson<{ name?: string; definition?: Record<string, unknown> }>(req);\n const workflow = store.createWorkflow({\n name: body.name ?? 'Untitled workflow',\n definition: body.definition ?? {},\n });\n return void sendJson(res, 201, workflowToApi(workflow));\n }\n }\n\n // Collection sub-routes registered before {id}.\n if (seg[1] === 'used-credentials' && method === 'GET') {\n return void sendJson(res, 200, { data: [] });\n }\n if (seg[1] === 'used-credential-types' && method === 'GET') {\n return void sendJson(res, 200, { data: [] });\n }\n\n const id = Number.parseInt(seg[1] ?? '', 10);\n if (Number.isNaN(id)) {\n throw new DevApiError(404, `No route for workflows/${seg.slice(1).join('/')}`);\n }\n\n // Triggers\n if (seg[2] === 'triggers') {\n if (seg.length === 3 && method === 'GET') {\n return void sendJson(res, 200, { data: store.listTriggers(id).map(triggerToApi) });\n }\n if (seg.length === 3 && method === 'POST') {\n const body = await readJson<{ type?: string; name?: string; config?: Record<string, unknown>; active?: boolean }>(req);\n if (!body.type) {\n throw new DevApiError(422, 'Field `type` is required.');\n }\n const trigger = store.createTrigger({ workflowId: id, type: body.type, name: body.name, config: body.config, active: body.active });\n return void sendJson(res, 201, triggerToApi(trigger));\n }\n const triggerId = seg[3];\n if (triggerId && method === 'PUT') {\n const body = await readJson<{ type?: string; name?: string; config?: Record<string, unknown>; active?: boolean }>(req);\n if (!body.type) {\n throw new DevApiError(422, 'Field `type` is required.');\n }\n const trigger = store.replaceTrigger(triggerId, { type: body.type, name: body.name, config: body.config, active: body.active });\n if (!trigger) {\n throw new DevApiError(404, `Trigger '${triggerId}' not found.`);\n }\n return void sendJson(res, 200, triggerToApi(trigger));\n }\n if (triggerId && method === 'DELETE') {\n store.deleteTrigger(triggerId);\n return void sendJson(res, 200, { deleted: true });\n }\n }\n\n // Item-level workflow routes.\n if (seg.length === 2) {\n const record = store.getWorkflow(id);\n if (method === 'GET') {\n if (!record) {\n throw new DevApiError(404, `Workflow '${id}' not found.`);\n }\n return void sendJson(res, 200, workflowToApi(record));\n }\n if (method === 'PUT') {\n const body = await readJson<{ name?: string; definition?: Record<string, unknown> }>(req);\n const updated = store.updateWorkflow(id, { name: body.name, definition: body.definition });\n if (!updated) {\n throw new DevApiError(404, `Workflow '${id}' not found.`);\n }\n return void sendJson(res, 200, workflowToApi(updated));\n }\n if (method === 'DELETE') {\n store.deleteWorkflow(id);\n return void sendJson(res, 200, { deleted: true });\n }\n }\n\n if ((seg[2] === 'credentials' || seg[2] === 'credential-types') && method === 'GET') {\n return void sendJson(res, 200, { data: [] });\n }\n\n throw new DevApiError(404, `No route for workflows/${seg.slice(1).join('/')}`);\n}\n","import type http from 'node:http';\nimport { DevApiError } from './errors.js';\n\nexport function sendJson(res: http.ServerResponse, status: number, body: unknown): void {\n const payload = JSON.stringify(body);\n res.writeHead(status, {\n 'Content-Type': 'application/json',\n 'Access-Control-Allow-Origin': '*',\n 'Access-Control-Allow-Headers': '*',\n 'Access-Control-Allow-Methods': 'GET,POST,PUT,PATCH,DELETE,OPTIONS',\n });\n res.end(payload);\n}\n\n/** Maps a thrown error to the Laravel-style `{message}` / `{message, errors}` body. */\nexport function sendError(res: http.ServerResponse, err: unknown): void {\n if (err instanceof DevApiError) {\n sendJson(res, err.status, err.errors ? { message: err.message, errors: err.errors } : { message: err.message });\n return;\n }\n sendJson(res, 500, { message: (err as Error)?.message ?? 'Internal error' });\n}\n\nexport async function readBody(req: http.IncomingMessage): Promise<string> {\n let body = '';\n for await (const chunk of req) {\n body += chunk;\n }\n return body;\n}\n\n/** Reads + parses a JSON body; throws {@link DevApiError} 400 on malformed input. */\nexport async function readJson<T>(req: http.IncomingMessage): Promise<T> {\n const raw = await readBody(req);\n if (raw.trim() === '') {\n return {} as T;\n }\n try {\n return JSON.parse(raw) as T;\n } catch {\n throw new DevApiError(400, 'Invalid JSON body.');\n }\n}\n","import type { ICredentialDescription, INodeDescription, ITemplateDescription } from '@revenexx/integrations-node-sdk';\nimport { MANIFEST_VERSION } from '@revenexx/integrations-node-sdk';\nimport type { CredentialRecord, SecretRecord, TriggerRecord, WorkflowRecord } from './store.js';\n\n/**\n * Maps internal records + manifest descriptions to the exact JSON shapes the\n * production Laravel `/api/v1` surface returns, so the Cockpit UI consumes the\n * mock API without any awareness that it is mocked.\n */\n\nexport function hasDynamicOptions(desc: INodeDescription): boolean {\n return (desc.config ?? []).some(f => f.dynamic === true);\n}\n\nexport function hasDynamicSchema(desc: INodeDescription): boolean {\n return (desc.config ?? []).some(f => f.type === 'dynamic-schema');\n}\n\nexport function hasDynamicOutputs(desc: INodeDescription): boolean {\n return (desc.outputs ?? []).some(o => o.resolveOutputs === true);\n}\n\nexport function nodeToApi(desc: INodeDescription): Record<string, unknown> {\n const [namespace] = desc.slug.split(':');\n return {\n name: desc.name,\n namespace: namespace ?? null,\n slug: desc.slug,\n version: desc.version,\n manifest_version: MANIFEST_VERSION,\n manifest: desc,\n has_dynamic_options: hasDynamicOptions(desc),\n has_dynamic_schema: hasDynamicSchema(desc),\n has_dynamic_outputs: hasDynamicOutputs(desc),\n created_at: null,\n updated_at: null,\n };\n}\n\nexport function credentialTypeToApi(desc: ICredentialDescription): Record<string, unknown> {\n return {\n slug: desc.slug,\n version: desc.version,\n name: desc.name,\n description: desc.description ?? null,\n icon: desc.icon ?? null,\n auth_kind: desc.authKind,\n fields: desc.fields,\n };\n}\n\n/** Projects a credential instance to its masked public API shape (no secrets). */\nexport function credentialInstanceToApi(record: CredentialRecord, type: ICredentialDescription | undefined): Record<string, unknown> {\n const secretKeys = new Set((type?.fields ?? []).filter(f => f.type === 'secret').map(f => f.key));\n const knownKeys = new Set((type?.fields ?? []).map(f => f.key));\n const publicConfig: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(record.config)) {\n // Only surface known, non-secret fields; drop everything else defensively.\n if (knownKeys.has(key) && !secretKeys.has(key)) {\n publicConfig[key] = value;\n }\n }\n return {\n id: record.id,\n tenant_id: record.tenantId,\n credential_type_slug: record.credentialTypeSlug,\n name: record.name,\n status: record.status,\n public_config: publicConfig,\n created_at: record.createdAt,\n updated_at: record.updatedAt,\n };\n}\n\nexport function secretToApi(record: SecretRecord): Record<string, unknown> {\n return {\n key: record.key,\n created_at: record.createdAt,\n updated_at: record.updatedAt,\n };\n}\n\nexport function workflowToApi(record: WorkflowRecord): Record<string, unknown> {\n return {\n id: record.id,\n name: record.name,\n definition: record.definition,\n build_status: record.buildStatus,\n created_at: record.createdAt,\n updated_at: record.updatedAt,\n };\n}\n\nexport function triggerToApi(record: TriggerRecord): Record<string, unknown> {\n return {\n handle: record.id,\n id: record.id,\n workflow_id: record.workflowId,\n type: record.type,\n name: record.name,\n config: record.config,\n active: record.active,\n created_at: record.createdAt,\n updated_at: record.updatedAt,\n };\n}\n\nexport function templateSummaryToApi(t: ITemplateDescription): Record<string, unknown> {\n return {\n slug: t.slug,\n version: t.version,\n category: t.category,\n level: t.level,\n name: t.name,\n shortDescription: t.shortDescription ?? null,\n description: t.description ?? null,\n icon: t.icon ?? null,\n industries: t.industries ?? [],\n vendors: t.vendors ?? [],\n triggerTypes: (t.triggers ?? []).map(tr => tr.type),\n };\n}\n\nexport function templateFullToApi(t: ITemplateDescription): Record<string, unknown> {\n return {\n ...templateSummaryToApi(t),\n blobVersion: t.blobVersion,\n definition: t.definition,\n triggers: t.triggers ?? [],\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKA,IAAM,mBAAmB,MACvB,OAAO,aAAa,cAChB,IAAI,IAAI,QAAQ,UAAU,EAAE,EAAE,OAC7B,SAAS,iBAAiB,SAAS,cAAc,QAAQ,YAAY,MAAM,WAC1E,SAAS,cAAc,MACvB,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;AAEtC,IAAM,gBAAgC,iCAAiB;;;ADH9D,IAAAA,kBAA6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,CAAC,SAAS;AACZ,cAAM,IAAI,YAAY,KAAK,aAAa,EAAE,cAAc;AAAA,MAC1D;AACA,aAAO,KAAK,SAAS,KAAK,KAAK,cAAc,OAAO,CAAC;AAAA,IACvD;AACA,QAAI,WAAW,UAAU;AACvB,YAAM,eAAe,EAAE;AACvB,aAAO,KAAK,SAAS,KAAK,KAAK,EAAE,SAAS,KAAK,CAAC;AAAA,IAClD;AAAA,EACF;AAEA,OAAK,IAAI,CAAC,MAAM,iBAAiB,IAAI,CAAC,MAAM,uBAAuB,WAAW,OAAO;AACnF,WAAO,KAAK,SAAS,KAAK,KAAK,EAAE,MAAM,CAAC,EAAE,CAAC;AAAA,EAC7C;AAEA,QAAM,IAAI,YAAY,KAAK,0BAA0B,IAAI,MAAM,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE;AAC/E;;;ARvbA,IAAM,cAAc,IAAI,IAAI,mBAAmB,aAAe;AACvD,IAAM,iBAAyB,KAAK,UAAM,8BAAa,aAAa,MAAM,CAAC,EAAE;","names":["import_node_fs","import_node_fs","import_node_path","import_integrations_node_sdk","v","import_integrations_node_sdk","http"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { INode, ICredential, ITemplateDescription, NodeManifest, IConfigOption, IConfigField, IOutputPort, ICredentialDescription, ICredentialResolveResult, ICredentialTestResult } from '@revenexx/integrations-node-sdk';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `.env` loading for the CLI.
|
|
6
|
+
*
|
|
7
|
+
* Seeds reference secrets as `${VAR}` and {@link interpolateEnv} resolves those
|
|
8
|
+
* from `process.env`, so without this the documented workflow — commit the
|
|
9
|
+
* reference, keep the value in `.env` — only worked if the developer exported
|
|
10
|
+
* the variables by hand.
|
|
11
|
+
*
|
|
12
|
+
* Loading happens before option parsing, because the CLI reads `PORT` for its
|
|
13
|
+
* default port; a `.env` that sets `PORT` would otherwise be read too late.
|
|
14
|
+
*
|
|
15
|
+
* `process.loadEnvFile` deliberately does not overwrite variables that are
|
|
16
|
+
* already set, so a shell-provided value always beats the file:
|
|
17
|
+
*
|
|
18
|
+
* REVENEXX_DEV_API_KEY=… npm run preview
|
|
19
|
+
*
|
|
20
|
+
* The flag is `--env`, *not* `--env-file`: Node reserves `--env-file` and
|
|
21
|
+
* `--env-file-if-exists` and acts on them wherever they appear, including after
|
|
22
|
+
* the script path. `node cli.js --env-file missing` therefore dies inside Node
|
|
23
|
+
* with exit code 9 before this module is ever reached, so the devkit cannot own
|
|
24
|
+
* that name. {@link nodeOwnedEnvFlag} spots the mistake and explains it.
|
|
25
|
+
*/
|
|
26
|
+
/** Minimum Node version shipping `process.loadEnvFile`. */
|
|
27
|
+
declare const ENV_FILE_MIN_NODE = "20.12";
|
|
28
|
+
interface EnvFileChoice {
|
|
29
|
+
/** Absolute path to load, or `null` when `--no-env` disabled loading. */
|
|
30
|
+
path: string | null;
|
|
31
|
+
/** True when the file was named with `--env` rather than defaulted to. */
|
|
32
|
+
explicit: boolean;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Returns the Node-owned env flag present in `argv`, if any. Node has already
|
|
36
|
+
* acted on it by the time the CLI runs — this exists only so the CLI can say so
|
|
37
|
+
* instead of leaving the user wondering why `--env-file` behaved oddly.
|
|
38
|
+
*/
|
|
39
|
+
declare function nodeOwnedEnvFlag(argv: string[]): string | null;
|
|
40
|
+
/** Decides which env file to load. Pure — touches neither disk nor `process.env`. */
|
|
41
|
+
declare function resolveEnvFile(argv: string[], cwd?: string): EnvFileChoice;
|
|
42
|
+
interface LoadEnvFileOptions {
|
|
43
|
+
cwd?: string;
|
|
44
|
+
warn?: (message: string) => void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Loads the env file chosen by {@link resolveEnvFile} into `process.env` and
|
|
48
|
+
* returns its path, or `null` when nothing was loaded.
|
|
49
|
+
*
|
|
50
|
+
* A missing *default* `.env` is fine — most packages do not have one. A file
|
|
51
|
+
* asked for by name and missing is an error: ignoring it would hide a typo and
|
|
52
|
+
* resurface much later as a puzzling `Seed references ${X}` failure.
|
|
53
|
+
*/
|
|
54
|
+
declare function loadEnvFile(argv: string[], options?: LoadEnvFileOptions): string | null;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* An error that maps to an HTTP status + JSON body in the mock API, mirroring
|
|
58
|
+
* Laravel's `{message}` / `{message, errors}` envelopes.
|
|
59
|
+
*/
|
|
60
|
+
declare class DevApiError extends Error {
|
|
61
|
+
readonly status: number;
|
|
62
|
+
readonly errors?: Record<string, string[]> | undefined;
|
|
63
|
+
constructor(status: number, message: string, errors?: Record<string, string[]> | undefined);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A node package loaded into the dev process: its live `NODES` / `CREDENTIALS`
|
|
68
|
+
* / `TEMPLATES` instances (so author-time resolvers, `test`, and `resolve` can
|
|
69
|
+
* be invoked in-process — no bundle, no sandbox) plus the derived manifest the
|
|
70
|
+
* mock API serves.
|
|
71
|
+
*/
|
|
72
|
+
interface LoadedPackage {
|
|
73
|
+
nodes: INode[];
|
|
74
|
+
credentials: ICredential[];
|
|
75
|
+
templates: ITemplateDescription[];
|
|
76
|
+
manifest: NodeManifest;
|
|
77
|
+
}
|
|
78
|
+
interface PackageExports {
|
|
79
|
+
NODES?: unknown;
|
|
80
|
+
CREDENTIALS?: unknown;
|
|
81
|
+
TEMPLATES?: unknown;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Validates a package's module exports and builds a {@link LoadedPackage}.
|
|
85
|
+
* Mirrors the checks in the SDK's `rvnxx-nodes manifest` CLI so the dev loop
|
|
86
|
+
* and the build produce identical manifests.
|
|
87
|
+
*/
|
|
88
|
+
declare function resolveExports(mod: PackageExports): LoadedPackage;
|
|
89
|
+
/**
|
|
90
|
+
* Registers the `tsx` ESM loader once per process so `import()` can load
|
|
91
|
+
* TypeScript sources directly. Idempotent.
|
|
92
|
+
*/
|
|
93
|
+
declare function ensureTsxRegistered(): Promise<void>;
|
|
94
|
+
/** Imports a module by path, registering tsx first for TypeScript sources. */
|
|
95
|
+
declare function importFresh<T = unknown>(entryPath: string): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Imports a package entry and resolves its exports. Supports TypeScript
|
|
98
|
+
* sources directly (via `tsx`) so the preview runs against the developer's
|
|
99
|
+
* live `src/`, not a built artifact. A cache-busting query is appended so
|
|
100
|
+
* repeated calls (hot-reload) re-evaluate the module.
|
|
101
|
+
*/
|
|
102
|
+
declare function loadPackageFromEntry(entryPath: string): Promise<LoadedPackage>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* In-memory data store backing the mock Integrations API. Holds the tenant-
|
|
106
|
+
* scoped resources a developer creates in the preview (credentials, secrets,
|
|
107
|
+
* workflows, triggers). Serializable so a session can be persisted to and
|
|
108
|
+
* rehydrated from `.revenexx-dev/state.json`.
|
|
109
|
+
*/
|
|
110
|
+
declare const DEV_TENANT_ID = "dev-tenant";
|
|
111
|
+
interface CredentialRecord {
|
|
112
|
+
id: string;
|
|
113
|
+
tenantId: string;
|
|
114
|
+
credentialTypeSlug: string;
|
|
115
|
+
name: string;
|
|
116
|
+
status: string;
|
|
117
|
+
/** Full user-entered config, including secret fields (never sent to the UI verbatim). */
|
|
118
|
+
config: Record<string, unknown>;
|
|
119
|
+
/** System-managed long-lived secrets (e.g. an OAuth refresh token). */
|
|
120
|
+
durableCreds: Record<string, unknown> | null;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
}
|
|
124
|
+
interface SecretRecord {
|
|
125
|
+
key: string;
|
|
126
|
+
value: string;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
updatedAt: string;
|
|
129
|
+
}
|
|
130
|
+
interface WorkflowRecord {
|
|
131
|
+
id: number;
|
|
132
|
+
name: string;
|
|
133
|
+
definition: Record<string, unknown>;
|
|
134
|
+
buildStatus: string;
|
|
135
|
+
createdAt: string;
|
|
136
|
+
updatedAt: string;
|
|
137
|
+
}
|
|
138
|
+
interface TriggerRecord {
|
|
139
|
+
id: string;
|
|
140
|
+
workflowId: number;
|
|
141
|
+
type: string;
|
|
142
|
+
name: string | null;
|
|
143
|
+
config: Record<string, unknown>;
|
|
144
|
+
active: boolean;
|
|
145
|
+
createdAt: string;
|
|
146
|
+
updatedAt: string;
|
|
147
|
+
}
|
|
148
|
+
interface DevStoreSnapshot {
|
|
149
|
+
schemaVersion: number;
|
|
150
|
+
credentials: CredentialRecord[];
|
|
151
|
+
secrets: SecretRecord[];
|
|
152
|
+
workflows: WorkflowRecord[];
|
|
153
|
+
triggers: TriggerRecord[];
|
|
154
|
+
nextWorkflowId: number;
|
|
155
|
+
}
|
|
156
|
+
declare const STORE_SCHEMA_VERSION = 1;
|
|
157
|
+
declare class DevStore {
|
|
158
|
+
private onChange?;
|
|
159
|
+
private credentials;
|
|
160
|
+
private secrets;
|
|
161
|
+
private workflows;
|
|
162
|
+
private triggers;
|
|
163
|
+
private nextWorkflowId;
|
|
164
|
+
/**
|
|
165
|
+
* @param onChange fired after any mutation so a caller (the CLI) can persist
|
|
166
|
+
* the session to `.revenexx-dev/state.json`.
|
|
167
|
+
*/
|
|
168
|
+
constructor(onChange?: (() => void) | undefined);
|
|
169
|
+
/** (Re)wire the post-mutation callback — e.g. attach it only after seeding. */
|
|
170
|
+
setOnMutation(onChange: (() => void) | undefined): void;
|
|
171
|
+
private touch;
|
|
172
|
+
listCredentials(typeSlug?: string): CredentialRecord[];
|
|
173
|
+
getCredential(id: string): CredentialRecord | undefined;
|
|
174
|
+
createCredential(input: {
|
|
175
|
+
credentialTypeSlug: string;
|
|
176
|
+
name: string;
|
|
177
|
+
config: Record<string, unknown>;
|
|
178
|
+
status?: string;
|
|
179
|
+
/** Stable id — pass to keep a seeded credential's id fixed across restarts. */
|
|
180
|
+
id?: string;
|
|
181
|
+
durableCreds?: Record<string, unknown> | null;
|
|
182
|
+
}): CredentialRecord;
|
|
183
|
+
updateCredential(id: string, patch: Partial<Pick<CredentialRecord, 'name' | 'config' | 'status' | 'durableCreds'>>): CredentialRecord | undefined;
|
|
184
|
+
deleteCredential(id: string): boolean;
|
|
185
|
+
listSecrets(): SecretRecord[];
|
|
186
|
+
getSecret(key: string): SecretRecord | undefined;
|
|
187
|
+
setSecret(key: string, value: string): SecretRecord;
|
|
188
|
+
deleteSecret(key: string): boolean;
|
|
189
|
+
listWorkflows(): WorkflowRecord[];
|
|
190
|
+
getWorkflow(id: number): WorkflowRecord | undefined;
|
|
191
|
+
createWorkflow(input: {
|
|
192
|
+
name: string;
|
|
193
|
+
definition: Record<string, unknown>;
|
|
194
|
+
}): WorkflowRecord;
|
|
195
|
+
updateWorkflow(id: number, patch: Partial<Pick<WorkflowRecord, 'name' | 'definition' | 'buildStatus'>>): WorkflowRecord | undefined;
|
|
196
|
+
deleteWorkflow(id: number): boolean;
|
|
197
|
+
listTriggers(workflowId: number): TriggerRecord[];
|
|
198
|
+
getTrigger(id: string): TriggerRecord | undefined;
|
|
199
|
+
createTrigger(input: {
|
|
200
|
+
workflowId: number;
|
|
201
|
+
type: string;
|
|
202
|
+
name?: string | null;
|
|
203
|
+
config?: Record<string, unknown>;
|
|
204
|
+
active?: boolean;
|
|
205
|
+
id?: string;
|
|
206
|
+
}): TriggerRecord;
|
|
207
|
+
replaceTrigger(id: string, input: {
|
|
208
|
+
type: string;
|
|
209
|
+
name?: string | null;
|
|
210
|
+
config?: Record<string, unknown>;
|
|
211
|
+
active?: boolean;
|
|
212
|
+
}): TriggerRecord | undefined;
|
|
213
|
+
deleteTrigger(id: string): boolean;
|
|
214
|
+
toSnapshot(): DevStoreSnapshot;
|
|
215
|
+
loadSnapshot(snapshot: DevStoreSnapshot): void;
|
|
216
|
+
/**
|
|
217
|
+
* Overlays a snapshot on top of the current contents (upsert by id/key), used
|
|
218
|
+
* to layer the persisted `.revenexx-dev/state.json` session over the freshly
|
|
219
|
+
* applied committed seeds. State entries win over seed entries with the same
|
|
220
|
+
* id/key; seed-only entries are preserved.
|
|
221
|
+
*/
|
|
222
|
+
mergeSnapshot(snapshot: DevStoreSnapshot): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Layered persistence for the preview session:
|
|
227
|
+
* 1. committed seeds (this module's {@link applySeeds}) — the durable base,
|
|
228
|
+
* with `${ENV_VAR}` references interpolated from the environment;
|
|
229
|
+
* 2. `.revenexx-dev/state.json` overlay ({@link loadState}/{@link saveState}) —
|
|
230
|
+
* interactive session state, versioned and disposable.
|
|
231
|
+
*/
|
|
232
|
+
interface CredentialSeed {
|
|
233
|
+
credentialTypeSlug: string;
|
|
234
|
+
name: string;
|
|
235
|
+
config: Record<string, unknown>;
|
|
236
|
+
/** Stable id so workflows can reference the credential across restarts. */
|
|
237
|
+
id?: string;
|
|
238
|
+
status?: string;
|
|
239
|
+
durableCreds?: Record<string, unknown> | null;
|
|
240
|
+
}
|
|
241
|
+
interface SecretSeed {
|
|
242
|
+
key: string;
|
|
243
|
+
value: string;
|
|
244
|
+
}
|
|
245
|
+
interface WorkflowSeed {
|
|
246
|
+
name: string;
|
|
247
|
+
definition: Record<string, unknown>;
|
|
248
|
+
}
|
|
249
|
+
interface DevSeeds {
|
|
250
|
+
credentials?: CredentialSeed[];
|
|
251
|
+
secrets?: SecretSeed[];
|
|
252
|
+
workflows?: WorkflowSeed[];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Recursively replaces `${ENV_VAR}` references in string values from `env`.
|
|
256
|
+
* Throws a clear error when a referenced variable is unset so a developer
|
|
257
|
+
* knows to add it to their `.env` — keeping secrets out of committed seeds.
|
|
258
|
+
*/
|
|
259
|
+
declare function interpolateEnv<T>(value: T, env?: NodeJS.ProcessEnv): T;
|
|
260
|
+
/** Applies committed seeds to the store (env-interpolated). */
|
|
261
|
+
declare function applySeeds(store: DevStore, seeds: DevSeeds, env?: NodeJS.ProcessEnv): void;
|
|
262
|
+
/**
|
|
263
|
+
* Reads a persisted session snapshot. Returns `null` (and warns) when the file
|
|
264
|
+
* is absent or its `schemaVersion` no longer matches — the overlay is
|
|
265
|
+
* disposable, so a mismatch is discarded rather than migrated.
|
|
266
|
+
*/
|
|
267
|
+
declare function loadState(file: string, log?: (msg: string) => void): DevStoreSnapshot | null;
|
|
268
|
+
declare function saveState(file: string, snapshot: DevStoreSnapshot): void;
|
|
269
|
+
/**
|
|
270
|
+
* Loads committed seeds from a directory (default `dev/seeds`). Resolves the
|
|
271
|
+
* first present entry file and reads its `default` or named `seeds` export.
|
|
272
|
+
* Returns empty seeds when no seed directory/entry exists.
|
|
273
|
+
*/
|
|
274
|
+
declare function loadSeedsFromDir(dir: string): Promise<DevSeeds>;
|
|
275
|
+
|
|
276
|
+
declare function nodeVersions(loaded: LoadedPackage, slug: string): string[];
|
|
277
|
+
declare function findNode(loaded: LoadedPackage, slug: string, version?: string): INode;
|
|
278
|
+
declare function findCredential(loaded: LoadedPackage, slug: string): ICredential;
|
|
279
|
+
declare function findCredentialType(loaded: LoadedPackage, slug: string): ICredentialDescription;
|
|
280
|
+
/** Resolves a credential instance's access data by running its real `resolve`. */
|
|
281
|
+
declare function resolveCredentialInstance(loaded: LoadedPackage, store: DevStore, credentialId: string): Promise<ICredentialResolveResult>;
|
|
282
|
+
interface ResolveNodeConfigInput {
|
|
283
|
+
slug: string;
|
|
284
|
+
version?: string;
|
|
285
|
+
/** `"*"` (all), `"outputs"`, or a specific config field key. */
|
|
286
|
+
target: string;
|
|
287
|
+
config: Record<string, unknown>;
|
|
288
|
+
locale?: string;
|
|
289
|
+
}
|
|
290
|
+
interface ResolveNodeConfigResult {
|
|
291
|
+
options?: IConfigOption[];
|
|
292
|
+
fields?: IConfigField[];
|
|
293
|
+
outputs?: IOutputPort[];
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Runs a node's author-time resolvers for the requested `target`, mirroring
|
|
297
|
+
* the server's `config:resolve` semantics.
|
|
298
|
+
*/
|
|
299
|
+
declare function resolveNodeConfig(loaded: LoadedPackage, store: DevStore, input: ResolveNodeConfigInput): Promise<ResolveNodeConfigResult>;
|
|
300
|
+
interface ValidateNodeConfigInput {
|
|
301
|
+
slug: string;
|
|
302
|
+
version?: string;
|
|
303
|
+
config: Record<string, unknown>;
|
|
304
|
+
locale?: string;
|
|
305
|
+
}
|
|
306
|
+
interface ValidateNodeConfigResult {
|
|
307
|
+
valid: boolean;
|
|
308
|
+
/** Config field key → human-readable messages. Empty object when valid. */
|
|
309
|
+
errors: Record<string, string[]>;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Validates a submitted node `config` against the field rules in its manifest
|
|
313
|
+
* (`required`, `IConfigValidation`, types, static options). For `dynamic-schema`
|
|
314
|
+
* fields the resolved child schema is fetched and its rules applied to the
|
|
315
|
+
* flattened keys. Deep cross-field validation is intentionally out of scope
|
|
316
|
+
* (the production service does that on save); this mirrors the mock's
|
|
317
|
+
* "light, schema-based" fidelity. Unknown extra keys are ignored.
|
|
318
|
+
*/
|
|
319
|
+
declare function validateNodeConfig(loaded: LoadedPackage, store: DevStore, input: ValidateNodeConfigInput): Promise<ValidateNodeConfigResult>;
|
|
320
|
+
/** Runs a credential type's `test` against inline (unsaved) config. */
|
|
321
|
+
declare function testCredentialConfig(loaded: LoadedPackage, store: DevStore, typeSlug: string, config: Record<string, unknown>): Promise<ICredentialTestResult>;
|
|
322
|
+
/** Runs `test` against a saved credential instance's stored config. */
|
|
323
|
+
declare function testCredentialInstance(loaded: LoadedPackage, store: DevStore, credentialId: string): Promise<ICredentialTestResult>;
|
|
324
|
+
declare function buildOAuthAuthorizeUrl(loaded: LoadedPackage, store: DevStore, credentialId: string, params: {
|
|
325
|
+
redirectUri: string;
|
|
326
|
+
state: string;
|
|
327
|
+
}): Promise<{
|
|
328
|
+
authorizeUrl: string;
|
|
329
|
+
codeVerifier?: string;
|
|
330
|
+
}>;
|
|
331
|
+
declare function exchangeOAuthCode(loaded: LoadedPackage, store: DevStore, credentialId: string, params: {
|
|
332
|
+
code: string;
|
|
333
|
+
redirectUri: string;
|
|
334
|
+
codeVerifier?: string;
|
|
335
|
+
}): Promise<{
|
|
336
|
+
durableCreds: Record<string, unknown>;
|
|
337
|
+
}>;
|
|
338
|
+
|
|
339
|
+
interface DevServerDeps {
|
|
340
|
+
/** Returns the currently-loaded package; a function so hot-reload can swap it. */
|
|
341
|
+
getPackage(): LoadedPackage;
|
|
342
|
+
store: DevStore;
|
|
343
|
+
/** JSON schemas served at `/schemas/{domain}[/{version}]`, keyed by `domain` and `domain/version`. */
|
|
344
|
+
schemas?: Record<string, unknown>;
|
|
345
|
+
}
|
|
346
|
+
/** Builds the `(req, res)` request listener implementing the mock `/api/v1` surface. */
|
|
347
|
+
declare function createRequestListener(deps: DevServerDeps): http.RequestListener;
|
|
348
|
+
declare function createDevServer(deps: DevServerDeps): http.Server;
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* `@revenexx/integrations-node-devkit` — local development kit for Revenexx
|
|
352
|
+
* integration node packages. Dev/CI only; never bundled into a node package.
|
|
353
|
+
*
|
|
354
|
+
* Two surfaces:
|
|
355
|
+
* - `@revenexx/integrations-node-devkit` → the mock-API preview server (this entry)
|
|
356
|
+
* - `@revenexx/integrations-node-devkit/testing` → the unit-testing harness
|
|
357
|
+
*/
|
|
358
|
+
declare const DEVKIT_VERSION: string;
|
|
359
|
+
|
|
360
|
+
export { type CredentialRecord, type CredentialSeed, DEVKIT_VERSION, DEV_TENANT_ID, DevApiError, type DevSeeds, type DevServerDeps, DevStore, type DevStoreSnapshot, ENV_FILE_MIN_NODE, type EnvFileChoice, type LoadEnvFileOptions, type LoadedPackage, type ResolveNodeConfigInput, type ResolveNodeConfigResult, STORE_SCHEMA_VERSION, type SecretRecord, type SecretSeed, type TriggerRecord, type ValidateNodeConfigInput, type ValidateNodeConfigResult, type WorkflowRecord, type WorkflowSeed, applySeeds, buildOAuthAuthorizeUrl, createDevServer, createRequestListener, ensureTsxRegistered, exchangeOAuthCode, findCredential, findCredentialType, findNode, importFresh, interpolateEnv, loadEnvFile, loadPackageFromEntry, loadSeedsFromDir, loadState, nodeOwnedEnvFlag, nodeVersions, resolveCredentialInstance, resolveEnvFile, resolveExports, resolveNodeConfig, saveState, testCredentialConfig, testCredentialInstance, validateNodeConfig };
|