Skip to content

Commit 36af43f

Browse files
authored
ts fixes (#992)
<!-- ELLIPSIS_HIDDEN --> > [!IMPORTANT] > Add `BamlLogEvent` support and update callback types to allow `undefined` in TypeScript, JavaScript, and Rust files. > > - **Exports**: > - Add `BamlLogEvent` to exports in `index.d.ts`, `index.js`, and `typescript_src/index.ts`. > - **TypeScript Definitions**: > - Update `streamFunction` and `streamFunctionSync` in `native.d.ts` to allow `cb` parameter to be `undefined`. > - **JavaScript**: > - Replace `console.error` with `loadErrors.push` in `native.js` for error handling. > - **Rust**: > - Update `stream_function` and `stream_function_sync` in `runtime.rs` to allow `cb` parameter to be `undefined`. > - **Dependencies**: > - Update `@napi-rs/cli` version in `package.json` from `3.0.0-alpha.56` to `3.0.0-alpha.62`. > > <sup>This description was created by </sup>[<img alt="Ellipsis" src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=BoundaryML%2Fbaml&utm_source=github&utm_medium=referral)<sup> for 12d7646. It will automatically update as commits are pushed.</sup> <!-- ELLIPSIS_HIDDEN -->
1 parent 0960ab2 commit 36af43f

File tree

9 files changed

+228
-331
lines changed

9 files changed

+228
-331
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { BamlRuntime, FunctionResult, FunctionResultStream, BamlImage as Image, ClientBuilder, BamlAudio as Audio, invoke_runtime_cli, ClientRegistry, } from './native';
1+
export { BamlRuntime, FunctionResult, FunctionResultStream, BamlImage as Image, ClientBuilder, BamlAudio as Audio, invoke_runtime_cli, ClientRegistry, BamlLogEvent, } from './native';
22
export { BamlStream } from './stream';
33
export { BamlCtxManager } from './async_context_vars';
44
//# sourceMappingURL=index.d.ts.map

engine/language_client_typescript/index.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

engine/language_client_typescript/index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use strict";
22
Object.defineProperty(exports, "__esModule", { value: true });
3-
exports.BamlCtxManager = exports.BamlStream = exports.ClientRegistry = exports.invoke_runtime_cli = exports.Audio = exports.ClientBuilder = exports.Image = exports.FunctionResultStream = exports.FunctionResult = exports.BamlRuntime = void 0;
3+
exports.BamlCtxManager = exports.BamlStream = exports.BamlLogEvent = exports.ClientRegistry = exports.invoke_runtime_cli = exports.Audio = exports.ClientBuilder = exports.Image = exports.FunctionResultStream = exports.FunctionResult = exports.BamlRuntime = void 0;
44
var native_1 = require("./native");
55
Object.defineProperty(exports, "BamlRuntime", { enumerable: true, get: function () { return native_1.BamlRuntime; } });
66
Object.defineProperty(exports, "FunctionResult", { enumerable: true, get: function () { return native_1.FunctionResult; } });
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "ClientBuilder", { enumerable: true, get: functio
1010
Object.defineProperty(exports, "Audio", { enumerable: true, get: function () { return native_1.BamlAudio; } });
1111
Object.defineProperty(exports, "invoke_runtime_cli", { enumerable: true, get: function () { return native_1.invoke_runtime_cli; } });
1212
Object.defineProperty(exports, "ClientRegistry", { enumerable: true, get: function () { return native_1.ClientRegistry; } });
13+
Object.defineProperty(exports, "BamlLogEvent", { enumerable: true, get: function () { return native_1.BamlLogEvent; } });
1314
var stream_1 = require("./stream");
1415
Object.defineProperty(exports, "BamlStream", { enumerable: true, get: function () { return stream_1.BamlStream; } });
1516
var async_context_vars_1 = require("./async_context_vars");

engine/language_client_typescript/native.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export declare class BamlRuntime {
2525
createContextManager(): RuntimeContextManager
2626
callFunction(functionName: string, args: { [string]: any }, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, cb?: ClientRegistry | undefined | null): Promise<FunctionResult>
2727
callFunctionSync(functionName: string, args: { [string]: any }, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, cb?: ClientRegistry | undefined | null): FunctionResult
28-
streamFunction(functionName: string, args: { [string]: any }, cb: (err: any, param: FunctionResult) => void, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, clientRegistry?: ClientRegistry | undefined | null): FunctionResultStream
29-
streamFunctionSync(functionName: string, args: { [string]: any }, cb: (err: any, param: FunctionResult) => void, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, clientRegistry?: ClientRegistry | undefined | null): FunctionResultStream
28+
streamFunction(functionName: string, args: { [string]: any }, cb: ((err: any, param: FunctionResult) => void) | undefined, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, clientRegistry?: ClientRegistry | undefined | null): FunctionResultStream
29+
streamFunctionSync(functionName: string, args: { [string]: any }, cb: ((err: any, param: FunctionResult) => void) | undefined, ctx: RuntimeContextManager, tb?: TypeBuilder | undefined | null, clientRegistry?: ClientRegistry | undefined | null): FunctionResultStream
3030
setLogEventCallback(func?: undefined | ((err: any, param: BamlLogEvent) => void)): void
3131
flush(): void
3232
drainStats(): TraceStats

engine/language_client_typescript/native.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,15 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
336336
nativeBinding = require('./baml.wasi.cjs')
337337
} catch (err) {
338338
if (process.env.NAPI_RS_FORCE_WASI) {
339-
console.error(err)
339+
loadErrors.push(err)
340340
}
341341
}
342342
if (!nativeBinding) {
343343
try {
344344
nativeBinding = require('@boundaryml/baml-wasm32-wasi')
345345
} catch (err) {
346346
if (process.env.NAPI_RS_FORCE_WASI) {
347-
console.error(err)
347+
loadErrors.push(err)
348348
}
349349
}
350350
}

engine/language_client_typescript/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
},
6868
"devDependencies": {
6969
"@biomejs/biome": "^1.7.3",
70-
"@napi-rs/cli": "3.0.0-alpha.56",
70+
"@napi-rs/cli": "3.0.0-alpha.62",
7171
"@types/node": "^20.12.11",
7272
"npm-run-all2": "^6.1.2",
7373
"ts-node": "^10.9.2",

0 commit comments

Comments
 (0)