Skip to content

Commit

Permalink
Add test proto for json_types
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Jun 14, 2024
1 parent 23e0195 commit c025d07
Show file tree
Hide file tree
Showing 161 changed files with 7,212 additions and 39,282 deletions.
59 changes: 59 additions & 0 deletions packages/protobuf-test/extra/json_types.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2021-2024 Buf Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";
package spec;

import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/struct.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";

message JsonTypesMessage {
bool bool_field = 1;
double double_field = 2;
bytes bytes_field = 3;
int64 int64_field = 4;
JsonTypeEnum enum_field = 5;
JsonTypesMessage message_field = 6;
google.protobuf.Any any_field = 7;
google.protobuf.Duration duration_field = 8;
google.protobuf.Empty empty_field = 9;
google.protobuf.FieldMask field_mask_field = 10;
google.protobuf.Struct struct_field = 11;
google.protobuf.Value value_field = 12;
google.protobuf.ListValue list_value_field = 13;
google.protobuf.NullValue null_value_field = 14;
google.protobuf.Timestamp timestamp_field = 15;
google.protobuf.DoubleValue wrapped_double_field = 16;
google.protobuf.FloatValue wrapped_float_field = 17;
google.protobuf.Int64Value wrapped_int64_field = 18;
google.protobuf.UInt64Value wrapped_uint64_field = 19;
google.protobuf.Int32Value wrapped_int32_field = 20;
google.protobuf.UInt32Value wrapped_uint32_field = 21;
google.protobuf.BoolValue wrapped_bool_field = 22;
google.protobuf.StringValue wrapped_string_field = 23;
google.protobuf.BytesValue wrapped_bytes_field = 24;
repeated JsonTypeEnum repeated_enum_field = 25;
map<bool, JsonTypeEnum> map_bool_enum_field = 26;
}

enum JsonTypeEnum {
JSON_TYPE_ENUM_UNSPECIFIED = 0;
JSON_TYPE_ENUM_YES = 1;
JSON_TYPE_ENUM_NO = 2;
}
2 changes: 1 addition & 1 deletion packages/protobuf-test/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const config = {
coverageProvider: "v8",

// The root directory that Jest should scan for tests and modules within
rootDir: "dist/esm",
rootDir: "dist",

// Enable worker threads for assertion failures involving BigInt
// See https://github.com/jestjs/jest/issues/11617#issuecomment-1458155552
Expand Down
16 changes: 8 additions & 8 deletions packages/protobuf-test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"name": "@bufbuild/protobuf-test",
"private": true,
"scripts": {
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
"build": "npm run build:esm+types && npm run build:copy-gen-js && npm run build:copy-perf-payload",
"build:esm+types": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist/esm --declaration --declarationDir ./dist/types",
"build:copy-gen-js": "rsync -a --exclude '*.js' src/gen/js dist/types/gen && rsync -a --exclude '*.d.ts' src/gen/js dist/esm/gen",
"build:copy-perf-payload": "cp src/perf-payload.* dist/esm/",
"clean": "rm -rf ./dist/*",
"build": "../../node_modules/typescript/bin/tsc --project tsconfig.json --outDir ./dist --declaration",
"postbuild": "cp src/perf-payload.* dist && cp -r src/gen/js* dist/gen",
"pregenerate": "rm -rf src/gen/*/* descriptorset.*",
"generate": "npm run generate:ts && npm run generate:js",
"generate:ts": "protoc --es_out=src/gen/ts --es_opt=ts_nocheck=false,target=ts,import_extension=.js,json_types=true --proto_path=. $(buf ls-files extra) --proto_path=$(upstream-include test) $(upstream-files test) google/protobuf/type.proto",
"generate:js": "protoc --es_out=src/gen/js --es_opt=ts_nocheck=false,target=js+dts,import_extension=.js,json_types=true --proto_path=. $(buf ls-files extra) --proto_path=$(upstream-include test) $(upstream-files test) google/protobuf/type.proto",
"generate": "npm run generate:ts && npm run generate:js && npm run generate:ts,json_types && npm run generate:js,json_types",
"generate:ts": "protoc --es_out=src/gen/ts --es_opt=ts_nocheck=false,target=ts,import_extension=.js --proto_path=. $(buf ls-files extra) --proto_path=$(upstream-include test) $(upstream-files test) google/protobuf/type.proto",
"generate:js": "protoc --es_out=src/gen/js --es_opt=ts_nocheck=false,target=js+dts,import_extension=.js --proto_path=. $(buf ls-files extra) --proto_path=$(upstream-include test) $(upstream-files test) google/protobuf/type.proto",
"generate:ts,json_types": "protoc --es_out=src/gen/ts,json_types --es_opt=ts_nocheck=false,target=ts,import_extension=.js,json_types=true --proto_path=. extra/json_types.proto",
"generate:js,json_types": "protoc --es_out=src/gen/js,json_types --es_opt=ts_nocheck=false,target=js+dts,import_extension=.js,json_types=true --proto_path=. extra/json_types.proto",
"postgenerate": "license-header src/gen",
"perf": "tsx src/perf.ts benchmark '.*'",
"profile": "dexnode dist/esm/perf.js run 'fromBinary perf-payload.bin' 10000",
Expand Down
Loading

0 comments on commit c025d07

Please sign in to comment.