Skip to main content

TypeScript and JavaScript Authoring

Enterprise 3.3.0+. Install a public @outburn/types release containing the author contracts. Use type-only imports: the package supplies declarations, not a runtime SDK, evaluator, FHIR client, or private engine dependency.

ContractPurpose
FumePluginModule<TConfig, TFunctions>Manifest and sync/async factory; native declarations require a factory.
FumePluginManifestVersioned manifest metadata and exposure definitions.
FumePluginVariableDefinition, FumePluginNativeDefinition, FumePluginMappingDefinitionVariable, native export and FUME mapping declarations.
FumePluginNativeFunction<TArgs, TResult>Typed argument tuple and data-only sync/async result.
FumePluginFunctionMapFactory's callable implementation map.
FumePluginJsonValueJSON-only manifest and configuration values.
FumePluginData, FumePluginBindingsTransportable invocation data, including undefined, and named bindings.
FumePluginHostOnly callMapping(localName, input?, bindings?).
FumePluginDeploymentConfig, FumePluginInstallationConfig, FumePluginRootAliasOperator deployment shape.
FumePluginErrorCode, FumePluginHostErrorClosed error-code union and error interface, not a runtime error class.

TypeScript entry​

This complete HTTP adapter uses a typed config, argument tuple and result. Its timers are cleared on success and failure. Supply a local mock or your own explicit endpoint; no endpoint is created by the runtime.

mock-api/entry.ts
/**
* © Copyright Outburn Ltd. 2022-2026 All Rights Reserved
* Project name: FUME
*/

import type { FumePluginData, FumePluginModule, FumePluginNativeFunction } from '@outburn/types';

interface Config { endpoint: string; timeoutMs: number }
const plugin: FumePluginModule<Config, { request: FumePluginNativeFunction<[FumePluginData], FumePluginData> }> = {
manifest: {
apiVersion: 1, id: 'mock-api', version: '1.0.0',
functions: [{ export: 'request', localName: 'httpAdapter', signature: '<x:x>' }],
mappings: [{ id: 'request', globalName: 'mockRequest', rootRoute: '/mock-api', expression: '$httpAdapter($)' }]
},
createFunctions: config => ({
request: async input => {
const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), config.timeoutMs);
const post = async (pathname: string, value: FumePluginData): Promise<FumePluginData> => {
const response = await fetch(new URL(pathname, config.endpoint), {
method: 'POST', headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(value), signal: controller.signal
});
if (!response.ok) throw new Error('Mock adapter request failed');
return await response.json();
};
try {
const result = await post('transform', input);
await post('output', result);
return result;
} finally { clearTimeout(timer); }
}
})
};

export = plugin;

Use export = plugin and compile to CommonJS. A minimal tsconfig.json is:

{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"strict": true,
"types": ["node"],
"outDir": "build"
},
"include": ["entry.ts"]
}

Run npx tsc --noEmit, then bundle the entry to a .cjs artifact. JavaScript authors can use the complete JSDoc-typed basic entry with --allowJs --checkJs.

The concrete generic factory types preserve argument and result types; host.callMapping intentionally returns general data and must be narrowed. Do not assert a specific result schema merely because a mapping returned an object. TypeScript does not validate signature strings, route grammar, semantic versions, finite numbers, cycles, descriptors, prototypes or deployment ranges; startup and the transport codec enforce those rules.

Keep config, host and expression bindings distinct. Config is frozen worker-local factory input; host is an invocation-limited capability; declared variables and functions are evaluator bindings. No hidden JavaScript this, execution context, logger, engine or service handle is supplied to a native function.