Skip to content

Commit 3dce24d

Browse files
authored
Merge pull request #32 from betwixt-labs/vnext
bump
2 parents a64f9d9 + 628d5bb commit 3dce24d

File tree

22 files changed

+1546
-61
lines changed

22 files changed

+1546
-61
lines changed

.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION=0.0.10
1+
VERSION=0.0.12
Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
2-
"inputFiles": [
3-
"./shared/greeter.bop"
4-
],
5-
"exclude": [
6-
"node_modules"
7-
],
8-
"generators": [
9-
{
10-
"alias": "ts",
11-
"outFile": "./shared/index.ts"
12-
}
13-
]
14-
}
2+
"include": ["**/*.bop"],
3+
"exclude": ["node_modules"],
4+
"generators": {
5+
"ts": {
6+
"outFile": "./shared/index.ts"
7+
}
8+
}
9+
}

examples/typescript/minimal/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"version": "0.0.1",
55
"type": "module",
66
"scripts": {
7-
"build:server": "bebopc && tsup ./server/index.ts --out-dir ./dist/server/",
8-
"dev:server": "bebopc && tsx watch server",
9-
"dev:client": "bebopc && wait-port 3000 && tsx watch client",
7+
"build:server": "bebopc build && tsup ./server/index.ts --out-dir ./dist/server/",
8+
"dev:server": "bebopc build && tsx watch server",
9+
"dev:client": "bebopc build && wait-port 3000 && tsx watch client",
1010
"dev:browser": "yarn webpack serve --mode development --open --hot",
11-
"start:server": "bebopc && node ./dist/server/index.cjs",
11+
"start:server": "bebopc build && node ./dist/server/index.cjs",
1212
"build:browser": "webpack --mode production"
1313
},
1414
"workspaces": [
@@ -18,16 +18,17 @@
1818
"browser"
1919
],
2020
"devDependencies": {
21+
"@swc/core": "^1.4.0",
2122
"@types/node": "^18.7.20",
22-
"bebop-tools": "^2.8.5",
23+
"bebop-tools": "^3.0.3-beta.2",
2324
"tsup": "^6.7.0",
2425
"tsx": "^3.12.7",
2526
"typescript": "^4.8.3",
2627
"wait-port": "^1.0.4"
2728
},
2829
"dependencies": {
29-
"@tempojs/client": "^0.0.10",
30-
"@tempojs/node-http-router": "^0.0.10",
31-
"bebop": "^2.8.5"
30+
"@tempojs/client": "^0.0.11-alpha.2",
31+
"@tempojs/node-http-router": "^0.0.11-alpha.2",
32+
"bebop": "3.0.3-beta.3"
3233
}
3334
}

examples/typescript/minimal/shared/index.ts

Lines changed: 141 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,102 @@
44
//
55
//
66
// bebopc version:
7-
// 2.7.0
7+
// 3.0.3-beta.2
88
//
99
//
1010
// bebopc source:
11-
// https://github.com/RainwayApp/bebop
11+
// https://github.com/betwixt-labs/bebop
1212
//
1313
//
1414
// Changes to this file may cause incorrect behavior and will be lost if
1515
// the code is regenerated.
1616
// </auto-generated>
17-
import { BebopView, BebopRuntimeError, BebopRecord } from "bebop";
17+
import { BebopView, BebopRuntimeError, BebopRecord, BebopJson, BebopTypeGuard, Guid, GuidMap } from "bebop";
1818
import { Metadata, MethodType } from "@tempojs/common";
1919
import { BaseClient, MethodInfo, CallOptions } from "@tempojs/client";
2020
import { ServiceRegistry, BaseService, ServerContext, BebopMethodAny, BebopMethod } from "@tempojs/server";
2121

22+
export const BEBOP_SCHEMA = new Uint8Array([
23+
3, 2, 0, 0, 0, 72, 101, 108, 108, 111, 82, 101, 113, 117,
24+
101, 115, 116, 0, 1, 0, 0, 4, 0, 0, 0, 0, 1, 110, 97, 109,
25+
101, 0, 245, 255, 255, 255, 0, 72, 101, 108, 108, 111, 82,
26+
101, 115, 112, 111, 110, 115, 101, 0, 1, 0, 0, 4, 0, 0, 0,
27+
0, 1, 115, 101, 114, 118, 105, 99, 101, 77, 101, 115, 115,
28+
97, 103, 101, 0, 245, 255, 255, 255, 0, 1, 0, 0, 0, 71,
29+
114, 101, 101, 116, 101, 114, 0, 0, 4, 0, 0, 0, 115, 97,
30+
121, 72, 101, 108, 108, 111, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
31+
0, 85, 246, 254, 77, 115, 97, 121, 72, 101, 108, 108, 111,
32+
67, 108, 105, 101, 110, 116, 0, 0, 2, 0, 0, 0, 0, 1, 0, 0,
33+
0, 196, 25, 111, 204, 115, 97, 121, 72, 101, 108, 108,
34+
111, 83, 101, 114, 118, 101, 114, 0, 0, 1, 0, 0, 0, 0, 1,
35+
0, 0, 0, 84, 166, 66, 202, 115, 97, 121, 72, 101, 108,
36+
108, 111, 68, 117, 112, 108, 101, 120, 0, 0, 3, 0, 0, 0,
37+
0, 1, 0, 0, 0, 66, 158, 17, 152
38+
]);
39+
2240
/**
2341
* `HelloRequest` is a struct representing a request to the Greeter service.
2442
*/
2543
export interface IHelloRequest extends BebopRecord {
2644
/**
2745
* The name to be used in the greeting, of type string.
2846
*/
29-
name: string;
47+
readonly name: string;
3048
}
3149

3250
export class HelloRequest implements IHelloRequest {
33-
public name: string;
51+
public readonly name: string;
3452

3553
constructor(record: IHelloRequest) {
3654
this.name = record.name;
3755
}
3856

57+
/**
58+
* Serializes the current instance into a JSON-Over-Bebop string
59+
*/
60+
public toJSON(): string {
61+
return HelloRequest.encodeToJSON(this);
62+
}
63+
64+
/**
65+
* Serializes the specified object into a JSON-Over-Bebop string
66+
*/
67+
public static encodeToJSON(record: IHelloRequest): string {
68+
return JSON.stringify(record, BebopJson.replacer);
69+
}
70+
71+
/**
72+
* Validates that the runtime types of members in the current instance are correct.
73+
*/
74+
public validateTypes(): void {
75+
HelloRequest.validateCompatibility(this);
76+
}
77+
78+
/**
79+
* Validates that the specified dynamic object can become an instance of {@link HelloRequest}.
80+
*/
81+
public static validateCompatibility(record: IHelloRequest): void {
82+
BebopTypeGuard.ensureString(record.name)
83+
}
84+
85+
/**
86+
* Unsafely creates an instance of {@link HelloRequest} from the specified dynamic object. No type checking is performed.
87+
*/
88+
public static unsafeCast(record: any): IHelloRequest {
89+
return new HelloRequest(record);
90+
}
91+
92+
/**
93+
* Creates a new {@link HelloRequest} instance from a JSON-Over-Bebop string. Type checking is performed.
94+
*/
95+
public static fromJSON(json: string): IHelloRequest {
96+
if (typeof json !== 'string' || json.trim().length === 0) {
97+
throw new BebopRuntimeError(`HelloRequest.fromJSON: expected string`);
98+
}
99+
const parsed = JSON.parse(json, BebopJson.reviver);
100+
HelloRequest.validateCompatibility(parsed);
101+
return HelloRequest.unsafeCast(parsed);
102+
}
39103
public encode(): Uint8Array {
40104
return HelloRequest.encode(this);
41105
}
@@ -66,7 +130,7 @@ export class HelloRequest implements IHelloRequest {
66130
let message: IHelloRequest = {
67131
name: field0,
68132
};
69-
return new this(message);
133+
return new HelloRequest(message);
70134
}
71135
}
72136

@@ -77,16 +141,62 @@ export interface IHelloResponse extends BebopRecord {
77141
/**
78142
* The greeting message generated by the service, of type string.
79143
*/
80-
serviceMessage: string;
144+
readonly serviceMessage: string;
81145
}
82146

83147
export class HelloResponse implements IHelloResponse {
84-
public serviceMessage: string;
148+
public readonly serviceMessage: string;
85149

86150
constructor(record: IHelloResponse) {
87151
this.serviceMessage = record.serviceMessage;
88152
}
89153

154+
/**
155+
* Serializes the current instance into a JSON-Over-Bebop string
156+
*/
157+
public toJSON(): string {
158+
return HelloResponse.encodeToJSON(this);
159+
}
160+
161+
/**
162+
* Serializes the specified object into a JSON-Over-Bebop string
163+
*/
164+
public static encodeToJSON(record: IHelloResponse): string {
165+
return JSON.stringify(record, BebopJson.replacer);
166+
}
167+
168+
/**
169+
* Validates that the runtime types of members in the current instance are correct.
170+
*/
171+
public validateTypes(): void {
172+
HelloResponse.validateCompatibility(this);
173+
}
174+
175+
/**
176+
* Validates that the specified dynamic object can become an instance of {@link HelloResponse}.
177+
*/
178+
public static validateCompatibility(record: IHelloResponse): void {
179+
BebopTypeGuard.ensureString(record.serviceMessage)
180+
}
181+
182+
/**
183+
* Unsafely creates an instance of {@link HelloResponse} from the specified dynamic object. No type checking is performed.
184+
*/
185+
public static unsafeCast(record: any): IHelloResponse {
186+
return new HelloResponse(record);
187+
}
188+
189+
/**
190+
* Creates a new {@link HelloResponse} instance from a JSON-Over-Bebop string. Type checking is performed.
191+
*/
192+
public static fromJSON(json: string): IHelloResponse {
193+
if (typeof json !== 'string' || json.trim().length === 0) {
194+
throw new BebopRuntimeError(`HelloResponse.fromJSON: expected string`);
195+
}
196+
const parsed = JSON.parse(json, BebopJson.reviver);
197+
HelloResponse.validateCompatibility(parsed);
198+
return HelloResponse.unsafeCast(parsed);
199+
}
90200
public encode(): Uint8Array {
91201
return HelloResponse.encode(this);
92202
}
@@ -117,7 +227,7 @@ export class HelloResponse implements IHelloResponse {
117227
let message: IHelloResponse = {
118228
serviceMessage: field0,
119229
};
120-
return new this(message);
230+
return new HelloResponse(message);
121231
}
122232
}
123233

@@ -178,6 +288,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
178288
invoke: service.sayHello,
179289
serialize: HelloResponse.encode,
180290
deserialize: HelloRequest.decode,
291+
toJSON: HelloResponse.encodeToJSON,
292+
fromJSON: HelloRequest.fromJSON,
181293
type: MethodType.Unary,
182294
} as BebopMethod<IHelloRequest, IHelloResponse>);
183295
if (this.methods.has(3429833156)) {
@@ -190,6 +302,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
190302
invoke: service.sayHelloClient,
191303
serialize: HelloResponse.encode,
192304
deserialize: HelloRequest.decode,
305+
toJSON: HelloResponse.encodeToJSON,
306+
fromJSON: HelloRequest.fromJSON,
193307
type: MethodType.ClientStream,
194308
} as BebopMethod<IHelloRequest, IHelloResponse>);
195309
if (this.methods.has(3393365588)) {
@@ -202,6 +316,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
202316
invoke: service.sayHelloServer,
203317
serialize: HelloResponse.encode,
204318
deserialize: HelloRequest.decode,
319+
toJSON: HelloResponse.encodeToJSON,
320+
fromJSON: HelloRequest.fromJSON,
205321
type: MethodType.ServerStream,
206322
} as BebopMethod<IHelloRequest, IHelloResponse>);
207323
if (this.methods.has(2551291458)) {
@@ -214,6 +330,8 @@ export class TempoServiceRegistry extends ServiceRegistry {
214330
invoke: service.sayHelloDuplex,
215331
serialize: HelloResponse.encode,
216332
deserialize: HelloRequest.decode,
333+
toJSON: HelloResponse.encodeToJSON,
334+
fromJSON: HelloRequest.fromJSON,
217335
type: MethodType.DuplexStream,
218336
} as BebopMethod<IHelloRequest, IHelloResponse>);
219337
}
@@ -231,10 +349,13 @@ export interface IGreeterClient {
231349
*/
232350
sayHello(request: IHelloRequest): Promise<IHelloResponse>;
233351
sayHello(request: IHelloRequest, metadata: Metadata): Promise<IHelloResponse>;
352+
234353
sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<IHelloResponse>;
235354
sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, metadata: Metadata): Promise<IHelloResponse>;
355+
236356
sayHelloServer(request: IHelloRequest): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
237357
sayHelloServer(request: IHelloRequest, metadata: Metadata): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
358+
238359
sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
239360
sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, metadata: Metadata): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
240361
}
@@ -249,6 +370,8 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
249370
id: 1308554837,
250371
serialize: HelloRequest.encode,
251372
deserialize: HelloResponse.decode,
373+
toJSON: HelloRequest.encodeToJSON,
374+
fromJSON: HelloResponse.fromJSON,
252375
type: MethodType.Unary,
253376
}
254377
/**
@@ -265,8 +388,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
265388
id: 3429833156,
266389
serialize: HelloRequest.encode,
267390
deserialize: HelloResponse.decode,
391+
toJSON: HelloRequest.encodeToJSON,
392+
fromJSON: HelloResponse.fromJSON,
268393
type: MethodType.ClientStream,
269394
}
395+
270396
async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<IHelloResponse>;
271397
async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options: CallOptions): Promise<IHelloResponse>;
272398
async sayHelloClient(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options?: CallOptions): Promise<IHelloResponse> {
@@ -278,8 +404,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
278404
id: 3393365588,
279405
serialize: HelloRequest.encode,
280406
deserialize: HelloResponse.decode,
407+
toJSON: HelloRequest.encodeToJSON,
408+
fromJSON: HelloResponse.fromJSON,
281409
type: MethodType.ServerStream,
282410
}
411+
283412
async sayHelloServer(request: IHelloRequest): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
284413
async sayHelloServer(request: IHelloRequest, options: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
285414
async sayHelloServer(request: IHelloRequest, options?: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>> {
@@ -291,8 +420,11 @@ export class GreeterClient extends BaseClient implements IGreeterClient {
291420
id: 2551291458,
292421
serialize: HelloRequest.encode,
293422
deserialize: HelloResponse.decode,
423+
toJSON: HelloRequest.encodeToJSON,
424+
fromJSON: HelloResponse.fromJSON,
294425
type: MethodType.DuplexStream,
295426
}
427+
296428
async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
297429
async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>>;
298430
async sayHelloDuplex(request: () => AsyncGenerator<IHelloRequest, void, undefined>, options?: CallOptions): Promise<AsyncGenerator<IHelloResponse, void, undefined>> {

0 commit comments

Comments
 (0)