webpb 0.0.36 → 0.0.39
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/index.d.ts +13 -0
- package/package.json +1 -1
- package/proto/webpb/WebpbExtend.proto +134 -0
- package/webpb-version.properties +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,19 @@ export interface WebpbMeta {
|
|
|
15
15
|
context: string;
|
|
16
16
|
path: string;
|
|
17
17
|
}
|
|
18
|
+
export interface WebpbValidationRule {
|
|
19
|
+
required?: boolean;
|
|
20
|
+
notBlank?: boolean;
|
|
21
|
+
minLen?: number;
|
|
22
|
+
maxLen?: number;
|
|
23
|
+
min?: number | string;
|
|
24
|
+
max?: number | string;
|
|
25
|
+
pattern?: string;
|
|
26
|
+
patternFlags?: string;
|
|
27
|
+
email?: boolean;
|
|
28
|
+
valid?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export type WebpbValidation = Record<string, WebpbValidationRule>;
|
|
18
31
|
export declare function assign(src: unknown, dest: unknown, excludes?: readonly string[]): void;
|
|
19
32
|
export declare function getter(data: unknown, path: string): unknown;
|
|
20
33
|
export declare function query(pre: string, params: {
|
package/package.json
CHANGED
|
@@ -14,6 +14,7 @@ message FileOpts {
|
|
|
14
14
|
optional OptFileOpts opt = 1000;
|
|
15
15
|
optional JavaFileOpts java = 1001;
|
|
16
16
|
optional TsFileOpts ts = 1002;
|
|
17
|
+
optional GoFileOpts go = 1003;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
message OptFileOpts {
|
|
@@ -26,6 +27,26 @@ message JavaFileOpts {
|
|
|
26
27
|
repeated string annotation = 1003;
|
|
27
28
|
repeated string field_annotation = 1004;
|
|
28
29
|
repeated string repeatable_annotation = 1005;
|
|
30
|
+
// Maps language-agnostic (opts).opt.valid constraints to Java annotations.
|
|
31
|
+
// File-level value overrides the shared WebpbOptions.proto defaults;
|
|
32
|
+
// unset templates fall back to the generator built-ins (jakarta.validation).
|
|
33
|
+
// Placeholders: {{value}} for single-value constraints,
|
|
34
|
+
// {{min}}/{{max}} for the size interval, {{flags}} for pattern flags.
|
|
35
|
+
optional JavaValidationMapping validation = 1006;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Template set for rendering FieldValidation into Java annotations.
|
|
39
|
+
// Example: size_template = "@Size(min = {{min}}, max = {{max}})"
|
|
40
|
+
// renders {min_len: 1} as "@Size(min = 1)".
|
|
41
|
+
message JavaValidationMapping {
|
|
42
|
+
optional string required_template = 1;
|
|
43
|
+
optional string not_blank_template = 2;
|
|
44
|
+
optional string size_template = 3;
|
|
45
|
+
optional string min_template = 4;
|
|
46
|
+
optional string max_template = 5;
|
|
47
|
+
optional string pattern_template = 6;
|
|
48
|
+
optional string email_template = 7;
|
|
49
|
+
optional string valid_template = 8;
|
|
29
50
|
}
|
|
30
51
|
|
|
31
52
|
message TsFileOpts {
|
|
@@ -39,6 +60,65 @@ message TsFileOpts {
|
|
|
39
60
|
optional bool enum_by_value = 1007;
|
|
40
61
|
optional bool enum_helpers = 1008;
|
|
41
62
|
optional string enum_emit_mode = 1009;
|
|
63
|
+
// Maps language-agnostic (opts).opt.valid constraints to TS decorators
|
|
64
|
+
// (class-validator style by default). Same override chain as Java.
|
|
65
|
+
// Placeholders: {{value}}, {{min}}/{{max}}, {{flags}}.
|
|
66
|
+
optional TsValidationMapping validation = 1010;
|
|
67
|
+
// Emit a framework-neutral validation descriptor per message:
|
|
68
|
+
// export const XxxValidation = { field: { minLen: 1, ... } } as const;
|
|
69
|
+
// Usage sites bridge it to zod / class-validator / form libs themselves,
|
|
70
|
+
// so generated code stays dependency-free (no zod/class-validator import,
|
|
71
|
+
// no experimentalDecorators). Only constraints actually declared are
|
|
72
|
+
// included; fields without constraints are omitted.
|
|
73
|
+
optional bool validation_object = 1011 [default = false];
|
|
74
|
+
// Emit class-validator decorators from `validation` templates. Default
|
|
75
|
+
// false: decorators require experimentalDecorators plus the
|
|
76
|
+
// class-validator dependency at the usage site.
|
|
77
|
+
optional bool validation_decorators = 1012 [default = false];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Template set for rendering FieldValidation into TS decorators.
|
|
81
|
+
// String length uses length/min_length/max_length; repeated/map size uses
|
|
82
|
+
// array_min_size/array_max_size. The generator picks by field cardinality.
|
|
83
|
+
message TsValidationMapping {
|
|
84
|
+
optional string required_template = 1;
|
|
85
|
+
optional string not_blank_template = 2;
|
|
86
|
+
optional string length_template = 3;
|
|
87
|
+
optional string min_length_template = 4;
|
|
88
|
+
optional string max_length_template = 5;
|
|
89
|
+
optional string array_min_size_template = 6;
|
|
90
|
+
optional string array_max_size_template = 7;
|
|
91
|
+
optional string min_template = 8;
|
|
92
|
+
optional string max_template = 9;
|
|
93
|
+
optional string pattern_template = 10;
|
|
94
|
+
optional string email_template = 11;
|
|
95
|
+
optional string valid_template = 12;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
message GoFileOpts {
|
|
99
|
+
repeated string import = 1000;
|
|
100
|
+
optional bool int64_as_string = 1001;
|
|
101
|
+
optional bool auto_alias = 1002;
|
|
102
|
+
optional bool enum_auto_alias = 1003;
|
|
103
|
+
// Overrides the generated Go package name (defaults to the plugin parameter).
|
|
104
|
+
optional string package = 1004;
|
|
105
|
+
// Maps language-agnostic (opts).opt.valid constraints to
|
|
106
|
+
// go-playground/validator tag fragments joined by comma
|
|
107
|
+
// into `validate:"..."`. Placeholders: {{value}}.
|
|
108
|
+
optional GoValidationMapping validation = 1005;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Template set for rendering FieldValidation into Go validator tag fragments.
|
|
112
|
+
message GoValidationMapping {
|
|
113
|
+
optional string required_template = 1;
|
|
114
|
+
optional string not_blank_template = 2;
|
|
115
|
+
optional string min_len_template = 3;
|
|
116
|
+
optional string max_len_template = 4;
|
|
117
|
+
optional string min_template = 5;
|
|
118
|
+
optional string max_template = 6;
|
|
119
|
+
optional string pattern_template = 7;
|
|
120
|
+
optional string email_template = 8;
|
|
121
|
+
optional string valid_template = 9;
|
|
42
122
|
}
|
|
43
123
|
|
|
44
124
|
// message options
|
|
@@ -50,6 +130,7 @@ message MessageOpts {
|
|
|
50
130
|
optional OptMessageOpts opt = 1000;
|
|
51
131
|
optional JavaMessageOpts java = 1001;
|
|
52
132
|
optional TsMessageOpts ts = 1002;
|
|
133
|
+
optional GoMessageOpts go = 1003;
|
|
53
134
|
}
|
|
54
135
|
|
|
55
136
|
message OptMessageOpts {
|
|
@@ -79,6 +160,12 @@ message TsMessageOpts {
|
|
|
79
160
|
optional bool auto_alias = 1000;
|
|
80
161
|
}
|
|
81
162
|
|
|
163
|
+
message GoMessageOpts {
|
|
164
|
+
optional bool auto_alias = 1000;
|
|
165
|
+
// Emit a Go interface implemented by this message (for polymorphism).
|
|
166
|
+
optional string implements_interface = 1001;
|
|
167
|
+
}
|
|
168
|
+
|
|
82
169
|
// enum options
|
|
83
170
|
extend google.protobuf.EnumOptions {
|
|
84
171
|
optional EnumOpts e_opts = 1000;
|
|
@@ -88,6 +175,7 @@ message EnumOpts {
|
|
|
88
175
|
optional OptEnumOpts opt = 1000;
|
|
89
176
|
optional JavaEnumOpts java = 1001;
|
|
90
177
|
optional TsEnumOpts ts = 1002;
|
|
178
|
+
optional GoEnumOpts go = 1003;
|
|
91
179
|
}
|
|
92
180
|
|
|
93
181
|
message OptEnumOpts {
|
|
@@ -109,6 +197,10 @@ message TsEnumOpts {
|
|
|
109
197
|
optional string enum_emit_mode = 1007;
|
|
110
198
|
}
|
|
111
199
|
|
|
200
|
+
message GoEnumOpts {
|
|
201
|
+
optional bool auto_alias = 1000;
|
|
202
|
+
}
|
|
203
|
+
|
|
112
204
|
// field options
|
|
113
205
|
extend google.protobuf.FieldOptions {
|
|
114
206
|
optional FieldOpts opts = 1000;
|
|
@@ -118,11 +210,41 @@ message FieldOpts {
|
|
|
118
210
|
optional OptFieldOpts opt = 1000;
|
|
119
211
|
optional JavaFieldOpts java = 1001;
|
|
120
212
|
optional TsFieldOpts ts = 1002;
|
|
213
|
+
optional GoFieldOpts go = 1003;
|
|
121
214
|
}
|
|
122
215
|
|
|
123
216
|
message OptFieldOpts {
|
|
124
217
|
optional bool omitted = 1000;
|
|
125
218
|
optional bool in_query = 1001;
|
|
219
|
+
// Language-agnostic validation constraints. The generators render them
|
|
220
|
+
// into per-language annotations/decorators/tags using the
|
|
221
|
+
// Java/Ts/GoValidationMapping templates. Explicit proto presence
|
|
222
|
+
// (e.g. `required` keyword, proto2 required vs proto3 optional) does not
|
|
223
|
+
// imply validation; set valid.required explicitly when needed.
|
|
224
|
+
optional FieldValidation valid = 1002;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Language-agnostic field validation. min_len/max_len cover both string
|
|
228
|
+
// length and repeated/map size (merged by design); the generators pick the
|
|
229
|
+
// target spelling (@Size vs @Length/@ArrayMinSize vs min=/max=) from context.
|
|
230
|
+
message FieldValidation {
|
|
231
|
+
optional bool required = 1;
|
|
232
|
+
optional bool not_blank = 2;
|
|
233
|
+
optional int64 min_len = 3;
|
|
234
|
+
optional int64 max_len = 4;
|
|
235
|
+
// Numeric bounds as strings so int64 and double share one schema
|
|
236
|
+
// without precision loss; the Java generator picks @Min/@Max for
|
|
237
|
+
// integral fields and @DecimalMin/@DecimalMax for floating point ones.
|
|
238
|
+
optional string min = 5;
|
|
239
|
+
optional string max = 6;
|
|
240
|
+
// Regular expression without surrounding slashes.
|
|
241
|
+
optional string pattern = 7;
|
|
242
|
+
// Regex flags, e.g. "i" or "CASE_INSENSITIVE". Rendered via the
|
|
243
|
+
// {{flags}} placeholder of the per-language pattern template.
|
|
244
|
+
optional string pattern_flags = 8;
|
|
245
|
+
optional bool email = 9;
|
|
246
|
+
// Cascaded validation for message / repeated message fields.
|
|
247
|
+
optional bool valid = 10;
|
|
126
248
|
}
|
|
127
249
|
|
|
128
250
|
message JavaFieldOpts {
|
|
@@ -137,6 +259,14 @@ message TsFieldOpts {
|
|
|
137
259
|
optional bool auto_alias = 1002;
|
|
138
260
|
}
|
|
139
261
|
|
|
262
|
+
message GoFieldOpts {
|
|
263
|
+
optional bool as_string = 1000;
|
|
264
|
+
optional string alias = 1001;
|
|
265
|
+
optional bool auto_alias = 1002;
|
|
266
|
+
// Skip the field in generated structs (e.g. handled by another message).
|
|
267
|
+
optional bool omitted = 1003;
|
|
268
|
+
}
|
|
269
|
+
|
|
140
270
|
// enum value options
|
|
141
271
|
extend google.protobuf.EnumValueOptions {
|
|
142
272
|
optional EnumValueOpts v_opts = 1000;
|
|
@@ -146,6 +276,7 @@ message EnumValueOpts {
|
|
|
146
276
|
optional OptEnumValueOpts opt = 1000;
|
|
147
277
|
optional JavaEnumValueOpts java = 1001;
|
|
148
278
|
optional TsEnumValueOpts ts = 1002;
|
|
279
|
+
optional GoEnumValueOpts go = 1003;
|
|
149
280
|
}
|
|
150
281
|
|
|
151
282
|
message OptEnumValueOpts {
|
|
@@ -158,3 +289,6 @@ message JavaEnumValueOpts {
|
|
|
158
289
|
|
|
159
290
|
message TsEnumValueOpts {
|
|
160
291
|
}
|
|
292
|
+
|
|
293
|
+
message GoEnumValueOpts {
|
|
294
|
+
}
|
package/webpb-version.properties
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
webpbVersion=0.0.
|
|
1
|
+
webpbVersion=0.0.39
|
|
2
2
|
protobufVersion=4.36.1
|