Skip to content

Commit

Permalink
Merge pull request #1323 from samchon/feat/protobuf
Browse files Browse the repository at this point in the history
Fix #1321: `private` key in the `protobuf` functions
  • Loading branch information
samchon authored Oct 11, 2024
2 parents 9cafb03 + 1a1778d commit 453bf9d
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.4-dev.20240925.tgz"
"typia": "../typia-6.11.1.tgz"
}
}
2 changes: 1 addition & 1 deletion debug/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"dependencies": {
"tstl": "^3.0.0",
"typia": "../typia-6.11.0.tgz",
"typia": "../typia-6.11.1.tgz",
"uuid": "^10.0.0"
}
}
12 changes: 12 additions & 0 deletions debug/src/protobuf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import typia from "typia";

interface MyObj {
private: boolean | null;
}

const encode = typia.protobuf.createEncode<MyObj>();
console.log(
encode({
private: true,
}),
);
2 changes: 1 addition & 1 deletion errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"typescript": "^5.3.2"
},
"dependencies": {
"typia": "../typia-6.10.4-dev.20240925.tgz"
"typia": "../typia-6.11.1.tgz"
}
}
14 changes: 0 additions & 14 deletions src/factories/ProtobufFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import { TransformerError } from "../transformers/TransformerError";

import { ValidationPipe } from "../typings/ValidationPipe";

import { Escaper } from "../utils/Escaper";

import { MetadataCollection } from "./MetadataCollection";
import { MetadataFactory } from "./MetadataFactory";

Expand Down Expand Up @@ -167,18 +165,6 @@ export namespace ProtobufFactory {
noSupport(
"object type with mixed static and dynamic key typed properties. Keep statics or dynamic only.",
);
// STATIC PROPERTY, BUT INVALID KEY NAME
if (
meta.objects.length &&
meta.objects.some((obj) =>
obj.properties.some(
(p) =>
p.key.isSoleLiteral() === true &&
Escaper.variable(p.key.getSoleLiteral()!) === false,
),
)
)
noSupport(`object type with invalid static key name.`);
// DYNAMIC OBJECT, BUT PROPERTY VALUE TYPE IS ARRAY
if (
meta.objects.length &&
Expand Down
2 changes: 1 addition & 1 deletion test-esm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
"typescript": "^5.4.5"
},
"dependencies": {
"typia": "../typia-6.10.4-dev.20240925.tgz"
"typia": "../typia-6.11.1.tgz"
}
}
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
"suppress-warnings": "^1.0.2",
"tstl": "^3.0.0",
"uuid": "^9.0.1",
"typia": "../typia-6.10.4-dev.20240925.tgz"
"typia": "../typia-6.11.1.tgz"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import typia from "typia";

import { TestValidator } from "../../helpers/TestValidator";

type MyObj = {
private: boolean | null;
};

export const test_issue_1321_private_key_in_protobuf = (): void => {
const input: MyObj = {
private: true,
};
const encoded: Uint8Array = typia.protobuf.encode<MyObj>(input);
const decoded: MyObj = typia.protobuf.decode<MyObj>(encoded);
TestValidator.equals("decoded")(decoded)(input);
};

0 comments on commit 453bf9d

Please sign in to comment.