Skip to content

Commit

Permalink
feat: Bump ts poet for dprint perf increase (#668)
Browse files Browse the repository at this point in the history
* feat: Bump ts-poet for dprint perf increase.

* Re-codegen.
  • Loading branch information
stephenh committed Sep 3, 2022
1 parent eef42fe commit 961d388
Show file tree
Hide file tree
Showing 81 changed files with 332 additions and 328 deletions.
4 changes: 2 additions & 2 deletions integration/async-iterable-services/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class EchoerClientImpl implements Echoer {
Echo(request: EchoMsg): Promise<EchoMsg> {
const data = EchoMsg.encode(request).finish();
const promise = this.rpc.request("simple.Echoer", "Echo", data);
return promise.then(data => EchoMsg.decode(new _m0.Reader(data)));
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
}

EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg> {
Expand All @@ -123,7 +123,7 @@ export class EchoerClientImpl implements Echoer {
EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg> {
const data = EchoMsg.encodeTransform(request);
const promise = this.rpc.clientStreamingRequest("simple.Echoer", "EchoClientStream", data);
return promise.then(data => EchoMsg.decode(new _m0.Reader(data)));
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
}

EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg> {
Expand Down
1 change: 1 addition & 0 deletions integration/avoid-import-conflicts-types-only/simple2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */

export const protobufPackage = "simple2";

export enum SimpleEnum {
Expand Down
6 changes: 3 additions & 3 deletions integration/avoid-import-conflicts/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ export const Simple = {
toJSON(message: Simple): unknown {
const obj: any = {};
message.name !== undefined && (obj.name = message.name);
message.otherSimple !== undefined
&& (obj.otherSimple = message.otherSimple ? Simple3.toJSON(message.otherSimple) : undefined);
message.otherSimple !== undefined &&
(obj.otherSimple = message.otherSimple ? Simple3.toJSON(message.otherSimple) : undefined);
return obj;
},

Expand Down Expand Up @@ -295,7 +295,7 @@ export class FooServiceClientImpl implements FooService {
Create(request: FooServiceCreateRequest): Promise<FooServiceCreateResponse> {
const data = FooServiceCreateRequest.encode(request).finish();
const promise = this.rpc.request("simple.FooService", "Create", data);
return promise.then(data => FooServiceCreateResponse.decode(new _m0.Reader(data)));
return promise.then((data) => FooServiceCreateResponse.decode(new _m0.Reader(data)));
}
}

Expand Down
20 changes: 10 additions & 10 deletions integration/batching-with-context/batching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const BatchQueryRequest = {
toJSON(message: BatchQueryRequest): unknown {
const obj: any = {};
if (message.ids) {
obj.ids = message.ids.map(e => e);
obj.ids = message.ids.map((e) => e);
} else {
obj.ids = [];
}
Expand Down Expand Up @@ -134,7 +134,7 @@ export const BatchQueryResponse = {
toJSON(message: BatchQueryResponse): unknown {
const obj: any = {};
if (message.entities) {
obj.entities = message.entities.map(e => e ? Entity.toJSON(e) : undefined);
obj.entities = message.entities.map((e) => e ? Entity.toJSON(e) : undefined);
} else {
obj.entities = [];
}
Expand Down Expand Up @@ -185,7 +185,7 @@ export const BatchMapQueryRequest = {
toJSON(message: BatchMapQueryRequest): unknown {
const obj: any = {};
if (message.ids) {
obj.ids = message.ids.map(e => e);
obj.ids = message.ids.map((e) => e);
} else {
obj.ids = [];
}
Expand Down Expand Up @@ -589,7 +589,7 @@ export class EntityServiceClientImpl<Context extends DataLoaders> implements Ent
const dl = ctx.getDataLoader("batching.EntityService.BatchQuery", () => {
return new DataLoader<string, Entity>((ids) => {
const request = { ids };
return this.BatchQuery(ctx, request).then(res => res.entities);
return this.BatchQuery(ctx, request).then((res) => res.entities);
}, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions });
});
return dl.load(id);
Expand All @@ -598,15 +598,15 @@ export class EntityServiceClientImpl<Context extends DataLoaders> implements Ent
BatchQuery(ctx: Context, request: BatchQueryRequest): Promise<BatchQueryResponse> {
const data = BatchQueryRequest.encode(request).finish();
const promise = this.rpc.request(ctx, "batching.EntityService", "BatchQuery", data);
return promise.then(data => BatchQueryResponse.decode(new _m0.Reader(data)));
return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data)));
}

GetMapQuery(ctx: Context, id: string): Promise<Entity> {
const dl = ctx.getDataLoader("batching.EntityService.BatchMapQuery", () => {
return new DataLoader<string, Entity>((ids) => {
const request = { ids };
return this.BatchMapQuery(ctx, request).then(res => {
return ids.map(key => res.entities[key]);
return this.BatchMapQuery(ctx, request).then((res) => {
return ids.map((key) => res.entities[key]);
});
}, { cacheKeyFn: hash, ...ctx.rpcDataLoaderOptions });
});
Expand All @@ -616,13 +616,13 @@ export class EntityServiceClientImpl<Context extends DataLoaders> implements Ent
BatchMapQuery(ctx: Context, request: BatchMapQueryRequest): Promise<BatchMapQueryResponse> {
const data = BatchMapQueryRequest.encode(request).finish();
const promise = this.rpc.request(ctx, "batching.EntityService", "BatchMapQuery", data);
return promise.then(data => BatchMapQueryResponse.decode(new _m0.Reader(data)));
return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data)));
}

GetOnlyMethod(ctx: Context, request: GetOnlyMethodRequest): Promise<GetOnlyMethodResponse> {
const dl = ctx.getDataLoader("batching.EntityService.GetOnlyMethod", () => {
return new DataLoader<GetOnlyMethodRequest, GetOnlyMethodResponse>((requests) => {
const responses = requests.map(async request => {
const responses = requests.map(async (request) => {
const data = GetOnlyMethodRequest.encode(request).finish();
const response = await this.rpc.request(ctx, "batching.EntityService", "GetOnlyMethod", data);
return GetOnlyMethodResponse.decode(new _m0.Reader(response));
Expand All @@ -636,7 +636,7 @@ export class EntityServiceClientImpl<Context extends DataLoaders> implements Ent
WriteMethod(ctx: Context, request: WriteMethodRequest): Promise<WriteMethodResponse> {
const data = WriteMethodRequest.encode(request).finish();
const promise = this.rpc.request(ctx, "batching.EntityService", "WriteMethod", data);
return promise.then(data => WriteMethodResponse.decode(new _m0.Reader(data)));
return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data)));
}
}

Expand Down
14 changes: 7 additions & 7 deletions integration/batching/batching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const BatchQueryRequest = {
toJSON(message: BatchQueryRequest): unknown {
const obj: any = {};
if (message.ids) {
obj.ids = message.ids.map(e => e);
obj.ids = message.ids.map((e) => e);
} else {
obj.ids = [];
}
Expand Down Expand Up @@ -132,7 +132,7 @@ export const BatchQueryResponse = {
toJSON(message: BatchQueryResponse): unknown {
const obj: any = {};
if (message.entities) {
obj.entities = message.entities.map(e => e ? Entity.toJSON(e) : undefined);
obj.entities = message.entities.map((e) => e ? Entity.toJSON(e) : undefined);
} else {
obj.entities = [];
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export const BatchMapQueryRequest = {
toJSON(message: BatchMapQueryRequest): unknown {
const obj: any = {};
if (message.ids) {
obj.ids = message.ids.map(e => e);
obj.ids = message.ids.map((e) => e);
} else {
obj.ids = [];
}
Expand Down Expand Up @@ -584,25 +584,25 @@ export class EntityServiceClientImpl implements EntityService {
BatchQuery(request: BatchQueryRequest): Promise<BatchQueryResponse> {
const data = BatchQueryRequest.encode(request).finish();
const promise = this.rpc.request("batching.EntityService", "BatchQuery", data);
return promise.then(data => BatchQueryResponse.decode(new _m0.Reader(data)));
return promise.then((data) => BatchQueryResponse.decode(new _m0.Reader(data)));
}

BatchMapQuery(request: BatchMapQueryRequest): Promise<BatchMapQueryResponse> {
const data = BatchMapQueryRequest.encode(request).finish();
const promise = this.rpc.request("batching.EntityService", "BatchMapQuery", data);
return promise.then(data => BatchMapQueryResponse.decode(new _m0.Reader(data)));
return promise.then((data) => BatchMapQueryResponse.decode(new _m0.Reader(data)));
}

GetOnlyMethod(request: GetOnlyMethodRequest): Promise<GetOnlyMethodResponse> {
const data = GetOnlyMethodRequest.encode(request).finish();
const promise = this.rpc.request("batching.EntityService", "GetOnlyMethod", data);
return promise.then(data => GetOnlyMethodResponse.decode(new _m0.Reader(data)));
return promise.then((data) => GetOnlyMethodResponse.decode(new _m0.Reader(data)));
}

WriteMethod(request: WriteMethodRequest): Promise<WriteMethodResponse> {
const data = WriteMethodRequest.encode(request).finish();
const promise = this.rpc.request("batching.EntityService", "WriteMethod", data);
return promise.then(data => WriteMethodResponse.decode(new _m0.Reader(data)));
return promise.then((data) => WriteMethodResponse.decode(new _m0.Reader(data)));
}
}

Expand Down
5 changes: 3 additions & 2 deletions integration/bytes-as-base64/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */

export const protobufPackage = "";

export interface Message {
Expand All @@ -16,8 +17,8 @@ export const Message = {

toJSON(message: Message): unknown {
const obj: any = {};
message.data !== undefined
&& (obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
message.data !== undefined &&
(obj.data = base64FromBytes(message.data !== undefined ? message.data : new Uint8Array()));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/bytes-node/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ export const BytesValue = {

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined
&& (obj.value = base64FromBytes(message.value !== undefined ? message.value : Buffer.alloc(0)));
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : Buffer.alloc(0)));
return obj;
},

Expand Down
4 changes: 2 additions & 2 deletions integration/bytes-node/point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ export const Point = {

toJSON(message: Point): unknown {
const obj: any = {};
message.data !== undefined
&& (obj.data = base64FromBytes(message.data !== undefined ? message.data : Buffer.alloc(0)));
message.data !== undefined &&
(obj.data = base64FromBytes(message.data !== undefined ? message.data : Buffer.alloc(0)));
message.dataWrapped !== undefined && (obj.dataWrapped = message.dataWrapped);
return obj;
},
Expand Down
10 changes: 2 additions & 8 deletions integration/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ async function generate(binFile: string, baseDir: string, parameter: string) {
const filePath = `${baseDir}/${path}`;
const dirPath = parse(filePath).dir;
await promisify(mkdir)(dirPath, { recursive: true }).catch(() => {});
await promisify(writeFile)(
filePath,
prefixDisableLinter(await code.toStringWithImports({ ...getTsPoetOpts(options), path }))
);
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
}

if (options.outputTypeRegistry) {
Expand All @@ -54,10 +51,7 @@ async function generate(binFile: string, baseDir: string, parameter: string) {

const filePath = `${baseDir}/${path}`;

await promisify(writeFile)(
filePath,
prefixDisableLinter(await code.toStringWithImports({ ...getTsPoetOpts(options), path }))
);
await promisify(writeFile)(filePath, code.toString({ ...getTsPoetOpts(options), path }));
}
}

Expand Down
8 changes: 4 additions & 4 deletions integration/generic-metadata/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,19 @@ export class HeroServiceClientImpl implements HeroService {
FindOneHero(request: HeroById): Promise<Hero> {
const data = HeroById.encode(request).finish();
const promise = this.rpc.request("hero.HeroService", "FindOneHero", data);
return promise.then(data => Hero.decode(new _m0.Reader(data)));
return promise.then((data) => Hero.decode(new _m0.Reader(data)));
}

FindOneVillain(request: VillainById): Promise<Villain> {
const data = VillainById.encode(request).finish();
const promise = this.rpc.request("hero.HeroService", "FindOneVillain", data);
return promise.then(data => Villain.decode(new _m0.Reader(data)));
return promise.then((data) => Villain.decode(new _m0.Reader(data)));
}

FindManyVillain(request: Observable<VillainById>): Observable<Villain> {
const data = request.pipe(map(request => VillainById.encode(request).finish()));
const data = request.pipe(map((request) => VillainById.encode(request).finish()));
const result = this.rpc.bidirectionalStreamingRequest("hero.HeroService", "FindManyVillain", data);
return result.pipe(map(data => Villain.decode(new _m0.Reader(data))));
return result.pipe(map((data) => Villain.decode(new _m0.Reader(data))));
}
}

Expand Down
10 changes: 5 additions & 5 deletions integration/grpc-js/google/protobuf/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const Struct = {
wrap(object: { [key: string]: any } | undefined): Struct {
const struct = createBaseStruct();
if (object !== undefined) {
Object.keys(object).forEach(key => {
Object.keys(object).forEach((key) => {
struct.fields[key] = object[key];
});
}
Expand All @@ -183,7 +183,7 @@ export const Struct = {

unwrap(message: Struct): { [key: string]: any } {
const object: { [key: string]: any } = {};
Object.keys(message.fields).forEach(key => {
Object.keys(message.fields).forEach((key) => {
object[key] = message.fields[key];
});
return object;
Expand Down Expand Up @@ -325,8 +325,8 @@ export const Value = {

toJSON(message: Value): unknown {
const obj: any = {};
message.nullValue !== undefined
&& (obj.nullValue = message.nullValue !== undefined ? nullValueToJSON(message.nullValue) : undefined);
message.nullValue !== undefined &&
(obj.nullValue = message.nullValue !== undefined ? nullValueToJSON(message.nullValue) : undefined);
message.numberValue !== undefined && (obj.numberValue = message.numberValue);
message.stringValue !== undefined && (obj.stringValue = message.stringValue);
message.boolValue !== undefined && (obj.boolValue = message.boolValue);
Expand Down Expand Up @@ -423,7 +423,7 @@ export const ListValue = {
toJSON(message: ListValue): unknown {
const obj: any = {};
if (message.values) {
obj.values = message.values.map(e => e);
obj.values = message.values.map((e) => e);
} else {
obj.values = [];
}
Expand Down
4 changes: 2 additions & 2 deletions integration/grpc-js/google/protobuf/wrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ export const BytesValue = {

toJSON(message: BytesValue): unknown {
const obj: any = {};
message.value !== undefined
&& (obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
message.value !== undefined &&
(obj.value = base64FromBytes(message.value !== undefined ? message.value : new Uint8Array()));
return obj;
},

Expand Down
2 changes: 1 addition & 1 deletion integration/grpc-js/simple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ export interface TestClient extends Client {
}

export const TestClient = makeGenericClientConstructor(TestService, "simple.Test") as unknown as {
new(address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): TestClient;
new (address: string, credentials: ChannelCredentials, options?: Partial<ChannelOptions>): TestClient;
service: typeof TestService;
};

Expand Down
16 changes: 8 additions & 8 deletions integration/grpc-web-go-server/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ export const DashUserSettingsState = {
toJSON(message: DashUserSettingsState): unknown {
const obj: any = {};
message.email !== undefined && (obj.email = message.email);
message.urls !== undefined
&& (obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined);
message.urls !== undefined &&
(obj.urls = message.urls ? DashUserSettingsState_URLs.toJSON(message.urls) : undefined);
if (message.flashes) {
obj.flashes = message.flashes.map(e => e ? DashFlash.toJSON(e) : undefined);
obj.flashes = message.flashes.map((e) => e ? DashFlash.toJSON(e) : undefined);
} else {
obj.flashes = [];
}
Expand Down Expand Up @@ -605,13 +605,13 @@ export class DashStateClientImpl implements DashState {
UserSettings(request: Empty): Promise<DashUserSettingsState> {
const data = Empty.encode(request).finish();
const promise = this.rpc.request("rpx.DashState", "UserSettings", data);
return promise.then(data => DashUserSettingsState.decode(new _m0.Reader(data)));
return promise.then((data) => DashUserSettingsState.decode(new _m0.Reader(data)));
}

ActiveUserSettingsStream(request: Empty): Observable<DashUserSettingsState> {
const data = Empty.encode(request).finish();
const result = this.rpc.serverStreamingRequest("rpx.DashState", "ActiveUserSettingsStream", data);
return result.pipe(map(data => DashUserSettingsState.decode(new _m0.Reader(data))));
return result.pipe(map((data) => DashUserSettingsState.decode(new _m0.Reader(data))));
}
}

Expand All @@ -637,19 +637,19 @@ export class DashAPICredsClientImpl implements DashAPICreds {
Create(request: DashAPICredsCreateReq): Promise<DashCred> {
const data = DashAPICredsCreateReq.encode(request).finish();
const promise = this.rpc.request("rpx.DashAPICreds", "Create", data);
return promise.then(data => DashCred.decode(new _m0.Reader(data)));
return promise.then((data) => DashCred.decode(new _m0.Reader(data)));
}

Update(request: DashAPICredsUpdateReq): Promise<DashCred> {
const data = DashAPICredsUpdateReq.encode(request).finish();
const promise = this.rpc.request("rpx.DashAPICreds", "Update", data);
return promise.then(data => DashCred.decode(new _m0.Reader(data)));
return promise.then((data) => DashCred.decode(new _m0.Reader(data)));
}

Delete(request: DashAPICredsDeleteReq): Promise<DashCred> {
const data = DashAPICredsDeleteReq.encode(request).finish();
const promise = this.rpc.request("rpx.DashAPICreds", "Delete", data);
return promise.then(data => DashCred.decode(new _m0.Reader(data)));
return promise.then((data) => DashCred.decode(new _m0.Reader(data)));
}
}

Expand Down

0 comments on commit 961d388

Please sign in to comment.