@aptre/protobuf-es-lite 0.5.1 → 0.5.3
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 +1 -22
- package/dist/google/index.d.ts +9 -0
- package/dist/google/index.js +9 -0
- package/dist/google/protobuf/any.pb.d.ts +148 -0
- package/dist/google/protobuf/any.pb.js +120 -0
- package/dist/google/protobuf/api.pb.d.ts +232 -0
- package/dist/google/protobuf/api.pb.js +88 -0
- package/dist/google/protobuf/duration.pb.d.ts +93 -0
- package/dist/google/protobuf/duration.pb.js +89 -0
- package/dist/google/protobuf/empty.pb.d.ts +17 -0
- package/dist/google/protobuf/empty.pb.js +37 -0
- package/dist/google/protobuf/source_context.pb.d.ts +18 -0
- package/dist/google/protobuf/source_context.pb.js +39 -0
- package/dist/google/protobuf/struct.pb.d.ts +141 -0
- package/dist/google/protobuf/struct.pb.js +228 -0
- package/dist/google/protobuf/timestamp.pb.d.ts +125 -0
- package/dist/google/protobuf/timestamp.pb.js +137 -0
- package/dist/google/protobuf/type.pb.d.ts +401 -0
- package/dist/google/protobuf/type.pb.js +347 -0
- package/dist/google/protobuf/wrappers.pb.d.ts +201 -0
- package/dist/google/protobuf/wrappers.pb.js +365 -0
- package/dist/message.d.ts +1 -1
- package/dist/message.js +2 -0
- package/package.json +5 -5
- package/tsconfig.json +11 -1
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { JsonReadOptions, JsonValue, MessageType } from "../../index.js";
|
|
2
|
+
export declare const protobufPackage = "google.protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* A Duration represents a signed, fixed-length span of time represented
|
|
5
|
+
* as a count of seconds and fractions of seconds at nanosecond
|
|
6
|
+
* resolution. It is independent of any calendar and concepts like "day"
|
|
7
|
+
* or "month". It is related to Timestamp in that the difference between
|
|
8
|
+
* two Timestamp values is a Duration and it can be added or subtracted
|
|
9
|
+
* from a Timestamp. Range is approximately +-10,000 years.
|
|
10
|
+
*
|
|
11
|
+
* # Examples
|
|
12
|
+
*
|
|
13
|
+
* Example 1: Compute Duration from two Timestamps in pseudo code.
|
|
14
|
+
*
|
|
15
|
+
* Timestamp start = ...;
|
|
16
|
+
* Timestamp end = ...;
|
|
17
|
+
* Duration duration = ...;
|
|
18
|
+
*
|
|
19
|
+
* duration.seconds = end.seconds - start.seconds;
|
|
20
|
+
* duration.nanos = end.nanos - start.nanos;
|
|
21
|
+
*
|
|
22
|
+
* if (duration.seconds < 0 && duration.nanos > 0) {
|
|
23
|
+
* duration.seconds += 1;
|
|
24
|
+
* duration.nanos -= 1000000000;
|
|
25
|
+
* } else if (duration.seconds > 0 && duration.nanos < 0) {
|
|
26
|
+
* duration.seconds -= 1;
|
|
27
|
+
* duration.nanos += 1000000000;
|
|
28
|
+
* }
|
|
29
|
+
*
|
|
30
|
+
* Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
|
|
31
|
+
*
|
|
32
|
+
* Timestamp start = ...;
|
|
33
|
+
* Duration duration = ...;
|
|
34
|
+
* Timestamp end = ...;
|
|
35
|
+
*
|
|
36
|
+
* end.seconds = start.seconds + duration.seconds;
|
|
37
|
+
* end.nanos = start.nanos + duration.nanos;
|
|
38
|
+
*
|
|
39
|
+
* if (end.nanos < 0) {
|
|
40
|
+
* end.seconds -= 1;
|
|
41
|
+
* end.nanos += 1000000000;
|
|
42
|
+
* } else if (end.nanos >= 1000000000) {
|
|
43
|
+
* end.seconds += 1;
|
|
44
|
+
* end.nanos -= 1000000000;
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* Example 3: Compute Duration from datetime.timedelta in Python.
|
|
48
|
+
*
|
|
49
|
+
* td = datetime.timedelta(days=3, minutes=10)
|
|
50
|
+
* duration = Duration()
|
|
51
|
+
* duration.FromTimedelta(td)
|
|
52
|
+
*
|
|
53
|
+
* # JSON Mapping
|
|
54
|
+
*
|
|
55
|
+
* In JSON format, the Duration type is encoded as a string rather than an
|
|
56
|
+
* object, where the string ends in the suffix "s" (indicating seconds) and
|
|
57
|
+
* is preceded by the number of seconds, with nanoseconds expressed as
|
|
58
|
+
* fractional seconds. For example, 3 seconds with 0 nanoseconds should be
|
|
59
|
+
* encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
|
|
60
|
+
* be expressed in JSON format as "3.000000001s", and 3 seconds and 1
|
|
61
|
+
* microsecond should be expressed in JSON format as "3.000001s".
|
|
62
|
+
*
|
|
63
|
+
* protobuf-go-lite:disable-text
|
|
64
|
+
*
|
|
65
|
+
* @generated from message google.protobuf.Duration
|
|
66
|
+
*/
|
|
67
|
+
export interface Duration {
|
|
68
|
+
/**
|
|
69
|
+
* Signed seconds of the span of time. Must be from -315,576,000,000
|
|
70
|
+
* to +315,576,000,000 inclusive. Note: these bounds are computed from:
|
|
71
|
+
* 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
|
|
72
|
+
*
|
|
73
|
+
* @generated from field: int64 seconds = 1;
|
|
74
|
+
*/
|
|
75
|
+
seconds?: bigint;
|
|
76
|
+
/**
|
|
77
|
+
* Signed fractions of a second at nanosecond resolution of the span
|
|
78
|
+
* of time. Durations less than one second are represented with a 0
|
|
79
|
+
* `seconds` field and a positive or negative `nanos` field. For durations
|
|
80
|
+
* of one second or more, a non-zero value for the `nanos` field must be
|
|
81
|
+
* of the same sign as the `seconds` field. Must be from -999,999,999
|
|
82
|
+
* to +999,999,999 inclusive.
|
|
83
|
+
*
|
|
84
|
+
* @generated from field: int32 nanos = 2;
|
|
85
|
+
*/
|
|
86
|
+
nanos?: number;
|
|
87
|
+
}
|
|
88
|
+
declare const Duration_Wkt: {
|
|
89
|
+
fromJson(json: JsonValue | null | undefined, _options?: Partial<JsonReadOptions>): Duration;
|
|
90
|
+
toJson(msg: Duration): JsonValue;
|
|
91
|
+
};
|
|
92
|
+
export declare const Duration: MessageType<Duration> & typeof Duration_Wkt;
|
|
93
|
+
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
|
4
|
+
//
|
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
|
6
|
+
// modification, are permitted provided that the following conditions are
|
|
7
|
+
// met:
|
|
8
|
+
//
|
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
// in the documentation and/or other materials provided with the
|
|
14
|
+
// distribution.
|
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
|
17
|
+
// this software without specific prior written permission.
|
|
18
|
+
//
|
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
import { createMessageType, jsonDebugValue, protoInt64, ScalarType, } from "../../index.js";
|
|
31
|
+
export const protobufPackage = "google.protobuf";
|
|
32
|
+
// Duration_Wkt contains the well-known-type overrides for Duration.
|
|
33
|
+
const Duration_Wkt = {
|
|
34
|
+
fromJson(json, _options) {
|
|
35
|
+
if (typeof json !== "string") {
|
|
36
|
+
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
|
|
37
|
+
}
|
|
38
|
+
const match = json.match(/^(-?[0-9]+)(?:\.([0-9]+))?s/);
|
|
39
|
+
if (match === null) {
|
|
40
|
+
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
|
|
41
|
+
}
|
|
42
|
+
const longSeconds = Number(match[1]);
|
|
43
|
+
if (longSeconds > 315576000000 || longSeconds < -315576000000) {
|
|
44
|
+
throw new Error(`cannot decode google.protobuf.Duration from JSON: ${jsonDebugValue(json)}`);
|
|
45
|
+
}
|
|
46
|
+
const msg = {};
|
|
47
|
+
msg.seconds = protoInt64.parse(longSeconds);
|
|
48
|
+
if (typeof match[2] == "string") {
|
|
49
|
+
const nanosStr = match[2] + "0".repeat(9 - match[2].length);
|
|
50
|
+
msg.nanos = parseInt(nanosStr);
|
|
51
|
+
if (longSeconds < 0 || Object.is(longSeconds, -0)) {
|
|
52
|
+
msg.nanos = -msg.nanos;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return msg;
|
|
56
|
+
},
|
|
57
|
+
toJson(msg) {
|
|
58
|
+
const secs = Number(msg.seconds ?? 0);
|
|
59
|
+
const nanos = Number(msg.nanos ?? 0);
|
|
60
|
+
if (secs > 315576000000 || secs < -315576000000) {
|
|
61
|
+
throw new Error(`cannot encode google.protobuf.Duration to JSON: value out of range`);
|
|
62
|
+
}
|
|
63
|
+
let text = secs.toString();
|
|
64
|
+
if (nanos !== 0) {
|
|
65
|
+
let nanosStr = Math.abs(nanos).toString();
|
|
66
|
+
nanosStr = "0".repeat(9 - nanosStr.length) + nanosStr;
|
|
67
|
+
if (nanosStr.substring(3) === "000000") {
|
|
68
|
+
nanosStr = nanosStr.substring(0, 3);
|
|
69
|
+
}
|
|
70
|
+
else if (nanosStr.substring(6) === "000") {
|
|
71
|
+
nanosStr = nanosStr.substring(0, 6);
|
|
72
|
+
}
|
|
73
|
+
text += "." + nanosStr;
|
|
74
|
+
if (nanos < 0 && secs === 0) {
|
|
75
|
+
text = "-" + text;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return text + "s";
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
// Duration contains the message type declaration for Duration.
|
|
82
|
+
export const Duration = createMessageType({
|
|
83
|
+
typeName: "google.protobuf.Duration",
|
|
84
|
+
fields: [
|
|
85
|
+
{ no: 1, name: "seconds", kind: "scalar", T: ScalarType.INT64 },
|
|
86
|
+
{ no: 2, name: "nanos", kind: "scalar", T: ScalarType.INT32 },
|
|
87
|
+
],
|
|
88
|
+
packedByDefault: true,
|
|
89
|
+
}, Duration_Wkt);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { MessageType } from "../../index.js";
|
|
2
|
+
export declare const protobufPackage = "google.protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* A generic empty message that you can re-use to avoid defining duplicated
|
|
5
|
+
* empty messages in your APIs. A typical example is to use it as the request
|
|
6
|
+
* or the response type of an API method. For instance:
|
|
7
|
+
*
|
|
8
|
+
* service Foo {
|
|
9
|
+
* rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
*
|
|
13
|
+
* @generated from message google.protobuf.Empty
|
|
14
|
+
*/
|
|
15
|
+
export interface Empty {
|
|
16
|
+
}
|
|
17
|
+
export declare const Empty: MessageType<Empty>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
|
4
|
+
//
|
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
|
6
|
+
// modification, are permitted provided that the following conditions are
|
|
7
|
+
// met:
|
|
8
|
+
//
|
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
// in the documentation and/or other materials provided with the
|
|
14
|
+
// distribution.
|
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
|
17
|
+
// this software without specific prior written permission.
|
|
18
|
+
//
|
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
import { createMessageType } from "../../index.js";
|
|
31
|
+
export const protobufPackage = "google.protobuf";
|
|
32
|
+
// Empty contains the message type declaration for Empty.
|
|
33
|
+
export const Empty = createMessageType({
|
|
34
|
+
typeName: "google.protobuf.Empty",
|
|
35
|
+
fields: [],
|
|
36
|
+
packedByDefault: true,
|
|
37
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { MessageType } from "../../index.js";
|
|
2
|
+
export declare const protobufPackage = "google.protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* `SourceContext` represents information about the source of a
|
|
5
|
+
* protobuf element, like the file in which it is defined.
|
|
6
|
+
*
|
|
7
|
+
* @generated from message google.protobuf.SourceContext
|
|
8
|
+
*/
|
|
9
|
+
export interface SourceContext {
|
|
10
|
+
/**
|
|
11
|
+
* The path-qualified name of the .proto file that contained the associated
|
|
12
|
+
* protobuf element. For example: `"google/protobuf/source_context.proto"`.
|
|
13
|
+
*
|
|
14
|
+
* @generated from field: string file_name = 1;
|
|
15
|
+
*/
|
|
16
|
+
fileName?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const SourceContext: MessageType<SourceContext>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
|
4
|
+
//
|
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
|
6
|
+
// modification, are permitted provided that the following conditions are
|
|
7
|
+
// met:
|
|
8
|
+
//
|
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
// in the documentation and/or other materials provided with the
|
|
14
|
+
// distribution.
|
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
|
17
|
+
// this software without specific prior written permission.
|
|
18
|
+
//
|
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
import { createMessageType, ScalarType } from "../../index.js";
|
|
31
|
+
export const protobufPackage = "google.protobuf";
|
|
32
|
+
// SourceContext contains the message type declaration for SourceContext.
|
|
33
|
+
export const SourceContext = createMessageType({
|
|
34
|
+
typeName: "google.protobuf.SourceContext",
|
|
35
|
+
fields: [
|
|
36
|
+
{ no: 1, name: "file_name", kind: "scalar", T: ScalarType.STRING },
|
|
37
|
+
],
|
|
38
|
+
packedByDefault: true,
|
|
39
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { JsonReadOptions, JsonValue, JsonWriteOptions, MessageType } from "../../index.js";
|
|
2
|
+
export declare const protobufPackage = "google.protobuf";
|
|
3
|
+
/**
|
|
4
|
+
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
5
|
+
* `Value` type union.
|
|
6
|
+
*
|
|
7
|
+
* The JSON representation for `NullValue` is JSON `null`.
|
|
8
|
+
*
|
|
9
|
+
* @generated from enum google.protobuf.NullValue
|
|
10
|
+
*/
|
|
11
|
+
export declare enum NullValue {
|
|
12
|
+
/**
|
|
13
|
+
* Null value.
|
|
14
|
+
*
|
|
15
|
+
* @generated from enum value: NULL_VALUE = 0;
|
|
16
|
+
*/
|
|
17
|
+
NULL_VALUE = 0
|
|
18
|
+
}
|
|
19
|
+
export declare const NullValue_Enum: import("../../enum.js").EnumType;
|
|
20
|
+
/**
|
|
21
|
+
* `ListValue` is a wrapper around a repeated field of values.
|
|
22
|
+
*
|
|
23
|
+
* The JSON representation for `ListValue` is JSON array.
|
|
24
|
+
*
|
|
25
|
+
* @generated from message google.protobuf.ListValue
|
|
26
|
+
*/
|
|
27
|
+
export interface ListValue {
|
|
28
|
+
/**
|
|
29
|
+
* Repeated field of dynamically typed values.
|
|
30
|
+
*
|
|
31
|
+
* @generated from field: repeated google.protobuf.Value values = 1;
|
|
32
|
+
*/
|
|
33
|
+
values?: Value[];
|
|
34
|
+
}
|
|
35
|
+
declare const ListValue_Wkt: {
|
|
36
|
+
toJson(msg: ListValue, options?: Partial<JsonWriteOptions>): JsonValue;
|
|
37
|
+
fromJson(json: JsonValue | null | undefined, options?: Partial<JsonReadOptions>): ListValue;
|
|
38
|
+
};
|
|
39
|
+
export declare const ListValue: MessageType<ListValue> & typeof ListValue_Wkt;
|
|
40
|
+
/**
|
|
41
|
+
* `Value` represents a dynamically typed value which can be either
|
|
42
|
+
* null, a number, a string, a boolean, a recursive struct value, or a
|
|
43
|
+
* list of values. A producer of value is expected to set one of these
|
|
44
|
+
* variants. Absence of any variant indicates an error.
|
|
45
|
+
*
|
|
46
|
+
* The JSON representation for `Value` is JSON value.
|
|
47
|
+
*
|
|
48
|
+
* @generated from message google.protobuf.Value
|
|
49
|
+
*/
|
|
50
|
+
export interface Value {
|
|
51
|
+
/**
|
|
52
|
+
* The kind of value.
|
|
53
|
+
*
|
|
54
|
+
* @generated from oneof google.protobuf.Value.kind
|
|
55
|
+
*/
|
|
56
|
+
kind?: {
|
|
57
|
+
value?: undefined;
|
|
58
|
+
case: undefined;
|
|
59
|
+
} | {
|
|
60
|
+
/**
|
|
61
|
+
* Represents a null value.
|
|
62
|
+
*
|
|
63
|
+
* @generated from field: google.protobuf.NullValue null_value = 1;
|
|
64
|
+
*/
|
|
65
|
+
value: NullValue;
|
|
66
|
+
case: "nullValue";
|
|
67
|
+
} | {
|
|
68
|
+
/**
|
|
69
|
+
* Represents a double value.
|
|
70
|
+
*
|
|
71
|
+
* @generated from field: double number_value = 2;
|
|
72
|
+
*/
|
|
73
|
+
value: number;
|
|
74
|
+
case: "numberValue";
|
|
75
|
+
} | {
|
|
76
|
+
/**
|
|
77
|
+
* Represents a string value.
|
|
78
|
+
*
|
|
79
|
+
* @generated from field: string string_value = 3;
|
|
80
|
+
*/
|
|
81
|
+
value: string;
|
|
82
|
+
case: "stringValue";
|
|
83
|
+
} | {
|
|
84
|
+
/**
|
|
85
|
+
* Represents a boolean value.
|
|
86
|
+
*
|
|
87
|
+
* @generated from field: bool bool_value = 4;
|
|
88
|
+
*/
|
|
89
|
+
value: boolean;
|
|
90
|
+
case: "boolValue";
|
|
91
|
+
} | {
|
|
92
|
+
/**
|
|
93
|
+
* Represents a structured value.
|
|
94
|
+
*
|
|
95
|
+
* @generated from field: google.protobuf.Struct struct_value = 5;
|
|
96
|
+
*/
|
|
97
|
+
value: Struct;
|
|
98
|
+
case: "structValue";
|
|
99
|
+
} | {
|
|
100
|
+
/**
|
|
101
|
+
* Represents a repeated `Value`.
|
|
102
|
+
*
|
|
103
|
+
* @generated from field: google.protobuf.ListValue list_value = 6;
|
|
104
|
+
*/
|
|
105
|
+
value: ListValue;
|
|
106
|
+
case: "listValue";
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
declare const Value_Wkt: {
|
|
110
|
+
toJson(msg: Value, options?: Partial<JsonWriteOptions>): JsonValue;
|
|
111
|
+
fromJson(json: JsonValue | null | undefined, _options?: Partial<JsonReadOptions>): Value;
|
|
112
|
+
};
|
|
113
|
+
export declare const Value: MessageType<Value> & typeof Value_Wkt;
|
|
114
|
+
/**
|
|
115
|
+
* `Struct` represents a structured data value, consisting of fields
|
|
116
|
+
* which map to dynamically typed values. In some languages, `Struct`
|
|
117
|
+
* might be supported by a native representation. For example, in
|
|
118
|
+
* scripting languages like JS a struct is represented as an
|
|
119
|
+
* object. The details of that representation are described together
|
|
120
|
+
* with the proto support for the language.
|
|
121
|
+
*
|
|
122
|
+
* The JSON representation for `Struct` is JSON object.
|
|
123
|
+
*
|
|
124
|
+
* @generated from message google.protobuf.Struct
|
|
125
|
+
*/
|
|
126
|
+
export interface Struct {
|
|
127
|
+
/**
|
|
128
|
+
* Unordered map of dynamically typed values.
|
|
129
|
+
*
|
|
130
|
+
* @generated from field: map<string, google.protobuf.Value> fields = 1;
|
|
131
|
+
*/
|
|
132
|
+
fields?: {
|
|
133
|
+
[key: string]: Value;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
declare const Struct_Wkt: {
|
|
137
|
+
toJson(msg: Struct, options?: Partial<JsonWriteOptions>): JsonValue;
|
|
138
|
+
fromJson(json: JsonValue | null | undefined, _options?: Partial<JsonReadOptions>): Struct;
|
|
139
|
+
};
|
|
140
|
+
export declare const Struct: MessageType<Struct> & typeof Struct_Wkt;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Protocol Buffers - Google's data interchange format
|
|
2
|
+
// Copyright 2008 Google Inc. All rights reserved.
|
|
3
|
+
// https://developers.google.com/protocol-buffers/
|
|
4
|
+
//
|
|
5
|
+
// Redistribution and use in source and binary forms, with or without
|
|
6
|
+
// modification, are permitted provided that the following conditions are
|
|
7
|
+
// met:
|
|
8
|
+
//
|
|
9
|
+
// * Redistributions of source code must retain the above copyright
|
|
10
|
+
// notice, this list of conditions and the following disclaimer.
|
|
11
|
+
// * Redistributions in binary form must reproduce the above
|
|
12
|
+
// copyright notice, this list of conditions and the following disclaimer
|
|
13
|
+
// in the documentation and/or other materials provided with the
|
|
14
|
+
// distribution.
|
|
15
|
+
// * Neither the name of Google Inc. nor the names of its
|
|
16
|
+
// contributors may be used to endorse or promote products derived from
|
|
17
|
+
// this software without specific prior written permission.
|
|
18
|
+
//
|
|
19
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
20
|
+
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
21
|
+
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
22
|
+
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
23
|
+
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
24
|
+
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
25
|
+
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
import { createEnumType, createMessageType, jsonDebugValue, ScalarType, } from "../../index.js";
|
|
31
|
+
export const protobufPackage = "google.protobuf";
|
|
32
|
+
/**
|
|
33
|
+
* `NullValue` is a singleton enumeration to represent the null value for the
|
|
34
|
+
* `Value` type union.
|
|
35
|
+
*
|
|
36
|
+
* The JSON representation for `NullValue` is JSON `null`.
|
|
37
|
+
*
|
|
38
|
+
* @generated from enum google.protobuf.NullValue
|
|
39
|
+
*/
|
|
40
|
+
export var NullValue;
|
|
41
|
+
(function (NullValue) {
|
|
42
|
+
/**
|
|
43
|
+
* Null value.
|
|
44
|
+
*
|
|
45
|
+
* @generated from enum value: NULL_VALUE = 0;
|
|
46
|
+
*/
|
|
47
|
+
NullValue[NullValue["NULL_VALUE"] = 0] = "NULL_VALUE";
|
|
48
|
+
})(NullValue || (NullValue = {}));
|
|
49
|
+
// NullValue_Enum is the enum type for NullValue.
|
|
50
|
+
export const NullValue_Enum = createEnumType("google.protobuf.NullValue", [
|
|
51
|
+
{ no: 0, name: "NULL_VALUE" },
|
|
52
|
+
]);
|
|
53
|
+
// ListValue_Wkt contains the well-known-type overrides for ListValue.
|
|
54
|
+
const ListValue_Wkt = {
|
|
55
|
+
toJson(msg, options) {
|
|
56
|
+
return msg.values?.map((v) => Value.toJson(v, options)) ?? [];
|
|
57
|
+
},
|
|
58
|
+
fromJson(json, options) {
|
|
59
|
+
if (json == null) {
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
if (!Array.isArray(json)) {
|
|
63
|
+
throw new Error(`cannot decode google.protobuf.ListValue from JSON ${jsonDebugValue(json)}`);
|
|
64
|
+
}
|
|
65
|
+
const values = json.map((v) => Value.fromJson(v, options));
|
|
66
|
+
return { values: values };
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
// ListValue contains the message type declaration for ListValue.
|
|
70
|
+
export const ListValue = createMessageType({
|
|
71
|
+
typeName: "google.protobuf.ListValue",
|
|
72
|
+
fields: [
|
|
73
|
+
{
|
|
74
|
+
no: 1,
|
|
75
|
+
name: "values",
|
|
76
|
+
kind: "message",
|
|
77
|
+
T: () => Value,
|
|
78
|
+
repeated: true,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
packedByDefault: true,
|
|
82
|
+
}, ListValue_Wkt);
|
|
83
|
+
// Value_Wkt contains the well-known-type overrides for Value.
|
|
84
|
+
const Value_Wkt = {
|
|
85
|
+
toJson(msg, options) {
|
|
86
|
+
switch (msg.kind?.case) {
|
|
87
|
+
case "nullValue":
|
|
88
|
+
return null;
|
|
89
|
+
case "numberValue":
|
|
90
|
+
if (!Number.isFinite(msg.kind.value)) {
|
|
91
|
+
throw new Error("google.protobuf.Value cannot be NaN or Infinity");
|
|
92
|
+
}
|
|
93
|
+
return msg.kind.value;
|
|
94
|
+
case "boolValue":
|
|
95
|
+
return msg.kind.value;
|
|
96
|
+
case "stringValue":
|
|
97
|
+
return msg.kind.value;
|
|
98
|
+
case "structValue":
|
|
99
|
+
return Struct.toJson(msg.kind.value, {
|
|
100
|
+
...options,
|
|
101
|
+
emitDefaultValues: true,
|
|
102
|
+
});
|
|
103
|
+
case "listValue":
|
|
104
|
+
return ListValue.toJson(msg.kind.value, {
|
|
105
|
+
...options,
|
|
106
|
+
emitDefaultValues: true,
|
|
107
|
+
});
|
|
108
|
+
case null:
|
|
109
|
+
case undefined:
|
|
110
|
+
default:
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
fromJson(json, _options) {
|
|
115
|
+
const msg = {};
|
|
116
|
+
switch (typeof json) {
|
|
117
|
+
case "number":
|
|
118
|
+
msg.kind = { case: "numberValue", value: json };
|
|
119
|
+
break;
|
|
120
|
+
case "string":
|
|
121
|
+
msg.kind = { case: "stringValue", value: json };
|
|
122
|
+
break;
|
|
123
|
+
case "boolean":
|
|
124
|
+
msg.kind = { case: "boolValue", value: json };
|
|
125
|
+
break;
|
|
126
|
+
case "object":
|
|
127
|
+
if (json == null) {
|
|
128
|
+
msg.kind = { case: "nullValue", value: NullValue.NULL_VALUE };
|
|
129
|
+
}
|
|
130
|
+
else if (Array.isArray(json)) {
|
|
131
|
+
msg.kind = { case: "listValue", value: ListValue.fromJson(json) };
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
msg.kind = { case: "structValue", value: Struct.fromJson(json) };
|
|
135
|
+
}
|
|
136
|
+
break;
|
|
137
|
+
default:
|
|
138
|
+
throw new Error(`cannot decode google.protobuf.Value from JSON ${jsonDebugValue(json)}`);
|
|
139
|
+
}
|
|
140
|
+
return msg;
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
// Value contains the message type declaration for Value.
|
|
144
|
+
export const Value = createMessageType({
|
|
145
|
+
typeName: "google.protobuf.Value",
|
|
146
|
+
fields: [
|
|
147
|
+
{
|
|
148
|
+
no: 1,
|
|
149
|
+
name: "null_value",
|
|
150
|
+
kind: "enum",
|
|
151
|
+
T: NullValue_Enum,
|
|
152
|
+
oneof: "kind",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
no: 2,
|
|
156
|
+
name: "number_value",
|
|
157
|
+
kind: "scalar",
|
|
158
|
+
T: ScalarType.DOUBLE,
|
|
159
|
+
oneof: "kind",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
no: 3,
|
|
163
|
+
name: "string_value",
|
|
164
|
+
kind: "scalar",
|
|
165
|
+
T: ScalarType.STRING,
|
|
166
|
+
oneof: "kind",
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
no: 4,
|
|
170
|
+
name: "bool_value",
|
|
171
|
+
kind: "scalar",
|
|
172
|
+
T: ScalarType.BOOL,
|
|
173
|
+
oneof: "kind",
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
no: 5,
|
|
177
|
+
name: "struct_value",
|
|
178
|
+
kind: "message",
|
|
179
|
+
T: () => Struct,
|
|
180
|
+
oneof: "kind",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
no: 6,
|
|
184
|
+
name: "list_value",
|
|
185
|
+
kind: "message",
|
|
186
|
+
T: () => ListValue,
|
|
187
|
+
oneof: "kind",
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
packedByDefault: true,
|
|
191
|
+
}, Value_Wkt);
|
|
192
|
+
// Struct_Wkt contains the well-known-type overrides for Struct.
|
|
193
|
+
const Struct_Wkt = {
|
|
194
|
+
toJson(msg, options) {
|
|
195
|
+
const json = {};
|
|
196
|
+
if (!msg.fields) {
|
|
197
|
+
return json;
|
|
198
|
+
}
|
|
199
|
+
for (const [k, v] of Object.entries(msg.fields)) {
|
|
200
|
+
json[k] = v != null ? Value.toJson(v, options) : null;
|
|
201
|
+
}
|
|
202
|
+
return json;
|
|
203
|
+
},
|
|
204
|
+
fromJson(json, _options) {
|
|
205
|
+
if (typeof json != "object" || json == null || Array.isArray(json)) {
|
|
206
|
+
throw new Error(`cannot decode google.protobuf.Struct from JSON ${jsonDebugValue(json)}`);
|
|
207
|
+
}
|
|
208
|
+
const fields = {};
|
|
209
|
+
for (const [k, v] of Object.entries(json)) {
|
|
210
|
+
fields[k] = Value.fromJson(v);
|
|
211
|
+
}
|
|
212
|
+
return { fields: fields };
|
|
213
|
+
},
|
|
214
|
+
};
|
|
215
|
+
// Struct contains the message type declaration for Struct.
|
|
216
|
+
export const Struct = createMessageType({
|
|
217
|
+
typeName: "google.protobuf.Struct",
|
|
218
|
+
fields: [
|
|
219
|
+
{
|
|
220
|
+
no: 1,
|
|
221
|
+
name: "fields",
|
|
222
|
+
kind: "map",
|
|
223
|
+
K: ScalarType.STRING,
|
|
224
|
+
V: { kind: "message", T: () => Value },
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
packedByDefault: true,
|
|
228
|
+
}, Struct_Wkt);
|