@bufbuild/protobuf 0.0.8 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -4
- package/dist/cjs/codegen-info.js +60 -0
- package/dist/cjs/create-descriptor-set.js +952 -0
- package/dist/cjs/create-registry-from-desc.js +270 -0
- package/dist/cjs/create-registry.js +75 -0
- package/dist/cjs/descriptor-set.js +0 -436
- package/dist/cjs/google/protobuf/descriptor_pb.js +2 -2
- package/dist/cjs/google/protobuf/empty_pb.js +0 -1
- package/dist/cjs/google/protobuf/struct_pb.js +1 -1
- package/dist/cjs/google/protobuf/type_pb.js +1 -1
- package/dist/cjs/google/varint.js +85 -37
- package/dist/cjs/index.js +11 -7
- package/dist/cjs/private/enum.js +22 -31
- package/dist/cjs/private/field-wrapper.js +30 -1
- package/dist/cjs/private/field.js +1 -1
- package/dist/cjs/private/json-format-common.js +6 -6
- package/dist/cjs/private/names.js +168 -29
- package/dist/cjs/proto-int64.js +23 -40
- package/dist/cjs/proto2.js +2 -2
- package/dist/cjs/proto3.js +2 -2
- package/dist/cjs/type-registry.js +0 -87
- package/dist/esm/codegen-info.js +57 -0
- package/dist/esm/create-descriptor-set.js +947 -0
- package/dist/esm/create-registry-from-desc.js +266 -0
- package/dist/esm/create-registry.js +71 -0
- package/dist/esm/descriptor-set.js +1 -434
- package/dist/esm/google/protobuf/descriptor_pb.js +2 -2
- package/dist/esm/google/protobuf/empty_pb.js +0 -1
- package/dist/esm/google/protobuf/struct_pb.js +1 -1
- package/dist/esm/google/protobuf/type_pb.js +1 -1
- package/dist/esm/google/varint.js +81 -34
- package/dist/esm/index.js +6 -3
- package/dist/esm/private/enum.js +22 -31
- package/dist/esm/private/field-wrapper.js +28 -0
- package/dist/esm/private/field.js +2 -2
- package/dist/esm/private/json-format-common.js +6 -6
- package/dist/esm/private/names.js +163 -24
- package/dist/esm/proto-int64.js +24 -41
- package/dist/esm/proto2.js +3 -3
- package/dist/esm/proto3.js +3 -3
- package/dist/esm/type-registry.js +1 -85
- package/dist/types/codegen-info.d.ts +19 -0
- package/dist/types/create-descriptor-set.d.ts +16 -0
- package/dist/types/create-registry-from-desc.d.ts +15 -0
- package/dist/types/create-registry.d.ts +8 -0
- package/dist/types/descriptor-set.d.ts +554 -108
- package/dist/types/enum.d.ts +9 -5
- package/dist/types/google/protobuf/descriptor_pb.d.ts +6 -6
- package/dist/types/google/protobuf/empty_pb.d.ts +0 -1
- package/dist/types/google/varint.d.ts +21 -9
- package/dist/types/index.d.ts +6 -3
- package/dist/types/message.d.ts +3 -1
- package/dist/types/private/enum.d.ts +4 -8
- package/dist/types/private/field-wrapper.d.ts +7 -0
- package/dist/types/private/message-type.d.ts +1 -4
- package/dist/types/private/names.d.ts +26 -8
- package/dist/types/private/proto-runtime.d.ts +2 -2
- package/dist/types/private/util.d.ts +1 -6
- package/dist/types/proto-int64.d.ts +14 -13
- package/dist/types/type-registry.d.ts +0 -38
- package/package.json +6 -10
- package/dist/cjs/descriptor-registry.js +0 -460
- package/dist/esm/descriptor-registry.js +0 -456
- package/dist/protobuf.cjs +0 -2
- package/dist/protobuf.cjs.map +0 -1
- package/dist/protobuf.esm.js +0 -2
- package/dist/protobuf.esm.js.map +0 -1
- package/dist/protobuf.modern.js +0 -2
- package/dist/protobuf.modern.js.map +0 -1
- package/dist/types/descriptor-registry.d.ts +0 -43
|
@@ -13,90 +13,3 @@
|
|
|
13
13
|
// See the License for the specific language governing permissions and
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.TypeRegistry = void 0;
|
|
17
|
-
/**
|
|
18
|
-
* TypeRegistry is a simple registry for all message, enum, or service types.
|
|
19
|
-
*/
|
|
20
|
-
class TypeRegistry {
|
|
21
|
-
constructor() {
|
|
22
|
-
this.messages = {};
|
|
23
|
-
this.enums = {};
|
|
24
|
-
this.services = {};
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Find a message type by its protobuf type name.
|
|
28
|
-
*/
|
|
29
|
-
findMessage(typeName) {
|
|
30
|
-
return this.messages[typeName];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Find an enum type by its protobuf type name.
|
|
34
|
-
*/
|
|
35
|
-
findEnum(typeName) {
|
|
36
|
-
return this.enums[typeName];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Find a service type by its protobuf type name.
|
|
40
|
-
*/
|
|
41
|
-
findService(typeName) {
|
|
42
|
-
return this.services[typeName];
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Create a new TypeRegistry from the given types.
|
|
46
|
-
*/
|
|
47
|
-
static from(...types) {
|
|
48
|
-
const registry = new TypeRegistry();
|
|
49
|
-
for (const type of types) {
|
|
50
|
-
registry.add(type);
|
|
51
|
-
}
|
|
52
|
-
return registry;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* @deprecated use TypeRegistry.from()
|
|
56
|
-
*/
|
|
57
|
-
static fromIterable(types) {
|
|
58
|
-
return TypeRegistry.from(...types);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use TypeRegistry.from()
|
|
62
|
-
*/
|
|
63
|
-
static fromTypes(...types) {
|
|
64
|
-
return TypeRegistry.from(...types);
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Add a type to the registry. For messages, the types used in message
|
|
68
|
-
* fields are added recursively. For services, the message types used
|
|
69
|
-
* for requests and responses are added recursively.
|
|
70
|
-
*/
|
|
71
|
-
add(type) {
|
|
72
|
-
if ("fields" in type) {
|
|
73
|
-
if (!this.findMessage(type.typeName)) {
|
|
74
|
-
this.messages[type.typeName] = type;
|
|
75
|
-
for (const field of type.fields.list()) {
|
|
76
|
-
if (field.kind == "message") {
|
|
77
|
-
this.add(field.T);
|
|
78
|
-
}
|
|
79
|
-
else if (field.kind == "map" && field.V.kind == "message") {
|
|
80
|
-
this.add(field.V.T);
|
|
81
|
-
}
|
|
82
|
-
else if (field.kind == "enum") {
|
|
83
|
-
this.add(field.T);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else if ("methods" in type) {
|
|
89
|
-
if (!this.findService(type.typeName)) {
|
|
90
|
-
this.services[type.typeName] = type;
|
|
91
|
-
for (const method of Object.values(type.methods)) {
|
|
92
|
-
this.add(method.I);
|
|
93
|
-
this.add(method.O);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
this.enums[type.typeName] = type;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.TypeRegistry = TypeRegistry;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Copyright 2021-2022 Buf Technologies, Inc.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
import { localName } from "./private/names.js";
|
|
15
|
+
import { getUnwrappedFieldType } from "./private/field-wrapper.js";
|
|
16
|
+
import { scalarDefaultValue } from "./private/scalars.js";
|
|
17
|
+
const packageName = "@bufbuild/protobuf";
|
|
18
|
+
export const codegenInfo = {
|
|
19
|
+
packageName,
|
|
20
|
+
localName,
|
|
21
|
+
getUnwrappedFieldType,
|
|
22
|
+
scalarDefaultValue,
|
|
23
|
+
// prettier-ignore
|
|
24
|
+
symbols: {
|
|
25
|
+
proto2: { typeOnly: false, privateImportPath: "./proto2.js", publicImportPath: packageName },
|
|
26
|
+
proto3: { typeOnly: false, privateImportPath: "./proto3.js", publicImportPath: packageName },
|
|
27
|
+
Message: { typeOnly: false, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
28
|
+
PartialMessage: { typeOnly: true, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
29
|
+
PlainMessage: { typeOnly: true, privateImportPath: "./message.js", publicImportPath: packageName },
|
|
30
|
+
FieldList: { typeOnly: true, privateImportPath: "./field-list.js", publicImportPath: packageName },
|
|
31
|
+
MessageType: { typeOnly: true, privateImportPath: "./message-type.js", publicImportPath: packageName },
|
|
32
|
+
BinaryReadOptions: { typeOnly: true, privateImportPath: "./binary-format.js", publicImportPath: packageName },
|
|
33
|
+
BinaryWriteOptions: { typeOnly: true, privateImportPath: "./binary-format.js", publicImportPath: packageName },
|
|
34
|
+
JsonReadOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
35
|
+
JsonWriteOptions: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
36
|
+
JsonValue: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
37
|
+
JsonObject: { typeOnly: true, privateImportPath: "./json-format.js", publicImportPath: packageName },
|
|
38
|
+
protoInt64: { typeOnly: false, privateImportPath: "./proto-int64.js", publicImportPath: packageName },
|
|
39
|
+
ScalarType: { typeOnly: false, privateImportPath: "./field.js", publicImportPath: packageName },
|
|
40
|
+
MethodKind: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
|
|
41
|
+
MethodIdempotency: { typeOnly: false, privateImportPath: "./service-type.js", publicImportPath: packageName },
|
|
42
|
+
},
|
|
43
|
+
wktSourceFiles: [
|
|
44
|
+
"google/protobuf/compiler/plugin.proto",
|
|
45
|
+
"google/protobuf/any.proto",
|
|
46
|
+
"google/protobuf/api.proto",
|
|
47
|
+
"google/protobuf/descriptor.proto",
|
|
48
|
+
"google/protobuf/duration.proto",
|
|
49
|
+
"google/protobuf/empty.proto",
|
|
50
|
+
"google/protobuf/field_mask.proto",
|
|
51
|
+
"google/protobuf/source_context.proto",
|
|
52
|
+
"google/protobuf/struct.proto",
|
|
53
|
+
"google/protobuf/timestamp.proto",
|
|
54
|
+
"google/protobuf/type.proto",
|
|
55
|
+
"google/protobuf/wrappers.proto",
|
|
56
|
+
],
|
|
57
|
+
};
|