protostar 0.1.0.beta1

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.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +60 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +647 -0
  5. data/THIRD_PARTY_NOTICES.md +61 -0
  6. data/exe/protoc-gen-protostar +7 -0
  7. data/exe/protostar +7 -0
  8. data/lib/protostar/builder/generator.rb +71 -0
  9. data/lib/protostar/builder/sink.rb +35 -0
  10. data/lib/protostar/builder.rb +965 -0
  11. data/lib/protostar/cli.rb +267 -0
  12. data/lib/protostar/codec/decode_generator.rb +199 -0
  13. data/lib/protostar/codec/decoder.rb +296 -0
  14. data/lib/protostar/codec/encode_generator.rb +224 -0
  15. data/lib/protostar/codec/encoder.rb +121 -0
  16. data/lib/protostar/codec/sizer.rb +91 -0
  17. data/lib/protostar/codec.rb +15 -0
  18. data/lib/protostar/compiler/ast.rb +193 -0
  19. data/lib/protostar/compiler/emitters/descriptor_set.rb +57 -0
  20. data/lib/protostar/compiler/emitters/google_ruby.rb +103 -0
  21. data/lib/protostar/compiler/emitters/grpc.rb +175 -0
  22. data/lib/protostar/compiler/emitters/protostar_rbs.rb +252 -0
  23. data/lib/protostar/compiler/emitters/rbs.rb +394 -0
  24. data/lib/protostar/compiler/emitters/ruby.rb +503 -0
  25. data/lib/protostar/compiler/emitters.rb +268 -0
  26. data/lib/protostar/compiler/include/LICENSE +32 -0
  27. data/lib/protostar/compiler/include/google/protobuf/any.proto +106 -0
  28. data/lib/protostar/compiler/include/google/protobuf/api.proto +229 -0
  29. data/lib/protostar/compiler/include/google/protobuf/compiler/plugin.proto +180 -0
  30. data/lib/protostar/compiler/include/google/protobuf/cpp_features.proto +87 -0
  31. data/lib/protostar/compiler/include/google/protobuf/descriptor.proto +1532 -0
  32. data/lib/protostar/compiler/include/google/protobuf/duration.proto +115 -0
  33. data/lib/protostar/compiler/include/google/protobuf/empty.proto +51 -0
  34. data/lib/protostar/compiler/include/google/protobuf/field_mask.proto +243 -0
  35. data/lib/protostar/compiler/include/google/protobuf/java_features.proto +132 -0
  36. data/lib/protostar/compiler/include/google/protobuf/source_context.proto +48 -0
  37. data/lib/protostar/compiler/include/google/protobuf/struct.proto +111 -0
  38. data/lib/protostar/compiler/include/google/protobuf/timestamp.proto +145 -0
  39. data/lib/protostar/compiler/include/google/protobuf/type.proto +217 -0
  40. data/lib/protostar/compiler/include/google/protobuf/wrappers.proto +157 -0
  41. data/lib/protostar/compiler/lexer.rb +659 -0
  42. data/lib/protostar/compiler/linker.rb +894 -0
  43. data/lib/protostar/compiler/option_interpreter.rb +363 -0
  44. data/lib/protostar/compiler/parser.rb +1696 -0
  45. data/lib/protostar/compiler/retention.rb +104 -0
  46. data/lib/protostar/compiler/run.rb +184 -0
  47. data/lib/protostar/compiler/source_info.rb +161 -0
  48. data/lib/protostar/compiler/symbol_table.rb +223 -0
  49. data/lib/protostar/compiler/text_format.rb +340 -0
  50. data/lib/protostar/compiler/validator.rb +944 -0
  51. data/lib/protostar/compiler.rb +304 -0
  52. data/lib/protostar/diagnostics/codes.rb +1307 -0
  53. data/lib/protostar/diagnostics/formats.rb +64 -0
  54. data/lib/protostar/diagnostics/renderer.rb +240 -0
  55. data/lib/protostar/diagnostics/source.rb +153 -0
  56. data/lib/protostar/diagnostics.rb +117 -0
  57. data/lib/protostar/dsl.rb +367 -0
  58. data/lib/protostar/enum.rb +70 -0
  59. data/lib/protostar/errors.rb +23 -0
  60. data/lib/protostar/google/protobuf/any_pb.rb +90 -0
  61. data/lib/protostar/google/protobuf/api_pb.rb +199 -0
  62. data/lib/protostar/google/protobuf/compiler/plugin_pb.rb +168 -0
  63. data/lib/protostar/google/protobuf/descriptor_pb.rb +1239 -0
  64. data/lib/protostar/google/protobuf/duration_pb.rb +99 -0
  65. data/lib/protostar/google/protobuf/empty_pb.rb +36 -0
  66. data/lib/protostar/google/protobuf/field_mask_pb.rb +228 -0
  67. data/lib/protostar/google/protobuf/source_context_pb.rb +33 -0
  68. data/lib/protostar/google/protobuf/struct_pb.rb +91 -0
  69. data/lib/protostar/google/protobuf/timestamp_pb.rb +129 -0
  70. data/lib/protostar/google/protobuf/type_pb.rb +202 -0
  71. data/lib/protostar/google/protobuf/wrappers_pb.rb +125 -0
  72. data/lib/protostar/google_protobuf_shim.rb +24 -0
  73. data/lib/protostar/json/encoder.rb +340 -0
  74. data/lib/protostar/json/errors.rb +34 -0
  75. data/lib/protostar/json/parser.rb +437 -0
  76. data/lib/protostar/json/path.rb +39 -0
  77. data/lib/protostar/json.rb +95 -0
  78. data/lib/protostar/lint/command.rb +197 -0
  79. data/lib/protostar/lint/config.rb +98 -0
  80. data/lib/protostar/lint/context.rb +126 -0
  81. data/lib/protostar/lint/directives.rb +56 -0
  82. data/lib/protostar/lint/fixer.rb +165 -0
  83. data/lib/protostar/lint/naming.rb +54 -0
  84. data/lib/protostar/lint/rule.rb +120 -0
  85. data/lib/protostar/lint/rules/comment_enum.rb +31 -0
  86. data/lib/protostar/lint/rules/comment_enum_value.rb +32 -0
  87. data/lib/protostar/lint/rules/comment_field.rb +33 -0
  88. data/lib/protostar/lint/rules/comment_message.rb +31 -0
  89. data/lib/protostar/lint/rules/comment_rpc.rb +31 -0
  90. data/lib/protostar/lint/rules/comment_service.rb +31 -0
  91. data/lib/protostar/lint/rules/edition_recommended.rb +31 -0
  92. data/lib/protostar/lint/rules/enum_first_value_zero.rb +34 -0
  93. data/lib/protostar/lint/rules/enum_pascal_case.rb +25 -0
  94. data/lib/protostar/lint/rules/enum_value_prefix.rb +38 -0
  95. data/lib/protostar/lint/rules/enum_value_upper_snake_case.rb +28 -0
  96. data/lib/protostar/lint/rules/enum_zero_value_suffix.rb +41 -0
  97. data/lib/protostar/lint/rules/field_lower_snake_case.rb +34 -0
  98. data/lib/protostar/lint/rules/field_not_required.rb +39 -0
  99. data/lib/protostar/lint/rules/field_number_reuse_risk.rb +45 -0
  100. data/lib/protostar/lint/rules/field_numbers_hot_range.rb +44 -0
  101. data/lib/protostar/lint/rules/file_lower_snake_case.rb +27 -0
  102. data/lib/protostar/lint/rules/import_no_public.rb +29 -0
  103. data/lib/protostar/lint/rules/import_no_weak.rb +28 -0
  104. data/lib/protostar/lint/rules/import_used.rb +33 -0
  105. data/lib/protostar/lint/rules/message_pascal_case.rb +27 -0
  106. data/lib/protostar/lint/rules/no_deprecated_features.rb +50 -0
  107. data/lib/protostar/lint/rules/no_groups.rb +34 -0
  108. data/lib/protostar/lint/rules/oneof_lower_snake_case.rb +27 -0
  109. data/lib/protostar/lint/rules/package_defined.rb +28 -0
  110. data/lib/protostar/lint/rules/package_directory_match.rb +33 -0
  111. data/lib/protostar/lint/rules/package_lower_snake_case.rb +28 -0
  112. data/lib/protostar/lint/rules/package_same_directory.rb +39 -0
  113. data/lib/protostar/lint/rules/package_version_suffix.rb +31 -0
  114. data/lib/protostar/lint/rules/reserved_names_with_numbers.rb +44 -0
  115. data/lib/protostar/lint/rules/rpc_pascal_case.rb +25 -0
  116. data/lib/protostar/lint/rules/rpc_request_response_unique.rb +40 -0
  117. data/lib/protostar/lint/rules/rpc_request_standard_name.rb +32 -0
  118. data/lib/protostar/lint/rules/rpc_response_standard_name.rb +31 -0
  119. data/lib/protostar/lint/rules/service_pascal_case.rb +25 -0
  120. data/lib/protostar/lint/rules/service_suffix.rb +28 -0
  121. data/lib/protostar/lint/rules/syntax_specified.rb +35 -0
  122. data/lib/protostar/lint/runner.rb +135 -0
  123. data/lib/protostar/lint.rb +122 -0
  124. data/lib/protostar/message/accessors.rb +86 -0
  125. data/lib/protostar/message/coercion.rb +171 -0
  126. data/lib/protostar/message/field_info.rb +145 -0
  127. data/lib/protostar/message/reflection.rb +149 -0
  128. data/lib/protostar/message.rb +572 -0
  129. data/lib/protostar/plugin.rb +94 -0
  130. data/lib/protostar/schema/default_value.rb +113 -0
  131. data/lib/protostar/schema/descriptor.rb +41 -0
  132. data/lib/protostar/schema/draft/copy.rb +88 -0
  133. data/lib/protostar/schema/draft/resolution.rb +177 -0
  134. data/lib/protostar/schema/draft.rb +779 -0
  135. data/lib/protostar/schema/enum.rb +106 -0
  136. data/lib/protostar/schema/extension_range.rb +37 -0
  137. data/lib/protostar/schema/features.rb +153 -0
  138. data/lib/protostar/schema/field.rb +201 -0
  139. data/lib/protostar/schema/file.rb +217 -0
  140. data/lib/protostar/schema/freezer.rb +61 -0
  141. data/lib/protostar/schema/message.rb +104 -0
  142. data/lib/protostar/schema/oneof.rb +38 -0
  143. data/lib/protostar/schema/options.rb +367 -0
  144. data/lib/protostar/schema/pool.rb +179 -0
  145. data/lib/protostar/schema/proto.rb +576 -0
  146. data/lib/protostar/schema/resolver.rb +118 -0
  147. data/lib/protostar/schema/service.rb +89 -0
  148. data/lib/protostar/schema/source_info.rb +53 -0
  149. data/lib/protostar/schema.rb +65 -0
  150. data/lib/protostar/short_names/any.rb +7 -0
  151. data/lib/protostar/short_names/duration.rb +7 -0
  152. data/lib/protostar/short_names/empty.rb +7 -0
  153. data/lib/protostar/short_names/field_mask.rb +7 -0
  154. data/lib/protostar/short_names/struct.rb +9 -0
  155. data/lib/protostar/short_names/timestamp.rb +7 -0
  156. data/lib/protostar/short_names/wrappers.rb +15 -0
  157. data/lib/protostar/text/extensions.rb +114 -0
  158. data/lib/protostar/text/parser.rb +439 -0
  159. data/lib/protostar/text/printer.rb +304 -0
  160. data/lib/protostar/text/tokenizer.rb +116 -0
  161. data/lib/protostar/text.rb +67 -0
  162. data/lib/protostar/types.rb +152 -0
  163. data/lib/protostar/unknown_field.rb +58 -0
  164. data/lib/protostar/version.rb +5 -0
  165. data/lib/protostar/view/generator.rb +298 -0
  166. data/lib/protostar/view/map.rb +194 -0
  167. data/lib/protostar/view/repeated.rb +143 -0
  168. data/lib/protostar/view/scan.rb +183 -0
  169. data/lib/protostar/view.rb +283 -0
  170. data/lib/protostar/well_known/any.rb +52 -0
  171. data/lib/protostar/well_known/duration.rb +53 -0
  172. data/lib/protostar/well_known/list_value.rb +63 -0
  173. data/lib/protostar/well_known/struct.rb +55 -0
  174. data/lib/protostar/well_known/timestamp.rb +64 -0
  175. data/lib/protostar/well_known/value.rb +60 -0
  176. data/lib/protostar/well_known.rb +38 -0
  177. data/lib/protostar/wire/io_source.rb +40 -0
  178. data/lib/protostar/wire/reader.rb +254 -0
  179. data/lib/protostar/wire/writer.rb +201 -0
  180. data/lib/protostar/wire.rb +96 -0
  181. data/lib/protostar.rb +95 -0
  182. data/shims/google-protobuf/lib/google/protobuf/any_pb.rb +17 -0
  183. data/shims/google-protobuf/lib/google/protobuf/api_pb.rb +22 -0
  184. data/shims/google-protobuf/lib/google/protobuf/compiler/plugin_pb.rb +25 -0
  185. data/shims/google-protobuf/lib/google/protobuf/descriptor_pb.rb +72 -0
  186. data/shims/google-protobuf/lib/google/protobuf/descriptor_pool.rb +164 -0
  187. data/shims/google-protobuf/lib/google/protobuf/descriptors.rb +553 -0
  188. data/shims/google-protobuf/lib/google/protobuf/duration_pb.rb +17 -0
  189. data/shims/google-protobuf/lib/google/protobuf/empty_pb.rb +17 -0
  190. data/shims/google-protobuf/lib/google/protobuf/field_mask_pb.rb +17 -0
  191. data/shims/google-protobuf/lib/google/protobuf/internal/convert.rb +180 -0
  192. data/shims/google-protobuf/lib/google/protobuf/internal/extensions.rb +154 -0
  193. data/shims/google-protobuf/lib/google/protobuf/internal/json.rb +104 -0
  194. data/shims/google-protobuf/lib/google/protobuf/internal/well_known.rb +140 -0
  195. data/shims/google-protobuf/lib/google/protobuf/map.rb +216 -0
  196. data/shims/google-protobuf/lib/google/protobuf/message.rb +544 -0
  197. data/shims/google-protobuf/lib/google/protobuf/message_exts.rb +41 -0
  198. data/shims/google-protobuf/lib/google/protobuf/plugin_pb.rb +4 -0
  199. data/shims/google-protobuf/lib/google/protobuf/repeated_field.rb +366 -0
  200. data/shims/google-protobuf/lib/google/protobuf/source_context_pb.rb +17 -0
  201. data/shims/google-protobuf/lib/google/protobuf/struct_pb.rb +20 -0
  202. data/shims/google-protobuf/lib/google/protobuf/timestamp_pb.rb +17 -0
  203. data/shims/google-protobuf/lib/google/protobuf/type_pb.rb +27 -0
  204. data/shims/google-protobuf/lib/google/protobuf/well_known_types.rb +37 -0
  205. data/shims/google-protobuf/lib/google/protobuf/wrappers_pb.rb +25 -0
  206. data/shims/google-protobuf/lib/google/protobuf.rb +107 -0
  207. data/shims/google-protobuf/lib/google/protobuf_ffi.rb +5 -0
  208. data/shims/google-protobuf/lib/google/protobuf_native.rb +5 -0
  209. data/sig/protostar/google/protobuf/any_pb.rbs +77 -0
  210. data/sig/protostar/google/protobuf/api_pb.rbs +242 -0
  211. data/sig/protostar/google/protobuf/compiler/plugin_pb.rbs +264 -0
  212. data/sig/protostar/google/protobuf/descriptor_pb.rbs +2220 -0
  213. data/sig/protostar/google/protobuf/duration_pb.rbs +82 -0
  214. data/sig/protostar/google/protobuf/empty_pb.rbs +18 -0
  215. data/sig/protostar/google/protobuf/field_mask_pb.rbs +170 -0
  216. data/sig/protostar/google/protobuf/source_context_pb.rbs +24 -0
  217. data/sig/protostar/google/protobuf/struct_pb.rbs +135 -0
  218. data/sig/protostar/google/protobuf/timestamp_pb.rbs +102 -0
  219. data/sig/protostar/google/protobuf/type_pb.rbs +304 -0
  220. data/sig/protostar/google/protobuf/wrappers_pb.rbs +169 -0
  221. data/sig/protostar/lint.rbs +216 -0
  222. data/sig/protostar.rbs +326 -0
  223. metadata +366 -0
@@ -0,0 +1,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/duration.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/duration.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ cc_enable_arenas: true,
12
+ go_package: "google.golang.org/protobuf/types/known/durationpb",
13
+ java_package: "com.google.protobuf",
14
+ java_outer_classname: "DurationProto",
15
+ java_multiple_files: true,
16
+ objc_class_prefix: "GPB",
17
+ csharp_namespace: "Google.Protobuf.WellKnownTypes"
18
+ ) do |f|
19
+ # A Duration represents a signed, fixed-length span of time represented
20
+ # as a count of seconds and fractions of seconds at nanosecond
21
+ # resolution. It is independent of any calendar and concepts like "day"
22
+ # or "month". It is related to Timestamp in that the difference between
23
+ # two Timestamp values is a Duration and it can be added or subtracted
24
+ # from a Timestamp. Range is approximately +-10,000 years.
25
+ #
26
+ # # Examples
27
+ #
28
+ # Example 1: Compute Duration from two Timestamps in pseudo code.
29
+ #
30
+ # Timestamp start = ...;
31
+ # Timestamp end = ...;
32
+ # Duration duration = ...;
33
+ #
34
+ # duration.seconds = end.seconds - start.seconds;
35
+ # duration.nanos = end.nanos - start.nanos;
36
+ #
37
+ # if (duration.seconds < 0 && duration.nanos > 0) {
38
+ # duration.seconds += 1;
39
+ # duration.nanos -= 1000000000;
40
+ # } else if (duration.seconds > 0 && duration.nanos < 0) {
41
+ # duration.seconds -= 1;
42
+ # duration.nanos += 1000000000;
43
+ # }
44
+ #
45
+ # Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.
46
+ #
47
+ # Timestamp start = ...;
48
+ # Duration duration = ...;
49
+ # Timestamp end = ...;
50
+ #
51
+ # end.seconds = start.seconds + duration.seconds;
52
+ # end.nanos = start.nanos + duration.nanos;
53
+ #
54
+ # if (end.nanos < 0) {
55
+ # end.seconds -= 1;
56
+ # end.nanos += 1000000000;
57
+ # } else if (end.nanos >= 1000000000) {
58
+ # end.seconds += 1;
59
+ # end.nanos -= 1000000000;
60
+ # }
61
+ #
62
+ # Example 3: Compute Duration from datetime.timedelta in Python.
63
+ #
64
+ # td = datetime.timedelta(days=3, minutes=10)
65
+ # duration = Duration()
66
+ # duration.FromTimedelta(td)
67
+ #
68
+ # # JSON Mapping
69
+ #
70
+ # In JSON format, the Duration type is encoded as a string rather than an
71
+ # object, where the string ends in the suffix "s" (indicating seconds) and
72
+ # is preceded by the number of seconds, with nanoseconds expressed as
73
+ # fractional seconds. For example, 3 seconds with 0 nanoseconds should be
74
+ # encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should
75
+ # be expressed in JSON format as "3.000000001s", and 3 seconds and 1
76
+ # microsecond should be expressed in JSON format as "3.000001s".
77
+ #
78
+ f.message "Duration" do |m|
79
+ # Signed seconds of the span of time. Must be from -315,576,000,000
80
+ # to +315,576,000,000 inclusive. Note: these bounds are computed from:
81
+ # 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years
82
+ m.field :seconds, 1, :int64
83
+ # Signed fractions of a second at nanosecond resolution of the span
84
+ # of time. Durations less than one second are represented with a 0
85
+ # `seconds` field and a positive or negative `nanos` field. For durations
86
+ # of one second or more, a non-zero value for the `nanos` field must be
87
+ # of the same sign as the `seconds` field. Must be from -999,999,999
88
+ # to +999,999,999 inclusive.
89
+ m.field :nanos, 2, :int32
90
+ end
91
+ end
92
+
93
+ module Protostar
94
+ module Google
95
+ module Protobuf
96
+ Duration = Protostar::DSL.message("google.protobuf.Duration")
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/empty.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/empty.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ go_package: "google.golang.org/protobuf/types/known/emptypb",
12
+ java_package: "com.google.protobuf",
13
+ java_outer_classname: "EmptyProto",
14
+ java_multiple_files: true,
15
+ objc_class_prefix: "GPB",
16
+ csharp_namespace: "Google.Protobuf.WellKnownTypes",
17
+ cc_enable_arenas: true
18
+ ) do |f|
19
+ # A generic empty message that you can re-use to avoid defining duplicated
20
+ # empty messages in your APIs. A typical example is to use it as the request
21
+ # or the response type of an API method. For instance:
22
+ #
23
+ # service Foo {
24
+ # rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
25
+ # }
26
+ #
27
+ f.message "Empty"
28
+ end
29
+
30
+ module Protostar
31
+ module Google
32
+ module Protobuf
33
+ Empty = Protostar::DSL.message("google.protobuf.Empty")
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,228 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/field_mask.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/field_mask.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ java_package: "com.google.protobuf",
12
+ java_outer_classname: "FieldMaskProto",
13
+ java_multiple_files: true,
14
+ objc_class_prefix: "GPB",
15
+ csharp_namespace: "Google.Protobuf.WellKnownTypes",
16
+ go_package: "google.golang.org/protobuf/types/known/fieldmaskpb",
17
+ cc_enable_arenas: true
18
+ ) do |f|
19
+ # `FieldMask` represents a set of symbolic field paths, for example:
20
+ #
21
+ # paths: "f.a"
22
+ # paths: "f.b.d"
23
+ #
24
+ # Here `f` represents a field in some root message, `a` and `b`
25
+ # fields in the message found in `f`, and `d` a field found in the
26
+ # message in `f.b`.
27
+ #
28
+ # Field masks are used to specify a subset of fields that should be
29
+ # returned by a get operation or modified by an update operation.
30
+ # Field masks also have a custom JSON encoding (see below).
31
+ #
32
+ # # Field Masks in Projections
33
+ #
34
+ # When used in the context of a projection, a response message or
35
+ # sub-message is filtered by the API to only contain those fields as
36
+ # specified in the mask. For example, if the mask in the previous
37
+ # example is applied to a response message as follows:
38
+ #
39
+ # f {
40
+ # a : 22
41
+ # b {
42
+ # d : 1
43
+ # x : 2
44
+ # }
45
+ # y : 13
46
+ # }
47
+ # z: 8
48
+ #
49
+ # The result will not contain specific values for fields x,y and z
50
+ # (their value will be set to the default, and omitted in proto text
51
+ # output):
52
+ #
53
+ #
54
+ # f {
55
+ # a : 22
56
+ # b {
57
+ # d : 1
58
+ # }
59
+ # }
60
+ #
61
+ # A repeated field is not allowed except at the last position of a
62
+ # paths string.
63
+ #
64
+ # If a FieldMask object is not present in a get operation, the
65
+ # operation applies to all fields (as if a FieldMask of all fields
66
+ # had been specified).
67
+ #
68
+ # Note that a field mask does not necessarily apply to the
69
+ # top-level response message. In case of a REST get operation, the
70
+ # field mask applies directly to the response, but in case of a REST
71
+ # list operation, the mask instead applies to each individual message
72
+ # in the returned resource list. In case of a REST custom method,
73
+ # other definitions may be used. Where the mask applies will be
74
+ # clearly documented together with its declaration in the API. In
75
+ # any case, the effect on the returned resource/resources is required
76
+ # behavior for APIs.
77
+ #
78
+ # # Field Masks in Update Operations
79
+ #
80
+ # A field mask in update operations specifies which fields of the
81
+ # targeted resource are going to be updated. The API is required
82
+ # to only change the values of the fields as specified in the mask
83
+ # and leave the others untouched. If a resource is passed in to
84
+ # describe the updated values, the API ignores the values of all
85
+ # fields not covered by the mask.
86
+ #
87
+ # If a repeated field is specified for an update operation, new values will
88
+ # be appended to the existing repeated field in the target resource. Note that
89
+ # a repeated field is only allowed in the last position of a `paths` string.
90
+ #
91
+ # If a sub-message is specified in the last position of the field mask for an
92
+ # update operation, then new value will be merged into the existing sub-message
93
+ # in the target resource.
94
+ #
95
+ # For example, given the target message:
96
+ #
97
+ # f {
98
+ # b {
99
+ # d: 1
100
+ # x: 2
101
+ # }
102
+ # c: [1]
103
+ # }
104
+ #
105
+ # And an update message:
106
+ #
107
+ # f {
108
+ # b {
109
+ # d: 10
110
+ # }
111
+ # c: [2]
112
+ # }
113
+ #
114
+ # then if the field mask is:
115
+ #
116
+ # paths: ["f.b", "f.c"]
117
+ #
118
+ # then the result will be:
119
+ #
120
+ # f {
121
+ # b {
122
+ # d: 10
123
+ # x: 2
124
+ # }
125
+ # c: [1, 2]
126
+ # }
127
+ #
128
+ # An implementation may provide options to override this default behavior for
129
+ # repeated and message fields.
130
+ #
131
+ # Note that libraries which implement FieldMask resolution have various
132
+ # different behaviors in the face of empty masks or the special "*" mask.
133
+ # When implementing a service you should confirm these cases have the
134
+ # appropriate behavior in the underlying FieldMask library that you desire,
135
+ # and you may need to special case those cases in your application code if
136
+ # the underlying field mask library behavior differs from your intended
137
+ # service semantics.
138
+ #
139
+ # Update methods implementing https://google.aip.dev/134
140
+ # - MUST support the special value * meaning "full replace"
141
+ # - MUST treat an omitted field mask as "replace fields which are present".
142
+ #
143
+ # Other methods implementing https://google.aip.dev/157
144
+ # - SHOULD support the special value "*" to mean "get all".
145
+ # - MUST treat an omitted field mask to mean "get all", unless otherwise
146
+ # documented.
147
+ #
148
+ # ## Considerations for HTTP REST
149
+ #
150
+ # The HTTP kind of an update operation which uses a field mask must
151
+ # be set to PATCH instead of PUT in order to satisfy HTTP semantics
152
+ # (PUT must only be used for full updates).
153
+ #
154
+ # # JSON Encoding of Field Masks
155
+ #
156
+ # In JSON, a field mask is encoded as a single string where paths are
157
+ # separated by a comma. Fields name in each path are converted
158
+ # to/from lower-camel naming conventions.
159
+ #
160
+ # As an example, consider the following message declarations:
161
+ #
162
+ # message Profile {
163
+ # User user = 1;
164
+ # Photo photo = 2;
165
+ # }
166
+ # message User {
167
+ # string display_name = 1;
168
+ # string address = 2;
169
+ # }
170
+ #
171
+ # In proto a field mask for `Profile` may look as such:
172
+ #
173
+ # mask {
174
+ # paths: "user.display_name"
175
+ # paths: "photo"
176
+ # }
177
+ #
178
+ # In JSON, the same mask is represented as below:
179
+ #
180
+ # {
181
+ # mask: "user.displayName,photo"
182
+ # }
183
+ #
184
+ # # Field Masks and Oneof Fields
185
+ #
186
+ # Field masks treat fields in oneofs just as regular fields. Consider the
187
+ # following message:
188
+ #
189
+ # message SampleMessage {
190
+ # oneof test_oneof {
191
+ # string name = 4;
192
+ # SubMessage sub_message = 9;
193
+ # }
194
+ # }
195
+ #
196
+ # The field mask can be:
197
+ #
198
+ # mask {
199
+ # paths: "name"
200
+ # }
201
+ #
202
+ # Or:
203
+ #
204
+ # mask {
205
+ # paths: "sub_message"
206
+ # }
207
+ #
208
+ # Note that oneof type names ("test_oneof" in this case) cannot be used in
209
+ # paths.
210
+ #
211
+ # ## Field Mask Verification
212
+ #
213
+ # The implementation of any API method which has a FieldMask type field in the
214
+ # request should verify the included field paths, and return an
215
+ # `INVALID_ARGUMENT` error if any path is unmappable.
216
+ f.message "FieldMask" do |m|
217
+ # The set of field mask paths.
218
+ m.field :paths, 1, :string, label: :repeated
219
+ end
220
+ end
221
+
222
+ module Protostar
223
+ module Google
224
+ module Protobuf
225
+ FieldMask = Protostar::DSL.message("google.protobuf.FieldMask")
226
+ end
227
+ end
228
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/source_context.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/source_context.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ java_package: "com.google.protobuf",
12
+ java_outer_classname: "SourceContextProto",
13
+ java_multiple_files: true,
14
+ objc_class_prefix: "GPB",
15
+ csharp_namespace: "Google.Protobuf.WellKnownTypes",
16
+ go_package: "google.golang.org/protobuf/types/known/sourcecontextpb"
17
+ ) do |f|
18
+ # `SourceContext` represents information about the source of a
19
+ # protobuf element, like the file in which it is defined.
20
+ f.message "SourceContext" do |m|
21
+ # The path-qualified name of the .proto file that contained the associated
22
+ # protobuf element. For example: `"google/protobuf/source_context.proto"`.
23
+ m.field :file_name, 1, :string
24
+ end
25
+ end
26
+
27
+ module Protostar
28
+ module Google
29
+ module Protobuf
30
+ SourceContext = Protostar::DSL.message("google.protobuf.SourceContext")
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/struct.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/struct.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ cc_enable_arenas: true,
12
+ go_package: "google.golang.org/protobuf/types/known/structpb",
13
+ java_package: "com.google.protobuf",
14
+ java_outer_classname: "StructProto",
15
+ java_multiple_files: true,
16
+ objc_class_prefix: "GPB",
17
+ csharp_namespace: "Google.Protobuf.WellKnownTypes"
18
+ ) do |f|
19
+ # Represents a JSON object.
20
+ #
21
+ # An unordered key-value map, intending to perfectly capture the semantics of a
22
+ # JSON object. This enables parsing any arbitrary JSON payload as a message
23
+ # field in ProtoJSON format.
24
+ #
25
+ # This follows RFC 8259 guidelines for interoperable JSON: notably this type
26
+ # cannot represent large Int64 values or `NaN`/`Infinity` numbers,
27
+ # since the JSON format generally does not support those values in its number
28
+ # type.
29
+ #
30
+ # If you do not intend to parse arbitrary JSON into your message, a custom
31
+ # typed message should be preferred instead of using this type.
32
+ f.message "Struct" do |m|
33
+ # Unordered map of dynamically typed values.
34
+ m.map :fields, 1, :string, :message, ".google.protobuf.Value"
35
+ end
36
+ # Represents a JSON value.
37
+ #
38
+ # `Value` represents a dynamically typed value which can be either
39
+ # null, a number, a string, a boolean, a recursive struct value, or a
40
+ # list of values. A producer of value is expected to set one of these
41
+ # variants. Absence of any variant is an invalid state.
42
+ f.message "Value" do |m|
43
+ # The kind of value.
44
+ m.oneof :kind do |o|
45
+ # Represents a JSON `null`.
46
+ o.field :null_value, 1, :enum, ".google.protobuf.NullValue"
47
+ # Represents a JSON number. Must not be `NaN`, `Infinity` or
48
+ # `-Infinity`, since those are not supported in JSON. This also cannot
49
+ # represent large Int64 values, since JSON format generally does not
50
+ # support them in its number type.
51
+ o.field :number_value, 2, :double
52
+ # Represents a JSON string.
53
+ o.field :string_value, 3, :string
54
+ # Represents a JSON boolean (`true` or `false` literal in JSON).
55
+ o.field :bool_value, 4, :bool
56
+ # Represents a JSON object.
57
+ o.field :struct_value, 5, :message, ".google.protobuf.Struct"
58
+ # Represents a JSON array.
59
+ o.field :list_value, 6, :message, ".google.protobuf.ListValue"
60
+ end
61
+ end
62
+ # Represents a JSON array.
63
+ f.message "ListValue" do |m|
64
+ # Repeated field of dynamically typed values.
65
+ m.field :values, 1, :message, ".google.protobuf.Value", label: :repeated
66
+ end
67
+ # Represents a JSON `null`.
68
+ #
69
+ # `NullValue` is a sentinel, using an enum with only one value to represent
70
+ # the null value for the `Value` type union.
71
+ #
72
+ # A field of type `NullValue` with any value other than `0` is considered
73
+ # invalid. Most ProtoJSON serializers will emit a `Value` with a `null_value`
74
+ # set as a JSON `null` regardless of the integer value, and so will round trip
75
+ # to a `0` value.
76
+ f.enum "NullValue" do |e|
77
+ # Null value.
78
+ e.value :NULL_VALUE, 0
79
+ end
80
+ end
81
+
82
+ module Protostar
83
+ module Google
84
+ module Protobuf
85
+ Struct = Protostar::DSL.message("google.protobuf.Struct")
86
+ Value = Protostar::DSL.message("google.protobuf.Value")
87
+ ListValue = Protostar::DSL.message("google.protobuf.ListValue")
88
+ NullValue = Protostar::DSL.enum("google.protobuf.NullValue")
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,129 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by protostar from google/protobuf/timestamp.proto. Do not edit.
4
+
5
+ require "protostar"
6
+
7
+ Protostar::DSL.file(
8
+ "google/protobuf/timestamp.proto",
9
+ package: "google.protobuf",
10
+ syntax: :proto3,
11
+ cc_enable_arenas: true,
12
+ go_package: "google.golang.org/protobuf/types/known/timestamppb",
13
+ java_package: "com.google.protobuf",
14
+ java_outer_classname: "TimestampProto",
15
+ java_multiple_files: true,
16
+ objc_class_prefix: "GPB",
17
+ csharp_namespace: "Google.Protobuf.WellKnownTypes"
18
+ ) do |f|
19
+ # A Timestamp represents a point in time independent of any time zone or local
20
+ # calendar, encoded as a count of seconds and fractions of seconds at
21
+ # nanosecond resolution. The count is relative to an epoch at UTC midnight on
22
+ # January 1, 1970, in the proleptic Gregorian calendar which extends the
23
+ # Gregorian calendar backwards to year one.
24
+ #
25
+ # All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap
26
+ # second table is needed for interpretation, using a [24-hour linear
27
+ # smear](https://developers.google.com/time/smear).
28
+ #
29
+ # The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By
30
+ # restricting to that range, we ensure that we can convert to and from [RFC
31
+ # 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.
32
+ #
33
+ # # Examples
34
+ #
35
+ # Example 1: Compute Timestamp from POSIX `time()`.
36
+ #
37
+ # Timestamp timestamp;
38
+ # timestamp.set_seconds(time(NULL));
39
+ # timestamp.set_nanos(0);
40
+ #
41
+ # Example 2: Compute Timestamp from POSIX `gettimeofday()`.
42
+ #
43
+ # struct timeval tv;
44
+ # gettimeofday(&tv, NULL);
45
+ #
46
+ # Timestamp timestamp;
47
+ # timestamp.set_seconds(tv.tv_sec);
48
+ # timestamp.set_nanos(tv.tv_usec * 1000);
49
+ #
50
+ # Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.
51
+ #
52
+ # FILETIME ft;
53
+ # GetSystemTimeAsFileTime(&ft);
54
+ # UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;
55
+ #
56
+ # // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z
57
+ # // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.
58
+ # Timestamp timestamp;
59
+ # timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));
60
+ # timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));
61
+ #
62
+ # Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.
63
+ #
64
+ # long millis = System.currentTimeMillis();
65
+ #
66
+ # Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)
67
+ # .setNanos((int) ((millis % 1000) * 1000000)).build();
68
+ #
69
+ # Example 5: Compute Timestamp from Java `Instant.now()`.
70
+ #
71
+ # Instant now = Instant.now();
72
+ #
73
+ # Timestamp timestamp =
74
+ # Timestamp.newBuilder().setSeconds(now.getEpochSecond())
75
+ # .setNanos(now.getNano()).build();
76
+ #
77
+ # Example 6: Compute Timestamp from current time in Python.
78
+ #
79
+ # timestamp = Timestamp()
80
+ # timestamp.GetCurrentTime()
81
+ #
82
+ # # JSON Mapping
83
+ #
84
+ # In JSON format, the Timestamp type is encoded as a string in the
85
+ # [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the
86
+ # format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z"
87
+ # where {year} is always expressed using four digits while {month}, {day},
88
+ # {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional
89
+ # seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),
90
+ # are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone
91
+ # is required. A ProtoJSON serializer should always use UTC (as indicated by
92
+ # "Z") when printing the Timestamp type and a ProtoJSON parser should be
93
+ # able to accept both UTC and other timezones (as indicated by an offset).
94
+ #
95
+ # For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past
96
+ # 01:30 UTC on January 15, 2017.
97
+ #
98
+ # In JavaScript, one can convert a Date object to this format using the
99
+ # standard
100
+ # [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
101
+ # method. In Python, a standard `datetime.datetime` object can be converted
102
+ # to this format using
103
+ # [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with
104
+ # the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use
105
+ # the Joda Time's [`ISODateTimeFormat.dateTime()`](
106
+ # http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()
107
+ # ) to obtain a formatter capable of generating timestamps in this format.
108
+ #
109
+ f.message "Timestamp" do |m|
110
+ # Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must
111
+ # be between -62135596800 and 253402300799 inclusive (which corresponds to
112
+ # 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z).
113
+ m.field :seconds, 1, :int64
114
+ # Non-negative fractions of a second at nanosecond resolution. This field is
115
+ # the nanosecond portion of the duration, not an alternative to seconds.
116
+ # Negative second values with fractions must still have non-negative nanos
117
+ # values that count forward in time. Must be between 0 and 999,999,999
118
+ # inclusive.
119
+ m.field :nanos, 2, :int32
120
+ end
121
+ end
122
+
123
+ module Protostar
124
+ module Google
125
+ module Protobuf
126
+ Timestamp = Protostar::DSL.message("google.protobuf.Timestamp")
127
+ end
128
+ end
129
+ end