@songtonyli/dsh-cli 0.1.32 → 0.1.33
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 -1
- package/bin/dsh.mjs +1 -1
- package/node_modules/@bufbuild/protobuf/README.md +41 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/clone.js +66 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/boot.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/enum.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/extension.js +28 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/file.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/index.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/message.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/service.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/symbols.js +43 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv1/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/boot.js +105 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/embed.js +244 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/enum.js +58 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/extension.js +28 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/file.js +35 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/index.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/message.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/restore-json-names.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/scalar.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/service.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/symbols.js +74 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/codegenv2/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/create.js +296 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/descriptors.js +53 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/equals.js +209 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/extensions.js +168 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/fields.js +45 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-binary.js +415 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/from-json.js +1037 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/index.js +55 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/is-message.js +33 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/json-value.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/merge.js +70 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/package.json +4 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/proto-int64.js +131 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/error.js +36 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/guard.js +78 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/index.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/message.js +157 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/names.js +115 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/nested-types.js +110 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/path.js +376 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-check.js +292 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect-types.js +16 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/reflect.js +469 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/scalar.js +129 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/reflect/unsafe.js +149 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/registry.js +954 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-binary.js +437 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/to-json.js +625 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/from-text.js +684 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/index.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/is-group-like.js +47 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/reader.js +481 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/to-text.js +358 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/txtpb/writer.js +220 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/types.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/unknown-enum.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/base64-encoding.js +188 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/binary-encoding.js +726 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/index.js +37 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/size-delimited.js +191 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-encoding.js +106 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/text-format.js +199 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wire/varint.js +334 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/any.js +75 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/duration.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/any_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/api_pb.js +39 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/compiler/plugin_pb.js +68 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/cpp_features_pb.js +60 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/descriptor_pb.js +892 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/duration_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/empty_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/field_mask_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/go_features_pb.js +126 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/java_features_pb.js +106 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/source_context_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/struct_pb.js +59 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/timestamp_pb.js +27 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/type_pb.js +242 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/gen/google/protobuf/wrappers_pb.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/index.js +48 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/json.js +44 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/timestamp.js +57 -0
- package/node_modules/@bufbuild/protobuf/dist/commonjs/wkt/wrappers.js +66 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/clone.js +63 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/boot.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/enum.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/extension.js +25 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/file.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/index.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/message.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/service.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/symbols.js +40 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv1/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/boot.js +101 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/embed.js +239 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/enum.js +53 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/extension.js +25 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/file.js +32 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/index.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/message.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/restore-json-names.js +26 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/scalar.js +63 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/service.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/symbols.js +71 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/codegenv2/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/create.js +293 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/descriptors.js +50 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/equals.js +206 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/extensions.js +159 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/fields.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/from-binary.js +409 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/from-json.js +1029 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/index.js +29 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/is-message.js +30 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/json-value.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/merge.js +67 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/package.json +4 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js +128 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/error.js +31 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/guard.js +71 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/index.js +21 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/message.js +152 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/names.js +109 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/nested-types.js +105 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/path.js +369 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-check.js +284 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect-types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/reflect.js +464 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/scalar.js +124 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/reflect/unsafe.js +140 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/registry.js +948 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/to-binary.js +433 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/to-json.js +620 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/from-text.js +680 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/index.js +15 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/is-group-like.js +44 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/reader.js +477 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/to-text.js +355 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/txtpb/writer.js +214 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/types.js +14 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/unknown-enum.js +23 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/base64-encoding.js +184 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/binary-encoding.js +721 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/index.js +18 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/size-delimited.js +186 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-encoding.js +101 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/text-format.js +195 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wire/varint.js +325 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/any.js +69 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/duration.js +35 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/any_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/api_pb.js +36 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/compiler/plugin_pb.js +65 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/cpp_features_pb.js +57 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/descriptor_pb.js +888 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/duration_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/empty_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/field_mask_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/go_features_pb.js +123 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/java_features_pb.js +103 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/source_context_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/struct_pb.js +56 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/timestamp_pb.js +24 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/type_pb.js +239 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/gen/google/protobuf/wrappers_pb.js +64 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/index.js +32 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/json.js +41 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/timestamp.js +50 -0
- package/node_modules/@bufbuild/protobuf/dist/esm/wkt/wrappers.js +61 -0
- package/node_modules/@bufbuild/protobuf/package.json +136 -0
- package/node_modules/@deepseek-ai/dsh-base/package.json +1 -0
- package/node_modules/@deepseek-ai/dsh-client-ui-primitives/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-client-ui-sidebar/lib/client.js +1 -1
- package/node_modules/@deepseek-ai/dsh-client-ui-slots/package.json +2 -2
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.i18n.yaml +6 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.md +142 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/README.zh.md +142 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/lib/index.js +3013 -0
- package/node_modules/@deepseek-ai/dsh-llm-cursor/package.json +61 -0
- package/node_modules/@deepseek-ai/dsh-tui-app/README.i18n.yaml +2 -2
- package/node_modules/@deepseek-ai/dsh-tui-app/README.md +5 -5
- package/node_modules/@deepseek-ai/dsh-tui-app/README.zh.md +5 -5
- package/node_modules/@deepseek-ai/dsh-tui-app/lib/index.js +44 -18
- package/package.json +5 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.getOption = exports.hasOption = exports.clearExtension = exports.setExtension = exports.getExtension = exports.hasExtension = exports.mergeFromBinary = exports.fromBinary = exports.toBinary = void 0;
|
|
31
|
+
__exportStar(require("./types.js"), exports);
|
|
32
|
+
__exportStar(require("./is-message.js"), exports);
|
|
33
|
+
__exportStar(require("./create.js"), exports);
|
|
34
|
+
__exportStar(require("./clone.js"), exports);
|
|
35
|
+
__exportStar(require("./descriptors.js"), exports);
|
|
36
|
+
__exportStar(require("./equals.js"), exports);
|
|
37
|
+
__exportStar(require("./fields.js"), exports);
|
|
38
|
+
__exportStar(require("./registry.js"), exports);
|
|
39
|
+
var to_binary_js_1 = require("./to-binary.js");
|
|
40
|
+
Object.defineProperty(exports, "toBinary", { enumerable: true, get: function () { return to_binary_js_1.toBinary; } });
|
|
41
|
+
var from_binary_js_1 = require("./from-binary.js");
|
|
42
|
+
Object.defineProperty(exports, "fromBinary", { enumerable: true, get: function () { return from_binary_js_1.fromBinary; } });
|
|
43
|
+
Object.defineProperty(exports, "mergeFromBinary", { enumerable: true, get: function () { return from_binary_js_1.mergeFromBinary; } });
|
|
44
|
+
__exportStar(require("./to-json.js"), exports);
|
|
45
|
+
__exportStar(require("./from-json.js"), exports);
|
|
46
|
+
__exportStar(require("./merge.js"), exports);
|
|
47
|
+
var extensions_js_1 = require("./extensions.js");
|
|
48
|
+
Object.defineProperty(exports, "hasExtension", { enumerable: true, get: function () { return extensions_js_1.hasExtension; } });
|
|
49
|
+
Object.defineProperty(exports, "getExtension", { enumerable: true, get: function () { return extensions_js_1.getExtension; } });
|
|
50
|
+
Object.defineProperty(exports, "setExtension", { enumerable: true, get: function () { return extensions_js_1.setExtension; } });
|
|
51
|
+
Object.defineProperty(exports, "clearExtension", { enumerable: true, get: function () { return extensions_js_1.clearExtension; } });
|
|
52
|
+
Object.defineProperty(exports, "hasOption", { enumerable: true, get: function () { return extensions_js_1.hasOption; } });
|
|
53
|
+
Object.defineProperty(exports, "getOption", { enumerable: true, get: function () { return extensions_js_1.getOption; } });
|
|
54
|
+
__exportStar(require("./proto-int64.js"), exports);
|
|
55
|
+
__exportStar(require("./unknown-enum.js"), exports);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.isMessage = isMessage;
|
|
17
|
+
/**
|
|
18
|
+
* Determine whether the given `arg` is a message.
|
|
19
|
+
* If `desc` is set, determine whether `arg` is this specific message.
|
|
20
|
+
*/
|
|
21
|
+
function isMessage(arg, schema) {
|
|
22
|
+
const isMessage = arg !== null &&
|
|
23
|
+
typeof arg == "object" &&
|
|
24
|
+
"$typeName" in arg &&
|
|
25
|
+
typeof arg.$typeName == "string";
|
|
26
|
+
if (!isMessage) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
if (schema === undefined) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return schema.typeName === arg.$typeName;
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.merge = merge;
|
|
17
|
+
const reflect_js_1 = require("./reflect/reflect.js");
|
|
18
|
+
/**
|
|
19
|
+
* Merge message `source` into message `target`, following Protobuf semantics.
|
|
20
|
+
*
|
|
21
|
+
* This is the same as serializing the source message, then deserializing it
|
|
22
|
+
* into the target message via `mergeFromBinary()`, with one difference:
|
|
23
|
+
* While serialization will create a copy of all values, `merge()` will copy
|
|
24
|
+
* the reference for `bytes` and messages.
|
|
25
|
+
*
|
|
26
|
+
* Also see https://protobuf.com/docs/language-spec#merging-protobuf-messages
|
|
27
|
+
*/
|
|
28
|
+
function merge(schema, target, source) {
|
|
29
|
+
reflectMerge((0, reflect_js_1.reflect)(schema, target), (0, reflect_js_1.reflect)(schema, source));
|
|
30
|
+
}
|
|
31
|
+
function reflectMerge(target, source) {
|
|
32
|
+
var _a;
|
|
33
|
+
var _b;
|
|
34
|
+
const sourceUnknown = source.message.$unknown;
|
|
35
|
+
if (sourceUnknown !== undefined && sourceUnknown.length > 0) {
|
|
36
|
+
(_a = (_b = target.message).$unknown) !== null && _a !== void 0 ? _a : (_b.$unknown = []);
|
|
37
|
+
target.message.$unknown.push(...sourceUnknown);
|
|
38
|
+
}
|
|
39
|
+
for (const f of target.fields) {
|
|
40
|
+
if (!source.isSet(f)) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
switch (f.fieldKind) {
|
|
44
|
+
case "scalar":
|
|
45
|
+
case "enum":
|
|
46
|
+
target.set(f, source.get(f));
|
|
47
|
+
break;
|
|
48
|
+
case "message":
|
|
49
|
+
if (target.isSet(f)) {
|
|
50
|
+
reflectMerge(target.get(f), source.get(f));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
target.set(f, source.get(f));
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
case "list":
|
|
57
|
+
const list = target.get(f);
|
|
58
|
+
for (const e of source.get(f)) {
|
|
59
|
+
list.add(e);
|
|
60
|
+
}
|
|
61
|
+
break;
|
|
62
|
+
case "map":
|
|
63
|
+
const map = target.get(f);
|
|
64
|
+
for (const [k, v] of source.get(f)) {
|
|
65
|
+
map.set(k, v);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.protoInt64 = void 0;
|
|
17
|
+
const varint_js_1 = require("./wire/varint.js");
|
|
18
|
+
/**
|
|
19
|
+
* Int64Support for the current environment.
|
|
20
|
+
*/
|
|
21
|
+
exports.protoInt64 = makeInt64Support();
|
|
22
|
+
function makeInt64Support() {
|
|
23
|
+
const dv = new DataView(new ArrayBuffer(8));
|
|
24
|
+
// note that Safari 14 implements BigInt, but not the DataView methods
|
|
25
|
+
const ok = typeof BigInt === "function" &&
|
|
26
|
+
typeof dv.getBigInt64 === "function" &&
|
|
27
|
+
typeof dv.getBigUint64 === "function" &&
|
|
28
|
+
typeof dv.setBigInt64 === "function" &&
|
|
29
|
+
typeof dv.setBigUint64 === "function" &&
|
|
30
|
+
(!!globalThis.Deno ||
|
|
31
|
+
!!globalThis.Bun ||
|
|
32
|
+
typeof process != "object" ||
|
|
33
|
+
typeof process.env != "object" ||
|
|
34
|
+
process.env.BUF_BIGINT_DISABLE !== "1");
|
|
35
|
+
if (ok) {
|
|
36
|
+
const MIN = BigInt("-9223372036854775808");
|
|
37
|
+
const MAX = BigInt("9223372036854775807");
|
|
38
|
+
const UMIN = BigInt("0");
|
|
39
|
+
const UMAX = BigInt("18446744073709551615");
|
|
40
|
+
return {
|
|
41
|
+
zero: BigInt(0),
|
|
42
|
+
supported: true,
|
|
43
|
+
parse(value) {
|
|
44
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
45
|
+
if (bi > MAX || bi < MIN) {
|
|
46
|
+
throw new Error(`invalid int64: ${value}`);
|
|
47
|
+
}
|
|
48
|
+
return bi;
|
|
49
|
+
},
|
|
50
|
+
uParse(value) {
|
|
51
|
+
const bi = typeof value == "bigint" ? value : BigInt(value);
|
|
52
|
+
if (bi > UMAX || bi < UMIN) {
|
|
53
|
+
throw new Error(`invalid uint64: ${value}`);
|
|
54
|
+
}
|
|
55
|
+
return bi;
|
|
56
|
+
},
|
|
57
|
+
enc(value) {
|
|
58
|
+
dv.setBigInt64(0, this.parse(value), true);
|
|
59
|
+
return {
|
|
60
|
+
lo: dv.getInt32(0, true),
|
|
61
|
+
hi: dv.getInt32(4, true),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
uEnc(value) {
|
|
65
|
+
dv.setBigInt64(0, this.uParse(value), true);
|
|
66
|
+
return {
|
|
67
|
+
lo: dv.getInt32(0, true),
|
|
68
|
+
hi: dv.getInt32(4, true),
|
|
69
|
+
};
|
|
70
|
+
},
|
|
71
|
+
dec(lo, hi) {
|
|
72
|
+
dv.setInt32(0, lo, true);
|
|
73
|
+
dv.setInt32(4, hi, true);
|
|
74
|
+
return dv.getBigInt64(0, true);
|
|
75
|
+
},
|
|
76
|
+
uDec(lo, hi) {
|
|
77
|
+
dv.setInt32(0, lo, true);
|
|
78
|
+
dv.setInt32(4, hi, true);
|
|
79
|
+
return dv.getBigUint64(0, true);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
zero: "0",
|
|
85
|
+
supported: false,
|
|
86
|
+
parse(value) {
|
|
87
|
+
if (typeof value != "string") {
|
|
88
|
+
value = value.toString();
|
|
89
|
+
}
|
|
90
|
+
assertInt64String(value);
|
|
91
|
+
return value;
|
|
92
|
+
},
|
|
93
|
+
uParse(value) {
|
|
94
|
+
if (typeof value != "string") {
|
|
95
|
+
value = value.toString();
|
|
96
|
+
}
|
|
97
|
+
assertUInt64String(value);
|
|
98
|
+
return value;
|
|
99
|
+
},
|
|
100
|
+
enc(value) {
|
|
101
|
+
if (typeof value != "string") {
|
|
102
|
+
value = value.toString();
|
|
103
|
+
}
|
|
104
|
+
assertInt64String(value);
|
|
105
|
+
return (0, varint_js_1.int64FromString)(value);
|
|
106
|
+
},
|
|
107
|
+
uEnc(value) {
|
|
108
|
+
if (typeof value != "string") {
|
|
109
|
+
value = value.toString();
|
|
110
|
+
}
|
|
111
|
+
assertUInt64String(value);
|
|
112
|
+
return (0, varint_js_1.int64FromString)(value);
|
|
113
|
+
},
|
|
114
|
+
dec(lo, hi) {
|
|
115
|
+
return (0, varint_js_1.int64ToString)(lo, hi);
|
|
116
|
+
},
|
|
117
|
+
uDec(lo, hi) {
|
|
118
|
+
return (0, varint_js_1.uInt64ToString)(lo, hi);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function assertInt64String(value) {
|
|
123
|
+
if (!/^-?[0-9]+$/.test(value)) {
|
|
124
|
+
throw new Error("invalid int64: " + value);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function assertUInt64String(value) {
|
|
128
|
+
if (!/^[0-9]+$/.test(value)) {
|
|
129
|
+
throw new Error("invalid uint64: " + value);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.FieldError = void 0;
|
|
17
|
+
exports.isFieldError = isFieldError;
|
|
18
|
+
const errorNames = [
|
|
19
|
+
"FieldValueInvalidError",
|
|
20
|
+
"FieldListRangeError",
|
|
21
|
+
"ForeignFieldError",
|
|
22
|
+
];
|
|
23
|
+
class FieldError extends Error {
|
|
24
|
+
constructor(fieldOrOneof, message, name = "FieldValueInvalidError") {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.field = () => fieldOrOneof;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.FieldError = FieldError;
|
|
31
|
+
function isFieldError(arg) {
|
|
32
|
+
return (arg instanceof Error &&
|
|
33
|
+
errorNames.includes(arg.name) &&
|
|
34
|
+
"field" in arg &&
|
|
35
|
+
typeof arg.field == "function");
|
|
36
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.isObject = isObject;
|
|
17
|
+
exports.isOneofADT = isOneofADT;
|
|
18
|
+
exports.isReflectList = isReflectList;
|
|
19
|
+
exports.isReflectMap = isReflectMap;
|
|
20
|
+
exports.isReflectMessage = isReflectMessage;
|
|
21
|
+
const unsafe_js_1 = require("./unsafe.js");
|
|
22
|
+
function isObject(arg) {
|
|
23
|
+
return arg !== null && typeof arg == "object" && !Array.isArray(arg);
|
|
24
|
+
}
|
|
25
|
+
function isOneofADT(arg) {
|
|
26
|
+
return (arg !== null &&
|
|
27
|
+
typeof arg == "object" &&
|
|
28
|
+
"case" in arg &&
|
|
29
|
+
((typeof arg.case == "string" && "value" in arg && arg.value != null) ||
|
|
30
|
+
(arg.case === undefined &&
|
|
31
|
+
(!("value" in arg) || arg.value === undefined))));
|
|
32
|
+
}
|
|
33
|
+
function isReflectList(arg, field) {
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
|
+
if (isObject(arg) &&
|
|
36
|
+
unsafe_js_1.unsafeLocal in arg &&
|
|
37
|
+
"add" in arg &&
|
|
38
|
+
"field" in arg &&
|
|
39
|
+
typeof arg.field == "function") {
|
|
40
|
+
if (field !== undefined) {
|
|
41
|
+
const a = field;
|
|
42
|
+
const b = arg.field();
|
|
43
|
+
return (a.listKind == b.listKind &&
|
|
44
|
+
a.scalar === b.scalar &&
|
|
45
|
+
((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) &&
|
|
46
|
+
((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName));
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
function isReflectMap(arg, field) {
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
if (isObject(arg) &&
|
|
55
|
+
unsafe_js_1.unsafeLocal in arg &&
|
|
56
|
+
"has" in arg &&
|
|
57
|
+
"field" in arg &&
|
|
58
|
+
typeof arg.field == "function") {
|
|
59
|
+
if (field !== undefined) {
|
|
60
|
+
const a = field, b = arg.field();
|
|
61
|
+
return (a.mapKey === b.mapKey &&
|
|
62
|
+
a.mapKind == b.mapKind &&
|
|
63
|
+
a.scalar === b.scalar &&
|
|
64
|
+
((_a = a.message) === null || _a === void 0 ? void 0 : _a.typeName) === ((_b = b.message) === null || _b === void 0 ? void 0 : _b.typeName) &&
|
|
65
|
+
((_c = a.enum) === null || _c === void 0 ? void 0 : _c.typeName) === ((_d = b.enum) === null || _d === void 0 ? void 0 : _d.typeName));
|
|
66
|
+
}
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
function isReflectMessage(arg, messageDesc) {
|
|
72
|
+
return (isObject(arg) &&
|
|
73
|
+
unsafe_js_1.unsafeLocal in arg &&
|
|
74
|
+
"desc" in arg &&
|
|
75
|
+
isObject(arg.desc) &&
|
|
76
|
+
arg.desc.kind === "message" &&
|
|
77
|
+
(messageDesc === undefined || arg.desc.typeName == messageDesc.typeName));
|
|
78
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
27
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.isReflectMessage = exports.isReflectMap = exports.isReflectList = void 0;
|
|
31
|
+
__exportStar(require("./error.js"), exports);
|
|
32
|
+
__exportStar(require("./names.js"), exports);
|
|
33
|
+
__exportStar(require("./nested-types.js"), exports);
|
|
34
|
+
__exportStar(require("./reflect.js"), exports);
|
|
35
|
+
__exportStar(require("./reflect-types.js"), exports);
|
|
36
|
+
__exportStar(require("./scalar.js"), exports);
|
|
37
|
+
__exportStar(require("./path.js"), exports);
|
|
38
|
+
var guard_js_1 = require("./guard.js");
|
|
39
|
+
Object.defineProperty(exports, "isReflectList", { enumerable: true, get: function () { return guard_js_1.isReflectList; } });
|
|
40
|
+
Object.defineProperty(exports, "isReflectMap", { enumerable: true, get: function () { return guard_js_1.isReflectMap; } });
|
|
41
|
+
Object.defineProperty(exports, "isReflectMessage", { enumerable: true, get: function () { return guard_js_1.isReflectMessage; } });
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright 2021-2026 Buf Technologies, Inc.
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
// you may not use this file except in compliance with the License.
|
|
6
|
+
// You may obtain a copy of the License at
|
|
7
|
+
//
|
|
8
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
//
|
|
10
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
// See the License for the specific language governing permissions and
|
|
14
|
+
// limitations under the License.
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.localMessageMapper = localMessageMapper;
|
|
17
|
+
exports.wktStructToReflect = wktStructToReflect;
|
|
18
|
+
exports.wktStructToLocal = wktStructToLocal;
|
|
19
|
+
const create_js_1 = require("../create.js");
|
|
20
|
+
const guard_js_1 = require("./guard.js");
|
|
21
|
+
const wrappers_js_1 = require("../wkt/wrappers.js");
|
|
22
|
+
// google.protobuf.NullValue.NULL_VALUE;
|
|
23
|
+
const NULL_VALUE = 0;
|
|
24
|
+
/**
|
|
25
|
+
* Return the conversions between the local representation of the field
|
|
26
|
+
* value and the message it represents.
|
|
27
|
+
*
|
|
28
|
+
* @private
|
|
29
|
+
*/
|
|
30
|
+
function localMessageMapper(field) {
|
|
31
|
+
// google.protobuf.Struct fields are stored as JsonObject.
|
|
32
|
+
if (usesJsonRepresentation(field)) {
|
|
33
|
+
return {
|
|
34
|
+
toMessage: (local) => wktStructToReflect(local),
|
|
35
|
+
toLocal: (message) => wktStructToLocal(message),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// Singular wrapper fields outside a oneof are unwrapped to the scalar value.
|
|
39
|
+
if (field.fieldKind == "message" &&
|
|
40
|
+
!field.oneof &&
|
|
41
|
+
(0, wrappers_js_1.isWrapperDesc)(field.message)) {
|
|
42
|
+
const wrapperDesc = field.message;
|
|
43
|
+
const valueLocalName = wrapperDesc.fields[0].localName;
|
|
44
|
+
return {
|
|
45
|
+
toMessage: (local) => {
|
|
46
|
+
const message = (0, create_js_1.create)(wrapperDesc);
|
|
47
|
+
if (local !== undefined) {
|
|
48
|
+
message[valueLocalName] = local;
|
|
49
|
+
}
|
|
50
|
+
return message;
|
|
51
|
+
},
|
|
52
|
+
toLocal: (message) => message[valueLocalName],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// For all other fields, the local value is the message itself.
|
|
56
|
+
const childDesc = field.message;
|
|
57
|
+
return {
|
|
58
|
+
toMessage: (local) => (local === undefined ? (0, create_js_1.create)(childDesc) : local),
|
|
59
|
+
toLocal: (message) => message,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns true if values of this field are stored as JsonValue instead of
|
|
64
|
+
* a message: google.protobuf.Struct is represented with JsonObject when
|
|
65
|
+
* used in a field, except when used in google.protobuf.Value.
|
|
66
|
+
*/
|
|
67
|
+
function usesJsonRepresentation(field) {
|
|
68
|
+
return (field.message.typeName == "google.protobuf.Struct" &&
|
|
69
|
+
field.parent.typeName != "google.protobuf.Value");
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Convert the JsonValue representation of a google.protobuf.Struct to the
|
|
73
|
+
* message representation.
|
|
74
|
+
*
|
|
75
|
+
* @private
|
|
76
|
+
*/
|
|
77
|
+
function wktStructToReflect(json) {
|
|
78
|
+
const struct = {
|
|
79
|
+
$typeName: "google.protobuf.Struct",
|
|
80
|
+
fields: {},
|
|
81
|
+
};
|
|
82
|
+
if ((0, guard_js_1.isObject)(json)) {
|
|
83
|
+
for (const k of Object.keys(json)) {
|
|
84
|
+
struct.fields[k] = wktValueToReflect(json[k]);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return struct;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convert a google.protobuf.Struct message to its JsonValue representation.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
function wktStructToLocal(val) {
|
|
95
|
+
const json = {};
|
|
96
|
+
for (const k of Object.keys(val.fields)) {
|
|
97
|
+
json[k] = wktValueToLocal(val.fields[k]);
|
|
98
|
+
}
|
|
99
|
+
return json;
|
|
100
|
+
}
|
|
101
|
+
function wktValueToLocal(val) {
|
|
102
|
+
switch (val.kind.case) {
|
|
103
|
+
case "structValue":
|
|
104
|
+
return wktStructToLocal(val.kind.value);
|
|
105
|
+
case "listValue":
|
|
106
|
+
return val.kind.value.values.map(wktValueToLocal);
|
|
107
|
+
case "nullValue":
|
|
108
|
+
case undefined:
|
|
109
|
+
return null;
|
|
110
|
+
default:
|
|
111
|
+
return val.kind.value;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function wktValueToReflect(json) {
|
|
115
|
+
const value = {
|
|
116
|
+
$typeName: "google.protobuf.Value",
|
|
117
|
+
kind: { case: undefined },
|
|
118
|
+
};
|
|
119
|
+
switch (typeof json) {
|
|
120
|
+
case "number":
|
|
121
|
+
value.kind = { case: "numberValue", value: json };
|
|
122
|
+
break;
|
|
123
|
+
case "string":
|
|
124
|
+
value.kind = { case: "stringValue", value: json };
|
|
125
|
+
break;
|
|
126
|
+
case "boolean":
|
|
127
|
+
value.kind = { case: "boolValue", value: json };
|
|
128
|
+
break;
|
|
129
|
+
case "object":
|
|
130
|
+
if (json === null) {
|
|
131
|
+
value.kind = { case: "nullValue", value: NULL_VALUE };
|
|
132
|
+
}
|
|
133
|
+
else if (Array.isArray(json)) {
|
|
134
|
+
const listValue = {
|
|
135
|
+
$typeName: "google.protobuf.ListValue",
|
|
136
|
+
values: [],
|
|
137
|
+
};
|
|
138
|
+
if (Array.isArray(json)) {
|
|
139
|
+
for (const e of json) {
|
|
140
|
+
listValue.values.push(wktValueToReflect(e));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
value.kind = {
|
|
144
|
+
case: "listValue",
|
|
145
|
+
value: listValue,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
value.kind = {
|
|
150
|
+
case: "structValue",
|
|
151
|
+
value: wktStructToReflect(json),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
return value;
|
|
157
|
+
}
|