diff --git a/README.md b/README.md index 57c197214a..6d79c595a4 100644 --- a/README.md +++ b/README.md @@ -320,6 +320,8 @@ See [RPC Clients](#rpc-clients) for more info. | `prototypes.typingsFormat.useExact` | defaults to false, but if enabled uses the `Exact` TS type | `false` | | `prototypes.typingsFormat.timestamp` | use either `date` or `timestamp` for `Timestamp` proto type | "date" | | `prototypes.typingsFormat.duration` | use either `duration` or `string` for `Duration` proto type | "duration"| +| `prototypes.typingsFormat.setDefaultEnumToUnrecognized` | false: enum empty value would be 0, true: -1(value for enum unrecognized) |true| +| `prototypes.typingsFormat.setDefaultCustomTypesToUndefined` | true: Timestamp,Duration,Any,Coin empty value would be undefined., false: using fromPartial to get an empty obj |false| ### Protobuf parser @@ -720,7 +722,7 @@ Below will be an example of scaffold a `grant` Proto Msg for grpc-web and grpc-g const signed_tx = await signClient.sign('granter_address', [msg], fee, 'telescope: grant', signerData); const txRawBytes = Uint8Array.from(TxRaw.encode(signed_tx).finish()); - const res = await client.cosmos.tx.v1beta1.broadcastTx( + const res = await client.cosmos.tx.v1beta1.broadcastTx( { txBytes: txRawBytes, mode: BroadcastMode.BROADCAST_MODE_BLOCK diff --git a/__fixtures__/output1/helpers.ts b/__fixtures__/output1/helpers.ts index 8658b32ada..d14762f911 100644 --- a/__fixtures__/output1/helpers.ts +++ b/__fixtures__/output1/helpers.ts @@ -140,7 +140,7 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) = } if (typeof pagination?.key !== "undefined") { // String to Uint8Array - // let uint8arr = new Uint8Array(Buffer.from(data,'base64')); + // let uint8arr = new Uint8Array(Buffer.from(data,'base64')); // Uint8Array to String options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64'); diff --git a/__fixtures__/output2/helpers.ts b/__fixtures__/output2/helpers.ts index 9d0f745204..cd20308db2 100644 --- a/__fixtures__/output2/helpers.ts +++ b/__fixtures__/output2/helpers.ts @@ -142,7 +142,7 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) = } if (typeof pagination?.key !== "undefined") { // String to Uint8Array - // let uint8arr = new Uint8Array(Buffer.from(data,'base64')); + // let uint8arr = new Uint8Array(Buffer.from(data,'base64')); // Uint8Array to String options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64'); diff --git a/__fixtures__/v-next/outputosmojs/akash/cert/v1beta2/query.pinia.store.ts b/__fixtures__/v-next/outputosmojs/akash/cert/v1beta2/query.pinia.store.ts index 68c2ce0e1e..2638dce5ad 100644 --- a/__fixtures__/v-next/outputosmojs/akash/cert/v1beta2/query.pinia.store.ts +++ b/__fixtures__/v-next/outputosmojs/akash/cert/v1beta2/query.pinia.store.ts @@ -18,7 +18,7 @@ export const usePiniaStore = defineStore('akash/cert/v1beta2/query.proto', { } }, actions: { - async fetchCertificates(param: QueryCertificatesRequestSDKType) { + async fetchCertificates(param : QueryCertificatesRequestSDKType) { this.certificates = await this.lcdClient.certificates(param); return this.certificates; } diff --git a/__fixtures__/v-next/outputosmojs/binary.ts b/__fixtures__/v-next/outputosmojs/binary.ts index e36065aa4b..f8751d571c 100644 --- a/__fixtures__/v-next/outputosmojs/binary.ts +++ b/__fixtures__/v-next/outputosmojs/binary.ts @@ -348,12 +348,12 @@ export class BinaryWriter { (value = value >>> 0) < 128 ? 1 : value < 16384 - ? 2 - : value < 2097152 - ? 3 - : value < 268435456 - ? 4 - : 5, + ? 2 + : value < 2097152 + ? 3 + : value < 268435456 + ? 4 + : 5, value )).len; return this; @@ -463,10 +463,10 @@ function pool( function indexOutOfRange(reader: BinaryReader, writeLength?: number) { return RangeError( "index out of range: " + - reader.pos + - " + " + - (writeLength || 1) + - " > " + - reader.len + reader.pos + + " + " + + (writeLength || 1) + + " > " + + reader.len ); } diff --git a/__fixtures__/v-next/outputosmojs/evmos/erc20/v1/query.pinia.store.ts b/__fixtures__/v-next/outputosmojs/evmos/erc20/v1/query.pinia.store.ts index 8949ba1a68..47e7006eac 100644 --- a/__fixtures__/v-next/outputosmojs/evmos/erc20/v1/query.pinia.store.ts +++ b/__fixtures__/v-next/outputosmojs/evmos/erc20/v1/query.pinia.store.ts @@ -21,15 +21,15 @@ export const usePiniaStore = defineStore('evmos/erc20/v1/query.proto', { } }, actions: { - async fetchTokenPairs(param: QueryTokenPairsRequestSDKType) { + async fetchTokenPairs(param : QueryTokenPairsRequestSDKType) { this.tokenPairs = await this.lcdClient.tokenPairs(param); return this.tokenPairs; }, - async fetchTokenPair(param: QueryTokenPairRequestSDKType) { + async fetchTokenPair(param : QueryTokenPairRequestSDKType) { this.tokenPair = await this.lcdClient.tokenPair(param); return this.tokenPair; }, - async fetchParams(param: QueryParamsRequestSDKType) { + async fetchParams(param : QueryParamsRequestSDKType) { this.params = await this.lcdClient.params(param); return this.params; } diff --git a/__fixtures__/v-next/outputosmojs/helpers.ts b/__fixtures__/v-next/outputosmojs/helpers.ts index 7bfab7552c..f92d2b935a 100644 --- a/__fixtures__/v-next/outputosmojs/helpers.ts +++ b/__fixtures__/v-next/outputosmojs/helpers.ts @@ -182,9 +182,9 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & Record< - Exclude>, - never - >; + Exclude>, + never + >; export interface Rpc { request( diff --git a/__fixtures__/v-next/outputosmojs/index.ts b/__fixtures__/v-next/outputosmojs/index.ts index dc53658195..3c5f68131c 100644 --- a/__fixtures__/v-next/outputosmojs/index.ts +++ b/__fixtures__/v-next/outputosmojs/index.ts @@ -3,7 +3,7 @@ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or yarn proto command to regenerate this bundle. */ - + export * from "./akash/bundle"; export * from "./akash/client"; export * from "./ics23/bundle"; diff --git a/__fixtures__/v-next/outputosmojs/osmosis/gamm/v1beta1/query.pinia.store.ts b/__fixtures__/v-next/outputosmojs/osmosis/gamm/v1beta1/query.pinia.store.ts index 1d793b645e..ec9c29e017 100644 --- a/__fixtures__/v-next/outputosmojs/osmosis/gamm/v1beta1/query.pinia.store.ts +++ b/__fixtures__/v-next/outputosmojs/osmosis/gamm/v1beta1/query.pinia.store.ts @@ -34,63 +34,63 @@ export const usePiniaStore = defineStore('osmosis/gamm/v1beta1/query.proto', { } }, actions: { - async fetchPools(param: QueryPoolsRequestSDKType) { + async fetchPools(param : QueryPoolsRequestSDKType) { this.pools = await this.lcdClient.pools(param); return this.pools; }, - async fetchNumPools(param: QueryNumPoolsRequestSDKType) { + async fetchNumPools(param : QueryNumPoolsRequestSDKType) { this.numPools = await this.lcdClient.numPools(param); return this.numPools; }, - async fetchTotalLiquidity(param: QueryTotalLiquidityRequestSDKType) { + async fetchTotalLiquidity(param : QueryTotalLiquidityRequestSDKType) { this.totalLiquidity = await this.lcdClient.totalLiquidity(param); return this.totalLiquidity; }, - async fetchPoolsWithFilter(param: QueryPoolsWithFilterRequestSDKType) { + async fetchPoolsWithFilter(param : QueryPoolsWithFilterRequestSDKType) { this.poolsWithFilter = await this.lcdClient.poolsWithFilter(param); return this.poolsWithFilter; }, - async fetchPool(param: QueryPoolRequestSDKType) { + async fetchPool(param : QueryPoolRequestSDKType) { this.pool = await this.lcdClient.pool(param); return this.pool; }, - async fetchPoolType(param: QueryPoolTypeRequestSDKType) { + async fetchPoolType(param : QueryPoolTypeRequestSDKType) { this.poolType = await this.lcdClient.poolType(param); return this.poolType; }, - async fetchCalcJoinPoolNoSwapShares(param: QueryCalcJoinPoolNoSwapSharesRequestSDKType) { + async fetchCalcJoinPoolNoSwapShares(param : QueryCalcJoinPoolNoSwapSharesRequestSDKType) { this.calcJoinPoolNoSwapShares = await this.lcdClient.calcJoinPoolNoSwapShares(param); return this.calcJoinPoolNoSwapShares; }, - async fetchCalcJoinPoolShares(param: QueryCalcJoinPoolSharesRequestSDKType) { + async fetchCalcJoinPoolShares(param : QueryCalcJoinPoolSharesRequestSDKType) { this.calcJoinPoolShares = await this.lcdClient.calcJoinPoolShares(param); return this.calcJoinPoolShares; }, - async fetchCalcExitPoolCoinsFromShares(param: QueryCalcExitPoolCoinsFromSharesRequestSDKType) { + async fetchCalcExitPoolCoinsFromShares(param : QueryCalcExitPoolCoinsFromSharesRequestSDKType) { this.calcExitPoolCoinsFromShares = await this.lcdClient.calcExitPoolCoinsFromShares(param); return this.calcExitPoolCoinsFromShares; }, - async fetchPoolParams(param: QueryPoolParamsRequestSDKType) { + async fetchPoolParams(param : QueryPoolParamsRequestSDKType) { this.poolParams = await this.lcdClient.poolParams(param); return this.poolParams; }, - async fetchTotalPoolLiquidity(param: QueryTotalPoolLiquidityRequestSDKType) { + async fetchTotalPoolLiquidity(param : QueryTotalPoolLiquidityRequestSDKType) { this.totalPoolLiquidity = await this.lcdClient.totalPoolLiquidity(param); return this.totalPoolLiquidity; }, - async fetchTotalShares(param: QueryTotalSharesRequestSDKType) { + async fetchTotalShares(param : QueryTotalSharesRequestSDKType) { this.totalShares = await this.lcdClient.totalShares(param); return this.totalShares; }, - async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) { + async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) { this.spotPrice = await this.lcdClient.spotPrice(param); return this.spotPrice; }, - async fetchEstimateSwapExactAmountIn(param: QuerySwapExactAmountInRequestSDKType) { + async fetchEstimateSwapExactAmountIn(param : QuerySwapExactAmountInRequestSDKType) { this.estimateSwapExactAmountIn = await this.lcdClient.estimateSwapExactAmountIn(param); return this.estimateSwapExactAmountIn; }, - async fetchEstimateSwapExactAmountOut(param: QuerySwapExactAmountOutRequestSDKType) { + async fetchEstimateSwapExactAmountOut(param : QuerySwapExactAmountOutRequestSDKType) { this.estimateSwapExactAmountOut = await this.lcdClient.estimateSwapExactAmountOut(param); return this.estimateSwapExactAmountOut; } diff --git a/__fixtures__/v-next/outputosmojs/osmosis/gamm/v2/query.pinia.store.ts b/__fixtures__/v-next/outputosmojs/osmosis/gamm/v2/query.pinia.store.ts index 0953a7c89e..8ccee9dc1f 100644 --- a/__fixtures__/v-next/outputosmojs/osmosis/gamm/v2/query.pinia.store.ts +++ b/__fixtures__/v-next/outputosmojs/osmosis/gamm/v2/query.pinia.store.ts @@ -16,7 +16,7 @@ export const usePiniaStore = defineStore('osmosis/gamm/v2/query.proto', { } }, actions: { - async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) { + async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) { this.spotPrice = await this.lcdClient.spotPrice(param); return this.spotPrice; } diff --git a/__fixtures__/v-next/outputosmojs/varint.ts b/__fixtures__/v-next/outputosmojs/varint.ts index ae2e63b3b2..a83418dbc0 100644 --- a/__fixtures__/v-next/outputosmojs/varint.ts +++ b/__fixtures__/v-next/outputosmojs/varint.ts @@ -454,18 +454,18 @@ export function int64Length(lo: number, hi: number) { ? 1 : 2 : part0 < 2097152 - ? 3 - : 4 + ? 3 + : 4 : part1 < 16384 - ? part1 < 128 - ? 5 - : 6 - : part1 < 2097152 - ? 7 - : 8 + ? part1 < 128 + ? 5 + : 6 + : part1 < 2097152 + ? 7 + : 8 : part2 < 128 - ? 9 - : 10; + ? 9 + : 10; } export function writeFixed32( diff --git a/__fixtures__/v-next/outputv2/helpers.ts b/__fixtures__/v-next/outputv2/helpers.ts index 8658b32ada..53124a848b 100644 --- a/__fixtures__/v-next/outputv2/helpers.ts +++ b/__fixtures__/v-next/outputv2/helpers.ts @@ -146,11 +146,11 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) = options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64'); } if (typeof pagination?.limit !== "undefined") { - options.params["pagination.limit"] = pagination.limit.toString() + options.params["pagination.limit"] = pagination.limit.toString() } if (typeof pagination?.offset !== "undefined") { - options.params["pagination.offset"] = pagination.offset.toString() - } + options.params["pagination.offset"] = pagination.offset.toString() + } if (typeof pagination?.reverse !== "undefined") { options.params['pagination.reverse'] = pagination.reverse; } @@ -221,22 +221,22 @@ const fromJSON = (object: any): Timestamp => { }; const timestampFromJSON = (object: any): Timestamp => { - return { - seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, - }; + return { + seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; } - + export function fromJsonTimestamp(o: any): Timestamp { - if (o instanceof Date) { - return toTimestamp(o); - } else if (typeof o === "string") { - return toTimestamp(new Date(o)); - } else { - return timestampFromJSON(o); - } + if (o instanceof Date) { + return toTimestamp(o); + } else if (typeof o === "string") { + return toTimestamp(new Date(o)); + } else { + return timestampFromJSON(o); + } } - + function numberToLong(number: number) { return Long.fromNumber(number); } diff --git a/__fixtures__/v-next/outputv2/index.ts b/__fixtures__/v-next/outputv2/index.ts index 54aac3212c..86bee137e0 100644 --- a/__fixtures__/v-next/outputv2/index.ts +++ b/__fixtures__/v-next/outputv2/index.ts @@ -3,7 +3,7 @@ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or yarn proto command to regenerate this bundle. */ - + export * from "./akash/bundle"; export * from "./akash/client"; export * from "./ics23/bundle"; diff --git a/__fixtures__/v-next/outputv3/grpc-gateway.ts b/__fixtures__/v-next/outputv3/grpc-gateway.ts index 9a1da6a8ef..a7d79a8b24 100644 --- a/__fixtures__/v-next/outputv3/grpc-gateway.ts +++ b/__fixtures__/v-next/outputv3/grpc-gateway.ts @@ -18,10 +18,10 @@ const s64 = new Array(123); // 65..90, 97..122, 48..57, 43, 47 for (let i = 0; i < 64;) - s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; + s64[b64[i] = i < 26 ? i + 65 : i < 52 ? i + 71 : i < 62 ? i - 4 : i - 59 | 43] = i++; export function b64Encode(buffer: Uint8Array, start: number, end: number): string { - let parts: string[] = null; + let parts: string[] = null; const chunk = []; let i = 0, // output index j = 0, // goto index @@ -67,16 +67,16 @@ export function b64Encode(buffer: Uint8Array, start: number, end: number): strin const invalidEncoding = "invalid encoding"; export function b64Decode(s: string): Uint8Array { - const buffer = []; - let offset = 0; + const buffer = []; + let offset = 0; let j = 0, // goto index - t; // temporary + t; // temporary for (let i = 0; i < s.length;) { let c = s.charCodeAt(i++); if (c === 61 && j > 1) - break; + break; if ((c = s64[c]) === undefined) - throw Error(invalidEncoding); + throw Error(invalidEncoding); switch (j) { case 0: t = c; @@ -99,12 +99,12 @@ export function b64Decode(s: string): Uint8Array { } } if (j === 1) - throw Error(invalidEncoding); + throw Error(invalidEncoding); return new Uint8Array(buffer); } function b64Test(s: string): boolean { - return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s); + return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(s); } export interface InitReq extends RequestInit { @@ -112,7 +112,7 @@ export interface InitReq extends RequestInit { } export function replacer(key: any, value: any): any { - if (value && value.constructor === Uint8Array) { + if(value && value.constructor === Uint8Array) { return b64Encode(value, 0, value.length); } @@ -120,7 +120,7 @@ export function replacer(key: any, value: any): any { } export function fetchReq(path: string, init?: InitReq): Promise { - const { pathPrefix, ...req } = init || {} + const {pathPrefix, ...req} = init || {} const url = pathPrefix ? `${pathPrefix}${path}` : path @@ -139,7 +139,7 @@ export type NotifyStreamEntityArrival = (resp: T) => void * all entities will be returned as an array after the call finishes. **/ export async function fetchStreamingRequest(path: string, callback?: NotifyStreamEntityArrival, init?: InitReq) { - const { pathPrefix, ...req } = init || {} + const {pathPrefix, ...req} = init || {} const url = pathPrefix ? `${pathPrefix}${path}` : path const result = await fetch(url, req) // needs to use the .ok to check the status of HTTP status code diff --git a/__fixtures__/v-next/outputv3/helpers.ts b/__fixtures__/v-next/outputv3/helpers.ts index 8658b32ada..53124a848b 100644 --- a/__fixtures__/v-next/outputv3/helpers.ts +++ b/__fixtures__/v-next/outputv3/helpers.ts @@ -146,11 +146,11 @@ export const setPaginationParams = (options: Params, pagination?: PageRequest) = options.params['pagination.key'] = Buffer.from(pagination.key).toString('base64'); } if (typeof pagination?.limit !== "undefined") { - options.params["pagination.limit"] = pagination.limit.toString() + options.params["pagination.limit"] = pagination.limit.toString() } if (typeof pagination?.offset !== "undefined") { - options.params["pagination.offset"] = pagination.offset.toString() - } + options.params["pagination.offset"] = pagination.offset.toString() + } if (typeof pagination?.reverse !== "undefined") { options.params['pagination.reverse'] = pagination.reverse; } @@ -221,22 +221,22 @@ const fromJSON = (object: any): Timestamp => { }; const timestampFromJSON = (object: any): Timestamp => { - return { - seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, - nanos: isSet(object.nanos) ? Number(object.nanos) : 0, - }; + return { + seconds: isSet(object.seconds) ? Long.fromValue(object.seconds) : Long.ZERO, + nanos: isSet(object.nanos) ? Number(object.nanos) : 0, + }; } - + export function fromJsonTimestamp(o: any): Timestamp { - if (o instanceof Date) { - return toTimestamp(o); - } else if (typeof o === "string") { - return toTimestamp(new Date(o)); - } else { - return timestampFromJSON(o); - } + if (o instanceof Date) { + return toTimestamp(o); + } else if (typeof o === "string") { + return toTimestamp(new Date(o)); + } else { + return timestampFromJSON(o); + } } - + function numberToLong(number: number) { return Long.fromNumber(number); } diff --git a/__fixtures__/v-next/outputv3/index.ts b/__fixtures__/v-next/outputv3/index.ts index 37c43a6886..a9b781e874 100644 --- a/__fixtures__/v-next/outputv3/index.ts +++ b/__fixtures__/v-next/outputv3/index.ts @@ -3,7 +3,7 @@ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or yarn proto command to regenerate this bundle. */ - + export * from "./akash/bundle"; export * from "./akash/client"; export * from "./ics23/bundle"; diff --git a/__fixtures__/v-next/outputv4/akash/cert/v1beta2/query.pinia.store.ts b/__fixtures__/v-next/outputv4/akash/cert/v1beta2/query.pinia.store.ts index 68c2ce0e1e..2638dce5ad 100644 --- a/__fixtures__/v-next/outputv4/akash/cert/v1beta2/query.pinia.store.ts +++ b/__fixtures__/v-next/outputv4/akash/cert/v1beta2/query.pinia.store.ts @@ -18,7 +18,7 @@ export const usePiniaStore = defineStore('akash/cert/v1beta2/query.proto', { } }, actions: { - async fetchCertificates(param: QueryCertificatesRequestSDKType) { + async fetchCertificates(param : QueryCertificatesRequestSDKType) { this.certificates = await this.lcdClient.certificates(param); return this.certificates; } diff --git a/__fixtures__/v-next/outputv4/binary.ts b/__fixtures__/v-next/outputv4/binary.ts index e36065aa4b..f8751d571c 100644 --- a/__fixtures__/v-next/outputv4/binary.ts +++ b/__fixtures__/v-next/outputv4/binary.ts @@ -348,12 +348,12 @@ export class BinaryWriter { (value = value >>> 0) < 128 ? 1 : value < 16384 - ? 2 - : value < 2097152 - ? 3 - : value < 268435456 - ? 4 - : 5, + ? 2 + : value < 2097152 + ? 3 + : value < 268435456 + ? 4 + : 5, value )).len; return this; @@ -463,10 +463,10 @@ function pool( function indexOutOfRange(reader: BinaryReader, writeLength?: number) { return RangeError( "index out of range: " + - reader.pos + - " + " + - (writeLength || 1) + - " > " + - reader.len + reader.pos + + " + " + + (writeLength || 1) + + " > " + + reader.len ); } diff --git a/__fixtures__/v-next/outputv4/evmos/erc20/v1/query.pinia.store.ts b/__fixtures__/v-next/outputv4/evmos/erc20/v1/query.pinia.store.ts index 8949ba1a68..47e7006eac 100644 --- a/__fixtures__/v-next/outputv4/evmos/erc20/v1/query.pinia.store.ts +++ b/__fixtures__/v-next/outputv4/evmos/erc20/v1/query.pinia.store.ts @@ -21,15 +21,15 @@ export const usePiniaStore = defineStore('evmos/erc20/v1/query.proto', { } }, actions: { - async fetchTokenPairs(param: QueryTokenPairsRequestSDKType) { + async fetchTokenPairs(param : QueryTokenPairsRequestSDKType) { this.tokenPairs = await this.lcdClient.tokenPairs(param); return this.tokenPairs; }, - async fetchTokenPair(param: QueryTokenPairRequestSDKType) { + async fetchTokenPair(param : QueryTokenPairRequestSDKType) { this.tokenPair = await this.lcdClient.tokenPair(param); return this.tokenPair; }, - async fetchParams(param: QueryParamsRequestSDKType) { + async fetchParams(param : QueryParamsRequestSDKType) { this.params = await this.lcdClient.params(param); return this.params; } diff --git a/__fixtures__/v-next/outputv4/helpers.ts b/__fixtures__/v-next/outputv4/helpers.ts index 7bfab7552c..f92d2b935a 100644 --- a/__fixtures__/v-next/outputv4/helpers.ts +++ b/__fixtures__/v-next/outputv4/helpers.ts @@ -182,9 +182,9 @@ type KeysOfUnion = T extends T ? keyof T : never; export type Exact = P extends Builtin ? P : P & { [K in keyof P]: Exact } & Record< - Exclude>, - never - >; + Exclude>, + never + >; export interface Rpc { request( diff --git a/__fixtures__/v-next/outputv4/index.ts b/__fixtures__/v-next/outputv4/index.ts index 81735d4a8c..3424ed57e4 100644 --- a/__fixtures__/v-next/outputv4/index.ts +++ b/__fixtures__/v-next/outputv4/index.ts @@ -3,7 +3,7 @@ * DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain * and run the transpile command or yarn proto command to regenerate this bundle. */ - + export * from "./akash/bundle"; export * from "./akash/client"; export * from "./ics23/bundle"; diff --git a/__fixtures__/v-next/outputv4/osmosis/gamm/v1beta1/query.pinia.store.ts b/__fixtures__/v-next/outputv4/osmosis/gamm/v1beta1/query.pinia.store.ts index 1d793b645e..ec9c29e017 100644 --- a/__fixtures__/v-next/outputv4/osmosis/gamm/v1beta1/query.pinia.store.ts +++ b/__fixtures__/v-next/outputv4/osmosis/gamm/v1beta1/query.pinia.store.ts @@ -34,63 +34,63 @@ export const usePiniaStore = defineStore('osmosis/gamm/v1beta1/query.proto', { } }, actions: { - async fetchPools(param: QueryPoolsRequestSDKType) { + async fetchPools(param : QueryPoolsRequestSDKType) { this.pools = await this.lcdClient.pools(param); return this.pools; }, - async fetchNumPools(param: QueryNumPoolsRequestSDKType) { + async fetchNumPools(param : QueryNumPoolsRequestSDKType) { this.numPools = await this.lcdClient.numPools(param); return this.numPools; }, - async fetchTotalLiquidity(param: QueryTotalLiquidityRequestSDKType) { + async fetchTotalLiquidity(param : QueryTotalLiquidityRequestSDKType) { this.totalLiquidity = await this.lcdClient.totalLiquidity(param); return this.totalLiquidity; }, - async fetchPoolsWithFilter(param: QueryPoolsWithFilterRequestSDKType) { + async fetchPoolsWithFilter(param : QueryPoolsWithFilterRequestSDKType) { this.poolsWithFilter = await this.lcdClient.poolsWithFilter(param); return this.poolsWithFilter; }, - async fetchPool(param: QueryPoolRequestSDKType) { + async fetchPool(param : QueryPoolRequestSDKType) { this.pool = await this.lcdClient.pool(param); return this.pool; }, - async fetchPoolType(param: QueryPoolTypeRequestSDKType) { + async fetchPoolType(param : QueryPoolTypeRequestSDKType) { this.poolType = await this.lcdClient.poolType(param); return this.poolType; }, - async fetchCalcJoinPoolNoSwapShares(param: QueryCalcJoinPoolNoSwapSharesRequestSDKType) { + async fetchCalcJoinPoolNoSwapShares(param : QueryCalcJoinPoolNoSwapSharesRequestSDKType) { this.calcJoinPoolNoSwapShares = await this.lcdClient.calcJoinPoolNoSwapShares(param); return this.calcJoinPoolNoSwapShares; }, - async fetchCalcJoinPoolShares(param: QueryCalcJoinPoolSharesRequestSDKType) { + async fetchCalcJoinPoolShares(param : QueryCalcJoinPoolSharesRequestSDKType) { this.calcJoinPoolShares = await this.lcdClient.calcJoinPoolShares(param); return this.calcJoinPoolShares; }, - async fetchCalcExitPoolCoinsFromShares(param: QueryCalcExitPoolCoinsFromSharesRequestSDKType) { + async fetchCalcExitPoolCoinsFromShares(param : QueryCalcExitPoolCoinsFromSharesRequestSDKType) { this.calcExitPoolCoinsFromShares = await this.lcdClient.calcExitPoolCoinsFromShares(param); return this.calcExitPoolCoinsFromShares; }, - async fetchPoolParams(param: QueryPoolParamsRequestSDKType) { + async fetchPoolParams(param : QueryPoolParamsRequestSDKType) { this.poolParams = await this.lcdClient.poolParams(param); return this.poolParams; }, - async fetchTotalPoolLiquidity(param: QueryTotalPoolLiquidityRequestSDKType) { + async fetchTotalPoolLiquidity(param : QueryTotalPoolLiquidityRequestSDKType) { this.totalPoolLiquidity = await this.lcdClient.totalPoolLiquidity(param); return this.totalPoolLiquidity; }, - async fetchTotalShares(param: QueryTotalSharesRequestSDKType) { + async fetchTotalShares(param : QueryTotalSharesRequestSDKType) { this.totalShares = await this.lcdClient.totalShares(param); return this.totalShares; }, - async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) { + async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) { this.spotPrice = await this.lcdClient.spotPrice(param); return this.spotPrice; }, - async fetchEstimateSwapExactAmountIn(param: QuerySwapExactAmountInRequestSDKType) { + async fetchEstimateSwapExactAmountIn(param : QuerySwapExactAmountInRequestSDKType) { this.estimateSwapExactAmountIn = await this.lcdClient.estimateSwapExactAmountIn(param); return this.estimateSwapExactAmountIn; }, - async fetchEstimateSwapExactAmountOut(param: QuerySwapExactAmountOutRequestSDKType) { + async fetchEstimateSwapExactAmountOut(param : QuerySwapExactAmountOutRequestSDKType) { this.estimateSwapExactAmountOut = await this.lcdClient.estimateSwapExactAmountOut(param); return this.estimateSwapExactAmountOut; } diff --git a/__fixtures__/v-next/outputv4/osmosis/gamm/v2/query.pinia.store.ts b/__fixtures__/v-next/outputv4/osmosis/gamm/v2/query.pinia.store.ts index 0953a7c89e..8ccee9dc1f 100644 --- a/__fixtures__/v-next/outputv4/osmosis/gamm/v2/query.pinia.store.ts +++ b/__fixtures__/v-next/outputv4/osmosis/gamm/v2/query.pinia.store.ts @@ -16,7 +16,7 @@ export const usePiniaStore = defineStore('osmosis/gamm/v2/query.proto', { } }, actions: { - async fetchSpotPrice(param: QuerySpotPriceRequestSDKType) { + async fetchSpotPrice(param : QuerySpotPriceRequestSDKType) { this.spotPrice = await this.lcdClient.spotPrice(param); return this.spotPrice; } diff --git a/__fixtures__/v-next/outputv4/varint.ts b/__fixtures__/v-next/outputv4/varint.ts index ae2e63b3b2..a83418dbc0 100644 --- a/__fixtures__/v-next/outputv4/varint.ts +++ b/__fixtures__/v-next/outputv4/varint.ts @@ -454,18 +454,18 @@ export function int64Length(lo: number, hi: number) { ? 1 : 2 : part0 < 2097152 - ? 3 - : 4 + ? 3 + : 4 : part1 < 16384 - ? part1 < 128 - ? 5 - : 6 - : part1 < 2097152 - ? 7 - : 8 + ? part1 < 128 + ? 5 + : 6 + : part1 < 2097152 + ? 7 + : 8 : part2 < 128 - ? 9 - : 10; + ? 9 + : 10; } export function writeFixed32( diff --git a/packages/ast/src/encoding/proto/__snapshots__/proto.type.spec.ts.snap b/packages/ast/src/encoding/proto/__snapshots__/proto.type.spec.ts.snap index f1d892e320..dc67cbfbc5 100644 --- a/packages/ast/src/encoding/proto/__snapshots__/proto.type.spec.ts.snap +++ b/packages/ast/src/encoding/proto/__snapshots__/proto.type.spec.ts.snap @@ -97,6 +97,27 @@ exports[`createCreateProtoType ValidatorUpdate 1`] = ` }" `; +exports[`createCreateProtoType orginal logic Header 1`] = ` +"function createBaseHeader(): Header { + return { + version: Consensus.fromPartial({}), + chainId: "", + height: Long.ZERO, + time: undefined, + lastBlockId: BlockID.fromPartial({}), + lastCommitHash: new Uint8Array(), + dataHash: new Uint8Array(), + validatorsHash: new Uint8Array(), + nextValidatorsHash: new Uint8Array(), + consensusHash: new Uint8Array(), + appHash: new Uint8Array(), + lastResultsHash: new Uint8Array(), + evidenceHash: new Uint8Array(), + proposerAddress: new Uint8Array() + }; +}" +`; + exports[`oneofs Value 1`] = ` "/** * \`Value\` represents a dynamically typed value which can be either diff --git a/packages/ast/src/encoding/proto/from-amino/utils.ts b/packages/ast/src/encoding/proto/from-amino/utils.ts index e064e1b622..cce7baab8c 100644 --- a/packages/ast/src/encoding/proto/from-amino/utils.ts +++ b/packages/ast/src/encoding/proto/from-amino/utils.ts @@ -300,6 +300,8 @@ export const fromAminoJSON = { origName } = getFieldNames(args.field); + const setDefaultEnumToUnrecognized = args.context.pluginValue('prototypes.typingsFormat.setDefaultEnumToUnrecognized'); + args.context.addUtil('isSet'); const fromAminoJSONFuncName = args.context.getFromEnum(args.field); @@ -324,7 +326,7 @@ export const fromAminoJSON = { ) ] ), - args.isOptional ? t.identifier('undefined') : t.numericLiteral(-1) + args.isOptional ? t.identifier('undefined') : t.numericLiteral(!setDefaultEnumToUnrecognized ? 0 : -1) ) ); }, diff --git a/packages/ast/src/encoding/proto/from-json/utils.ts b/packages/ast/src/encoding/proto/from-json/utils.ts index 278cc9d16d..1f6735c628 100644 --- a/packages/ast/src/encoding/proto/from-json/utils.ts +++ b/packages/ast/src/encoding/proto/from-json/utils.ts @@ -215,6 +215,7 @@ export const fromJSON = { // mode: isSet(object.mode) ? signModeFromJSON(object.mode) : 0, enum(args: FromJSONMethod) { const { messageProp, objProp } = getPropNames(args.field); + const setDefaultEnumToUnrecognized = args.context.pluginValue('prototypes.typingsFormat.setDefaultEnumToUnrecognized'); args.context.addUtil('isSet'); const fromJSONFuncName = args.context.getFromEnum(args.field); @@ -239,7 +240,7 @@ export const fromJSON = { ) ] ), - args.isOptional ? t.identifier('undefined') : t.numericLiteral(-1) + args.isOptional ? t.identifier('undefined') : t.numericLiteral(!setDefaultEnumToUnrecognized ? 0 : -1) ) ); }, @@ -330,7 +331,7 @@ export const fromJSON = { const env = args.context.pluginValue( 'env' ); - if (env == 'default') { + if (!env || env == 'default') { timestampFormat = 'timestamp'; } switch (timestampFormat) { diff --git a/packages/ast/src/encoding/proto/from-sdk-json/utils.ts b/packages/ast/src/encoding/proto/from-sdk-json/utils.ts index e95c73d2eb..7f3781ff13 100644 --- a/packages/ast/src/encoding/proto/from-sdk-json/utils.ts +++ b/packages/ast/src/encoding/proto/from-sdk-json/utils.ts @@ -149,6 +149,7 @@ export const fromSDKJSON = { enum(args: FromSDKJSONMethod) { const { origName } = getFieldNames(args.field); args.context.addUtil('isSet'); + const setDefaultEnumToUnrecognized = args.context.pluginValue('prototypes.typingsFormat.setDefaultEnumToUnrecognized'); const fromSDKJSONFuncName = args.context.getFromEnum(args.field); return t.objectProperty( @@ -160,7 +161,7 @@ export const fromSDKJSON = { t.callExpression(t.identifier(fromSDKJSONFuncName), [ t.memberExpression(t.identifier('object'), t.identifier(origName)) ]), - args.isOptional ? t.identifier('undefined') : t.numericLiteral(-1) + args.isOptional ? t.identifier('undefined') : t.numericLiteral(!setDefaultEnumToUnrecognized ? 0 : -1) ) ); }, diff --git a/packages/ast/src/encoding/proto/from-sdk/utils.ts b/packages/ast/src/encoding/proto/from-sdk/utils.ts index 5efbb93867..f55a942fb0 100644 --- a/packages/ast/src/encoding/proto/from-sdk/utils.ts +++ b/packages/ast/src/encoding/proto/from-sdk/utils.ts @@ -107,6 +107,7 @@ export const fromSDK = { propName, origName } = getFieldNames(args.field); + const setDefaultEnumToUnrecognized = args.context.pluginValue('prototypes.typingsFormat.setDefaultEnumToUnrecognized'); args.context.addUtil('isSet'); const fromSDKFuncName = args.context.getFromEnum(args.field); @@ -132,7 +133,7 @@ export const fromSDK = { ) ] ), - args.isOptional ? t.identifier('undefined') : t.numericLiteral(-1) + args.isOptional ? t.identifier('undefined') : t.numericLiteral(!setDefaultEnumToUnrecognized ? 0 : -1) ) ); }, @@ -152,7 +153,7 @@ export const fromSDK = { const env = args.context.pluginValue( 'env' ); - if(env == 'default'){ + if(!env || env == 'default'){ timestampFormat = 'timestamp'; } switch (timestampFormat) { diff --git a/packages/ast/src/encoding/proto/proto.type.spec.ts b/packages/ast/src/encoding/proto/proto.type.spec.ts index 926f7b5128..248f0482be 100644 --- a/packages/ast/src/encoding/proto/proto.type.spec.ts +++ b/packages/ast/src/encoding/proto/proto.type.spec.ts @@ -8,6 +8,7 @@ import { traverse, getNestedProto } from '@cosmology/proto-parser' import { defaultTelescopeOptions } from '@cosmology/types' import { ProtoParseContext } from '../context'; import { getTestProtoStore, expectCode, printCode } from '../../../test-utils'; +import deepmerge from 'deepmerge'; const store = getTestProtoStore(); store.traverseAll(); @@ -87,6 +88,29 @@ describe('createCreateProtoType', () => { }); }); +describe('createCreateProtoType orginal logic', () => { + const ref = store.findProto('tendermint/types/types.proto'); + + const options = deepmerge(defaultTelescopeOptions, { + prototypes: { + typingsFormat:{ + setDefaultEnumToUnrecognized: false, + setDefaultCustomTypesToUndefined: true, + } + } + }); + + const context = new ProtoParseContext(ref, store, options); + + it('Header', () => { + expectCode(createCreateProtoType( + context, + 'Header', + getNestedProto(types_tendermint).Header + )); + }); +}); + describe('traversed', () => { it('osmosis/claim/v1beta1/params', async () => { const ref = store.findProto('osmosis/claim/v1beta1/params.proto'); diff --git a/packages/ast/src/encoding/proto/to-sdk/utils.ts b/packages/ast/src/encoding/proto/to-sdk/utils.ts index aae448ebc8..9ba6d126e5 100644 --- a/packages/ast/src/encoding/proto/to-sdk/utils.ts +++ b/packages/ast/src/encoding/proto/to-sdk/utils.ts @@ -156,7 +156,7 @@ export const toSDK = { const env = args.context.pluginValue( 'env' ); - if(env == 'default'){ + if(!env || env == 'default'){ timestampFormat = 'timestamp'; } switch (timestampFormat) { diff --git a/packages/ast/src/encoding/types.ts b/packages/ast/src/encoding/types.ts index 46fa4f9694..8e761acdd5 100644 --- a/packages/ast/src/encoding/types.ts +++ b/packages/ast/src/encoding/types.ts @@ -401,6 +401,8 @@ export const getDefaultTSTypeFromProtoType = ( const isOptional = getFieldOptionalityForDefaults(context, field, isOneOf); + const setDefaultCustomTypesToUndefined = context.pluginValue('prototypes.typingsFormat.setDefaultCustomTypesToUndefined'); + if (isOptional) { return t.identifier('undefined'); } @@ -451,25 +453,51 @@ export const getDefaultTSTypeFromProtoType = ( // OTHER TYPES case 'google.protobuf.Timestamp': - if (context.pluginValue('prototypes.typingsFormat.timestamp') === 'timestamp') { - return t.callExpression( + if(setDefaultCustomTypesToUndefined){ + return t.identifier('undefined'); + } else { + const timestampType = context.pluginValue('prototypes.typingsFormat.timestamp'); + + switch (timestampType) { + case 'timestamp': + return t.callExpression( t.memberExpression( t.identifier('Timestamp'), t.identifier('fromPartial') ), [t.objectExpression([])] - ) - } - if (context.pluginValue('prototypes.typingsFormat.timestamp') === 'date') { - return t.newExpression( + ) + case 'date': + return t.newExpression( t.identifier('Date'), [] - ); + ); + + default: + return t.identifier('undefined'); + } } - // TODO: add cases for this later on - // case 'google.protobuf.Duration': - // return t.identifier('undefined'); + // TODO: add cases for this later on + case 'google.protobuf.Duration': + if(setDefaultCustomTypesToUndefined) { + return t.identifier('undefined'); + } else { + return getDefaultTSTypeFromProtoTypeDefault(field); + } + case 'google.protobuf.Any': + if(setDefaultCustomTypesToUndefined) { + return t.identifier('undefined'); + } else { + return getDefaultTSTypeFromProtoTypeDefault(field); + } + + case 'cosmos.base.v1beta1.Coin': + if(setDefaultCustomTypesToUndefined) { + return t.identifier('undefined'); + } else { + return getDefaultTSTypeFromProtoTypeDefault(field); + } case 'cosmos.base.v1beta1.Coins': return t.arrayExpression([]); @@ -478,15 +506,19 @@ export const getDefaultTSTypeFromProtoType = ( console.warn('Undefined! Can\'t get field of type:', field); return t.identifier('undefined'); } else { - const temp = field.type.split("."); - const fieldName = temp[temp.length - 1]; - return t.callExpression( - t.memberExpression( - t.identifier(fieldName), - t.identifier('fromPartial') - ), - [t.objectExpression([])] - ) + return getDefaultTSTypeFromProtoTypeDefault(field) } }; }; + +function getDefaultTSTypeFromProtoTypeDefault(field: ProtoField) { + const temp = field.type.split("."); + const fieldName = temp[temp.length - 1]; + return t.callExpression( + t.memberExpression( + t.identifier(fieldName), + t.identifier('fromPartial') + ), + [t.objectExpression([])] + ) +} \ No newline at end of file diff --git a/packages/ast/tsconfig.json b/packages/ast/tsconfig.json index defba4e081..65f1b78448 100644 --- a/packages/ast/tsconfig.json +++ b/packages/ast/tsconfig.json @@ -1,20 +1,19 @@ { - "compilerOptions": { - "target": "esnext", - "moduleResolution": "node", - "allowJs": true, - "esModuleInterop": true, - "declaration": true, - "declarationDir": "./types", - "emitDeclarationOnly": true, - "isolatedModules": true - }, - "include": [ - "src/**/*" - ], - "exclude": [ - "node_modules", - "src/**/*.spec.ts", - "src/__fixtures__/**/*" - ] -} \ No newline at end of file + "compilerOptions": { + "target": "esnext", + "moduleResolution": "node", + "allowJs": true, + "esModuleInterop": true, + "declaration": true, + "declarationDir": "./types", + "emitDeclarationOnly": true, + "isolatedModules": true + }, + "include": ["src/**/*"], + "exclude": [ + "node_modules", + "src/**/*.spec.ts", + "src/__fixtures__/**/*", + "types" + ] +} diff --git a/packages/ast/types/src/docs/rpc-clients.d.ts b/packages/ast/types/src/docs/rpc-clients.d.ts index 0aea007d5f..daa6dc3451 100644 --- a/packages/ast/types/src/docs/rpc-clients.d.ts +++ b/packages/ast/types/src/docs/rpc-clients.d.ts @@ -15,4 +15,4 @@ interface DocumentService { } export declare const documentRpcClients: (context: ProtoParseContext, myBase: string, store: ProtoStore) => DocumentRpcClient[]; export declare const documentRpcClientsReadme: (context: ProtoParseContext, myBase: string, store: ProtoStore) => string; -export { }; +export {}; diff --git a/packages/ast/types/src/encoding/amino/converter/index.d.ts b/packages/ast/types/src/encoding/amino/converter/index.d.ts index b0ecfe5919..ed7c453df5 100644 --- a/packages/ast/types/src/encoding/amino/converter/index.d.ts +++ b/packages/ast/types/src/encoding/amino/converter/index.d.ts @@ -14,4 +14,4 @@ interface AminoConverterParams { protos: ProtoType[]; } export declare const createAminoConverter: ({ name, root, context, protos }: AminoConverterParams) => t.ExportNamedDeclaration; -export { }; +export {}; diff --git a/packages/ast/types/src/encoding/amino/from-amino-json/index.d.ts b/packages/ast/types/src/encoding/amino/from-amino-json/index.d.ts index a6219788f4..26afc0a66a 100644 --- a/packages/ast/types/src/encoding/amino/from-amino-json/index.d.ts +++ b/packages/ast/types/src/encoding/amino/from-amino-json/index.d.ts @@ -16,4 +16,4 @@ interface fromAminoJSON { proto: ProtoType; } export declare const fromAminoJsonMethod: ({ context, proto }: fromAminoJSON) => t.ArrowFunctionExpression; -export { }; +export {}; diff --git a/packages/ast/types/src/encoding/amino/to-amino-json/index.d.ts b/packages/ast/types/src/encoding/amino/to-amino-json/index.d.ts index 50b983e296..98accb3193 100644 --- a/packages/ast/types/src/encoding/amino/to-amino-json/index.d.ts +++ b/packages/ast/types/src/encoding/amino/to-amino-json/index.d.ts @@ -16,4 +16,4 @@ interface toAminoJSON { proto: ProtoType; } export declare const toAminoJsonMethod: ({ context, proto }: toAminoJSON) => t.ArrowFunctionExpression; -export { }; +export {}; diff --git a/packages/ast/types/src/encoding/context.d.ts b/packages/ast/types/src/encoding/context.d.ts index f084c53744..efa4f56fb5 100644 --- a/packages/ast/types/src/encoding/context.d.ts +++ b/packages/ast/types/src/encoding/context.d.ts @@ -48,4 +48,4 @@ export declare class ProtoParseContext extends GenericParseContext implements Pa getToEnum(field: ProtoField): string; getFromEnum(field: ProtoField): string; } -export { }; +export {}; diff --git a/packages/ast/types/test-utils/index.d.ts b/packages/ast/types/test-utils/index.d.ts index b9d24415be..2bb9b9fcd5 100644 --- a/packages/ast/types/test-utils/index.d.ts +++ b/packages/ast/types/test-utils/index.d.ts @@ -62,6 +62,8 @@ export declare const defaultTelescopeOptions: { useExact?: boolean; timestamp?: "date" | "timestamp"; duration?: "string" | "duration"; + setDefaultEnumToUnrecognized?: boolean; + setDefaultCustomTypesToUndefined?: boolean; updatedDuration?: boolean; }; }; diff --git a/packages/parser/types/store.d.ts b/packages/parser/types/store.d.ts index 931183503c..d87f738a4a 100644 --- a/packages/parser/types/store.d.ts +++ b/packages/parser/types/store.d.ts @@ -46,4 +46,4 @@ export declare class ProtoStore { getTypeUrlMap(ref: ProtoRef): import("@cosmology/types").InterfaceTypeUrlMap; getServices(myBase: string): Record; } -export { }; +export {}; diff --git a/packages/parser/types/utils.d.ts b/packages/parser/types/utils.d.ts index 050954a3d5..8ee6f99f21 100644 --- a/packages/parser/types/utils.d.ts +++ b/packages/parser/types/utils.d.ts @@ -8,7 +8,7 @@ export declare const createTypeUrlTypeMap: (store: ProtoStore, fromRef: ProtoRef /** * test if a proto ref is included by the operation. * @param ref a ProtoRef with proto file info and package. - * @param exclude patterns(will be deprecated soon), packages, proto files to include + * @param include patterns(will be deprecated soon), packages, proto files to include * @returns */ export declare const isRefIncluded: (ref: ProtoRef, include?: { diff --git a/packages/telescope/types/commands/transpile.d.ts b/packages/telescope/types/commands/transpile.d.ts index d83188a8f3..7cda34517c 100644 --- a/packages/telescope/types/commands/transpile.d.ts +++ b/packages/telescope/types/commands/transpile.d.ts @@ -1,2 +1,4 @@ -declare const _default: (argv: any) => Promise; +declare const _default: (argv: { + [key: string]: string | string[]; +}) => Promise; export default _default; diff --git a/packages/telescope/types/parse.d.ts b/packages/telescope/types/parse.d.ts index 1c4521593a..5aeb130d5c 100644 --- a/packages/telescope/types/parse.d.ts +++ b/packages/telescope/types/parse.d.ts @@ -12,4 +12,4 @@ interface ParseRecur { isNested: boolean; } export declare const parseRecur: ({ context, obj, scope, isNested }: ParseRecur) => void; -export { }; +export {}; diff --git a/packages/types/src/telescope.ts b/packages/types/src/telescope.ts index f957e896c9..828b33b0a1 100644 --- a/packages/types/src/telescope.ts +++ b/packages/types/src/telescope.ts @@ -76,6 +76,10 @@ interface TelescopeOpts { useExact?: boolean; timestamp?: 'date' | 'timestamp', duration?: 'duration' | 'string', + + setDefaultEnumToUnrecognized?: boolean; + setDefaultCustomTypesToUndefined?: boolean; + // temporary field to avoid breaking changes updatedDuration?: boolean }; @@ -261,7 +265,9 @@ export const defaultTelescopeOptions: TelescopeOptions = { useExact: false, timestamp: 'date', duration: 'duration', - updatedDuration: false + updatedDuration: false, + + setDefaultEnumToUnrecognized: true, }, }, diff --git a/packages/types/types/telescope.d.ts b/packages/types/types/telescope.d.ts index db6be67cea..dfd4247824 100644 --- a/packages/types/types/telescope.d.ts +++ b/packages/types/types/telescope.d.ts @@ -65,6 +65,8 @@ interface TelescopeOpts { useExact?: boolean; timestamp?: 'date' | 'timestamp'; duration?: 'duration' | 'string'; + setDefaultEnumToUnrecognized?: boolean; + setDefaultCustomTypesToUndefined?: boolean; updatedDuration?: boolean; }; }; diff --git a/packages/utils/src/slugs.ts b/packages/utils/src/slugs.ts index a1ae808e7e..98b4cbfc87 100644 --- a/packages/utils/src/slugs.ts +++ b/packages/utils/src/slugs.ts @@ -1,4 +1,4 @@ -import { camel } from '@cosmology/utils'; +import { camel } from '.'; import { relative, dirname, extname } from 'path'; export const variableSlug = (str) => {