typed-bridge 3.0.0 → 3.0.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.
|
@@ -223,6 +223,31 @@ const removeSecondParamTransformer = context => {
|
|
|
223
223
|
};
|
|
224
224
|
/**
|
|
225
225
|
* Transformer #3:
|
|
226
|
+
* Make any parameter typed as `undefined` optional so callers can omit it.
|
|
227
|
+
* e.g. `(_args: undefined) => Promise<...>` → `(_args?: undefined) => Promise<...>`
|
|
228
|
+
*/
|
|
229
|
+
const optionalUndefinedParamTransformer = context => {
|
|
230
|
+
return sourceFile => {
|
|
231
|
+
function visitor(node) {
|
|
232
|
+
if (typescript_1.default.isFunctionTypeNode(node)) {
|
|
233
|
+
const params = node.parameters.map(param => {
|
|
234
|
+
if (param.type &&
|
|
235
|
+
typescript_1.default.isToken(param.type) &&
|
|
236
|
+
param.type.kind === typescript_1.default.SyntaxKind.UndefinedKeyword &&
|
|
237
|
+
!param.questionToken) {
|
|
238
|
+
return typescript_1.default.factory.updateParameterDeclaration(param, param.modifiers, param.dotDotDotToken, param.name, typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.QuestionToken), param.type, param.initializer);
|
|
239
|
+
}
|
|
240
|
+
return param;
|
|
241
|
+
});
|
|
242
|
+
return typescript_1.default.factory.updateFunctionTypeNode(node, node.typeParameters, typescript_1.default.factory.createNodeArray(params), node.type);
|
|
243
|
+
}
|
|
244
|
+
return typescript_1.default.visitEachChild(node, visitor, context);
|
|
245
|
+
}
|
|
246
|
+
return typescript_1.default.visitEachChild(sourceFile, visitor, context);
|
|
247
|
+
};
|
|
248
|
+
};
|
|
249
|
+
/**
|
|
250
|
+
* Transformer #4:
|
|
226
251
|
* Resolve ExtractHandlers<T> in the _default declaration by unwrapping
|
|
227
252
|
* { handler: fn, ... } entries to just the function type.
|
|
228
253
|
* Also removes helper type definitions and the entries declaration that
|
|
@@ -316,7 +341,7 @@ const unwrapBridgeEntryTransformer = _context => {
|
|
|
316
341
|
};
|
|
317
342
|
};
|
|
318
343
|
/**
|
|
319
|
-
* Transformer #
|
|
344
|
+
* Transformer #5:
|
|
320
345
|
* Remove the rollup default export (`export { X as default }` for any X, or
|
|
321
346
|
* `export default X`). The proxy snippet provides its own default export.
|
|
322
347
|
*/
|
|
@@ -343,7 +368,7 @@ const removeDefaultExportTransformer = _context => {
|
|
|
343
368
|
};
|
|
344
369
|
};
|
|
345
370
|
/**
|
|
346
|
-
* Transformer #
|
|
371
|
+
* Transformer #6:
|
|
347
372
|
* Drop every top-level statement that is not reachable from the `TypedBridge`
|
|
348
373
|
* alias. When typed-bridge is an external dependency, rollup leaves behind stray
|
|
349
374
|
* imports (e.g. `import * as ... from 'typed-bridge/dist/tools'`) and inlined
|
|
@@ -437,6 +462,7 @@ function cleanTsFile(src) {
|
|
|
437
462
|
unwrapBridgeEntryTransformer,
|
|
438
463
|
resolveZodTypesTransformer,
|
|
439
464
|
removeSecondParamTransformer,
|
|
465
|
+
optionalUndefinedParamTransformer,
|
|
440
466
|
removeDefaultExportTransformer,
|
|
441
467
|
pruneUnreachableTransformer
|
|
442
468
|
]);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typed-bridge",
|
|
3
3
|
"description": "Type-safe server functions for TypeScript that also expose your backend as an MCP server and LLM tools for AI agents",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.1",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"author": "neilveil",
|