@hyperweb/telescope 1.15.2 → 1.17.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.
Files changed (35) hide show
  1. package/README.md +5 -5
  2. package/main/generators/create-combined-stargate-clients.js +99 -0
  3. package/main/generators/create-helpers.js +15 -8
  4. package/main/generators/create-mcp-server.js +153 -279
  5. package/main/generators/create-root-readme.js +1 -1
  6. package/main/helpers/external-icjs.js +29 -19
  7. package/main/helpers/generated-type.js +24 -0
  8. package/main/helpers/helper-func-types-interface.js +8 -8
  9. package/main/helpers/helper-func-types.js +8 -8
  10. package/main/helpers/internalForBigInt.js +248 -0
  11. package/main/helpers/types.js +24 -0
  12. package/main/helpers/vue-query.js +91 -0
  13. package/main/protod/proto-download.js +57 -0
  14. package/module/generators/create-combined-stargate-clients.js +95 -0
  15. package/module/generators/create-helpers.js +15 -8
  16. package/module/generators/create-mcp-server.js +153 -279
  17. package/module/generators/create-root-readme.js +1 -1
  18. package/module/helpers/external-icjs.js +29 -19
  19. package/module/helpers/generated-type.js +21 -0
  20. package/module/helpers/helper-func-types-interface.js +8 -8
  21. package/module/helpers/helper-func-types.js +8 -8
  22. package/module/helpers/internalForBigInt.js +245 -0
  23. package/module/helpers/types.js +21 -0
  24. package/module/helpers/vue-query.js +87 -0
  25. package/module/protod/proto-download.js +55 -0
  26. package/module/telescope.js +0 -0
  27. package/package.json +6 -6
  28. package/src/generators/create-helpers.ts +29 -16
  29. package/src/generators/create-mcp-server.ts +154 -282
  30. package/src/generators/create-root-readme.ts +1 -1
  31. package/src/helpers/external-icjs.ts +29 -19
  32. package/src/helpers/helper-func-types-interface.ts +8 -8
  33. package/src/helpers/helper-func-types.ts +8 -8
  34. package/types/codegen/cosmos/orm/module/v1alpha1/module.d.ts +43 -0
  35. package/types/helpers/external-icjs.d.ts +1 -1
@@ -0,0 +1,95 @@
1
+ import { join, dirname, relative } from 'path';
2
+ import { importNamespace, GenericParseContext, createStargateClient, createStargateClientOptions, createStargateClientProtoRegistry, createStargateClientAminoRegistry, createGetTxRpc } from '@cosmology/ast';
3
+ import { camel, pascal } from 'case';
4
+ import { duplicateImportPathsWithExt, variableSlug, toPosixPath, isPackageIncluded } from '@cosmology/utils';
5
+ import { buildAllImportsFromGenericContext } from '../imports';
6
+ import { writeAstToFile } from '../utils/files';
7
+ export const plugin = (builder, allRegistries, allConverters) => {
8
+ builder.options.rpcClients.combinedClient.map((currentClient) => {
9
+ if (!allRegistries || !allRegistries.length) {
10
+ return;
11
+ }
12
+ const registryImports = [];
13
+ const converterImports = [];
14
+ const clientFile = currentClient.fileName;
15
+ const ctxRef = {
16
+ absolute: '/',
17
+ filename: '/',
18
+ proto: {
19
+ imports: [],
20
+ package: currentClient.name,
21
+ root: {},
22
+ }
23
+ };
24
+ const ctx = new GenericParseContext(ctxRef, null, builder.options);
25
+ const registryVariables = [];
26
+ const converterVariables = [];
27
+ const filteredRegistries = allRegistries.filter(item => isPackageIncluded(item.package, currentClient.include.patterns));
28
+ filteredRegistries.forEach(registry => {
29
+ let rel = relative(dirname(clientFile), registry.localname);
30
+ if (!rel.startsWith('.'))
31
+ rel = `./${rel}`;
32
+ rel = toPosixPath(rel);
33
+ const variable = variableSlug(registry.localname);
34
+ registryVariables.push(variable);
35
+ registryImports.push(importNamespace(variable, rel));
36
+ });
37
+ const filteredConverters = allConverters.filter(item => isPackageIncluded(item.package, currentClient.include.patterns));
38
+ filteredConverters.forEach(converter => {
39
+ let rel = relative(dirname(clientFile), converter.localname);
40
+ if (!rel.startsWith('.'))
41
+ rel = `./${rel}`;
42
+ rel = toPosixPath(rel);
43
+ const variable = variableSlug(converter.localname);
44
+ converterVariables.push(variable);
45
+ converterImports.push(importNamespace(variable, rel));
46
+ });
47
+ const name = 'get' + pascal(currentClient.name + 'SigningClient');
48
+ const txRpcName = 'get' + pascal(currentClient.name + 'SigningTxRpc');
49
+ const prefix = camel(currentClient.name);
50
+ const aminos = createStargateClientAminoRegistry({
51
+ context: ctx,
52
+ aminos: converterVariables,
53
+ aminoConverters: prefix + 'AminoConverters'
54
+ });
55
+ const protos = createStargateClientProtoRegistry({
56
+ context: ctx,
57
+ registries: registryVariables,
58
+ protoTypeRegistry: prefix + 'ProtoRegistry'
59
+ });
60
+ const clientOptions = createStargateClientOptions({
61
+ context: ctx,
62
+ name: name + 'Options',
63
+ protoTypeRegistry: prefix + 'ProtoRegistry',
64
+ aminoConverters: prefix + 'AminoConverters'
65
+ });
66
+ const clientBody = createStargateClient({
67
+ context: ctx,
68
+ name,
69
+ options: name + 'Options',
70
+ });
71
+ let getTxRpc;
72
+ if (ctx.pluginValue("stargateClients.addGetTxRpc")) {
73
+ getTxRpc = createGetTxRpc(ctx, txRpcName, name);
74
+ }
75
+ const imports = buildAllImportsFromGenericContext(ctx, clientFile);
76
+ let importDecls = [...imports, ...registryImports, ...converterImports];
77
+ importDecls = duplicateImportPathsWithExt(importDecls, builder.options.restoreImportExtension);
78
+ let cProg = importDecls
79
+ .concat(aminos)
80
+ .concat(protos)
81
+ .concat(clientOptions)
82
+ .concat(clientBody);
83
+ // replace all backslash path for windows
84
+ for (let i = 0; i < cProg.length; i++) {
85
+ if (cProg[i].source?.value) {
86
+ cProg[i].source.value = toPosixPath(cProg[i].source?.value);
87
+ }
88
+ }
89
+ if (getTxRpc) {
90
+ cProg = cProg.concat(getTxRpc);
91
+ }
92
+ const clientOutFile = join(builder.outPath, clientFile);
93
+ writeAstToFile(builder.outPath, builder.options, cProg, clientOutFile);
94
+ });
95
+ };
@@ -20,22 +20,27 @@ export const plugin = (builder) => {
20
20
  ? getHelperForBigint(builder.options)
21
21
  : getHelper(builder.options));
22
22
  // should be exported
23
- if (builder.options.stargateClients.addGetTxRpc ||
24
- builder.options.includeExternalHelpers ||
25
- builder.options.reactQuery?.enabled ||
26
- builder.options?.helperFunctions?.enabled) {
23
+ if (!builder.options.isGeneratingCosmosTypes &&
24
+ (builder.options.stargateClients.addGetTxRpc ||
25
+ builder.options.includeExternalHelpers ||
26
+ builder.options.reactQuery?.enabled ||
27
+ builder.options?.helperFunctions?.enabled)) {
27
28
  // also react-query needs these...
28
29
  builder.files.push("extern.ts");
29
30
  if (builder.options?.helperFunctions?.enabled) {
30
31
  write(builder, "extern.ts", externalIcJs);
31
32
  }
32
33
  else {
33
- write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet || builder.options.rpcClients?.useMakeClient ? externalComet : external);
34
+ write(builder, "extern.ts", builder.options.rpcClients?.useConnectComet ||
35
+ builder.options.rpcClients?.useMakeClient
36
+ ? externalComet
37
+ : external);
34
38
  }
35
39
  }
36
40
  if (builder.options.helperFunctions?.enabled) {
37
41
  builder.files.push("helper-func-types.ts");
38
- if (builder.options.interfaces?.enabled && builder.options.helperFunctions?.useGlobalDecoderRegistry) {
42
+ if (builder.options.interfaces?.enabled &&
43
+ builder.options.helperFunctions?.useGlobalDecoderRegistry) {
39
44
  write(builder, "helper-func-types.ts", getHelperFuncTypesForInterface(builder.options));
40
45
  }
41
46
  else {
@@ -99,13 +104,15 @@ export const plugin = (builder) => {
99
104
  }
100
105
  if (builder.options.prototypes?.typingsFormat?.useTelescopeGeneratedType ||
101
106
  (builder.options.interfaces?.enabled &&
102
- (builder.options.interfaces?.useGlobalDecoderRegistry || builder.options.helperFunctions?.useGlobalDecoderRegistry)) ||
107
+ (builder.options.interfaces?.useGlobalDecoderRegistry ||
108
+ builder.options.helperFunctions?.useGlobalDecoderRegistry)) ||
103
109
  builder.options.helperFunctions?.enabled) {
104
110
  builder.files.push("types.ts");
105
111
  write(builder, "types.ts", getTypesHelper(builder.options));
106
112
  }
107
113
  if (builder.options.interfaces?.enabled &&
108
- (builder.options.interfaces?.useGlobalDecoderRegistry || builder.options.helperFunctions?.useGlobalDecoderRegistry)) {
114
+ (builder.options.interfaces?.useGlobalDecoderRegistry ||
115
+ builder.options.helperFunctions?.useGlobalDecoderRegistry)) {
109
116
  builder.files.push("registry.ts");
110
117
  write(builder, "registry.ts", getRegistryHelper(builder.options));
111
118
  }