@bufbuild/protobuf 0.0.1-alpha.1
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 +6 -0
- package/dist/cjs/binary-encoding.js +434 -0
- package/dist/cjs/binary-format.js +2 -0
- package/dist/cjs/descriptor-registry.js +518 -0
- package/dist/cjs/descriptor-set.js +557 -0
- package/dist/cjs/enum.js +2 -0
- package/dist/cjs/field-list.js +2 -0
- package/dist/cjs/field.js +40 -0
- package/dist/cjs/google/protobuf/any_pb.js +280 -0
- package/dist/cjs/google/protobuf/api_pb.js +383 -0
- package/dist/cjs/google/protobuf/compiler/plugin_pb.js +334 -0
- package/dist/cjs/google/protobuf/descriptor_pb.js +2311 -0
- package/dist/cjs/google/protobuf/duration_pb.js +201 -0
- package/dist/cjs/google/protobuf/empty_pb.js +72 -0
- package/dist/cjs/google/protobuf/field_mask_pb.js +347 -0
- package/dist/cjs/google/protobuf/source_context_pb.js +74 -0
- package/dist/cjs/google/protobuf/struct_pb.js +288 -0
- package/dist/cjs/google/protobuf/timestamp_pb.js +271 -0
- package/dist/cjs/google/protobuf/type_pb.js +613 -0
- package/dist/cjs/google/protobuf/wrappers_pb.js +658 -0
- package/dist/cjs/google/varint.js +280 -0
- package/dist/cjs/index.js +148 -0
- package/dist/cjs/json-format.js +2 -0
- package/dist/cjs/message-type.js +2 -0
- package/dist/cjs/message.js +98 -0
- package/dist/cjs/private/assert.js +52 -0
- package/dist/cjs/private/base64.js +118 -0
- package/dist/cjs/private/binary-format-common.js +253 -0
- package/dist/cjs/private/binary-format-proto2.js +120 -0
- package/dist/cjs/private/binary-format-proto3.js +102 -0
- package/dist/cjs/private/enum.js +70 -0
- package/dist/cjs/private/field-list.js +62 -0
- package/dist/cjs/private/field-wrapper.js +25 -0
- package/dist/cjs/private/field.js +34 -0
- package/dist/cjs/private/json-format-common.js +482 -0
- package/dist/cjs/private/json-format-proto2.js +100 -0
- package/dist/cjs/private/json-format-proto3.js +103 -0
- package/dist/cjs/private/message-type.js +37 -0
- package/dist/cjs/private/names.js +101 -0
- package/dist/cjs/private/options-map.js +2 -0
- package/dist/cjs/private/proto-runtime.js +24 -0
- package/dist/cjs/private/scalars.js +138 -0
- package/dist/cjs/private/util-common.js +229 -0
- package/dist/cjs/private/util.js +2 -0
- package/dist/cjs/proto-int64.js +121 -0
- package/dist/cjs/proto2.js +86 -0
- package/dist/cjs/proto3.js +99 -0
- package/dist/cjs/service-type.js +43 -0
- package/dist/cjs/type-registry.js +42 -0
- package/dist/esm/binary-encoding.js +434 -0
- package/dist/esm/binary-format.js +1 -0
- package/dist/esm/descriptor-registry.js +521 -0
- package/dist/esm/descriptor-set.js +517 -0
- package/dist/esm/enum.js +1 -0
- package/dist/esm/field-list.js +1 -0
- package/dist/esm/field.js +37 -0
- package/dist/esm/google/protobuf/any_pb.js +276 -0
- package/dist/esm/google/protobuf/api_pb.js +350 -0
- package/dist/esm/google/protobuf/compiler/plugin_pb.js +318 -0
- package/dist/esm/google/protobuf/descriptor_pb.js +2213 -0
- package/dist/esm/google/protobuf/duration_pb.js +197 -0
- package/dist/esm/google/protobuf/empty_pb.js +68 -0
- package/dist/esm/google/protobuf/field_mask_pb.js +343 -0
- package/dist/esm/google/protobuf/source_context_pb.js +70 -0
- package/dist/esm/google/protobuf/struct_pb.js +282 -0
- package/dist/esm/google/protobuf/timestamp_pb.js +267 -0
- package/dist/esm/google/protobuf/type_pb.js +569 -0
- package/dist/esm/google/protobuf/wrappers_pb.js +574 -0
- package/dist/esm/google/varint.js +265 -0
- package/dist/esm/index.js +24 -0
- package/dist/esm/json-format.js +1 -0
- package/dist/esm/message-type.js +1 -0
- package/dist/esm/message.js +94 -0
- package/dist/esm/private/assert.js +41 -0
- package/dist/esm/private/base64.js +113 -0
- package/dist/esm/private/binary-format-common.js +243 -0
- package/dist/esm/private/binary-format-proto2.js +87 -0
- package/dist/esm/private/binary-format-proto3.js +74 -0
- package/dist/esm/private/enum.js +64 -0
- package/dist/esm/private/field-list.js +58 -0
- package/dist/esm/private/field-wrapper.js +20 -0
- package/dist/esm/private/field.js +27 -0
- package/dist/esm/private/json-format-common.js +473 -0
- package/dist/esm/private/json-format-proto2.js +90 -0
- package/dist/esm/private/json-format-proto3.js +89 -0
- package/dist/esm/private/message-type.js +33 -0
- package/dist/esm/private/names.js +90 -0
- package/dist/esm/private/options-map.js +1 -0
- package/dist/esm/private/proto-runtime.js +15 -0
- package/dist/esm/private/scalars.js +129 -0
- package/dist/esm/private/util-common.js +207 -0
- package/dist/esm/private/util.js +1 -0
- package/dist/esm/proto-int64.js +118 -0
- package/dist/esm/proto2.js +77 -0
- package/dist/esm/proto3.js +90 -0
- package/dist/esm/service-type.js +37 -0
- package/dist/esm/type-registry.js +38 -0
- package/dist/types/binary-encoding.d.ts +421 -0
- package/dist/types/binary-format.d.ts +109 -0
- package/dist/types/descriptor-registry.d.ts +42 -0
- package/dist/types/descriptor-set.d.ts +171 -0
- package/dist/types/enum.d.ts +31 -0
- package/dist/types/field-list.d.ts +27 -0
- package/dist/types/field.d.ts +295 -0
- package/dist/types/google/protobuf/any_pb.d.ts +167 -0
- package/dist/types/google/protobuf/api_pb.d.ts +296 -0
- package/dist/types/google/protobuf/compiler/plugin_pb.d.ts +294 -0
- package/dist/types/google/protobuf/descriptor_pb.d.ts +1959 -0
- package/dist/types/google/protobuf/duration_pb.d.ts +117 -0
- package/dist/types/google/protobuf/empty_pb.d.ts +44 -0
- package/dist/types/google/protobuf/field_mask_pb.d.ts +243 -0
- package/dist/types/google/protobuf/source_context_pb.d.ts +44 -0
- package/dist/types/google/protobuf/struct_pb.d.ts +205 -0
- package/dist/types/google/protobuf/timestamp_pb.d.ts +151 -0
- package/dist/types/google/protobuf/type_pb.d.ts +482 -0
- package/dist/types/google/protobuf/wrappers_pb.d.ts +379 -0
- package/dist/types/google/varint.d.ts +65 -0
- package/dist/types/index.d.ts +53 -0
- package/dist/types/json-format.d.ts +129 -0
- package/dist/types/message-type.d.ts +58 -0
- package/dist/types/message.d.ts +124 -0
- package/dist/types/private/assert.d.ts +19 -0
- package/dist/types/private/base64.d.ts +18 -0
- package/dist/types/private/binary-format-common.d.ts +38 -0
- package/dist/types/private/binary-format-proto2.d.ts +2 -0
- package/dist/types/private/binary-format-proto3.d.ts +2 -0
- package/dist/types/private/enum.d.ts +29 -0
- package/dist/types/private/field-list.d.ts +25 -0
- package/dist/types/private/field-wrapper.d.ts +27 -0
- package/dist/types/private/field.d.ts +15 -0
- package/dist/types/private/json-format-common.d.ts +30 -0
- package/dist/types/private/json-format-proto2.d.ts +2 -0
- package/dist/types/private/json-format-proto3.d.ts +2 -0
- package/dist/types/private/message-type.d.ts +15 -0
- package/dist/types/private/names.d.ts +19 -0
- package/dist/types/private/options-map.d.ts +7 -0
- package/dist/types/private/proto-runtime.d.ts +55 -0
- package/dist/types/private/scalars.d.ts +33 -0
- package/dist/types/private/util-common.d.ts +5 -0
- package/dist/types/private/util.d.ts +55 -0
- package/dist/types/proto-int64.d.ts +94 -0
- package/dist/types/proto2.d.ts +4 -0
- package/dist/types/proto3.d.ts +4 -0
- package/dist/types/service-type.d.ts +118 -0
- package/dist/types/type-registry.d.ts +37 -0
- package/package.json +31 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { AnyMessage, Message } from "./message.js";
|
|
2
|
+
import type { MessageType } from "./message-type.js";
|
|
3
|
+
/**
|
|
4
|
+
* ServiceType represents a protobuf services. It provides metadata for
|
|
5
|
+
* reflection-based operations.
|
|
6
|
+
*/
|
|
7
|
+
export interface ServiceType {
|
|
8
|
+
/**
|
|
9
|
+
* The fully qualified name of the service.
|
|
10
|
+
*/
|
|
11
|
+
readonly typeName: string;
|
|
12
|
+
/**
|
|
13
|
+
* A map of local name (safe to use in ECMAScript) to method.
|
|
14
|
+
*/
|
|
15
|
+
readonly methods: {
|
|
16
|
+
[localName: string]: MethodInfo;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* MethodInfo represents a method of a protobuf service, a remote procedure
|
|
21
|
+
* call. All methods provide the following properties:
|
|
22
|
+
*
|
|
23
|
+
* - "name": The original name of the protobuf rpc.
|
|
24
|
+
* - "localName": A variation of the name that follows the lowerCamelCase
|
|
25
|
+
* naming convention in ECMAScript.
|
|
26
|
+
* - "I": The input message type.
|
|
27
|
+
* - "O": The output message type.
|
|
28
|
+
* - "kind": The method type.
|
|
29
|
+
* - "idempotency": User-provided indication whether the method will cause
|
|
30
|
+
* the same effect every time it is called.
|
|
31
|
+
*/
|
|
32
|
+
export declare type MethodInfo<
|
|
33
|
+
I extends Message<I> = AnyMessage,
|
|
34
|
+
O extends Message<O> = AnyMessage
|
|
35
|
+
> =
|
|
36
|
+
| MethodInfoUnary<I, O>
|
|
37
|
+
| MethodInfoServerStreaming<I, O>
|
|
38
|
+
| MethodInfoClientStreaming<I, O>
|
|
39
|
+
| MethodInfoBiDiStreaming<I, O>;
|
|
40
|
+
/**
|
|
41
|
+
* A unary method: rpc (Input) returns (Output)
|
|
42
|
+
*/
|
|
43
|
+
export interface MethodInfoUnary<I extends Message<I>, O extends Message<O>>
|
|
44
|
+
extends miShared<I, O> {
|
|
45
|
+
readonly kind: MethodKind.Unary;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A server streaming method: rpc (Input) returns (stream Output)
|
|
49
|
+
*/
|
|
50
|
+
export interface MethodInfoServerStreaming<
|
|
51
|
+
I extends Message<I>,
|
|
52
|
+
O extends Message<O>
|
|
53
|
+
> extends miShared<I, O> {
|
|
54
|
+
readonly kind: MethodKind.ServerStreaming;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A client streaming method: rpc (stream Input) returns (Output)
|
|
58
|
+
*/
|
|
59
|
+
export interface MethodInfoClientStreaming<
|
|
60
|
+
I extends Message<I>,
|
|
61
|
+
O extends Message<O>
|
|
62
|
+
> extends miShared<I, O> {
|
|
63
|
+
readonly kind: MethodKind.ClientStreaming;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A method that streams bi-directionally: rpc (stream Input) returns (stream Output)
|
|
67
|
+
*/
|
|
68
|
+
export interface MethodInfoBiDiStreaming<
|
|
69
|
+
I extends Message<I>,
|
|
70
|
+
O extends Message<O>
|
|
71
|
+
> extends miShared<I, O> {
|
|
72
|
+
readonly kind: MethodKind.BiDiStreaming;
|
|
73
|
+
}
|
|
74
|
+
interface miShared<
|
|
75
|
+
I extends Message<I> = AnyMessage,
|
|
76
|
+
O extends Message<O> = AnyMessage
|
|
77
|
+
> {
|
|
78
|
+
readonly name: string;
|
|
79
|
+
readonly I: MessageType<I>;
|
|
80
|
+
readonly O: MessageType<O>;
|
|
81
|
+
readonly idempotency?: MethodIdempotency;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* MethodKind represents the four method types that can be declared in
|
|
85
|
+
* protobuf with the `stream` keyword:
|
|
86
|
+
*
|
|
87
|
+
* 1. Unary: rpc (Input) returns (Output)
|
|
88
|
+
* 2. ServerStreaming: rpc (Input) returns (stream Output)
|
|
89
|
+
* 3. ClientStreaming: rpc (stream Input) returns (Output)
|
|
90
|
+
* 4. BiDiStreaming: rpc (stream Input) returns (stream Output)
|
|
91
|
+
*/
|
|
92
|
+
export declare enum MethodKind {
|
|
93
|
+
Unary = 0,
|
|
94
|
+
ServerStreaming = 1,
|
|
95
|
+
ClientStreaming = 2,
|
|
96
|
+
BiDiStreaming = 3,
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Is this method side-effect-free (or safe in HTTP parlance), or just
|
|
100
|
+
* idempotent, or neither? HTTP based RPC implementation may choose GET verb
|
|
101
|
+
* for safe methods, and PUT verb for idempotent methods instead of the
|
|
102
|
+
* default POST.
|
|
103
|
+
*
|
|
104
|
+
* This enum matches the protobuf enum google.protobuf.MethodOptions.IdempotencyLevel,
|
|
105
|
+
* defined in the well-known type google/protobuf/descriptor.proto, but
|
|
106
|
+
* drops UNKNOWN.
|
|
107
|
+
*/
|
|
108
|
+
export declare enum MethodIdempotency {
|
|
109
|
+
/**
|
|
110
|
+
* Idempotent, no side effects.
|
|
111
|
+
*/
|
|
112
|
+
NoSideEffects = 1,
|
|
113
|
+
/**
|
|
114
|
+
* Idempotent, but may have side effects.
|
|
115
|
+
*/
|
|
116
|
+
Idempotent = 2,
|
|
117
|
+
}
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { MessageType } from "./message-type.js";
|
|
2
|
+
import type { EnumType } from "./enum.js";
|
|
3
|
+
import type { ServiceType } from "./service-type.js";
|
|
4
|
+
/**
|
|
5
|
+
* IMessageTypeRegistry provides look-up for message types.
|
|
6
|
+
*/
|
|
7
|
+
export interface IMessageTypeRegistry {
|
|
8
|
+
findMessage(typeName: string): MessageType | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* IEnumTypeRegistry provides look-up for enum types.
|
|
12
|
+
*/
|
|
13
|
+
export interface IEnumTypeRegistry {
|
|
14
|
+
findEnum(typeName: string): EnumType | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* IServiceTypeRegistry provides look-up for service types.
|
|
18
|
+
*/
|
|
19
|
+
export interface IServiceTypeRegistry {
|
|
20
|
+
findService(typeName: string): ServiceType | undefined;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* TypeRegistry is a basic type registry
|
|
24
|
+
*/
|
|
25
|
+
export declare class TypeRegistry
|
|
26
|
+
implements IMessageTypeRegistry, IEnumTypeRegistry, IServiceTypeRegistry
|
|
27
|
+
{
|
|
28
|
+
private readonly messages;
|
|
29
|
+
private readonly enums;
|
|
30
|
+
private readonly services;
|
|
31
|
+
findMessage(typeName: string): MessageType | undefined;
|
|
32
|
+
findEnum(typeName: string): EnumType | undefined;
|
|
33
|
+
findService(typeName: string): ServiceType | undefined;
|
|
34
|
+
private add;
|
|
35
|
+
static fromIterable(types: Iterable<MessageType>): TypeRegistry;
|
|
36
|
+
static fromTypes(...types: MessageType[]): TypeRegistry;
|
|
37
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bufbuild/protobuf",
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
|
+
"license": "(Apache-2.0 AND BSD-3-Clause)",
|
|
5
|
+
"description": "A complete implementation of protocol buffers in TypeScript, suitable for web browsers and Node.js.",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/bufbuild/protobuf-es.git",
|
|
9
|
+
"directory": "packages/protobuf"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "rm -rf ./dist/cjs/* ./dist/esm/* ./dist/types/*",
|
|
13
|
+
"build": "npm run build:cjs && npm run build:esm+types",
|
|
14
|
+
"build:cjs": "npx tsc --project tsconfig.json --module commonjs --outDir ./dist/cjs",
|
|
15
|
+
"build:esm+types": "npx tsc --project tsconfig.json --module ES2015 --outDir ./dist/esm --declaration --declarationDir ./dist/types"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"main": "./dist/cjs/index.js",
|
|
19
|
+
"types": "./dist/types/index.d.ts",
|
|
20
|
+
"exports": {
|
|
21
|
+
"import": "./dist/esm/index.js",
|
|
22
|
+
"require": "./dist/cjs/index.js",
|
|
23
|
+
"default": "./dist/esm/index.js"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"typescript": "^4.5.4"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist/**/"
|
|
30
|
+
]
|
|
31
|
+
}
|