@temporalio/cloud-api-definitions
Advanced tools
Comparing version 0.0.1-alpha.7 to 0.0.1-alpha.8
@@ -9,23 +9,24 @@ /** | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
import * as grpcWeb from "grpc-web"; | ||
import * as api_uiservice_service_pb from "../../api/uiservice/service_pb"; | ||
import * as grpcWeb from 'grpc-web'; | ||
import * as api_uiservice_service_pb from '../../api/uiservice/service_pb'; | ||
export class UIServiceClient { | ||
client_: grpcWeb.AbstractClientBase; | ||
hostname_: string; | ||
credentials_: null | { [index: string]: string }; | ||
options_: null | { [index: string]: any }; | ||
credentials_: null | { [index: string]: string; }; | ||
options_: null | { [index: string]: any; }; | ||
constructor( | ||
hostname: string, | ||
credentials?: null | { [index: string]: string }, | ||
options?: null | { [index: string]: any } | ||
) { | ||
constructor (hostname: string, | ||
credentials?: null | { [index: string]: string; }, | ||
options?: null | { [index: string]: any; }) { | ||
if (!options) options = {}; | ||
if (!credentials) credentials = {}; | ||
options["format"] = "text"; | ||
options['format'] = 'text'; | ||
@@ -39,3 +40,3 @@ this.client_ = new grpcWeb.GrpcWebClientBase(options); | ||
methodDescriptorGetUsersForNamespace = new grpcWeb.MethodDescriptor( | ||
"/api.uiservice.v1.UIService/GetUsersForNamespace", | ||
'/api.uiservice.v1.UIService/GetUsersForNamespace', | ||
grpcWeb.MethodType.UNARY, | ||
@@ -52,4 +53,3 @@ api_uiservice_service_pb.GetUsersForNamespaceRequest, | ||
request: api_uiservice_service_pb.GetUsersForNamespaceRequest, | ||
metadata: grpcWeb.Metadata | null | ||
): Promise<api_uiservice_service_pb.GetUsersForNamespaceResponse>; | ||
metadata: grpcWeb.Metadata | null): Promise<api_uiservice_service_pb.GetUsersForNamespaceResponse>; | ||
@@ -59,7 +59,4 @@ getUsersForNamespace( | ||
metadata: grpcWeb.Metadata | null, | ||
callback: ( | ||
err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersForNamespaceResponse | ||
) => void | ||
): grpcWeb.ClientReadableStream<api_uiservice_service_pb.GetUsersForNamespaceResponse>; | ||
callback: (err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersForNamespaceResponse) => void): grpcWeb.ClientReadableStream<api_uiservice_service_pb.GetUsersForNamespaceResponse>; | ||
@@ -69,26 +66,23 @@ getUsersForNamespace( | ||
metadata: grpcWeb.Metadata | null, | ||
callback?: ( | ||
err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersForNamespaceResponse | ||
) => void | ||
) { | ||
callback?: (err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersForNamespaceResponse) => void) { | ||
if (callback !== undefined) { | ||
return this.client_.rpcCall( | ||
this.hostname_ + "/api.uiservice.v1.UIService/GetUsersForNamespace", | ||
this.hostname_ + | ||
'/api.uiservice.v1.UIService/GetUsersForNamespace', | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersForNamespace, | ||
callback | ||
); | ||
callback); | ||
} | ||
return this.client_.unaryCall( | ||
this.hostname_ + "/api.uiservice.v1.UIService/GetUsersForNamespace", | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersForNamespace | ||
); | ||
this.hostname_ + | ||
'/api.uiservice.v1.UIService/GetUsersForNamespace', | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersForNamespace); | ||
} | ||
methodDescriptorGetUsersWithAccountRoles = new grpcWeb.MethodDescriptor( | ||
"/api.uiservice.v1.UIService/GetUsersWithAccountRoles", | ||
'/api.uiservice.v1.UIService/GetUsersWithAccountRoles', | ||
grpcWeb.MethodType.UNARY, | ||
@@ -105,4 +99,3 @@ api_uiservice_service_pb.GetUsersWithAccountRolesRequest, | ||
request: api_uiservice_service_pb.GetUsersWithAccountRolesRequest, | ||
metadata: grpcWeb.Metadata | null | ||
): Promise<api_uiservice_service_pb.GetUsersWithAccountRolesResponse>; | ||
metadata: grpcWeb.Metadata | null): Promise<api_uiservice_service_pb.GetUsersWithAccountRolesResponse>; | ||
@@ -112,7 +105,4 @@ getUsersWithAccountRoles( | ||
metadata: grpcWeb.Metadata | null, | ||
callback: ( | ||
err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersWithAccountRolesResponse | ||
) => void | ||
): grpcWeb.ClientReadableStream<api_uiservice_service_pb.GetUsersWithAccountRolesResponse>; | ||
callback: (err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersWithAccountRolesResponse) => void): grpcWeb.ClientReadableStream<api_uiservice_service_pb.GetUsersWithAccountRolesResponse>; | ||
@@ -122,24 +112,22 @@ getUsersWithAccountRoles( | ||
metadata: grpcWeb.Metadata | null, | ||
callback?: ( | ||
err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersWithAccountRolesResponse | ||
) => void | ||
) { | ||
console.log(this.client_, this.hostname_); | ||
callback?: (err: grpcWeb.RpcError, | ||
response: api_uiservice_service_pb.GetUsersWithAccountRolesResponse) => void) { | ||
if (callback !== undefined) { | ||
return this.client_.rpcCall( | ||
this.hostname_ + "/api.uiservice.v1.UIService/GetUsersWithAccountRoles", | ||
this.hostname_ + | ||
'/api.uiservice.v1.UIService/GetUsersWithAccountRoles', | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersWithAccountRoles, | ||
callback | ||
); | ||
callback); | ||
} | ||
return this.client_.unaryCall( | ||
this.hostname_ + "/api.uiservice.v1.UIService/GetUsersWithAccountRoles", | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersWithAccountRoles | ||
); | ||
this.hostname_ + | ||
'/api.uiservice.v1.UIService/GetUsersWithAccountRoles', | ||
request, | ||
metadata || {}, | ||
this.methodDescriptorGetUsersWithAccountRoles); | ||
} | ||
} | ||
@@ -6,3 +6,3 @@ import { | ||
} from "@grpc/grpc-js"; | ||
import { loadSync } from "@grpc/proto-loader"; | ||
import { loadSync, Options } from "@grpc/proto-loader"; | ||
import { readdirSync } from "fs"; | ||
@@ -20,3 +20,3 @@ import { join } from "path"; | ||
const loaderOptions = { | ||
const loaderOptions: Options = { | ||
keepCase: true, | ||
@@ -26,2 +26,4 @@ longs: String, | ||
arrays: true, | ||
objects: true, | ||
defaults: true, | ||
}; | ||
@@ -56,2 +58,3 @@ | ||
const packageDefinition = loadSync(files, loaderOptions); | ||
// console.log(packageDefinition["api.namespaceservice.v1.NamespaceService"]); | ||
const protos = loadPackageDefinition(packageDefinition) as any; | ||
@@ -58,0 +61,0 @@ |
import { UntypedServiceImplementation } from "@grpc/grpc-js"; | ||
import { UnaryCallback } from "@grpc/grpc-js/build/src/client"; | ||
import { | ||
GetNamespacesResponse, | ||
ListNamespacesResponse, | ||
} from "../../api/namespaceservice/v1/request_response_pb"; | ||
Namespace, | ||
NamespaceSpec, | ||
State, | ||
} from "../../api/namespace/v1/message_pb"; | ||
export const NamespaceServiceMockImplementation: UntypedServiceImplementation = | ||
{ | ||
listNamespaces: (call: any, callback: any) => { | ||
callback(null, new ListNamespacesResponse()); | ||
listNamespaces: ( | ||
_: any, | ||
callback: UnaryCallback<{ namespaces: string[] }> | ||
) => { | ||
callback(null, { | ||
namespaces: ["namespace-1", "namespace-2", "namespace-3"], | ||
}); | ||
}, | ||
getNamespaces: (call: any, callback: any) => { | ||
callback(null, new GetNamespacesResponse()); | ||
getNamespaces: ( | ||
_: any, | ||
callback: UnaryCallback<{ namespaces: Namespace.AsObject[] }> | ||
) => { | ||
const spec = new NamespaceSpec() | ||
.setRegion("us-east-1") | ||
.setRetentionDays(30); | ||
callback(null, { | ||
namespaces: [ | ||
new Namespace() | ||
.setNamespace("namespace-1") | ||
.setState(State.STATE_ACTIVE) | ||
.setSpec(spec) | ||
.toObject(), | ||
new Namespace() | ||
.setNamespace("namespace-2") | ||
.setState(State.STATE_ACTIVATING) | ||
.setSpec(spec) | ||
.toObject(), | ||
new Namespace() | ||
.setNamespace("namespace-3") | ||
.setState(State.STATE_ACTIVATION_FAILED) | ||
.setSpec(spec) | ||
.toObject(), | ||
], | ||
}); | ||
}, | ||
}; |
import { UntypedServiceImplementation } from "@grpc/grpc-js"; | ||
import { | ||
GetUsersForNamespaceResponse, | ||
GetUsersWithAccountRolesResponse, | ||
} from "../../api/uiservice/service_pb"; | ||
import { UnaryCallback } from "@grpc/grpc-js/build/src/client"; | ||
import { User, UserSpec } from "../../api/auth/v1/message_pb"; | ||
import { User as UIUser } from "../../api/uiservice/service_pb"; | ||
const getUsersWithAccountRolesResponse = new GetUsersWithAccountRolesResponse(); | ||
const getUsersForNamespaceResponse = new GetUsersForNamespaceResponse(); | ||
const users = [ | ||
new User() | ||
.setId("user-1") | ||
.setSpec(new UserSpec().setEmail("user-1@temporal.io")), | ||
new User() | ||
.setId("user-2") | ||
.setSpec(new UserSpec().setEmail("user-2@temporal.io")), | ||
new User() | ||
.setId("user-3") | ||
.setSpec(new UserSpec().setEmail("user-3@temporal.io")), | ||
]; | ||
export const UIServiceMockImplementation: UntypedServiceImplementation = { | ||
getUsersForNamespace: (_: any, callback: any) => { | ||
callback(null, getUsersForNamespaceResponse); | ||
getUsersForNamespace: ( | ||
_: any, | ||
callback: UnaryCallback<{ users: User.AsObject[] }> | ||
) => { | ||
callback(null, { | ||
users: users.map((u) => u.toObject()), | ||
}); | ||
}, | ||
getUsersWithAccountRoles: (_: any, callback: any) => { | ||
callback(null, getUsersWithAccountRolesResponse); | ||
getUsersWithAccountRoles: ( | ||
_: any, | ||
callback: UnaryCallback<{ users: UIUser.AsObject[] }> | ||
) => { | ||
callback(null, { | ||
users: [ | ||
new UIUser().setUser(users[0]).toObject(), | ||
new UIUser().setUser(users[1]).toObject(), | ||
new UIUser().setUser(users[2]).toObject(), | ||
], | ||
}); | ||
}, | ||
}; |
{ | ||
"name": "@temporalio/cloud-api-definitions", | ||
"version": "0.0.1-alpha.7", | ||
"version": "0.0.1-alpha.8", | ||
"files": [ | ||
@@ -5,0 +5,0 @@ "/api/**/*", |
771543
19149