webpb 0.0.38 → 0.0.40
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 +99 -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
|
@@ -27,6 +27,26 @@ message JavaFileOpts {
|
|
|
27
27
|
repeated string annotation = 1003;
|
|
28
28
|
repeated string field_annotation = 1004;
|
|
29
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;
|
|
30
50
|
}
|
|
31
51
|
|
|
32
52
|
message TsFileOpts {
|
|
@@ -40,6 +60,39 @@ message TsFileOpts {
|
|
|
40
60
|
optional bool enum_by_value = 1007;
|
|
41
61
|
optional bool enum_helpers = 1008;
|
|
42
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;
|
|
43
96
|
}
|
|
44
97
|
|
|
45
98
|
message GoFileOpts {
|
|
@@ -49,6 +102,23 @@ message GoFileOpts {
|
|
|
49
102
|
optional bool enum_auto_alias = 1003;
|
|
50
103
|
// Overrides the generated Go package name (defaults to the plugin parameter).
|
|
51
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;
|
|
52
122
|
}
|
|
53
123
|
|
|
54
124
|
// message options
|
|
@@ -146,6 +216,35 @@ message FieldOpts {
|
|
|
146
216
|
message OptFieldOpts {
|
|
147
217
|
optional bool omitted = 1000;
|
|
148
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;
|
|
149
248
|
}
|
|
150
249
|
|
|
151
250
|
message JavaFieldOpts {
|
package/webpb-version.properties
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
webpbVersion=0.0.
|
|
1
|
+
webpbVersion=0.0.40
|
|
2
2
|
protobufVersion=4.36.1
|