Skip to content

Commit

Permalink
refactor: Use more standard TypeScript project structure, update snap…
Browse files Browse the repository at this point in the history
…shots
  • Loading branch information
pojntfx committed Jan 10, 2024
1 parent 92aac4e commit b97891d
Show file tree
Hide file tree
Showing 14 changed files with 267 additions and 10 deletions.
Binary file modified bun.lockb
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { env, exit } from "process";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { Socket, createServer } from "net";
import { ILocalContext, Registry, remoteClosure } from "./index";
import { ILocalContext, Registry, remoteClosure } from "../index";

class Local {
// eslint-disable-next-line class-methods-use-this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInterface } from "readline/promises";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { Socket, createServer } from "net";
import { IRemoteContext, Registry } from "./index";
import { IRemoteContext, Registry } from "../index";

class Local {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInterface } from "readline/promises";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { Socket, createServer } from "net";
import { ILocalContext, IRemoteContext, Registry } from "./index";
import { ILocalContext, IRemoteContext, Registry } from "../index";

class Local {
// eslint-disable-next-line class-methods-use-this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInterface } from "readline/promises";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { Socket, createServer } from "net";
import { ILocalContext, IRemoteContext, Registry } from "./index";
import { ILocalContext, IRemoteContext, Registry } from "../index";

class Local {
private counter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInterface } from "readline/promises";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { WebSocketServer } from "ws";
import { ILocalContext, IRemoteContext, Registry } from "./index";
import { ILocalContext, IRemoteContext, Registry } from "../index";

class Local {
// eslint-disable-next-line class-methods-use-this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { createInterface } from "readline/promises";
import { parse } from "url";
// eslint-disable-next-line import/no-extraneous-dependencies
import { WebSocketServer } from "ws";
import { ILocalContext, IRemoteContext, Registry } from "./index";
import { ILocalContext, IRemoteContext, Registry } from "../index";

class Local {
private counter = 0;
Expand Down
6 changes: 3 additions & 3 deletions ts/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from "./registry";
export * from "./context";
export { ErrorClosureDoesNotExist } from "./manager";
export * from "./rpc/registry";
export * from "./rpc/context";
export { ErrorClosureDoesNotExist } from "./rpc/manager";
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ts/registry.ts → ts/rpc/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
unmarshalMessage,
unmarshalRequest,
unmarshalResponse,
} from "./messages";
} from "../utils/messages";
import { ILocalContext, IRemoteContext } from "./context";
import { ClosureManager, registerClosure } from "./manager";

Expand Down
257 changes: 257 additions & 0 deletions ts/utils/__snapshots__/messages.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
// Bun Snapshot v1, https://goo.gl/fbAQLP

exports[`Nested encoding Message can marshal a message with a request set 1`] = `"{"request":"eyJjYWxsIjoiMSIsImZ1bmN0aW9uIjoiUHJpbnRsbiIsImFyZ3MiOlsiSWtobGJHeHZMQ0IzYjNKc1pDRWkiXX0=","response":""}"`;

exports[`Nested encoding Message can unmarshal a message with a request set 1`] = `
{
"request": "eyJjYWxsIjoiMSIsImZ1bmN0aW9uIjoiUHJpbnRsbiIsImFyZ3MiOlsiSWtobGJHeHZMQ0IzYjNKc1pDRWkiXX0=",
"response": "",
}
`;

exports[`Nested encoding Message can marshal a message with a response set 1`] = `"{"request":"","response":"eyJjYWxsIjoiMSIsInZhbHVlIjoiZEhKMVpRPT0iLCJlcnIiOiIifQ=="}"`;

exports[`Nested encoding Message can unmarshal a message with a response set 1`] = `
{
"request": "",
"response": "eyJjYWxsIjoiMSIsInZhbHVlIjoiZEhKMVpRPT0iLCJlcnIiOiIifQ==",
}
`;

exports[`Nested encoding Request can marshal a simple request 1`] = `"eyJjYWxsIjoiMSIsImZ1bmN0aW9uIjoiUHJpbnRsbiIsImFyZ3MiOlsiSWtobGJHeHZMQ0IzYjNKc1pDRWkiXX0="`;

exports[`Nested encoding Request can unmarshal a simple request 1`] = `
{
"args": [
"Hello, world!",
],
"call": "1",
"functionName": "Println",
}
`;

exports[`Nested encoding Request can marshal a complex request 1`] = `"eyJjYWxsIjoiMS0yLTMiLCJmdW5jdGlvbiI6IkFkZCIsImFyZ3MiOlsiTVE9PSIsIk1nPT0iLCJleUpoYzJSbUlqb3hmUT09Il19"`;

exports[`Nested encoding Request can unmarshal a complex request 1`] = `
{
"args": [
1,
2,
{
"asdf": 1,
},
],
"call": "1-2-3",
"functionName": "Add",
}
`;

exports[`Nested encoding Response can marshal a simple response with no error 1`] = `"eyJjYWxsIjoiMSIsInZhbHVlIjoiZEhKMVpRPT0iLCJlcnIiOiIifQ=="`;

exports[`Nested encoding Response can unmarshal a simple response with no error 1`] = `
{
"call": "1",
"err": "",
"value": true,
}
`;

exports[`Nested encoding Response can marshal a simple response with error 1`] = `"eyJjYWxsIjoiMSIsInZhbHVlIjoiZEhKMVpRPT0iLCJlcnIiOiJ0ZXN0IGVycm9yIn0="`;

exports[`Nested encoding Response can unmarshal a simple response with error 1`] = `
{
"call": "1",
"err": "test error",
"value": true,
}
`;

exports[`Nested encoding Response can marshal a complex response with no error 1`] = `"eyJjYWxsIjoiMSIsInZhbHVlIjoiZXlKaElqb3hMQ0ppSWpwN0ltTWlPaUowWlhOMEluMTkiLCJlcnIiOiIifQ=="`;

exports[`Nested encoding Response can unmarshal a complex response with no error 1`] = `
{
"call": "1",
"err": "",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;

exports[`Nested encoding Response can marshal a complex response with error 1`] = `"eyJjYWxsIjoiMSIsInZhbHVlIjoiZXlKaElqb3hMQ0ppSWpwN0ltTWlPaUowWlhOMEluMTkiLCJlcnIiOiJ0ZXN0IGVycm9yIn0="`;

exports[`Nested encoding Response can unmarshal a complex response with error 1`] = `
{
"call": "1",
"err": "test error",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;

exports[`Flat encoding Message can marshal a message with a request set 1`] = `"{"request":{"call":"1","function":"Println","args":["Hello, world!"]},"response":""}"`;

exports[`Flat encoding Message can unmarshal a message with a request set 1`] = `
{
"request": {
"args": [
"Hello, world!",
],
"call": "1",
"function": "Println",
},
"response": "",
}
`;

exports[`Flat encoding Message can marshal a message with a response set 1`] = `"{"request":"","response":{"call":"1","value":true,"err":""}}"`;

exports[`Flat encoding Message can unmarshal a message with a response set 1`] = `
{
"request": "",
"response": {
"call": "1",
"err": "",
"value": true,
},
}
`;

exports[`Flat encoding Request can marshal a simple request 1`] = `
{
"args": [
"Hello, world!",
],
"call": "1",
"function": "Println",
}
`;

exports[`Flat encoding Request can unmarshal a simple request 1`] = `
{
"args": [
"Hello, world!",
],
"call": undefined,
"functionName": "Println",
}
`;

exports[`Flat encoding Request can marshal a complex request 1`] = `
{
"args": [
1,
2,
{
"asdf": 1,
},
],
"call": "1-2-3",
"function": "Add",
}
`;

exports[`Flat encoding Request can unmarshal a complex request 1`] = `
{
"args": [
1,
2,
{
"asdf": 1,
},
],
"call": undefined,
"functionName": "Add",
}
`;

exports[`Flat encoding Response can marshal a simple response with no error 1`] = `
{
"call": "1",
"err": "",
"value": true,
}
`;

exports[`Flat encoding Response can unmarshal a simple response with no error 1`] = `
{
"call": undefined,
"err": "",
"value": true,
}
`;

exports[`Flat encoding Response can marshal a simple response with error 1`] = `
{
"call": "1",
"err": "test error",
"value": true,
}
`;

exports[`Flat encoding Response can unmarshal a simple response with error 1`] = `
{
"call": undefined,
"err": "test error",
"value": true,
}
`;

exports[`Flat encoding Response can marshal a complex response with no error 1`] = `
{
"call": "1",
"err": "",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;

exports[`Flat encoding Response can unmarshal a complex response with no error 1`] = `
{
"call": undefined,
"err": "",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;

exports[`Flat encoding Response can marshal a complex response with error 1`] = `
{
"call": "1",
"err": "test error",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;

exports[`Flat encoding Response can unmarshal a complex response with error 1`] = `
{
"call": undefined,
"err": "test error",
"value": {
"a": 1,
"b": {
"c": "test",
},
},
}
`;
File renamed without changes.
File renamed without changes.

0 comments on commit b97891d

Please sign in to comment.