@bufbuild/protoc-gen-es 2.6.3 → 2.8.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/dist/cjs/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoc-gen-es",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Protocol Buffers code generator for ECMAScript",
|
|
6
6
|
"keywords": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"protoc-gen-es": "bin/protoc-gen-es"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"prebuild": "rm -rf ./dist/cjs/*",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"preferUnplugged": true,
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bufbuild/protobuf": "2.
|
|
36
|
-
"@bufbuild/protoplugin": "2.
|
|
35
|
+
"@bufbuild/protobuf": "2.8.0",
|
|
36
|
+
"@bufbuild/protoplugin": "2.8.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"upstream-protobuf": "*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@bufbuild/protobuf": "2.
|
|
42
|
+
"@bufbuild/protobuf": "2.8.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@bufbuild/protobuf": {
|
|
@@ -395,8 +395,7 @@ function generateMessageShape(f, message, target) {
|
|
|
395
395
|
// biome-ignore format: want this to read well
|
|
396
396
|
function generateMessageValidShape(f, message, validTypes, target) {
|
|
397
397
|
const declaration = target == "ts" ? "type" : "declare type";
|
|
398
|
-
|
|
399
|
-
if (!needsCustomValidType) {
|
|
398
|
+
if (!(0, valid_types_js_1.messageNeedsCustomValidType)(message, validTypes)) {
|
|
400
399
|
f.print(f.export(declaration, f.importValid(message).name), " = ", f.importShape(message), ";");
|
|
401
400
|
f.print();
|
|
402
401
|
return;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
import { type DescField } from "@bufbuild/protobuf";
|
|
1
|
+
import { type DescField, type DescMessage } from "@bufbuild/protobuf";
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the given message needs a ValidType. A message needs a ValidType
|
|
4
|
+
* if one or more of the following conditions are true:
|
|
5
|
+
* - A proto2 field has the `required` label
|
|
6
|
+
* - A edition field has the feature `field_presence = LEGACY_REQUIRED`
|
|
7
|
+
* - A field has the protovalidate `required` rule and not `ignore = IGNORE_ALWAYS`
|
|
8
|
+
* - A message field (repeated, singular, or map value) needs a ValidType
|
|
9
|
+
*/
|
|
10
|
+
export declare function messageNeedsCustomValidType(message: DescMessage, options: {
|
|
11
|
+
legacyRequired: boolean;
|
|
12
|
+
protovalidateRequired: boolean;
|
|
13
|
+
}): boolean;
|
|
2
14
|
/**
|
|
3
15
|
* Returns true if the field's protovalidate rules are (conditionally) disabled.
|
|
4
16
|
*
|
|
@@ -13,12 +13,56 @@
|
|
|
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.messageNeedsCustomValidType = messageNeedsCustomValidType;
|
|
16
17
|
exports.isProtovalidateDisabled = isProtovalidateDisabled;
|
|
17
18
|
exports.isProtovalidateRequired = isProtovalidateRequired;
|
|
18
19
|
exports.isLegacyRequired = isLegacyRequired;
|
|
19
20
|
const protobuf_1 = require("@bufbuild/protobuf");
|
|
20
21
|
const wkt_1 = require("@bufbuild/protobuf/wkt");
|
|
21
22
|
const minimal_validate_pb_js_1 = require("./gen/minimal-validate_pb.js");
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the given message needs a ValidType. A message needs a ValidType
|
|
25
|
+
* if one or more of the following conditions are true:
|
|
26
|
+
* - A proto2 field has the `required` label
|
|
27
|
+
* - A edition field has the feature `field_presence = LEGACY_REQUIRED`
|
|
28
|
+
* - A field has the protovalidate `required` rule and not `ignore = IGNORE_ALWAYS`
|
|
29
|
+
* - A message field (repeated, singular, or map value) needs a ValidType
|
|
30
|
+
*/
|
|
31
|
+
function messageNeedsCustomValidType(message, options) {
|
|
32
|
+
function usesProtovalidateRequired(message, seen = new Set()) {
|
|
33
|
+
seen.add(message.typeName);
|
|
34
|
+
for (const field of message.fields) {
|
|
35
|
+
if (isProtovalidateDisabled(field)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (isProtovalidateRequired(field)) {
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (field.message && !seen.has(field.message.typeName)) {
|
|
42
|
+
if (usesProtovalidateRequired(field.message, seen)) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
function usesLegacyRequired(message, seen = new Set()) {
|
|
50
|
+
seen.add(message.typeName);
|
|
51
|
+
for (const field of message.fields) {
|
|
52
|
+
if (isLegacyRequired(field)) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if (field.message && !seen.has(field.message.typeName)) {
|
|
56
|
+
if (usesLegacyRequired(field.message, seen)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
return ((options.protovalidateRequired && usesProtovalidateRequired(message)) ||
|
|
64
|
+
(options.legacyRequired && usesLegacyRequired(message)));
|
|
65
|
+
}
|
|
22
66
|
/**
|
|
23
67
|
* Returns true if the field's protovalidate rules are (conditionally) disabled.
|
|
24
68
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bufbuild/protoc-gen-es",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Protocol Buffers code generator for ECMAScript",
|
|
6
6
|
"keywords": [
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"protoc-gen-es": "bin/protoc-gen-es"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">=20"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"prebuild": "rm -rf ./dist/cjs/*",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"preferUnplugged": true,
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@bufbuild/protobuf": "2.
|
|
36
|
-
"@bufbuild/protoplugin": "2.
|
|
35
|
+
"@bufbuild/protobuf": "2.8.0",
|
|
36
|
+
"@bufbuild/protoplugin": "2.8.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"upstream-protobuf": "*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@bufbuild/protobuf": "2.
|
|
42
|
+
"@bufbuild/protobuf": "2.8.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@bufbuild/protobuf": {
|