typed-bridge 2.1.3 → 2.1.4

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.
@@ -124,6 +124,9 @@ const resolveZodTypesTransformer = context => {
124
124
  return resolveZodType(typeArgs[0]);
125
125
  if (name === 'ZodLiteral' && typeArgs && typeArgs.length >= 1)
126
126
  return typeArgs[0];
127
+ // v4: ZodRecord<ZodString, ZodNumber> -> Record<string, number>
128
+ if (name === 'ZodRecord' && typeArgs && typeArgs.length >= 2)
129
+ return typescript_1.default.factory.createTypeReferenceNode('Record', [resolveZodType(typeArgs[0]), resolveZodType(typeArgs[1])]);
127
130
  // v4: ZodEnum<{pending: "pending", confirmed: "confirmed", ...}>
128
131
  if (name === 'ZodEnum' && typeArgs && typeArgs.length >= 1 && typescript_1.default.isTypeLiteralNode(typeArgs[0])) {
129
132
  const types = [];
@@ -133,6 +136,9 @@ const resolveZodTypesTransformer = context => {
133
136
  }
134
137
  if (types.length > 0)
135
138
  return typescript_1.default.factory.createUnionTypeNode(types);
139
+ // ZodEnum<{[x: string]: string}> -> string (dynamic enum with index signature)
140
+ if (typeArgs[0].members.some(m => typescript_1.default.isIndexSignatureDeclaration(m)))
141
+ return typescript_1.default.factory.createKeywordTypeNode(typescript_1.default.SyntaxKind.StringKeyword);
136
142
  }
137
143
  // v4: ZodDiscriminatedUnion<[ZodObject<...>, ...], "disc">
138
144
  if (name === 'ZodDiscriminatedUnion' && typeArgs && typeArgs.length >= 1) {
@@ -173,7 +179,7 @@ const resolveZodTypesTransformer = context => {
173
179
  for (const stmt of sourceFile.statements) {
174
180
  if (typescript_1.default.isImportDeclaration(stmt) &&
175
181
  typescript_1.default.isStringLiteral(stmt.moduleSpecifier) &&
176
- (stmt.moduleSpecifier.text === 'zod' || stmt.moduleSpecifier.text.startsWith('zod/'))) {
182
+ (stmt.moduleSpecifier.text === 'zod' || stmt.moduleSpecifier.text.startsWith('zod/') || stmt.moduleSpecifier.text === 'typed-bridge')) {
177
183
  continue;
178
184
  }
179
185
  const transformed = typescript_1.default.visitEachChild(stmt, typeVisitor, context);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typed-bridge",
3
3
  "description": "Strictly typed server functions for typescript apps",
4
- "version": "2.1.3",
4
+ "version": "2.1.4",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "neilveil",