Skip to content

Commit

Permalink
refactor: format files and update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed May 16, 2024
1 parent 0c8bb6f commit 1792dfb
Show file tree
Hide file tree
Showing 8 changed files with 200 additions and 277 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
language: [ 'javascript' ]
node: [21.x]
node: [22.x]

steps:
- name: Checkout repository
Expand Down
3 changes: 3 additions & 0 deletions example/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package example;

import "google/protobuf/timestamp.proto";
import "google/protobuf/empty.proto";

// Echoer service returns the given message.
service Echoer {
Expand All @@ -13,6 +14,8 @@ service Echoer {
rpc EchoClientStream(stream EchoMsg) returns (EchoMsg);
// EchoBidiStream is an example of a two-way stream.
rpc EchoBidiStream(stream EchoMsg) returns (stream EchoMsg);
// DoNothing does nothing.
rpc DoNothing(.google.protobuf.Empty) returns (.google.protobuf.Empty);
}

// ExampleEnum is an example enumeration.
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,18 @@
"lz-string": "^1.5.0"
},
"devDependencies": {
"@types/node": "^20.12.7",
"@typescript-eslint/eslint-plugin": "^7.8.0",
"@typescript-eslint/parser": "^7.8.0",
"eslint": "^8.0.0",
"@types/node": "^20.12.12",
"@typescript-eslint/eslint-plugin": "^7.9.0",
"@typescript-eslint/parser": "^7.9.0",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-unused-imports": "^3.2.0",
"lint-staged": ">=10",
"pre-commit": "^1.2.2",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"rimraf": "^5.0.7",
"typescript": "^5.4.5",
"vitest": "^1.5.3"
"vitest": "^1.6.0"
},
"lint-staged": {
"package.json": "prettier --write",
Expand Down
2 changes: 1 addition & 1 deletion src/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ function readMapEntry(
val = readMessageField(
reader,
Object.create(null),
resolveMessageType(field.V.T).fields,
resolveMessageType(field.V.T).fields,
options,
undefined,
);
Expand Down
12 changes: 3 additions & 9 deletions src/google/protobuf/duration.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,19 @@ const Duration_Wkt = {
): Duration {
if (typeof json !== "string") {
throw new Error(
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`,
);
}
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
if (match === null) {
throw new Error(
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`,
);
}
const longSeconds = Number(match[1]);
if (longSeconds > 315576000000 || longSeconds < -315576000000) {
throw new Error(
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`,
);
}
const msg = {} as Duration;
Expand Down
12 changes: 3 additions & 9 deletions src/google/protobuf/struct.pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ const ListValue_Wkt = {
}
if (!Array.isArray(json)) {
throw new Error(
`cannot decode google.protobuf.ListValue from JSON ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.ListValue from JSON ${jsonDebugValue(json)}`,
);
}
const values: Value[] = json.map((v) => Value.fromJson(v, options));
Expand Down Expand Up @@ -265,9 +263,7 @@ const Value_Wkt = {
break;
default:
throw new Error(
`cannot decode google.protobuf.Value from JSON ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.Value from JSON ${jsonDebugValue(json)}`,
);
}
return msg;
Expand Down Expand Up @@ -369,9 +365,7 @@ const Struct_Wkt = {
): Struct {
if (typeof json != "object" || json == null || Array.isArray(json)) {
throw new Error(
`cannot decode google.protobuf.Struct from JSON ${jsonDebugValue(
json,
)}`,
`cannot decode google.protobuf.Struct from JSON ${jsonDebugValue(json)}`,
);
}
const fields = {} as { [key: string]: Value };
Expand Down
10 changes: 2 additions & 8 deletions src/partial.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ describe("applyPartialMessage", () => {
const source: Partial<EchoMsg> = {
body: "Hello",
ts: new Date(),
timestamps: [
new Date("2022-01-01"),
new Date("2022-02-01"),
],
timestamps: [new Date("2022-01-01"), new Date("2022-02-01")],
demo: { case: "exampleEnum", value: ExampleEnum.FIRST },
};
const target = {} as EchoMsg;
Expand All @@ -36,10 +33,7 @@ describe("applyPartialMessage", () => {
const target: EchoMsg = {
body: "Hello",
ts: new Date(),
timestamps: [
new Date("2022-01-01"),
new Date("2022-02-01"),
],
timestamps: [new Date("2022-01-01"), new Date("2022-02-01")],
demo: { case: "exampleString", value: "test" },
};
const fieldList = EchoMsg.fields;
Expand Down
Loading

0 comments on commit 1792dfb

Please sign in to comment.