Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript for 615, 666, 719 #733

Merged
merged 1 commit into from
Jun 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions web/src/AccountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import {
ServiceOptions,
SignInRequest,
TokenProtection,
LoginRequest,
LoginResponse,
LoginConfirmRequest,
LoginConfirmResponse,
AuthorizeWebhookRequest,
AuthorizeWebhookResponse,
} from "./proto";
import { Oberon } from "@trinsic/okapi";
import base64url from "base64url";
Expand Down Expand Up @@ -107,6 +113,24 @@ export class AccountService extends ServiceBase {
return authToken;
}

public async login(request: LoginRequest): Promise<LoginResponse> {
return this.client.login(request, {
metadata: await this.getMetadata(
ListDevicesRequest.encode(request).finish()
),
});
}

public async loginConfirm(
request: LoginConfirmRequest
): Promise<LoginConfirmResponse> {
return this.client.loginConfirm(request, {
metadata: await this.getMetadata(
ListDevicesRequest.encode(request).finish()
),
});
}

public async info(): Promise<AccountInfoResponse> {
const request = AccountInfoRequest.fromPartial({});

Expand Down Expand Up @@ -136,4 +160,14 @@ export class AccountService extends ServiceBase {
),
});
}

public async authorizeWebhook(
request: AuthorizeWebhookRequest
): Promise<AuthorizeWebhookResponse> {
return this.client.authorizeWebhook(request, {
metadata: await this.getMetadata(
ListDevicesRequest.encode(request).finish()
),
});
}
}
105 changes: 93 additions & 12 deletions web/src/ProviderService.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,24 @@
import ServiceBase from "./ServiceBase";
import {
CreateEcosystemRequest,
CreateEcosystemResponse,
InvitationStatusRequest,
InvitationStatusResponse,
InviteRequest,
InviteResponse,
ProviderDefinition,
ServiceOptions,
AddWebhookRequest, AddWebhookResponse,
CreateEcosystemRequest,
CreateEcosystemResponse, DeleteWebhookRequest, DeleteWebhookResponse,
EcosystemInfoRequest,
EcosystemInfoResponse,
GenerateTokenRequest,
GenerateTokenResponse,
GetEventTokenRequest,
GetEventTokenResponse,
GetOberonKeyRequest,
GetOberonKeyResponse,
InvitationStatusRequest,
InvitationStatusResponse,
InviteRequest,
InviteResponse,
ProviderDefinition,
ServiceOptions,
UpdateEcosystemRequest,
UpdateEcosystemResponse,
} from "./proto";

import type { Client as BrowserClient } from "nice-grpc-web";
Expand All @@ -21,6 +32,62 @@ export class ProviderService extends ServiceBase {
this.client = this.createClient(ProviderDefinition);
}

public async createEcosystem(
request: CreateEcosystemRequest
): Promise<CreateEcosystemResponse> {
return this.client.createEcosystem(request);
}

public async updateEcosystem(
request: UpdateEcosystemRequest
): Promise<UpdateEcosystemResponse> {
return this.client.updateEcosystem(request, {
metadata: await this.getMetadata(
UpdateEcosystemRequest.encode(request).finish()
),
});
}

public async addWebhook(
request: AddWebhookRequest
): Promise<AddWebhookResponse> {
return this.client.addWebhook(request, {
metadata: await this.getMetadata(
AddWebhookRequest.encode(request).finish()
),
});
}

public async deleteWebhook(
request: DeleteWebhookRequest
): Promise<DeleteWebhookResponse> {
return this.client.deleteWebhook(request, {
metadata: await this.getMetadata(
DeleteWebhookRequest.encode(request).finish()
),
});
}

public async ecosystemInfo(
request: EcosystemInfoRequest
): Promise<EcosystemInfoResponse> {
return this.client.ecosystemInfo(request, {
metadata: await this.getMetadata(
EcosystemInfoRequest.encode(request).finish()
),
});
}

public async generateToken(
request: GenerateTokenRequest
): Promise<GenerateTokenResponse> {
return this.client.generateToken(request, {
metadata: await this.getMetadata(
GenerateTokenRequest.encode(request).finish()
),
});
}

public async inviteParticipant(
request: InviteRequest
): Promise<InviteResponse> {
Expand All @@ -39,9 +106,23 @@ export class ProviderService extends ServiceBase {
});
}

public async createEcosystem(
request: CreateEcosystemRequest
): Promise<CreateEcosystemResponse> {
return this.client.createEcosystem(request);
public async getOberonKey(
request: GetOberonKeyRequest
): Promise<GetOberonKeyResponse> {
return this.client.getOberonKey(request, {
metadata: await this.getMetadata(
GetOberonKeyRequest.encode(request).finish()
),
});
}

public async getEventToken(
request: GetEventTokenRequest
): Promise<GetEventTokenResponse> {
return this.client.getEventToken(request, {
metadata: await this.getMetadata(
GetEventTokenRequest.encode(request).finish()
),
});
}
}
64 changes: 64 additions & 0 deletions web/src/TrinsicService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import ServiceBase from "./ServiceBase";
import {ServiceOptions} from "./proto/sdk/options/v1/options";
import {AccountService} from "./AccountService";
import {CredentialService} from "./CredentialService";
import {TemplateService} from "./TemplateService";
import {ProviderService} from "./ProviderService";
import {TrustRegistryService} from "./TrustRegistryService";
import {WalletService} from "./WalletService";


export class TrinsicService extends ServiceBase {
private _account: AccountService | undefined;
private _credential: CredentialService | undefined;
private _provider: ProviderService | undefined;
private _template: TemplateService | undefined;
private _trustRegistry: TrustRegistryService | undefined;
private _wallet: WalletService | undefined;

constructor(options?: ServiceOptions) {
super(options);
}

public account(): AccountService {
this._account =
this._account || new AccountService(this.options);

return this._account!;
}

public credential(): CredentialService {
this._credential =
this._credential || new CredentialService(this.options);

return this._credential!;
}

public provider(): ProviderService {
this._provider =
this._provider || new ProviderService(this.options);

return this._provider!;
}

public template(): TemplateService {
this._template =
this._template || new TemplateService(this.options);

return this._template!;
}

public trustRegistry(): TrustRegistryService {
this._trustRegistry =
this._trustRegistry || new TrustRegistryService(this.options);

return this._trustRegistry!;
}

public wallet(): WalletService {
this._wallet =
this._wallet || new WalletService(this.options);

return this._wallet!;
}
}
12 changes: 6 additions & 6 deletions web/src/proto/google/protobuf/descriptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ export interface UninterpretedOption {
* The name of the uninterpreted option. Each string represents a segment in
* a dot-separated name. is_extension is true iff a segment represents an
* extension (denoted with parentheses in options specs in .proto files).
* E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
* "foo.(bar.baz).qux".
* E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
* "foo.(bar.baz).moo".
*/
export interface UninterpretedOption_NamePart {
namePart: string;
Expand Down Expand Up @@ -1083,13 +1083,13 @@ export interface SourceCodeInfo_Location {
* // Comment attached to baz.
* // Another line attached to baz.
*
* // Comment attached to qux.
* // Comment attached to moo.
* //
* // Another line attached to qux.
* optional double qux = 4;
* // Another line attached to moo.
* optional double moo = 4;
*
* // Detached comment for corge. This is not leading or trailing comments
* // to qux or corge because there are blank lines separating it from
* // to moo or corge because there are blank lines separating it from
* // both.
*
* // Detached comment for corge paragraph 2.
Expand Down
2 changes: 0 additions & 2 deletions web/src/proto/google/protobuf/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import * as _m0 from "protobufjs/minimal";
* service Foo {
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
* }
*
* The JSON representation for `Empty` is empty JSON object `{}`.
*/
export interface Empty {}

Expand Down