Skip to content

Commit

Permalink
Merge pull request #32 from betwixt-labs/vnext
Browse files Browse the repository at this point in the history
bump
  • Loading branch information
andrewmd5 authored Mar 12, 2024
2 parents a64f9d9 + 628d5bb commit 3dce24d
Show file tree
Hide file tree
Showing 22 changed files with 1,546 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.0.10
VERSION=0.0.12
21 changes: 8 additions & 13 deletions examples/typescript/minimal/bebop.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"inputFiles": [
"./shared/greeter.bop"
],
"exclude": [
"node_modules"
],
"generators": [
{
"alias": "ts",
"outFile": "./shared/index.ts"
}
]
}
"include": ["**/*.bop"],
"exclude": ["node_modules"],
"generators": {
"ts": {
"outFile": "./shared/index.ts"
}
}
}
17 changes: 9 additions & 8 deletions examples/typescript/minimal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"version": "0.0.1",
"type": "module",
"scripts": {
"build:server": "bebopc && tsup ./server/index.ts --out-dir ./dist/server/",
"dev:server": "bebopc && tsx watch server",
"dev:client": "bebopc && wait-port 3000 && tsx watch client",
"build:server": "bebopc build && tsup ./server/index.ts --out-dir ./dist/server/",
"dev:server": "bebopc build && tsx watch server",
"dev:client": "bebopc build && wait-port 3000 && tsx watch client",
"dev:browser": "yarn webpack serve --mode development --open --hot",
"start:server": "bebopc && node ./dist/server/index.cjs",
"start:server": "bebopc build && node ./dist/server/index.cjs",
"build:browser": "webpack --mode production"
},
"workspaces": [
Expand All @@ -18,16 +18,17 @@
"browser"
],
"devDependencies": {
"@swc/core": "^1.4.0",
"@types/node": "^18.7.20",
"bebop-tools": "^2.8.5",
"bebop-tools": "^3.0.3-beta.2",
"tsup": "^6.7.0",
"tsx": "^3.12.7",
"typescript": "^4.8.3",
"wait-port": "^1.0.4"
},
"dependencies": {
"@tempojs/client": "^0.0.10",
"@tempojs/node-http-router": "^0.0.10",
"bebop": "^2.8.5"
"@tempojs/client": "^0.0.11-alpha.2",
"@tempojs/node-http-router": "^0.0.11-alpha.2",
"bebop": "3.0.3-beta.3"
}
}
150 changes: 141 additions & 9 deletions examples/typescript/minimal/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,102 @@
//
//
// bebopc version:
// 2.7.0
// 3.0.3-beta.2
//
//
// bebopc source:
// https://github.com/RainwayApp/bebop
// https://github.com/betwixt-labs/bebop
//
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
import { BebopView, BebopRuntimeError, BebopRecord } from "bebop";
import { BebopView, BebopRuntimeError, BebopRecord, BebopJson, BebopTypeGuard, Guid, GuidMap } from "bebop";
import { Metadata, MethodType } from "@tempojs/common";
import { BaseClient, MethodInfo, CallOptions } from "@tempojs/client";
import { ServiceRegistry, BaseService, ServerContext, BebopMethodAny, BebopMethod } from "@tempojs/server";

export const BEBOP_SCHEMA = new Uint8Array([
3, 2, 0, 0, 0, 72, 101, 108, 108, 111, 82, 101, 113, 117,
101, 115, 116, 0, 1, 0, 0, 4, 0, 0, 0, 0, 1, 110, 97, 109,
101, 0, 245, 255, 255, 255, 0, 72, 101, 108, 108, 111, 82,
101, 115, 112, 111, 110, 115, 101, 0, 1, 0, 0, 4, 0, 0, 0,
0, 1, 115, 101, 114, 118, 105, 99, 101, 77, 101, 115, 115,
97, 103, 101, 0, 245, 255, 255, 255, 0, 1, 0, 0, 0, 71,
114, 101, 101, 116, 101, 114, 0, 0, 4, 0, 0, 0, 115, 97,
121, 72, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
0, 85, 246, 254, 77, 115, 97, 121, 72, 101, 108, 108, 111,
67, 108, 105, 101, 110, 116, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0,
0, 196, 25, 111, 204, 115, 97, 121, 72, 101, 108, 108,
111, 83, 101, 114, 118, 101, 114, 0, 0, 1, 0, 0, 0, 0, 1,
0, 0, 0, 84, 166, 66, 202, 115, 97, 121, 72, 101, 108,
108, 111, 68, 117, 112, 108, 101, 120, 0, 0, 3, 0, 0, 0,
0, 1, 0, 0, 0, 66, 158, 17, 152
]);

/**
* `HelloRequest` is a struct representing a request to the Greeter service.
*/
export interface IHelloRequest extends BebopRecord {
/**
* The name to be used in the greeting, of type string.
*/
name: string;
readonly name: string;
}

export class HelloRequest implements IHelloRequest {
public name: string;
public readonly name: string;

constructor(record: IHelloRequest) {
this.name = record.name;
}

/**
* Serializes the current instance into a JSON-Over-Bebop string
*/
public toJSON(): string {
return HelloRequest.encodeToJSON(this);
}

/**
* Serializes the specified object into a JSON-Over-Bebop string
*/
public static encodeToJSON(record: IHelloRequest): string {
return JSON.stringify(record, BebopJson.replacer);
}

/**
* Validates that the runtime types of members in the current instance are correct.
*/
public validateTypes(): void {
HelloRequest.validateCompatibility(this);
}

/**
* Validates that the specified dynamic object can become an instance of {@link HelloRequest}.
*/
public static validateCompatibility(record: IHelloRequest): void {
BebopTypeGuard.ensureString(record.name)
}

/**
* Unsafely creates an instance of {@link HelloRequest} from the specified dynamic object. No type checking is performed.
*/
public static unsafeCast(record: any): IHelloRequest {
return new HelloRequest(record);
}

/**
* Creates a new {@link HelloRequest} instance from a JSON-Over-Bebop string. Type checking is performed.
*/
public static fromJSON(json: string): IHelloRequest {
if (typeof json !== 'string' || json.trim().length === 0) {
throw new BebopRuntimeError(`HelloRequest.fromJSON: expected string`);
}
const parsed = JSON.parse(json, BebopJson.reviver);
HelloRequest.validateCompatibility(parsed);
return HelloRequest.unsafeCast(parsed);
}
public encode(): Uint8Array {
return HelloRequest.encode(this);
}
Expand Down Expand Up @@ -66,7 +130,7 @@ export class HelloRequest implements IHelloRequest {
let message: IHelloRequest = {
name: field0,
};
return new this(message);
return new HelloRequest(message);
}
}

Expand All @@ -77,16 +141,62 @@ export interface IHelloResponse extends BebopRecord {
/**
* The greeting message generated by the service, of type string.
*/
serviceMessage: string;
readonly serviceMessage: string;
}

export class HelloResponse implements IHelloResponse {
public serviceMessage: string;
public readonly serviceMessage: string;

constructor(record: IHelloResponse) {
this.serviceMessage = record.serviceMessage;
}

/**
* Serializes the current instance into a JSON-Over-Bebop string
*/
public toJSON(): string {
return HelloResponse.encodeToJSON(this);
}

/**
* Serializes the specified object into a JSON-Over-Bebop string
*/
public static encodeToJSON(record: IHelloResponse): string {
return JSON.stringify(record, BebopJson.replacer);
}

/**
* Validates that the runtime types of members in the current instance are correct.
*/
public validateTypes(): void {
HelloResponse.validateCompatibility(this);
}

/**
* Validates that the specified dynamic object can become an instance of {@link HelloResponse}.
*/
public static validateCompatibility(record: IHelloResponse): void {
BebopTypeGuard.ensureString(record.serviceMessage)
}

/**
* Unsafely creates an instance of {@link HelloResponse} from the specified dynamic object. No type checking is performed.
*/
public static unsafeCast(record: any): IHelloResponse {
return new HelloResponse(record);
}

/**
* Creates a new {@link HelloResponse} instance from a JSON-Over-Bebop string. Type checking is performed.
*/
public static fromJSON(json: string): IHelloResponse {
if (typeof json !== 'string' || json.trim().length === 0) {
throw new BebopRuntimeError(`HelloResponse.fromJSON: expected string`);
}
const parsed = JSON.parse(json, BebopJson.reviver);
HelloResponse.validateCompatibility(parsed);
return HelloResponse.unsafeCast(parsed);
}
public encode(): Uint8Array {
return HelloResponse.encode(this);
}
Expand Down Expand Up @@ -117,7 +227,7 @@ export class HelloResponse implements IHelloResponse {
let message: IHelloResponse = {
serviceMessage: field0,
};
return new this(message);
return new HelloResponse(message);
}
}

Expand Down Expand Up @@ -178,6 +288,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
invoke: service.sayHello,
serialize: HelloResponse.encode,
deserialize: HelloRequest.decode,
toJSON: HelloResponse.encodeToJSON,
fromJSON: HelloRequest.fromJSON,
type: MethodType.Unary,
} as BebopMethod<IHelloRequest, IHelloResponse>);
if (this.methods.has(3429833156)) {
Expand All @@ -190,6 +302,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
invoke: service.sayHelloClient,
serialize: HelloResponse.encode,
deserialize: HelloRequest.decode,
toJSON: HelloResponse.encodeToJSON,
fromJSON: HelloRequest.fromJSON,
type: MethodType.ClientStream,
} as BebopMethod<IHelloRequest, IHelloResponse>);
if (this.methods.has(3393365588)) {
Expand All @@ -202,6 +316,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
invoke: service.sayHelloServer,
serialize: HelloResponse.encode,
deserialize: HelloRequest.decode,
toJSON: HelloResponse.encodeToJSON,
fromJSON: HelloRequest.fromJSON,
type: MethodType.ServerStream,
} as BebopMethod<IHelloRequest, IHelloResponse>);
if (this.methods.has(2551291458)) {
Expand All @@ -214,6 +330,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
invoke: service.sayHelloDuplex,
serialize: HelloResponse.encode,
deserialize: HelloRequest.decode,
toJSON: HelloResponse.encodeToJSON,
fromJSON: HelloRequest.fromJSON,
type: MethodType.DuplexStream,
} as BebopMethod<IHelloRequest, IHelloResponse>);
}
Expand All @@ -231,10 +349,13 @@ export interface IGreeterClient {
*/
sayHello(request: IHelloRequest): Promise<IHelloResponse>;
sayHello(request: IHelloRequest, metadata: Metadata): Promise<IHelloResponse>;

sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<IHelloResponse>;
sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, metadata: Metadata): Promise<IHelloResponse>;

sayHelloServer(request: IHelloRequest): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
sayHelloServer(request: IHelloRequest, metadata: Metadata): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;

sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, metadata: Metadata): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
}
Expand All @@ -249,6 +370,8 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
id: 1308554837,
serialize: HelloRequest.encode,
deserialize: HelloResponse.decode,
toJSON: HelloRequest.encodeToJSON,
fromJSON: HelloResponse.fromJSON,
type: MethodType.Unary,
}
/**
Expand All @@ -265,8 +388,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
id: 3429833156,
serialize: HelloRequest.encode,
deserialize: HelloResponse.decode,
toJSON: HelloRequest.encodeToJSON,
fromJSON: HelloResponse.fromJSON,
type: MethodType.ClientStream,
}

async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<IHelloResponse>;
async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options: CallOptions): Promise<IHelloResponse>;
async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options?: CallOptions): Promise<IHelloResponse> {
Expand All @@ -278,8 +404,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
id: 3393365588,
serialize: HelloRequest.encode,
deserialize: HelloResponse.decode,
toJSON: HelloRequest.encodeToJSON,
fromJSON: HelloResponse.fromJSON,
type: MethodType.ServerStream,
}

async sayHelloServer(request: IHelloRequest): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
async sayHelloServer(request: IHelloRequest, options: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
async sayHelloServer(request: IHelloRequest, options?: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>> {
Expand All @@ -291,8 +420,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
id: 2551291458,
serialize: HelloRequest.encode,
deserialize: HelloResponse.decode,
toJSON: HelloRequest.encodeToJSON,
fromJSON: HelloResponse.fromJSON,
type: MethodType.DuplexStream,
}

async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options?: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>> {
Expand Down
Loading

0 comments on commit 3dce24d

Please sign in to comment.