@hyperweb/telescope 1.17.2 → 1.17.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.
@@ -8,10 +8,10 @@ function getAliasedFunctionName(builder, functionName, packageName) {
8
8
  const duplicatedHelperFuncs = builder.store.getHelperFuncsInMultipleFiles();
9
9
  const isDuplicated = duplicatedHelperFuncs.includes(functionName);
10
10
  if (isDuplicated) {
11
- const serialNumber = builder.store.getAndIncTypeSerialNumber(functionName);
12
- if (serialNumber > 0) {
13
- return makeAliasNameWithPackageAtEnd({ package: packageName, name: functionName });
14
- }
11
+ return makeAliasNameWithPackageAtEnd({
12
+ package: packageName,
13
+ name: functionName,
14
+ });
15
15
  }
16
16
  return functionName;
17
17
  }
@@ -24,15 +24,15 @@ function cleanComment(comment) {
24
24
  // Remove lint directives and technical annotations
25
25
  const cleanedComment = comment
26
26
  // Remove buf:lint:ignore directives
27
- .replace(/buf:lint:ignore\s+[A-Z_]+/gi, '')
27
+ .replace(/buf:lint:ignore\s+[A-Z_]+/gi, "")
28
28
  // Remove other common lint directives
29
- .replace(/lint:ignore[:\s]+[A-Z_]+/gi, '')
29
+ .replace(/lint:ignore[:\s]+[A-Z_]+/gi, "")
30
30
  // Remove protolint directives
31
- .replace(/protolint:disable[:\s]+[A-Z_]+/gi, '')
31
+ .replace(/protolint:disable[:\s]+[A-Z_]+/gi, "")
32
32
  // Remove eslint directives
33
- .replace(/eslint-disable[:\s-]+[a-z-]+/gi, '')
33
+ .replace(/eslint-disable[:\s-]+[a-z-]+/gi, "")
34
34
  // Remove multiple consecutive spaces
35
- .replace(/\s+/g, ' ')
35
+ .replace(/\s+/g, " ")
36
36
  // Remove leading/trailing whitespace
37
37
  .trim();
38
38
  return cleanedComment;
@@ -55,7 +55,7 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
55
55
  const aliasedName = getAliasedFunctionName(builder, functionName, packageName);
56
56
  if (aliasedName !== functionName) {
57
57
  // Extract the top-level package name (e.g., 'akash' from 'akash.audit.v1beta2')
58
- const topLevelPackage = packageName.split('.')[0];
58
+ const topLevelPackage = packageName.split(".")[0];
59
59
  // Function is aliased and should be available in bundle
60
60
  return `${projectName}/${topLevelPackage}/bundle`;
61
61
  }
@@ -64,11 +64,11 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
64
64
  // This handles all functions with specific file locations
65
65
  if (sourceFilename) {
66
66
  // Remove .ts extension and convert to proper import path
67
- const filePath = sourceFilename.replace(/\.ts$/, '');
67
+ const filePath = sourceFilename.replace(/\.ts$/, "");
68
68
  return `${projectName}/${filePath}`;
69
69
  }
70
70
  // Fallback: import from the specific package path
71
- return `${projectName}/${packageName.replace(/\./g, '/')}`;
71
+ return `${projectName}/${packageName.replace(/\./g, "/")}`;
72
72
  }
73
73
  /**
74
74
  * Gets all types for a package by looking at export objects and filtering out extended forms
@@ -76,18 +76,18 @@ function getImportPath(builder, functionName, packageName, projectName, sourceFi
76
76
  function getTypesForPackage(builder, packageName) {
77
77
  const types = [];
78
78
  // Get all contexts for this package
79
- const packageContexts = builder.contexts.filter(ctx => ctx.ref.proto.package === packageName);
80
- packageContexts.forEach(context => {
79
+ const packageContexts = builder.contexts.filter((ctx) => ctx.ref.proto.package === packageName);
80
+ packageContexts.forEach((context) => {
81
81
  // Get types from this context
82
- const contextTypes = context.types.filter(type => !type.isNested);
83
- contextTypes.forEach(typeInfo => {
82
+ const contextTypes = context.types.filter((type) => !type.isNested);
83
+ contextTypes.forEach((typeInfo) => {
84
84
  const typeName = typeInfo.name;
85
85
  // Filter out extended forms (these are created during code generation but not in the types array)
86
- if (!typeName.endsWith('ProtoMsg') &&
87
- !typeName.endsWith('Amino') &&
88
- !typeName.endsWith('AminoMsg') &&
89
- !typeName.endsWith('Encoded') &&
90
- !typeName.endsWith('SDKType')) {
86
+ if (!typeName.endsWith("ProtoMsg") &&
87
+ !typeName.endsWith("Amino") &&
88
+ !typeName.endsWith("AminoMsg") &&
89
+ !typeName.endsWith("Encoded") &&
90
+ !typeName.endsWith("SDKType")) {
91
91
  // Get the actual source file from the store mapping
92
92
  const typeFiles = builder.store.getTypeFilesMapping(typeName);
93
93
  let sourceFile;
@@ -97,21 +97,22 @@ function getTypesForPackage(builder, packageName) {
97
97
  }
98
98
  else {
99
99
  // Fallback to context ref filename if not in mapping
100
- sourceFile = context.ref.filename.replace(/\.proto$/, '.ts');
100
+ sourceFile = context.ref.filename.replace(/\.proto$/, ".ts");
101
101
  }
102
102
  types.push({
103
103
  name: typeName,
104
- sourceFile
104
+ sourceFile,
105
105
  });
106
106
  }
107
107
  });
108
108
  });
109
109
  // Remove duplicates and sort
110
- const uniqueTypes = types.filter((type, index, self) => index === self.findIndex(t => t.name === type.name));
110
+ const uniqueTypes = types.filter((type, index, self) => index === self.findIndex((t) => t.name === type.name));
111
111
  return uniqueTypes.sort((a, b) => a.name.localeCompare(b.name));
112
112
  }
113
113
  export const plugin = (builder) => {
114
- if (!builder.options?.readme?.enabled && !builder.options?.mcpServer?.enabled) {
114
+ if (!builder.options?.readme?.enabled &&
115
+ !builder.options?.mcpServer?.enabled) {
115
116
  return;
116
117
  }
117
118
  const readmePath = join(builder.outPath, "README.md");
@@ -120,7 +121,9 @@ export const plugin = (builder) => {
120
121
  const functionMappings = builder.getFunctionMappings();
121
122
  // Generate package documentation
122
123
  let packageDocs = "";
123
- Object.keys(functionMappings).sort().forEach(packageName => {
124
+ Object.keys(functionMappings)
125
+ .sort()
126
+ .forEach((packageName) => {
124
127
  const packageServices = functionMappings[packageName];
125
128
  // Check if package has any methods before adding it
126
129
  const hasQueryMethods = packageServices.Query && Object.keys(packageServices.Query).length > 0;
@@ -135,10 +138,10 @@ export const plugin = (builder) => {
135
138
  packageDocs += `### Types\n\n`;
136
139
  packageDocs += `| Type | Name | Source |\n`;
137
140
  packageDocs += `| --- | --- | --- |\n`;
138
- types.forEach(type => {
141
+ types.forEach((type) => {
139
142
  packageDocs += `| Type | \`${type.name}\` | [View source ↗](${type.sourceFile}) |\n`;
140
143
  });
141
- packageDocs += '\n';
144
+ packageDocs += "\n";
142
145
  }
143
146
  // Query section
144
147
  if (packageServices.Query) {
@@ -156,7 +159,9 @@ export const plugin = (builder) => {
156
159
  }
157
160
  // Add import code block
158
161
  const functionImportPath = getImportPath(builder, method.functionName, packageName, projectName, method.sourceFilename);
159
- const hookImportPath = method.hookName ? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename) : functionImportPath;
162
+ const hookImportPath = method.hookName
163
+ ? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename)
164
+ : functionImportPath;
160
165
  packageDocs += `\`\`\`ts\n`;
161
166
  packageDocs += `import { ${aliasedFunctionName} } from '${functionImportPath}'\n`;
162
167
  if (method.hookName && aliasedHookName !== aliasedFunctionName) {
@@ -167,29 +172,33 @@ export const plugin = (builder) => {
167
172
  packageDocs += `| Field | Value | Source |\n`;
168
173
  packageDocs += `| --- | --- | --- |\n`;
169
174
  // Function source
170
- const functionSourcePath = method.sourceFilename || `${packageName.replace(/\./g, '/')}/query.rpc.func.ts`;
175
+ const functionSourcePath = method.sourceFilename ||
176
+ `${packageName.replace(/\./g, "/")}/query.rpc.func.ts`;
171
177
  packageDocs += `| Function | \`${aliasedFunctionName}\` | [View source ↗](${functionSourcePath}) |\n`;
172
178
  // Hook source (React)
173
179
  if (method.hookName && aliasedHookName !== aliasedFunctionName) {
174
- const hookSourcePath = method.hookSourceFilename || `${packageName.replace(/\./g, '/')}/query.rpc.react.ts`;
180
+ const hookSourcePath = method.hookSourceFilename ||
181
+ `${packageName.replace(/\./g, "/")}/query.rpc.react.ts`;
175
182
  packageDocs += `| Hook | \`${aliasedHookName}\` | [View source ↗](${hookSourcePath}) |\n`;
176
183
  }
177
184
  // Request type source
178
185
  if (method.requestType) {
179
- const requestSourcePath = method.typeSourceFilename || `${packageName.replace(/\./g, '/')}/query.ts`;
186
+ const requestSourcePath = method.typeSourceFilename ||
187
+ `${packageName.replace(/\./g, "/")}/query.ts`;
180
188
  packageDocs += `| Request | \`${method.requestType}\` | [View source ↗](${requestSourcePath}) |\n`;
181
189
  }
182
190
  // Response type source
183
191
  if (method.responseType) {
184
- const responseSourcePath = method.typeSourceFilename || `${packageName.replace(/\./g, '/')}/query.ts`;
192
+ const responseSourcePath = method.typeSourceFilename ||
193
+ `${packageName.replace(/\./g, "/")}/query.ts`;
185
194
  packageDocs += `| Response | \`${method.responseType}\` | [View source ↗](${responseSourcePath}) |\n`;
186
195
  }
187
196
  // Add spacing between methods (but not after the last one)
188
197
  if (index < queryMethods.length - 1) {
189
- packageDocs += '\n---\n\n';
198
+ packageDocs += "\n---\n\n";
190
199
  }
191
200
  else {
192
- packageDocs += '\n';
201
+ packageDocs += "\n";
193
202
  }
194
203
  });
195
204
  }
@@ -209,7 +218,9 @@ export const plugin = (builder) => {
209
218
  }
210
219
  // Add import code block
211
220
  const functionImportPath = getImportPath(builder, method.functionName, packageName, projectName, method.sourceFilename);
212
- const hookImportPath = method.hookName ? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename) : functionImportPath;
221
+ const hookImportPath = method.hookName
222
+ ? getImportPath(builder, method.hookName, packageName, projectName, method.hookSourceFilename)
223
+ : functionImportPath;
213
224
  packageDocs += `\`\`\`ts\n`;
214
225
  packageDocs += `import { ${aliasedFunctionName} } from '${functionImportPath}'\n`;
215
226
  if (method.hookName && aliasedHookName !== aliasedFunctionName) {
@@ -220,34 +231,38 @@ export const plugin = (builder) => {
220
231
  packageDocs += `| Field | Value | Source |\n`;
221
232
  packageDocs += `| --- | --- | --- |\n`;
222
233
  // Function source
223
- const functionSourcePath = method.sourceFilename || `${packageName.replace(/\./g, '/')}/tx.rpc.func.ts`;
234
+ const functionSourcePath = method.sourceFilename ||
235
+ `${packageName.replace(/\./g, "/")}/tx.rpc.func.ts`;
224
236
  packageDocs += `| Function | \`${aliasedFunctionName}\` | [View source ↗](${functionSourcePath}) |\n`;
225
237
  // Hook source (React)
226
238
  if (method.hookName && aliasedHookName !== aliasedFunctionName) {
227
- const hookSourcePath = method.hookSourceFilename || `${packageName.replace(/\./g, '/')}/tx.rpc.react.ts`;
239
+ const hookSourcePath = method.hookSourceFilename ||
240
+ `${packageName.replace(/\./g, "/")}/tx.rpc.react.ts`;
228
241
  packageDocs += `| Hook | \`${aliasedHookName}\` | [View source ↗](${hookSourcePath}) |\n`;
229
242
  }
230
243
  // Request type source
231
244
  if (method.requestType) {
232
- const requestSourcePath = method.typeSourceFilename || `${packageName.replace(/\./g, '/')}/tx.ts`;
245
+ const requestSourcePath = method.typeSourceFilename ||
246
+ `${packageName.replace(/\./g, "/")}/tx.ts`;
233
247
  packageDocs += `| Request | \`${method.requestType}\` | [View source ↗](${requestSourcePath}) |\n`;
234
248
  }
235
249
  // Response type source
236
250
  if (method.responseType) {
237
- const responseSourcePath = method.typeSourceFilename || `${packageName.replace(/\./g, '/')}/tx.ts`;
251
+ const responseSourcePath = method.typeSourceFilename ||
252
+ `${packageName.replace(/\./g, "/")}/tx.ts`;
238
253
  packageDocs += `| Response | \`${method.responseType}\` | [View source ↗](${responseSourcePath}) |\n`;
239
254
  }
240
255
  // Add spacing between methods (but not after the last one)
241
256
  if (index < msgMethods.length - 1) {
242
- packageDocs += '\n---\n\n';
257
+ packageDocs += "\n---\n\n";
243
258
  }
244
259
  else {
245
- packageDocs += '\n';
260
+ packageDocs += "\n";
246
261
  }
247
262
  });
248
263
  }
249
264
  // Add spacing between packages
250
- packageDocs += '\n';
265
+ packageDocs += "\n";
251
266
  });
252
267
  const readmeContent = `# Package Documentation
253
268
  ${packageDocs}`;
@@ -5,8 +5,8 @@ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExten
5
5
  import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
6
6
  import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
7
  import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
8
- import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
9
- import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
8
+ import { toConverters, toEncoders } from "@interchainjs/cosmos";
9
+ import { ISigningClient } from "@interchainjs/cosmos";` : ''}
10
10
 
11
11
  export interface QueryBuilderOptions<TReq, TRes> {
12
12
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -5,8 +5,8 @@ import { BinaryReader, BinaryWriter } from "./binary${options.restoreImportExten
5
5
  import { getRpcClient } from "./extern${options.restoreImportExtension ?? ""}";` : ''}
6
6
  import { isRpc, Rpc } from "./helpers${options.restoreImportExtension ?? ""}";${!options.isGeneratingCosmosTypes ? `
7
7
  import { TelescopeGeneratedCodec, DeliverTxResponse, Message, StdFee } from "./types${options.restoreImportExtension ?? ""}";` : ''}${!options.isGeneratingCosmosTypes ? `
8
- import { toConverters, toEncoders } from "@interchainjs/cosmos/utils";
9
- import { ISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";` : ''}
8
+ import { toConverters, toEncoders } from "@interchainjs/cosmos";
9
+ import { ISigningClient } from "@interchainjs/cosmos";` : ''}
10
10
 
11
11
  export interface QueryBuilderOptions<TReq, TRes> {
12
12
  encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -1,6 +1,6 @@
1
1
  export const getHelperForBigint = (options) => {
2
2
  return `${options.useInterchainJs ?
3
- 'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
3
+ 'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding\';' :
4
4
  `declare var self: any | undefined;
5
5
  declare var window: any | undefined;
6
6
  declare var global: any | undefined;
@@ -12,7 +12,7 @@ if (_m0.util.Long !== Long) {
12
12
  export { Long };
13
13
 
14
14
  ${options.useInterchainJs ?
15
- 'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding/base64\';' :
15
+ 'export { fromBase64 as bytesFromBase64, toBase64 as base64FromBytes } from \'@interchainjs/encoding\';' :
16
16
  `declare var self: any | undefined;
17
17
  declare var window: any | undefined;
18
18
  declare var global: any | undefined;
@@ -9,7 +9,7 @@ import {
9
9
  ITxArgs,
10
10
  EndpointOrRpc,
11
11
  } from './helper-func-types${options.restoreImportExtension ?? ""}'
12
- import { ISigningClient, isISigningClient } from "@interchainjs/cosmos/types/signing-client${options.restoreImportExtension ?? ""}";
12
+ import { ISigningClient, isISigningClient } from "@interchainjs/cosmos";
13
13
  import {
14
14
  StdFee,
15
15
  DeliverTxResponse,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperweb/telescope",
3
- "version": "1.17.2",
3
+ "version": "1.17.4",
4
4
  "description": "A TypeScript Transpiler for Cosmos Protobufs",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/hyperweb-io/telescope/tree/master/packages/telescope#readme",
@@ -90,10 +90,10 @@
90
90
  "@babel/parser": "^7.23.6",
91
91
  "@babel/traverse": "7.23.6",
92
92
  "@babel/types": "7.23.6",
93
- "@cosmology/ast": "^1.12.1",
94
- "@cosmology/proto-parser": "^1.11.1",
95
- "@cosmology/types": "^1.13.1",
96
- "@cosmology/utils": "^1.11.1",
93
+ "@cosmology/ast": "^1.12.2",
94
+ "@cosmology/proto-parser": "^1.11.2",
95
+ "@cosmology/types": "^1.13.2",
96
+ "@cosmology/utils": "^1.11.2",
97
97
  "@cosmwasm/ts-codegen": "0.35.7",
98
98
  "@types/parse-package-name": "0.1.0",
99
99
  "case": "1.6.3",
@@ -111,5 +111,5 @@
111
111
  "rimraf": "5.0.0",
112
112
  "yaml": "^2.3.4"
113
113
  },
114
- "gitHead": "40a4298beb51c0a2f7bfb5d44c53c5c49d121632"
114
+ "gitHead": "21d41a6bf946480c10d5e5c18b76a680f40164e8"
115
115
  }
@@ -5,7 +5,43 @@ import {
5
5
  exportTypesWithAlias,
6
6
  recursiveModuleBundle,
7
7
  } from "@cosmology/ast";
8
- import { duplicateImportPathsWithExt, makeAliasName, makeAliasNameWithPackageAtEnd } from "@cosmology/utils";
8
+ import {
9
+ duplicateImportPathsWithExt,
10
+ makeAliasName,
11
+ makeAliasNameWithPackageAtEnd,
12
+ } from "@cosmology/utils";
13
+
14
+ /**
15
+ * Process noAlias configuration to create a map of names to their first package
16
+ * This ensures that only the first occurrence of a name skips aliasing
17
+ */
18
+ const processNoAliasConfig = (noAlias?: Array<{ package: string; name: string }>) => {
19
+ if (!noAlias || noAlias.length === 0) {
20
+ return new Map<string, string>();
21
+ }
22
+
23
+ const nameToFirstPackage = new Map<string, string>();
24
+
25
+ for (const entry of noAlias) {
26
+ if (!nameToFirstPackage.has(entry.name)) {
27
+ nameToFirstPackage.set(entry.name, entry.package);
28
+ }
29
+ }
30
+
31
+ return nameToFirstPackage;
32
+ };
33
+
34
+ /**
35
+ * Check if a package/name combination should skip aliasing
36
+ */
37
+ const shouldSkipAlias = (
38
+ pkg: string,
39
+ name: string,
40
+ nameToFirstPackage: Map<string, string>
41
+ ): boolean => {
42
+ const firstPackage = nameToFirstPackage.get(name);
43
+ return firstPackage === pkg;
44
+ };
9
45
 
10
46
  export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
11
47
  if (!builder.options.bundle.enabled) {
@@ -14,6 +50,9 @@ export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
14
50
 
15
51
  let prog = [];
16
52
 
53
+ // Process noAlias configuration once at the beginning
54
+ const nameToFirstPackage = processNoAliasConfig((builder.options.bundle as any).noAlias);
55
+
17
56
  if (builder.options.bundle.type === "namespace") {
18
57
  const importPaths = duplicateImportPathsWithExt(
19
58
  bundler.bundle.importPaths,
@@ -56,29 +95,36 @@ export const plugin = (builder: TelescopeBuilder, bundler: Bundler) => {
56
95
  );
57
96
  if (duplicatedTypeNames.length > 0) {
58
97
  // export each, some duplicated with alias
59
- const typesWithAlias = exportObj.exportedIdentifiers.map((identifier) => {
60
- const duplicatedType = duplicatedTypeNames.find((type) => type === identifier);
61
- if (duplicatedType) {
62
- let alias: string;
63
- if (exportObj.isHelperFunc) {
64
- const serialNumber = builder.store.getAndIncTypeSerialNumber(identifier);
65
- if (serialNumber > 0) {
66
- alias = makeAliasNameWithPackageAtEnd({ package: exportObj.pkg, name: identifier });
67
- } else {
68
- alias = identifier;
69
- }
70
- } else {
71
- const serialNumber = builder.store.getAndIncTypeSerialNumber(identifier);
72
- if (serialNumber > 0) {
73
- alias = makeAliasName({ package: exportObj.pkg, name: identifier });
98
+ const typesWithAlias = exportObj.exportedIdentifiers.map(
99
+ (identifier) => {
100
+ const duplicatedType = duplicatedTypeNames.find(
101
+ (type) => type === identifier
102
+ );
103
+ if (duplicatedType) {
104
+ let alias: string;
105
+
106
+ // Check if this package/name combination should skip aliasing
107
+ if (shouldSkipAlias(exportObj.pkg, identifier, nameToFirstPackage)) {
108
+ alias = identifier; // Use original name, no alias
74
109
  } else {
75
- alias = identifier;
110
+ // Generate alias as usual
111
+ if (exportObj.isHelperFunc) {
112
+ alias = makeAliasNameWithPackageAtEnd({
113
+ package: exportObj.pkg,
114
+ name: identifier,
115
+ });
116
+ } else {
117
+ alias = makeAliasName({
118
+ package: exportObj.pkg,
119
+ name: identifier,
120
+ });
121
+ }
76
122
  }
123
+ return { name: identifier, alias: alias };
77
124
  }
78
- return { name: identifier, alias: alias };
125
+ return { name: identifier, alias: identifier };
79
126
  }
80
- return { name: identifier, alias: identifier };
81
- });
127
+ );
82
128
  prog.push(exportTypesWithAlias(typesWithAlias, exportObj.relativePath));
83
129
  } else {
84
130
  // export *