| 31 | import { HandleError } from "./helpers"; |
| 32 | |
| 33 | class InternalStore extends EventEmitter { |
| 34 | client: InternalServiceClient; |
| 35 | cachedSettings?: SettingsResponse; |
| 36 | |
| 37 | constructor() { |
| 38 | super(); |
| 39 | this.client = new InternalServiceClient(""); |
| 40 | } |
| 41 | |
| 42 | createApiKey = (req: CreateApiKeyRequest, callbackFunc: (resp: CreateApiKeyResponse) => void) => { |
| 43 | this.client.createApiKey(req, SessionStore.getMetadata(), (err, resp) => { |
| 44 | if (err !== null) { |
| 45 | HandleError(err); |
| 46 | return; |
| 47 | } |
| 48 | |
| 49 | notification.success({ |
| 50 | message: "API key created", |
| 51 | duration: 3, |
| 52 | }); |
| 53 | |
| 54 | callbackFunc(resp); |
| 55 | }); |
| 56 | }; |
| 57 | |
| 58 | deleteApiKey = (req: DeleteApiKeyRequest, callbackFunc: () => void) => { |
| 59 | this.client.deleteApiKey(req, SessionStore.getMetadata(), err => { |
| 60 | if (err !== null) { |
| 61 | HandleError(err); |
| 62 | return; |
| 63 | } |
| 64 | |
| 65 | notification.success({ |
| 66 | message: "API key deleted", |
| 67 | duration: 3, |
| 68 | }); |
| 69 | |
| 70 | callbackFunc(); |
| 71 | }); |
| 72 | }; |
| 73 | |
| 74 | listApiKeys = (req: ListApiKeysRequest, callbackFunc: (resp: ListApiKeysResponse) => void) => { |
| 75 | this.client.listApiKeys(req, SessionStore.getMetadata(), (err, resp) => { |
| 76 | if (err !== null) { |
| 77 | HandleError(err); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | callbackFunc(resp); |
| 82 | }); |
| 83 | }; |
| 84 | |
| 85 | streamGatewayFrames = (req: StreamGatewayFramesRequest, callbackFunc: (resp: LogItem) => void): (() => void) => { |
| 86 | let stream: grpcWeb.ClientReadableStream<LogItem> | undefined = undefined; |
| 87 | |
| 88 | const setup = () => { |
| 89 | console.log("Setting up gRPC stream"); |
| 90 | stream = this.client.streamGatewayFrames(req, SessionStore.getMetadata()); |
nothing calls this directly
no test coverage detected