node-red-contrib-tak-registration 0.11.6 → 0.12.1

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 (388) hide show
  1. package/node_modules/@types/node/README.md +2 -2
  2. package/node_modules/@types/node/assert.d.ts +88 -44
  3. package/node_modules/@types/node/async_hooks.d.ts +17 -15
  4. package/node_modules/@types/node/buffer.d.ts +29 -110
  5. package/node_modules/@types/node/child_process.d.ts +38 -34
  6. package/node_modules/@types/node/cluster.d.ts +165 -19
  7. package/node_modules/@types/node/console.d.ts +64 -27
  8. package/node_modules/@types/node/crypto.d.ts +106 -142
  9. package/node_modules/@types/node/dgram.d.ts +14 -14
  10. package/node_modules/@types/node/diagnostics_channel.d.ts +12 -3
  11. package/node_modules/@types/node/dns/promises.d.ts +79 -28
  12. package/node_modules/@types/node/dns.d.ts +124 -69
  13. package/node_modules/@types/node/dom-events.d.ts +2 -0
  14. package/node_modules/@types/node/domain.d.ts +4 -4
  15. package/node_modules/@types/node/events.d.ts +115 -63
  16. package/node_modules/@types/node/fs/promises.d.ts +34 -12
  17. package/node_modules/@types/node/fs.d.ts +104 -40
  18. package/node_modules/@types/node/globals.d.ts +1 -0
  19. package/node_modules/@types/node/http.d.ts +69 -48
  20. package/node_modules/@types/node/http2.d.ts +83 -47
  21. package/node_modules/@types/node/https.d.ts +3 -3
  22. package/node_modules/@types/node/index.d.ts +1 -0
  23. package/node_modules/@types/node/inspector.d.ts +5 -6
  24. package/node_modules/@types/node/module.d.ts +0 -14
  25. package/node_modules/@types/node/net.d.ts +58 -13
  26. package/node_modules/@types/node/os.d.ts +29 -12
  27. package/node_modules/@types/node/package.json +4 -16
  28. package/node_modules/@types/node/path.d.ts +1 -1
  29. package/node_modules/@types/node/perf_hooks.d.ts +308 -48
  30. package/node_modules/@types/node/process.d.ts +241 -48
  31. package/node_modules/@types/node/punycode.d.ts +4 -4
  32. package/node_modules/@types/node/querystring.d.ts +18 -6
  33. package/node_modules/@types/node/readline/promises.d.ts +9 -9
  34. package/node_modules/@types/node/readline.d.ts +23 -22
  35. package/node_modules/@types/node/repl.d.ts +21 -21
  36. package/node_modules/@types/node/sea.d.ts +153 -0
  37. package/node_modules/@types/node/stream/web.d.ts +3 -2
  38. package/node_modules/@types/node/stream.d.ts +63 -57
  39. package/node_modules/@types/node/string_decoder.d.ts +3 -3
  40. package/node_modules/@types/node/test.d.ts +363 -98
  41. package/node_modules/@types/node/timers/promises.d.ts +10 -6
  42. package/node_modules/@types/node/timers.d.ts +5 -5
  43. package/node_modules/@types/node/tls.d.ts +39 -32
  44. package/node_modules/@types/node/trace_events.d.ts +40 -25
  45. package/node_modules/@types/node/tty.d.ts +8 -8
  46. package/node_modules/@types/node/url.d.ts +15 -7
  47. package/node_modules/@types/node/util.d.ts +131 -22
  48. package/node_modules/@types/node/v8.d.ts +51 -7
  49. package/node_modules/@types/node/vm.d.ts +43 -24
  50. package/node_modules/@types/node/wasi.d.ts +12 -10
  51. package/node_modules/@types/node/worker_threads.d.ts +19 -16
  52. package/node_modules/@types/node/zlib.d.ts +16 -3
  53. package/node_modules/adm-zip/README.md +2 -1
  54. package/node_modules/adm-zip/adm-zip.js +46 -45
  55. package/node_modules/adm-zip/headers/entryHeader.js +14 -12
  56. package/node_modules/adm-zip/headers/mainHeader.js +1 -1
  57. package/node_modules/adm-zip/methods/inflater.js +6 -3
  58. package/node_modules/adm-zip/methods/zipcrypto.js +6 -2
  59. package/node_modules/adm-zip/package.json +2 -2
  60. package/node_modules/adm-zip/util/errors.js +1 -0
  61. package/node_modules/adm-zip/zipEntry.js +64 -43
  62. package/node_modules/adm-zip/zipFile.js +35 -35
  63. package/node_modules/axios/CHANGELOG.md +868 -759
  64. package/node_modules/axios/README.md +65 -17
  65. package/node_modules/axios/dist/axios.js +1330 -583
  66. package/node_modules/axios/dist/axios.js.map +1 -1
  67. package/node_modules/axios/dist/axios.min.js +1 -1
  68. package/node_modules/axios/dist/axios.min.js.map +1 -1
  69. package/node_modules/axios/dist/browser/axios.cjs +696 -316
  70. package/node_modules/axios/dist/browser/axios.cjs.map +1 -1
  71. package/node_modules/axios/dist/esm/axios.js +696 -316
  72. package/node_modules/axios/dist/esm/axios.js.map +1 -1
  73. package/node_modules/axios/dist/esm/axios.min.js +1 -1
  74. package/node_modules/axios/dist/esm/axios.min.js.map +1 -1
  75. package/node_modules/axios/dist/node/axios.cjs +607 -257
  76. package/node_modules/axios/dist/node/axios.cjs.map +1 -1
  77. package/node_modules/axios/index.d.cts +5 -2
  78. package/node_modules/axios/index.d.ts +5 -2
  79. package/node_modules/axios/lib/adapters/adapters.js +3 -1
  80. package/node_modules/axios/lib/adapters/fetch.js +227 -0
  81. package/node_modules/axios/lib/adapters/http.js +1 -1
  82. package/node_modules/axios/lib/adapters/xhr.js +31 -101
  83. package/node_modules/axios/lib/core/Axios.js +17 -11
  84. package/node_modules/axios/lib/core/AxiosHeaders.js +4 -0
  85. package/node_modules/axios/lib/core/mergeConfig.js +1 -1
  86. package/node_modules/axios/lib/defaults/index.js +7 -5
  87. package/node_modules/axios/lib/env/data.js +1 -1
  88. package/node_modules/axios/lib/helpers/AxiosTransformStream.js +9 -8
  89. package/node_modules/axios/lib/helpers/composeSignals.js +46 -0
  90. package/node_modules/axios/lib/helpers/progressEventReducer.js +32 -0
  91. package/node_modules/axios/lib/helpers/resolveConfig.js +57 -0
  92. package/node_modules/axios/lib/helpers/throttle.js +5 -3
  93. package/node_modules/axios/lib/helpers/trackStream.js +55 -0
  94. package/node_modules/axios/lib/platform/common/utils.js +4 -1
  95. package/node_modules/axios/lib/utils.js +7 -2
  96. package/node_modules/axios/package.json +27 -26
  97. package/node_modules/fast-xml-parser/CHANGELOG.md +14 -0
  98. package/node_modules/fast-xml-parser/README.md +7 -14
  99. package/node_modules/fast-xml-parser/package.json +1 -1
  100. package/node_modules/fast-xml-parser/src/fxp.d.ts +4 -4
  101. package/node_modules/fast-xml-parser/src/v5/CharsSymbol.js +16 -0
  102. package/node_modules/fast-xml-parser/src/v5/EntitiesParser.js +107 -0
  103. package/node_modules/fast-xml-parser/src/v5/OptionsBuilder.js +64 -0
  104. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/BaseOutputBuilder.js +71 -0
  105. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsArrBuilder.js +103 -0
  106. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsMinArrBuilder.js +102 -0
  107. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/JsObjBuilder.js +156 -0
  108. package/node_modules/fast-xml-parser/src/v5/OutputBuilders/ParserOptionsBuilder.js +96 -0
  109. package/node_modules/fast-xml-parser/src/v5/Report.js +0 -0
  110. package/node_modules/fast-xml-parser/src/v5/TagPath.js +81 -0
  111. package/node_modules/fast-xml-parser/src/v5/TagPathMatcher.js +15 -0
  112. package/node_modules/fast-xml-parser/src/v5/XMLParser.js +85 -0
  113. package/node_modules/fast-xml-parser/src/v5/Xml2JsParser.js +237 -0
  114. package/node_modules/fast-xml-parser/src/v5/XmlPartReader.js +212 -0
  115. package/node_modules/fast-xml-parser/src/v5/XmlSpecialTagsReader.js +118 -0
  116. package/node_modules/fast-xml-parser/src/v5/inputSource/BufferSource.js +118 -0
  117. package/node_modules/fast-xml-parser/src/v5/inputSource/StringSource.js +123 -0
  118. package/node_modules/fast-xml-parser/src/v5/valueParsers/EntitiesParser.js +107 -0
  119. package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParser.js +23 -0
  120. package/node_modules/fast-xml-parser/src/v5/valueParsers/booleanParserExt.js +20 -0
  121. package/node_modules/fast-xml-parser/src/v5/valueParsers/currency.js +31 -0
  122. package/node_modules/fast-xml-parser/src/v5/valueParsers/join.js +14 -0
  123. package/node_modules/fast-xml-parser/src/v5/valueParsers/number.js +16 -0
  124. package/node_modules/fast-xml-parser/src/v5/valueParsers/trim.js +8 -0
  125. package/node_modules/fast-xml-parser/src/validator.js +2 -0
  126. package/node_modules/fast-xml-parser/src/xmlparser/OrderedObjParser.js +13 -4
  127. package/node_modules/follow-redirects/index.js +1 -1
  128. package/node_modules/follow-redirects/package.json +1 -1
  129. package/node_modules/hasown/CHANGELOG.md +12 -0
  130. package/node_modules/hasown/index.d.ts +2 -2
  131. package/node_modules/hasown/package.json +5 -2
  132. package/node_modules/hasown/tsconfig.json +3 -46
  133. package/node_modules/object-is/.eslintrc +1 -1
  134. package/node_modules/object-is/.nycrc +0 -4
  135. package/node_modules/object-is/CHANGELOG.md +25 -0
  136. package/node_modules/object-is/README.md +20 -20
  137. package/node_modules/object-is/package.json +23 -14
  138. package/node_modules/protobufjs/LICENSE +39 -39
  139. package/node_modules/protobufjs/README.md +727 -740
  140. package/node_modules/protobufjs/dist/light/protobuf.js +6264 -6264
  141. package/node_modules/protobufjs/dist/light/protobuf.js.map +1 -1
  142. package/node_modules/protobufjs/dist/light/protobuf.min.js +2 -2
  143. package/node_modules/protobufjs/dist/light/protobuf.min.js.map +1 -1
  144. package/node_modules/protobufjs/dist/minimal/protobuf.js +1928 -1928
  145. package/node_modules/protobufjs/dist/minimal/protobuf.js.map +1 -1
  146. package/node_modules/protobufjs/dist/minimal/protobuf.min.js +2 -2
  147. package/node_modules/protobufjs/dist/minimal/protobuf.min.js.map +1 -1
  148. package/node_modules/protobufjs/dist/protobuf.js +7978 -7961
  149. package/node_modules/protobufjs/dist/protobuf.js.map +1 -1
  150. package/node_modules/protobufjs/dist/protobuf.min.js +3 -3
  151. package/node_modules/protobufjs/dist/protobuf.min.js.map +1 -1
  152. package/node_modules/protobufjs/ext/debug/README.md +4 -4
  153. package/node_modules/protobufjs/ext/debug/index.js +71 -71
  154. package/node_modules/protobufjs/ext/descriptor/README.md +72 -72
  155. package/node_modules/protobufjs/ext/descriptor/index.d.ts +191 -191
  156. package/node_modules/protobufjs/ext/descriptor/index.js +1052 -1052
  157. package/node_modules/protobufjs/ext/descriptor/test.js +54 -54
  158. package/node_modules/protobufjs/google/LICENSE +27 -27
  159. package/node_modules/protobufjs/google/README.md +1 -1
  160. package/node_modules/protobufjs/google/api/annotations.json +82 -82
  161. package/node_modules/protobufjs/google/api/annotations.proto +10 -10
  162. package/node_modules/protobufjs/google/api/http.json +85 -85
  163. package/node_modules/protobufjs/google/api/http.proto +30 -30
  164. package/node_modules/protobufjs/google/protobuf/api.json +117 -117
  165. package/node_modules/protobufjs/google/protobuf/api.proto +33 -33
  166. package/node_modules/protobufjs/google/protobuf/descriptor.json +738 -738
  167. package/node_modules/protobufjs/google/protobuf/descriptor.proto +286 -286
  168. package/node_modules/protobufjs/google/protobuf/source_context.json +19 -19
  169. package/node_modules/protobufjs/google/protobuf/source_context.proto +7 -7
  170. package/node_modules/protobufjs/google/protobuf/type.json +201 -201
  171. package/node_modules/protobufjs/google/protobuf/type.proto +89 -89
  172. package/node_modules/protobufjs/index.d.ts +2741 -2741
  173. package/node_modules/protobufjs/index.js +4 -4
  174. package/node_modules/protobufjs/light.d.ts +2 -2
  175. package/node_modules/protobufjs/light.js +3 -3
  176. package/node_modules/protobufjs/minimal.d.ts +2 -2
  177. package/node_modules/protobufjs/minimal.js +4 -4
  178. package/node_modules/protobufjs/package.json +111 -111
  179. package/node_modules/protobufjs/scripts/postinstall.js +32 -32
  180. package/node_modules/protobufjs/src/common.js +399 -399
  181. package/node_modules/protobufjs/src/converter.js +301 -301
  182. package/node_modules/protobufjs/src/decoder.js +129 -129
  183. package/node_modules/protobufjs/src/encoder.js +100 -100
  184. package/node_modules/protobufjs/src/enum.js +198 -198
  185. package/node_modules/protobufjs/src/field.js +377 -377
  186. package/node_modules/protobufjs/src/index-light.js +104 -104
  187. package/node_modules/protobufjs/src/index-minimal.js +36 -36
  188. package/node_modules/protobufjs/src/index.js +12 -12
  189. package/node_modules/protobufjs/src/mapfield.js +126 -126
  190. package/node_modules/protobufjs/src/message.js +138 -138
  191. package/node_modules/protobufjs/src/method.js +160 -160
  192. package/node_modules/protobufjs/src/namespace.js +433 -433
  193. package/node_modules/protobufjs/src/object.js +243 -243
  194. package/node_modules/protobufjs/src/oneof.js +203 -203
  195. package/node_modules/protobufjs/src/parse.js +889 -872
  196. package/node_modules/protobufjs/src/reader.js +416 -416
  197. package/node_modules/protobufjs/src/reader_buffer.js +51 -51
  198. package/node_modules/protobufjs/src/root.js +368 -368
  199. package/node_modules/protobufjs/src/roots.js +18 -18
  200. package/node_modules/protobufjs/src/rpc/service.js +142 -142
  201. package/node_modules/protobufjs/src/rpc.js +36 -36
  202. package/node_modules/protobufjs/src/service.js +167 -167
  203. package/node_modules/protobufjs/src/tokenize.js +416 -416
  204. package/node_modules/protobufjs/src/type.js +589 -589
  205. package/node_modules/protobufjs/src/types.js +196 -196
  206. package/node_modules/protobufjs/src/typescript.jsdoc +15 -15
  207. package/node_modules/protobufjs/src/util/longbits.js +200 -200
  208. package/node_modules/protobufjs/src/util/minimal.js +438 -438
  209. package/node_modules/protobufjs/src/util.js +212 -212
  210. package/node_modules/protobufjs/src/verifier.js +176 -176
  211. package/node_modules/protobufjs/src/wrappers.js +102 -102
  212. package/node_modules/protobufjs/src/writer.js +465 -465
  213. package/node_modules/protobufjs/src/writer_buffer.js +85 -85
  214. package/node_modules/protobufjs/tsconfig.json +7 -7
  215. package/node_modules/set-function-length/CHANGELOG.md +11 -0
  216. package/node_modules/set-function-length/env.d.ts +9 -6
  217. package/node_modules/set-function-length/env.js +1 -0
  218. package/node_modules/set-function-length/index.d.ts +6 -6
  219. package/node_modules/set-function-length/index.js +1 -3
  220. package/node_modules/set-function-length/package.json +11 -13
  221. package/node_modules/set-function-length/tsconfig.json +7 -57
  222. package/node_modules/undici-types/LICENSE +21 -0
  223. package/node_modules/undici-types/balanced-pool.d.ts +11 -0
  224. package/node_modules/undici-types/client.d.ts +12 -1
  225. package/node_modules/undici-types/diagnostics-channel.d.ts +1 -2
  226. package/node_modules/undici-types/dispatcher.d.ts +17 -3
  227. package/node_modules/undici-types/eventsource.d.ts +61 -0
  228. package/node_modules/undici-types/fetch.d.ts +22 -23
  229. package/node_modules/undici-types/handlers.d.ts +10 -4
  230. package/node_modules/undici-types/index.d.ts +6 -1
  231. package/node_modules/undici-types/package.json +1 -1
  232. package/node_modules/undici-types/pool.d.ts +11 -0
  233. package/node_modules/undici-types/proxy-agent.d.ts +0 -2
  234. package/node_modules/undici-types/readable.d.ts +2 -3
  235. package/node_modules/undici-types/retry-agent.d.ts +11 -0
  236. package/node_modules/undici-types/retry-handler.d.ts +116 -0
  237. package/node_modules/undici-types/util.d.ts +31 -0
  238. package/node_modules/undici-types/webidl.d.ts +6 -1
  239. package/node_modules/undici-types/websocket.d.ts +22 -1
  240. package/node_modules/uuid/CHANGELOG.md +18 -0
  241. package/node_modules/uuid/README.md +134 -16
  242. package/node_modules/uuid/dist/commonjs-browser/index.js +40 -15
  243. package/node_modules/uuid/dist/commonjs-browser/max.js +7 -0
  244. package/node_modules/uuid/dist/commonjs-browser/md5.js +30 -53
  245. package/node_modules/uuid/dist/commonjs-browser/native.js +3 -4
  246. package/node_modules/uuid/dist/commonjs-browser/nil.js +1 -2
  247. package/node_modules/uuid/dist/commonjs-browser/parse.js +14 -15
  248. package/node_modules/uuid/dist/commonjs-browser/regex.js +1 -2
  249. package/node_modules/uuid/dist/commonjs-browser/rng.js +2 -4
  250. package/node_modules/uuid/dist/commonjs-browser/sha1.js +27 -49
  251. package/node_modules/uuid/dist/commonjs-browser/stringify.js +10 -16
  252. package/node_modules/uuid/dist/commonjs-browser/v1.js +73 -49
  253. package/node_modules/uuid/dist/commonjs-browser/v1ToV6.js +26 -0
  254. package/node_modules/uuid/dist/commonjs-browser/v3.js +3 -8
  255. package/node_modules/uuid/dist/commonjs-browser/v35.js +15 -32
  256. package/node_modules/uuid/dist/commonjs-browser/v4.js +7 -18
  257. package/node_modules/uuid/dist/commonjs-browser/v5.js +3 -8
  258. package/node_modules/uuid/dist/commonjs-browser/v6.js +42 -0
  259. package/node_modules/uuid/dist/commonjs-browser/v6ToV1.js +26 -0
  260. package/node_modules/uuid/dist/commonjs-browser/v7.js +152 -0
  261. package/node_modules/uuid/dist/commonjs-browser/validate.js +2 -7
  262. package/node_modules/uuid/dist/commonjs-browser/version.js +2 -8
  263. package/node_modules/uuid/dist/esm-browser/index.js +9 -4
  264. package/node_modules/uuid/dist/esm-browser/max.js +1 -0
  265. package/node_modules/uuid/dist/esm-browser/md5.js +29 -50
  266. package/node_modules/uuid/dist/esm-browser/native.js +1 -1
  267. package/node_modules/uuid/dist/esm-browser/parse.js +12 -10
  268. package/node_modules/uuid/dist/esm-browser/regex.js +1 -1
  269. package/node_modules/uuid/dist/esm-browser/rng.js +3 -4
  270. package/node_modules/uuid/dist/esm-browser/sha1.js +26 -46
  271. package/node_modules/uuid/dist/esm-browser/stringify.js +9 -11
  272. package/node_modules/uuid/dist/esm-browser/v1.js +74 -44
  273. package/node_modules/uuid/dist/esm-browser/v1ToV6.js +20 -0
  274. package/node_modules/uuid/dist/esm-browser/v3.js +1 -1
  275. package/node_modules/uuid/dist/esm-browser/v35.js +14 -25
  276. package/node_modules/uuid/dist/esm-browser/v4.js +5 -9
  277. package/node_modules/uuid/dist/esm-browser/v5.js +1 -1
  278. package/node_modules/uuid/dist/esm-browser/v6.js +36 -0
  279. package/node_modules/uuid/dist/esm-browser/v6ToV1.js +20 -0
  280. package/node_modules/uuid/dist/esm-browser/v7.js +146 -0
  281. package/node_modules/uuid/dist/esm-browser/validate.js +0 -2
  282. package/node_modules/uuid/dist/esm-browser/version.js +0 -3
  283. package/node_modules/uuid/dist/esm-node/index.js +9 -4
  284. package/node_modules/uuid/dist/esm-node/max.js +1 -0
  285. package/node_modules/uuid/dist/esm-node/md5.js +1 -4
  286. package/node_modules/uuid/dist/esm-node/native.js +1 -1
  287. package/node_modules/uuid/dist/esm-node/parse.js +11 -9
  288. package/node_modules/uuid/dist/esm-node/regex.js +1 -1
  289. package/node_modules/uuid/dist/esm-node/rng.js +1 -3
  290. package/node_modules/uuid/dist/esm-node/sha1.js +1 -4
  291. package/node_modules/uuid/dist/esm-node/stringify.js +7 -9
  292. package/node_modules/uuid/dist/esm-node/v1.js +66 -36
  293. package/node_modules/uuid/dist/esm-node/v1ToV6.js +20 -0
  294. package/node_modules/uuid/dist/esm-node/v35.js +8 -19
  295. package/node_modules/uuid/dist/esm-node/v4.js +4 -8
  296. package/node_modules/uuid/dist/esm-node/v6.js +32 -0
  297. package/node_modules/uuid/dist/esm-node/v6ToV1.js +20 -0
  298. package/node_modules/uuid/dist/esm-node/v7.js +146 -0
  299. package/node_modules/uuid/dist/esm-node/validate.js +0 -2
  300. package/node_modules/uuid/dist/esm-node/version.js +0 -3
  301. package/node_modules/uuid/dist/index.js +40 -15
  302. package/node_modules/uuid/dist/max.js +7 -0
  303. package/node_modules/uuid/dist/md5-browser.js +8 -31
  304. package/node_modules/uuid/dist/md5.js +4 -10
  305. package/node_modules/uuid/dist/native-browser.js +2 -3
  306. package/node_modules/uuid/dist/native.js +5 -9
  307. package/node_modules/uuid/dist/nil.js +1 -2
  308. package/node_modules/uuid/dist/parse.js +13 -14
  309. package/node_modules/uuid/dist/regex.js +1 -2
  310. package/node_modules/uuid/dist/rng-browser.js +1 -3
  311. package/node_modules/uuid/dist/rng.js +3 -10
  312. package/node_modules/uuid/dist/sha1-browser.js +1 -23
  313. package/node_modules/uuid/dist/sha1.js +4 -10
  314. package/node_modules/uuid/dist/stringify.js +8 -14
  315. package/node_modules/uuid/dist/uuid-bin.js +12 -22
  316. package/node_modules/uuid/dist/v1.js +66 -42
  317. package/node_modules/uuid/dist/v1ToV6.js +26 -0
  318. package/node_modules/uuid/dist/v3.js +2 -7
  319. package/node_modules/uuid/dist/v35.js +11 -28
  320. package/node_modules/uuid/dist/v4.js +6 -17
  321. package/node_modules/uuid/dist/v5.js +2 -7
  322. package/node_modules/uuid/dist/v6.js +38 -0
  323. package/node_modules/uuid/dist/v6ToV1.js +26 -0
  324. package/node_modules/uuid/dist/v7.js +152 -0
  325. package/node_modules/uuid/dist/validate.js +2 -7
  326. package/node_modules/uuid/dist/version.js +2 -8
  327. package/node_modules/uuid/package.json +41 -34
  328. package/node_modules/uuid/wrapper.mjs +5 -0
  329. package/package.json +6 -6
  330. package/tak-ingest.js +1 -1
  331. package/tak-registration.js +8 -1
  332. package/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -8
  333. package/node_modules/@types/node/ts4.8/assert.d.ts +0 -996
  334. package/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -539
  335. package/node_modules/@types/node/ts4.8/buffer.d.ts +0 -2363
  336. package/node_modules/@types/node/ts4.8/child_process.d.ts +0 -1540
  337. package/node_modules/@types/node/ts4.8/cluster.d.ts +0 -432
  338. package/node_modules/@types/node/ts4.8/console.d.ts +0 -415
  339. package/node_modules/@types/node/ts4.8/constants.d.ts +0 -19
  340. package/node_modules/@types/node/ts4.8/crypto.d.ts +0 -4487
  341. package/node_modules/@types/node/ts4.8/dgram.d.ts +0 -596
  342. package/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -545
  343. package/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -425
  344. package/node_modules/@types/node/ts4.8/dns.d.ts +0 -809
  345. package/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -122
  346. package/node_modules/@types/node/ts4.8/domain.d.ts +0 -170
  347. package/node_modules/@types/node/ts4.8/events.d.ts +0 -879
  348. package/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -1239
  349. package/node_modules/@types/node/ts4.8/fs.d.ts +0 -4311
  350. package/node_modules/@types/node/ts4.8/globals.d.ts +0 -411
  351. package/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -1
  352. package/node_modules/@types/node/ts4.8/http.d.ts +0 -1887
  353. package/node_modules/@types/node/ts4.8/http2.d.ts +0 -2382
  354. package/node_modules/@types/node/ts4.8/https.d.ts +0 -550
  355. package/node_modules/@types/node/ts4.8/index.d.ts +0 -88
  356. package/node_modules/@types/node/ts4.8/inspector.d.ts +0 -2747
  357. package/node_modules/@types/node/ts4.8/module.d.ts +0 -315
  358. package/node_modules/@types/node/ts4.8/net.d.ts +0 -954
  359. package/node_modules/@types/node/ts4.8/os.d.ts +0 -478
  360. package/node_modules/@types/node/ts4.8/path.d.ts +0 -191
  361. package/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -645
  362. package/node_modules/@types/node/ts4.8/process.d.ts +0 -1561
  363. package/node_modules/@types/node/ts4.8/punycode.d.ts +0 -117
  364. package/node_modules/@types/node/ts4.8/querystring.d.ts +0 -141
  365. package/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -150
  366. package/node_modules/@types/node/ts4.8/readline.d.ts +0 -539
  367. package/node_modules/@types/node/ts4.8/repl.d.ts +0 -430
  368. package/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -12
  369. package/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -83
  370. package/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -366
  371. package/node_modules/@types/node/ts4.8/stream.d.ts +0 -1701
  372. package/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -67
  373. package/node_modules/@types/node/ts4.8/test.d.ts +0 -1465
  374. package/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -93
  375. package/node_modules/@types/node/ts4.8/timers.d.ts +0 -240
  376. package/node_modules/@types/node/ts4.8/tls.d.ts +0 -1210
  377. package/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -182
  378. package/node_modules/@types/node/ts4.8/tty.d.ts +0 -208
  379. package/node_modules/@types/node/ts4.8/url.d.ts +0 -944
  380. package/node_modules/@types/node/ts4.8/util.d.ts +0 -2183
  381. package/node_modules/@types/node/ts4.8/v8.d.ts +0 -764
  382. package/node_modules/@types/node/ts4.8/vm.d.ts +0 -903
  383. package/node_modules/@types/node/ts4.8/wasi.d.ts +0 -179
  384. package/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -691
  385. package/node_modules/@types/node/ts4.8/zlib.d.ts +0 -517
  386. package/node_modules/object-is/.eslintignore +0 -1
  387. package/node_modules/set-function-length/env.d.ts.map +0 -1
  388. package/node_modules/set-function-length/index.d.ts.map +0 -1
@@ -1,872 +1,889 @@
1
- "use strict";
2
- module.exports = parse;
3
-
4
- parse.filename = null;
5
- parse.defaults = { keepCase: false };
6
-
7
- var tokenize = require("./tokenize"),
8
- Root = require("./root"),
9
- Type = require("./type"),
10
- Field = require("./field"),
11
- MapField = require("./mapfield"),
12
- OneOf = require("./oneof"),
13
- Enum = require("./enum"),
14
- Service = require("./service"),
15
- Method = require("./method"),
16
- types = require("./types"),
17
- util = require("./util");
18
-
19
- var base10Re = /^[1-9][0-9]*$/,
20
- base10NegRe = /^-?[1-9][0-9]*$/,
21
- base16Re = /^0[x][0-9a-fA-F]+$/,
22
- base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
23
- base8Re = /^0[0-7]+$/,
24
- base8NegRe = /^-?0[0-7]+$/,
25
- numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
26
- nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
27
- typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
28
- fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
29
-
30
- /**
31
- * Result object returned from {@link parse}.
32
- * @interface IParserResult
33
- * @property {string|undefined} package Package name, if declared
34
- * @property {string[]|undefined} imports Imports, if any
35
- * @property {string[]|undefined} weakImports Weak imports, if any
36
- * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`)
37
- * @property {Root} root Populated root instance
38
- */
39
-
40
- /**
41
- * Options modifying the behavior of {@link parse}.
42
- * @interface IParseOptions
43
- * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
44
- * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
45
- * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
46
- */
47
-
48
- /**
49
- * Options modifying the behavior of JSON serialization.
50
- * @interface IToJSONOptions
51
- * @property {boolean} [keepComments=false] Serializes comments.
52
- */
53
-
54
- /**
55
- * Parses the given .proto source and returns an object with the parsed contents.
56
- * @param {string} source Source contents
57
- * @param {Root} root Root to populate
58
- * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
59
- * @returns {IParserResult} Parser result
60
- * @property {string} filename=null Currently processing file name for error reporting, if known
61
- * @property {IParseOptions} defaults Default {@link IParseOptions}
62
- */
63
- function parse(source, root, options) {
64
- /* eslint-disable callback-return */
65
- if (!(root instanceof Root)) {
66
- options = root;
67
- root = new Root();
68
- }
69
- if (!options)
70
- options = parse.defaults;
71
-
72
- var preferTrailingComment = options.preferTrailingComment || false;
73
- var tn = tokenize(source, options.alternateCommentMode || false),
74
- next = tn.next,
75
- push = tn.push,
76
- peek = tn.peek,
77
- skip = tn.skip,
78
- cmnt = tn.cmnt;
79
-
80
- var head = true,
81
- pkg,
82
- imports,
83
- weakImports,
84
- syntax,
85
- isProto3 = false;
86
-
87
- var ptr = root;
88
-
89
- var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
90
-
91
- /* istanbul ignore next */
92
- function illegal(token, name, insideTryCatch) {
93
- var filename = parse.filename;
94
- if (!insideTryCatch)
95
- parse.filename = null;
96
- return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
97
- }
98
-
99
- function readString() {
100
- var values = [],
101
- token;
102
- do {
103
- /* istanbul ignore if */
104
- if ((token = next()) !== "\"" && token !== "'")
105
- throw illegal(token);
106
-
107
- values.push(next());
108
- skip(token);
109
- token = peek();
110
- } while (token === "\"" || token === "'");
111
- return values.join("");
112
- }
113
-
114
- function readValue(acceptTypeRef) {
115
- var token = next();
116
- switch (token) {
117
- case "'":
118
- case "\"":
119
- push(token);
120
- return readString();
121
- case "true": case "TRUE":
122
- return true;
123
- case "false": case "FALSE":
124
- return false;
125
- }
126
- try {
127
- return parseNumber(token, /* insideTryCatch */ true);
128
- } catch (e) {
129
-
130
- /* istanbul ignore else */
131
- if (acceptTypeRef && typeRefRe.test(token))
132
- return token;
133
-
134
- /* istanbul ignore next */
135
- throw illegal(token, "value");
136
- }
137
- }
138
-
139
- function readRanges(target, acceptStrings) {
140
- var token, start;
141
- do {
142
- if (acceptStrings && ((token = peek()) === "\"" || token === "'"))
143
- target.push(readString());
144
- else
145
- target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
146
- } while (skip(",", true));
147
- skip(";");
148
- }
149
-
150
- function parseNumber(token, insideTryCatch) {
151
- var sign = 1;
152
- if (token.charAt(0) === "-") {
153
- sign = -1;
154
- token = token.substring(1);
155
- }
156
- switch (token) {
157
- case "inf": case "INF": case "Inf":
158
- return sign * Infinity;
159
- case "nan": case "NAN": case "Nan": case "NaN":
160
- return NaN;
161
- case "0":
162
- return 0;
163
- }
164
- if (base10Re.test(token))
165
- return sign * parseInt(token, 10);
166
- if (base16Re.test(token))
167
- return sign * parseInt(token, 16);
168
- if (base8Re.test(token))
169
- return sign * parseInt(token, 8);
170
-
171
- /* istanbul ignore else */
172
- if (numberRe.test(token))
173
- return sign * parseFloat(token);
174
-
175
- /* istanbul ignore next */
176
- throw illegal(token, "number", insideTryCatch);
177
- }
178
-
179
- function parseId(token, acceptNegative) {
180
- switch (token) {
181
- case "max": case "MAX": case "Max":
182
- return 536870911;
183
- case "0":
184
- return 0;
185
- }
186
-
187
- /* istanbul ignore if */
188
- if (!acceptNegative && token.charAt(0) === "-")
189
- throw illegal(token, "id");
190
-
191
- if (base10NegRe.test(token))
192
- return parseInt(token, 10);
193
- if (base16NegRe.test(token))
194
- return parseInt(token, 16);
195
-
196
- /* istanbul ignore else */
197
- if (base8NegRe.test(token))
198
- return parseInt(token, 8);
199
-
200
- /* istanbul ignore next */
201
- throw illegal(token, "id");
202
- }
203
-
204
- function parsePackage() {
205
-
206
- /* istanbul ignore if */
207
- if (pkg !== undefined)
208
- throw illegal("package");
209
-
210
- pkg = next();
211
-
212
- /* istanbul ignore if */
213
- if (!typeRefRe.test(pkg))
214
- throw illegal(pkg, "name");
215
-
216
- ptr = ptr.define(pkg);
217
- skip(";");
218
- }
219
-
220
- function parseImport() {
221
- var token = peek();
222
- var whichImports;
223
- switch (token) {
224
- case "weak":
225
- whichImports = weakImports || (weakImports = []);
226
- next();
227
- break;
228
- case "public":
229
- next();
230
- // eslint-disable-next-line no-fallthrough
231
- default:
232
- whichImports = imports || (imports = []);
233
- break;
234
- }
235
- token = readString();
236
- skip(";");
237
- whichImports.push(token);
238
- }
239
-
240
- function parseSyntax() {
241
- skip("=");
242
- syntax = readString();
243
- isProto3 = syntax === "proto3";
244
-
245
- /* istanbul ignore if */
246
- if (!isProto3 && syntax !== "proto2")
247
- throw illegal(syntax, "syntax");
248
-
249
- skip(";");
250
- }
251
-
252
- function parseCommon(parent, token) {
253
- switch (token) {
254
-
255
- case "option":
256
- parseOption(parent, token);
257
- skip(";");
258
- return true;
259
-
260
- case "message":
261
- parseType(parent, token);
262
- return true;
263
-
264
- case "enum":
265
- parseEnum(parent, token);
266
- return true;
267
-
268
- case "service":
269
- parseService(parent, token);
270
- return true;
271
-
272
- case "extend":
273
- parseExtension(parent, token);
274
- return true;
275
- }
276
- return false;
277
- }
278
-
279
- function ifBlock(obj, fnIf, fnElse) {
280
- var trailingLine = tn.line;
281
- if (obj) {
282
- if(typeof obj.comment !== "string") {
283
- obj.comment = cmnt(); // try block-type comment
284
- }
285
- obj.filename = parse.filename;
286
- }
287
- if (skip("{", true)) {
288
- var token;
289
- while ((token = next()) !== "}")
290
- fnIf(token);
291
- skip(";", true);
292
- } else {
293
- if (fnElse)
294
- fnElse();
295
- skip(";");
296
- if (obj && (typeof obj.comment !== "string" || preferTrailingComment))
297
- obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment
298
- }
299
- }
300
-
301
- function parseType(parent, token) {
302
-
303
- /* istanbul ignore if */
304
- if (!nameRe.test(token = next()))
305
- throw illegal(token, "type name");
306
-
307
- var type = new Type(token);
308
- ifBlock(type, function parseType_block(token) {
309
- if (parseCommon(type, token))
310
- return;
311
-
312
- switch (token) {
313
-
314
- case "map":
315
- parseMapField(type, token);
316
- break;
317
-
318
- case "required":
319
- case "repeated":
320
- parseField(type, token);
321
- break;
322
-
323
- case "optional":
324
- /* istanbul ignore if */
325
- if (isProto3) {
326
- parseField(type, "proto3_optional");
327
- } else {
328
- parseField(type, "optional");
329
- }
330
- break;
331
-
332
- case "oneof":
333
- parseOneOf(type, token);
334
- break;
335
-
336
- case "extensions":
337
- readRanges(type.extensions || (type.extensions = []));
338
- break;
339
-
340
- case "reserved":
341
- readRanges(type.reserved || (type.reserved = []), true);
342
- break;
343
-
344
- default:
345
- /* istanbul ignore if */
346
- if (!isProto3 || !typeRefRe.test(token))
347
- throw illegal(token);
348
-
349
- push(token);
350
- parseField(type, "optional");
351
- break;
352
- }
353
- });
354
- parent.add(type);
355
- }
356
-
357
- function parseField(parent, rule, extend) {
358
- var type = next();
359
- if (type === "group") {
360
- parseGroup(parent, rule);
361
- return;
362
- }
363
- // Type names can consume multiple tokens, in multiple variants:
364
- // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
365
- // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
366
- // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
367
- // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
368
- // Keep reading tokens until we get a type name with no period at the end,
369
- // and the next token does not start with a period.
370
- while (type.endsWith(".") || peek().startsWith(".")) {
371
- type += next();
372
- }
373
-
374
- /* istanbul ignore if */
375
- if (!typeRefRe.test(type))
376
- throw illegal(type, "type");
377
-
378
- var name = next();
379
-
380
- /* istanbul ignore if */
381
- if (!nameRe.test(name))
382
- throw illegal(name, "name");
383
-
384
- name = applyCase(name);
385
- skip("=");
386
-
387
- var field = new Field(name, parseId(next()), type, rule, extend);
388
- ifBlock(field, function parseField_block(token) {
389
-
390
- /* istanbul ignore else */
391
- if (token === "option") {
392
- parseOption(field, token);
393
- skip(";");
394
- } else
395
- throw illegal(token);
396
-
397
- }, function parseField_line() {
398
- parseInlineOptions(field);
399
- });
400
-
401
- if (rule === "proto3_optional") {
402
- // for proto3 optional fields, we create a single-member Oneof to mimic "optional" behavior
403
- var oneof = new OneOf("_" + name);
404
- field.setOption("proto3_optional", true);
405
- oneof.add(field);
406
- parent.add(oneof);
407
- } else {
408
- parent.add(field);
409
- }
410
-
411
- // JSON defaults to packed=true if not set so we have to set packed=false explicity when
412
- // parsing proto2 descriptors without the option, where applicable. This must be done for
413
- // all known packable types and anything that could be an enum (= is not a basic type).
414
- if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))
415
- field.setOption("packed", false, /* ifNotSet */ true);
416
- }
417
-
418
- function parseGroup(parent, rule) {
419
- var name = next();
420
-
421
- /* istanbul ignore if */
422
- if (!nameRe.test(name))
423
- throw illegal(name, "name");
424
-
425
- var fieldName = util.lcFirst(name);
426
- if (name === fieldName)
427
- name = util.ucFirst(name);
428
- skip("=");
429
- var id = parseId(next());
430
- var type = new Type(name);
431
- type.group = true;
432
- var field = new Field(fieldName, id, name, rule);
433
- field.filename = parse.filename;
434
- ifBlock(type, function parseGroup_block(token) {
435
- switch (token) {
436
-
437
- case "option":
438
- parseOption(type, token);
439
- skip(";");
440
- break;
441
-
442
- case "required":
443
- case "repeated":
444
- parseField(type, token);
445
- break;
446
-
447
- case "optional":
448
- /* istanbul ignore if */
449
- if (isProto3) {
450
- parseField(type, "proto3_optional");
451
- } else {
452
- parseField(type, "optional");
453
- }
454
- break;
455
-
456
- case "message":
457
- parseType(type, token);
458
- break;
459
-
460
- case "enum":
461
- parseEnum(type, token);
462
- break;
463
-
464
- /* istanbul ignore next */
465
- default:
466
- throw illegal(token); // there are no groups with proto3 semantics
467
- }
468
- });
469
- parent.add(type)
470
- .add(field);
471
- }
472
-
473
- function parseMapField(parent) {
474
- skip("<");
475
- var keyType = next();
476
-
477
- /* istanbul ignore if */
478
- if (types.mapKey[keyType] === undefined)
479
- throw illegal(keyType, "type");
480
-
481
- skip(",");
482
- var valueType = next();
483
-
484
- /* istanbul ignore if */
485
- if (!typeRefRe.test(valueType))
486
- throw illegal(valueType, "type");
487
-
488
- skip(">");
489
- var name = next();
490
-
491
- /* istanbul ignore if */
492
- if (!nameRe.test(name))
493
- throw illegal(name, "name");
494
-
495
- skip("=");
496
- var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);
497
- ifBlock(field, function parseMapField_block(token) {
498
-
499
- /* istanbul ignore else */
500
- if (token === "option") {
501
- parseOption(field, token);
502
- skip(";");
503
- } else
504
- throw illegal(token);
505
-
506
- }, function parseMapField_line() {
507
- parseInlineOptions(field);
508
- });
509
- parent.add(field);
510
- }
511
-
512
- function parseOneOf(parent, token) {
513
-
514
- /* istanbul ignore if */
515
- if (!nameRe.test(token = next()))
516
- throw illegal(token, "name");
517
-
518
- var oneof = new OneOf(applyCase(token));
519
- ifBlock(oneof, function parseOneOf_block(token) {
520
- if (token === "option") {
521
- parseOption(oneof, token);
522
- skip(";");
523
- } else {
524
- push(token);
525
- parseField(oneof, "optional");
526
- }
527
- });
528
- parent.add(oneof);
529
- }
530
-
531
- function parseEnum(parent, token) {
532
-
533
- /* istanbul ignore if */
534
- if (!nameRe.test(token = next()))
535
- throw illegal(token, "name");
536
-
537
- var enm = new Enum(token);
538
- ifBlock(enm, function parseEnum_block(token) {
539
- switch(token) {
540
- case "option":
541
- parseOption(enm, token);
542
- skip(";");
543
- break;
544
-
545
- case "reserved":
546
- readRanges(enm.reserved || (enm.reserved = []), true);
547
- break;
548
-
549
- default:
550
- parseEnumValue(enm, token);
551
- }
552
- });
553
- parent.add(enm);
554
- }
555
-
556
- function parseEnumValue(parent, token) {
557
-
558
- /* istanbul ignore if */
559
- if (!nameRe.test(token))
560
- throw illegal(token, "name");
561
-
562
- skip("=");
563
- var value = parseId(next(), true),
564
- dummy = {
565
- options: undefined
566
- };
567
- dummy.setOption = function(name, value) {
568
- if (this.options === undefined)
569
- this.options = {};
570
- this.options[name] = value;
571
- };
572
- ifBlock(dummy, function parseEnumValue_block(token) {
573
-
574
- /* istanbul ignore else */
575
- if (token === "option") {
576
- parseOption(dummy, token); // skip
577
- skip(";");
578
- } else
579
- throw illegal(token);
580
-
581
- }, function parseEnumValue_line() {
582
- parseInlineOptions(dummy); // skip
583
- });
584
- parent.add(token, value, dummy.comment, dummy.options);
585
- }
586
-
587
- function parseOption(parent, token) {
588
- var isCustom = skip("(", true);
589
-
590
- /* istanbul ignore if */
591
- if (!typeRefRe.test(token = next()))
592
- throw illegal(token, "name");
593
-
594
- var name = token;
595
- var option = name;
596
- var propName;
597
-
598
- if (isCustom) {
599
- skip(")");
600
- name = "(" + name + ")";
601
- option = name;
602
- token = peek();
603
- if (fqTypeRefRe.test(token)) {
604
- propName = token.slice(1); //remove '.' before property name
605
- name += token;
606
- next();
607
- }
608
- }
609
- skip("=");
610
- var optionValue = parseOptionValue(parent, name);
611
- setParsedOption(parent, option, optionValue, propName);
612
- }
613
-
614
- function parseOptionValue(parent, name) {
615
- // { a: "foo" b { c: "bar" } }
616
- if (skip("{", true)) {
617
- var objectResult = {};
618
-
619
- while (!skip("}", true)) {
620
- /* istanbul ignore if */
621
- if (!nameRe.test(token = next())) {
622
- throw illegal(token, "name");
623
- }
624
- if (token === null) {
625
- throw illegal(token, "end of input");
626
- }
627
-
628
- var value;
629
- var propName = token;
630
-
631
- skip(":", true);
632
-
633
- if (peek() === "{")
634
- value = parseOptionValue(parent, name + "." + token);
635
- else if (peek() === "[") {
636
- // option (my_option) = {
637
- // repeated_value: [ "foo", "bar" ]
638
- // };
639
- value = [];
640
- var lastValue;
641
- if (skip("[", true)) {
642
- do {
643
- lastValue = readValue(true);
644
- value.push(lastValue);
645
- } while (skip(",", true));
646
- skip("]");
647
- if (typeof lastValue !== "undefined") {
648
- setOption(parent, name + "." + token, lastValue);
649
- }
650
- }
651
- } else {
652
- value = readValue(true);
653
- setOption(parent, name + "." + token, value);
654
- }
655
-
656
- var prevValue = objectResult[propName];
657
-
658
- if (prevValue)
659
- value = [].concat(prevValue).concat(value);
660
-
661
- objectResult[propName] = value;
662
-
663
- // Semicolons and commas can be optional
664
- skip(",", true);
665
- skip(";", true);
666
- }
667
-
668
- return objectResult;
669
- }
670
-
671
- var simpleValue = readValue(true);
672
- setOption(parent, name, simpleValue);
673
- return simpleValue;
674
- // Does not enforce a delimiter to be universal
675
- }
676
-
677
- function setOption(parent, name, value) {
678
- if (parent.setOption)
679
- parent.setOption(name, value);
680
- }
681
-
682
- function setParsedOption(parent, name, value, propName) {
683
- if (parent.setParsedOption)
684
- parent.setParsedOption(name, value, propName);
685
- }
686
-
687
- function parseInlineOptions(parent) {
688
- if (skip("[", true)) {
689
- do {
690
- parseOption(parent, "option");
691
- } while (skip(",", true));
692
- skip("]");
693
- }
694
- return parent;
695
- }
696
-
697
- function parseService(parent, token) {
698
-
699
- /* istanbul ignore if */
700
- if (!nameRe.test(token = next()))
701
- throw illegal(token, "service name");
702
-
703
- var service = new Service(token);
704
- ifBlock(service, function parseService_block(token) {
705
- if (parseCommon(service, token))
706
- return;
707
-
708
- /* istanbul ignore else */
709
- if (token === "rpc")
710
- parseMethod(service, token);
711
- else
712
- throw illegal(token);
713
- });
714
- parent.add(service);
715
- }
716
-
717
- function parseMethod(parent, token) {
718
- // Get the comment of the preceding line now (if one exists) in case the
719
- // method is defined across multiple lines.
720
- var commentText = cmnt();
721
-
722
- var type = token;
723
-
724
- /* istanbul ignore if */
725
- if (!nameRe.test(token = next()))
726
- throw illegal(token, "name");
727
-
728
- var name = token,
729
- requestType, requestStream,
730
- responseType, responseStream;
731
-
732
- skip("(");
733
- if (skip("stream", true))
734
- requestStream = true;
735
-
736
- /* istanbul ignore if */
737
- if (!typeRefRe.test(token = next()))
738
- throw illegal(token);
739
-
740
- requestType = token;
741
- skip(")"); skip("returns"); skip("(");
742
- if (skip("stream", true))
743
- responseStream = true;
744
-
745
- /* istanbul ignore if */
746
- if (!typeRefRe.test(token = next()))
747
- throw illegal(token);
748
-
749
- responseType = token;
750
- skip(")");
751
-
752
- var method = new Method(name, type, requestType, responseType, requestStream, responseStream);
753
- method.comment = commentText;
754
- ifBlock(method, function parseMethod_block(token) {
755
-
756
- /* istanbul ignore else */
757
- if (token === "option") {
758
- parseOption(method, token);
759
- skip(";");
760
- } else
761
- throw illegal(token);
762
-
763
- });
764
- parent.add(method);
765
- }
766
-
767
- function parseExtension(parent, token) {
768
-
769
- /* istanbul ignore if */
770
- if (!typeRefRe.test(token = next()))
771
- throw illegal(token, "reference");
772
-
773
- var reference = token;
774
- ifBlock(null, function parseExtension_block(token) {
775
- switch (token) {
776
-
777
- case "required":
778
- case "repeated":
779
- parseField(parent, token, reference);
780
- break;
781
-
782
- case "optional":
783
- /* istanbul ignore if */
784
- if (isProto3) {
785
- parseField(parent, "proto3_optional", reference);
786
- } else {
787
- parseField(parent, "optional", reference);
788
- }
789
- break;
790
-
791
- default:
792
- /* istanbul ignore if */
793
- if (!isProto3 || !typeRefRe.test(token))
794
- throw illegal(token);
795
- push(token);
796
- parseField(parent, "optional", reference);
797
- break;
798
- }
799
- });
800
- }
801
-
802
- var token;
803
- while ((token = next()) !== null) {
804
- switch (token) {
805
-
806
- case "package":
807
-
808
- /* istanbul ignore if */
809
- if (!head)
810
- throw illegal(token);
811
-
812
- parsePackage();
813
- break;
814
-
815
- case "import":
816
-
817
- /* istanbul ignore if */
818
- if (!head)
819
- throw illegal(token);
820
-
821
- parseImport();
822
- break;
823
-
824
- case "syntax":
825
-
826
- /* istanbul ignore if */
827
- if (!head)
828
- throw illegal(token);
829
-
830
- parseSyntax();
831
- break;
832
-
833
- case "option":
834
-
835
- parseOption(ptr, token);
836
- skip(";");
837
- break;
838
-
839
- default:
840
-
841
- /* istanbul ignore else */
842
- if (parseCommon(ptr, token)) {
843
- head = false;
844
- continue;
845
- }
846
-
847
- /* istanbul ignore next */
848
- throw illegal(token);
849
- }
850
- }
851
-
852
- parse.filename = null;
853
- return {
854
- "package" : pkg,
855
- "imports" : imports,
856
- weakImports : weakImports,
857
- syntax : syntax,
858
- root : root
859
- };
860
- }
861
-
862
- /**
863
- * Parses the given .proto source and returns an object with the parsed contents.
864
- * @name parse
865
- * @function
866
- * @param {string} source Source contents
867
- * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
868
- * @returns {IParserResult} Parser result
869
- * @property {string} filename=null Currently processing file name for error reporting, if known
870
- * @property {IParseOptions} defaults Default {@link IParseOptions}
871
- * @variation 2
872
- */
1
+ "use strict";
2
+ module.exports = parse;
3
+
4
+ parse.filename = null;
5
+ parse.defaults = { keepCase: false };
6
+
7
+ var tokenize = require("./tokenize"),
8
+ Root = require("./root"),
9
+ Type = require("./type"),
10
+ Field = require("./field"),
11
+ MapField = require("./mapfield"),
12
+ OneOf = require("./oneof"),
13
+ Enum = require("./enum"),
14
+ Service = require("./service"),
15
+ Method = require("./method"),
16
+ types = require("./types"),
17
+ util = require("./util");
18
+
19
+ var base10Re = /^[1-9][0-9]*$/,
20
+ base10NegRe = /^-?[1-9][0-9]*$/,
21
+ base16Re = /^0[x][0-9a-fA-F]+$/,
22
+ base16NegRe = /^-?0[x][0-9a-fA-F]+$/,
23
+ base8Re = /^0[0-7]+$/,
24
+ base8NegRe = /^-?0[0-7]+$/,
25
+ numberRe = /^(?![eE])[0-9]*(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?$/,
26
+ nameRe = /^[a-zA-Z_][a-zA-Z_0-9]*$/,
27
+ typeRefRe = /^(?:\.?[a-zA-Z_][a-zA-Z_0-9]*)(?:\.[a-zA-Z_][a-zA-Z_0-9]*)*$/,
28
+ fqTypeRefRe = /^(?:\.[a-zA-Z_][a-zA-Z_0-9]*)+$/;
29
+
30
+ /**
31
+ * Result object returned from {@link parse}.
32
+ * @interface IParserResult
33
+ * @property {string|undefined} package Package name, if declared
34
+ * @property {string[]|undefined} imports Imports, if any
35
+ * @property {string[]|undefined} weakImports Weak imports, if any
36
+ * @property {string|undefined} syntax Syntax, if specified (either `"proto2"` or `"proto3"`)
37
+ * @property {Root} root Populated root instance
38
+ */
39
+
40
+ /**
41
+ * Options modifying the behavior of {@link parse}.
42
+ * @interface IParseOptions
43
+ * @property {boolean} [keepCase=false] Keeps field casing instead of converting to camel case
44
+ * @property {boolean} [alternateCommentMode=false] Recognize double-slash comments in addition to doc-block comments.
45
+ * @property {boolean} [preferTrailingComment=false] Use trailing comment when both leading comment and trailing comment exist.
46
+ */
47
+
48
+ /**
49
+ * Options modifying the behavior of JSON serialization.
50
+ * @interface IToJSONOptions
51
+ * @property {boolean} [keepComments=false] Serializes comments.
52
+ */
53
+
54
+ /**
55
+ * Parses the given .proto source and returns an object with the parsed contents.
56
+ * @param {string} source Source contents
57
+ * @param {Root} root Root to populate
58
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
59
+ * @returns {IParserResult} Parser result
60
+ * @property {string} filename=null Currently processing file name for error reporting, if known
61
+ * @property {IParseOptions} defaults Default {@link IParseOptions}
62
+ */
63
+ function parse(source, root, options) {
64
+ /* eslint-disable callback-return */
65
+ if (!(root instanceof Root)) {
66
+ options = root;
67
+ root = new Root();
68
+ }
69
+ if (!options)
70
+ options = parse.defaults;
71
+
72
+ var preferTrailingComment = options.preferTrailingComment || false;
73
+ var tn = tokenize(source, options.alternateCommentMode || false),
74
+ next = tn.next,
75
+ push = tn.push,
76
+ peek = tn.peek,
77
+ skip = tn.skip,
78
+ cmnt = tn.cmnt;
79
+
80
+ var head = true,
81
+ pkg,
82
+ imports,
83
+ weakImports,
84
+ syntax,
85
+ isProto3 = false;
86
+
87
+ var ptr = root;
88
+
89
+ var applyCase = options.keepCase ? function(name) { return name; } : util.camelCase;
90
+
91
+ /* istanbul ignore next */
92
+ function illegal(token, name, insideTryCatch) {
93
+ var filename = parse.filename;
94
+ if (!insideTryCatch)
95
+ parse.filename = null;
96
+ return Error("illegal " + (name || "token") + " '" + token + "' (" + (filename ? filename + ", " : "") + "line " + tn.line + ")");
97
+ }
98
+
99
+ function readString() {
100
+ var values = [],
101
+ token;
102
+ do {
103
+ /* istanbul ignore if */
104
+ if ((token = next()) !== "\"" && token !== "'")
105
+ throw illegal(token);
106
+
107
+ values.push(next());
108
+ skip(token);
109
+ token = peek();
110
+ } while (token === "\"" || token === "'");
111
+ return values.join("");
112
+ }
113
+
114
+ function readValue(acceptTypeRef) {
115
+ var token = next();
116
+ switch (token) {
117
+ case "'":
118
+ case "\"":
119
+ push(token);
120
+ return readString();
121
+ case "true": case "TRUE":
122
+ return true;
123
+ case "false": case "FALSE":
124
+ return false;
125
+ }
126
+ try {
127
+ return parseNumber(token, /* insideTryCatch */ true);
128
+ } catch (e) {
129
+
130
+ /* istanbul ignore else */
131
+ if (acceptTypeRef && typeRefRe.test(token))
132
+ return token;
133
+
134
+ /* istanbul ignore next */
135
+ throw illegal(token, "value");
136
+ }
137
+ }
138
+
139
+ function readRanges(target, acceptStrings) {
140
+ var token, start;
141
+ do {
142
+ if (acceptStrings && ((token = peek()) === "\"" || token === "'"))
143
+ target.push(readString());
144
+ else
145
+ target.push([ start = parseId(next()), skip("to", true) ? parseId(next()) : start ]);
146
+ } while (skip(",", true));
147
+ var dummy = {options: undefined};
148
+ dummy.setOption = function(name, value) {
149
+ if (this.options === undefined) this.options = {};
150
+ this.options[name] = value;
151
+ };
152
+ ifBlock(
153
+ dummy,
154
+ function parseRange_block(token) {
155
+ /* istanbul ignore else */
156
+ if (token === "option") {
157
+ parseOption(dummy, token); // skip
158
+ skip(";");
159
+ } else
160
+ throw illegal(token);
161
+ },
162
+ function parseRange_line() {
163
+ parseInlineOptions(dummy); // skip
164
+ });
165
+ }
166
+
167
+ function parseNumber(token, insideTryCatch) {
168
+ var sign = 1;
169
+ if (token.charAt(0) === "-") {
170
+ sign = -1;
171
+ token = token.substring(1);
172
+ }
173
+ switch (token) {
174
+ case "inf": case "INF": case "Inf":
175
+ return sign * Infinity;
176
+ case "nan": case "NAN": case "Nan": case "NaN":
177
+ return NaN;
178
+ case "0":
179
+ return 0;
180
+ }
181
+ if (base10Re.test(token))
182
+ return sign * parseInt(token, 10);
183
+ if (base16Re.test(token))
184
+ return sign * parseInt(token, 16);
185
+ if (base8Re.test(token))
186
+ return sign * parseInt(token, 8);
187
+
188
+ /* istanbul ignore else */
189
+ if (numberRe.test(token))
190
+ return sign * parseFloat(token);
191
+
192
+ /* istanbul ignore next */
193
+ throw illegal(token, "number", insideTryCatch);
194
+ }
195
+
196
+ function parseId(token, acceptNegative) {
197
+ switch (token) {
198
+ case "max": case "MAX": case "Max":
199
+ return 536870911;
200
+ case "0":
201
+ return 0;
202
+ }
203
+
204
+ /* istanbul ignore if */
205
+ if (!acceptNegative && token.charAt(0) === "-")
206
+ throw illegal(token, "id");
207
+
208
+ if (base10NegRe.test(token))
209
+ return parseInt(token, 10);
210
+ if (base16NegRe.test(token))
211
+ return parseInt(token, 16);
212
+
213
+ /* istanbul ignore else */
214
+ if (base8NegRe.test(token))
215
+ return parseInt(token, 8);
216
+
217
+ /* istanbul ignore next */
218
+ throw illegal(token, "id");
219
+ }
220
+
221
+ function parsePackage() {
222
+
223
+ /* istanbul ignore if */
224
+ if (pkg !== undefined)
225
+ throw illegal("package");
226
+
227
+ pkg = next();
228
+
229
+ /* istanbul ignore if */
230
+ if (!typeRefRe.test(pkg))
231
+ throw illegal(pkg, "name");
232
+
233
+ ptr = ptr.define(pkg);
234
+ skip(";");
235
+ }
236
+
237
+ function parseImport() {
238
+ var token = peek();
239
+ var whichImports;
240
+ switch (token) {
241
+ case "weak":
242
+ whichImports = weakImports || (weakImports = []);
243
+ next();
244
+ break;
245
+ case "public":
246
+ next();
247
+ // eslint-disable-next-line no-fallthrough
248
+ default:
249
+ whichImports = imports || (imports = []);
250
+ break;
251
+ }
252
+ token = readString();
253
+ skip(";");
254
+ whichImports.push(token);
255
+ }
256
+
257
+ function parseSyntax() {
258
+ skip("=");
259
+ syntax = readString();
260
+ isProto3 = syntax === "proto3";
261
+
262
+ /* istanbul ignore if */
263
+ if (!isProto3 && syntax !== "proto2")
264
+ throw illegal(syntax, "syntax");
265
+
266
+ skip(";");
267
+ }
268
+
269
+ function parseCommon(parent, token) {
270
+ switch (token) {
271
+
272
+ case "option":
273
+ parseOption(parent, token);
274
+ skip(";");
275
+ return true;
276
+
277
+ case "message":
278
+ parseType(parent, token);
279
+ return true;
280
+
281
+ case "enum":
282
+ parseEnum(parent, token);
283
+ return true;
284
+
285
+ case "service":
286
+ parseService(parent, token);
287
+ return true;
288
+
289
+ case "extend":
290
+ parseExtension(parent, token);
291
+ return true;
292
+ }
293
+ return false;
294
+ }
295
+
296
+ function ifBlock(obj, fnIf, fnElse) {
297
+ var trailingLine = tn.line;
298
+ if (obj) {
299
+ if(typeof obj.comment !== "string") {
300
+ obj.comment = cmnt(); // try block-type comment
301
+ }
302
+ obj.filename = parse.filename;
303
+ }
304
+ if (skip("{", true)) {
305
+ var token;
306
+ while ((token = next()) !== "}")
307
+ fnIf(token);
308
+ skip(";", true);
309
+ } else {
310
+ if (fnElse)
311
+ fnElse();
312
+ skip(";");
313
+ if (obj && (typeof obj.comment !== "string" || preferTrailingComment))
314
+ obj.comment = cmnt(trailingLine) || obj.comment; // try line-type comment
315
+ }
316
+ }
317
+
318
+ function parseType(parent, token) {
319
+
320
+ /* istanbul ignore if */
321
+ if (!nameRe.test(token = next()))
322
+ throw illegal(token, "type name");
323
+
324
+ var type = new Type(token);
325
+ ifBlock(type, function parseType_block(token) {
326
+ if (parseCommon(type, token))
327
+ return;
328
+
329
+ switch (token) {
330
+
331
+ case "map":
332
+ parseMapField(type, token);
333
+ break;
334
+
335
+ case "required":
336
+ case "repeated":
337
+ parseField(type, token);
338
+ break;
339
+
340
+ case "optional":
341
+ /* istanbul ignore if */
342
+ if (isProto3) {
343
+ parseField(type, "proto3_optional");
344
+ } else {
345
+ parseField(type, "optional");
346
+ }
347
+ break;
348
+
349
+ case "oneof":
350
+ parseOneOf(type, token);
351
+ break;
352
+
353
+ case "extensions":
354
+ readRanges(type.extensions || (type.extensions = []));
355
+ break;
356
+
357
+ case "reserved":
358
+ readRanges(type.reserved || (type.reserved = []), true);
359
+ break;
360
+
361
+ default:
362
+ /* istanbul ignore if */
363
+ if (!isProto3 || !typeRefRe.test(token))
364
+ throw illegal(token);
365
+
366
+ push(token);
367
+ parseField(type, "optional");
368
+ break;
369
+ }
370
+ });
371
+ parent.add(type);
372
+ }
373
+
374
+ function parseField(parent, rule, extend) {
375
+ var type = next();
376
+ if (type === "group") {
377
+ parseGroup(parent, rule);
378
+ return;
379
+ }
380
+ // Type names can consume multiple tokens, in multiple variants:
381
+ // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
382
+ // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
383
+ // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
384
+ // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
385
+ // Keep reading tokens until we get a type name with no period at the end,
386
+ // and the next token does not start with a period.
387
+ while (type.endsWith(".") || peek().startsWith(".")) {
388
+ type += next();
389
+ }
390
+
391
+ /* istanbul ignore if */
392
+ if (!typeRefRe.test(type))
393
+ throw illegal(type, "type");
394
+
395
+ var name = next();
396
+
397
+ /* istanbul ignore if */
398
+ if (!nameRe.test(name))
399
+ throw illegal(name, "name");
400
+
401
+ name = applyCase(name);
402
+ skip("=");
403
+
404
+ var field = new Field(name, parseId(next()), type, rule, extend);
405
+ ifBlock(field, function parseField_block(token) {
406
+
407
+ /* istanbul ignore else */
408
+ if (token === "option") {
409
+ parseOption(field, token);
410
+ skip(";");
411
+ } else
412
+ throw illegal(token);
413
+
414
+ }, function parseField_line() {
415
+ parseInlineOptions(field);
416
+ });
417
+
418
+ if (rule === "proto3_optional") {
419
+ // for proto3 optional fields, we create a single-member Oneof to mimic "optional" behavior
420
+ var oneof = new OneOf("_" + name);
421
+ field.setOption("proto3_optional", true);
422
+ oneof.add(field);
423
+ parent.add(oneof);
424
+ } else {
425
+ parent.add(field);
426
+ }
427
+
428
+ // JSON defaults to packed=true if not set so we have to set packed=false explicity when
429
+ // parsing proto2 descriptors without the option, where applicable. This must be done for
430
+ // all known packable types and anything that could be an enum (= is not a basic type).
431
+ if (!isProto3 && field.repeated && (types.packed[type] !== undefined || types.basic[type] === undefined))
432
+ field.setOption("packed", false, /* ifNotSet */ true);
433
+ }
434
+
435
+ function parseGroup(parent, rule) {
436
+ var name = next();
437
+
438
+ /* istanbul ignore if */
439
+ if (!nameRe.test(name))
440
+ throw illegal(name, "name");
441
+
442
+ var fieldName = util.lcFirst(name);
443
+ if (name === fieldName)
444
+ name = util.ucFirst(name);
445
+ skip("=");
446
+ var id = parseId(next());
447
+ var type = new Type(name);
448
+ type.group = true;
449
+ var field = new Field(fieldName, id, name, rule);
450
+ field.filename = parse.filename;
451
+ ifBlock(type, function parseGroup_block(token) {
452
+ switch (token) {
453
+
454
+ case "option":
455
+ parseOption(type, token);
456
+ skip(";");
457
+ break;
458
+
459
+ case "required":
460
+ case "repeated":
461
+ parseField(type, token);
462
+ break;
463
+
464
+ case "optional":
465
+ /* istanbul ignore if */
466
+ if (isProto3) {
467
+ parseField(type, "proto3_optional");
468
+ } else {
469
+ parseField(type, "optional");
470
+ }
471
+ break;
472
+
473
+ case "message":
474
+ parseType(type, token);
475
+ break;
476
+
477
+ case "enum":
478
+ parseEnum(type, token);
479
+ break;
480
+
481
+ /* istanbul ignore next */
482
+ default:
483
+ throw illegal(token); // there are no groups with proto3 semantics
484
+ }
485
+ });
486
+ parent.add(type)
487
+ .add(field);
488
+ }
489
+
490
+ function parseMapField(parent) {
491
+ skip("<");
492
+ var keyType = next();
493
+
494
+ /* istanbul ignore if */
495
+ if (types.mapKey[keyType] === undefined)
496
+ throw illegal(keyType, "type");
497
+
498
+ skip(",");
499
+ var valueType = next();
500
+
501
+ /* istanbul ignore if */
502
+ if (!typeRefRe.test(valueType))
503
+ throw illegal(valueType, "type");
504
+
505
+ skip(">");
506
+ var name = next();
507
+
508
+ /* istanbul ignore if */
509
+ if (!nameRe.test(name))
510
+ throw illegal(name, "name");
511
+
512
+ skip("=");
513
+ var field = new MapField(applyCase(name), parseId(next()), keyType, valueType);
514
+ ifBlock(field, function parseMapField_block(token) {
515
+
516
+ /* istanbul ignore else */
517
+ if (token === "option") {
518
+ parseOption(field, token);
519
+ skip(";");
520
+ } else
521
+ throw illegal(token);
522
+
523
+ }, function parseMapField_line() {
524
+ parseInlineOptions(field);
525
+ });
526
+ parent.add(field);
527
+ }
528
+
529
+ function parseOneOf(parent, token) {
530
+
531
+ /* istanbul ignore if */
532
+ if (!nameRe.test(token = next()))
533
+ throw illegal(token, "name");
534
+
535
+ var oneof = new OneOf(applyCase(token));
536
+ ifBlock(oneof, function parseOneOf_block(token) {
537
+ if (token === "option") {
538
+ parseOption(oneof, token);
539
+ skip(";");
540
+ } else {
541
+ push(token);
542
+ parseField(oneof, "optional");
543
+ }
544
+ });
545
+ parent.add(oneof);
546
+ }
547
+
548
+ function parseEnum(parent, token) {
549
+
550
+ /* istanbul ignore if */
551
+ if (!nameRe.test(token = next()))
552
+ throw illegal(token, "name");
553
+
554
+ var enm = new Enum(token);
555
+ ifBlock(enm, function parseEnum_block(token) {
556
+ switch(token) {
557
+ case "option":
558
+ parseOption(enm, token);
559
+ skip(";");
560
+ break;
561
+
562
+ case "reserved":
563
+ readRanges(enm.reserved || (enm.reserved = []), true);
564
+ break;
565
+
566
+ default:
567
+ parseEnumValue(enm, token);
568
+ }
569
+ });
570
+ parent.add(enm);
571
+ }
572
+
573
+ function parseEnumValue(parent, token) {
574
+
575
+ /* istanbul ignore if */
576
+ if (!nameRe.test(token))
577
+ throw illegal(token, "name");
578
+
579
+ skip("=");
580
+ var value = parseId(next(), true),
581
+ dummy = {
582
+ options: undefined
583
+ };
584
+ dummy.setOption = function(name, value) {
585
+ if (this.options === undefined)
586
+ this.options = {};
587
+ this.options[name] = value;
588
+ };
589
+ ifBlock(dummy, function parseEnumValue_block(token) {
590
+
591
+ /* istanbul ignore else */
592
+ if (token === "option") {
593
+ parseOption(dummy, token); // skip
594
+ skip(";");
595
+ } else
596
+ throw illegal(token);
597
+
598
+ }, function parseEnumValue_line() {
599
+ parseInlineOptions(dummy); // skip
600
+ });
601
+ parent.add(token, value, dummy.comment, dummy.options);
602
+ }
603
+
604
+ function parseOption(parent, token) {
605
+ var isCustom = skip("(", true);
606
+
607
+ /* istanbul ignore if */
608
+ if (!typeRefRe.test(token = next()))
609
+ throw illegal(token, "name");
610
+
611
+ var name = token;
612
+ var option = name;
613
+ var propName;
614
+
615
+ if (isCustom) {
616
+ skip(")");
617
+ name = "(" + name + ")";
618
+ option = name;
619
+ token = peek();
620
+ if (fqTypeRefRe.test(token)) {
621
+ propName = token.slice(1); //remove '.' before property name
622
+ name += token;
623
+ next();
624
+ }
625
+ }
626
+ skip("=");
627
+ var optionValue = parseOptionValue(parent, name);
628
+ setParsedOption(parent, option, optionValue, propName);
629
+ }
630
+
631
+ function parseOptionValue(parent, name) {
632
+ // { a: "foo" b { c: "bar" } }
633
+ if (skip("{", true)) {
634
+ var objectResult = {};
635
+
636
+ while (!skip("}", true)) {
637
+ /* istanbul ignore if */
638
+ if (!nameRe.test(token = next())) {
639
+ throw illegal(token, "name");
640
+ }
641
+ if (token === null) {
642
+ throw illegal(token, "end of input");
643
+ }
644
+
645
+ var value;
646
+ var propName = token;
647
+
648
+ skip(":", true);
649
+
650
+ if (peek() === "{")
651
+ value = parseOptionValue(parent, name + "." + token);
652
+ else if (peek() === "[") {
653
+ // option (my_option) = {
654
+ // repeated_value: [ "foo", "bar" ]
655
+ // };
656
+ value = [];
657
+ var lastValue;
658
+ if (skip("[", true)) {
659
+ do {
660
+ lastValue = readValue(true);
661
+ value.push(lastValue);
662
+ } while (skip(",", true));
663
+ skip("]");
664
+ if (typeof lastValue !== "undefined") {
665
+ setOption(parent, name + "." + token, lastValue);
666
+ }
667
+ }
668
+ } else {
669
+ value = readValue(true);
670
+ setOption(parent, name + "." + token, value);
671
+ }
672
+
673
+ var prevValue = objectResult[propName];
674
+
675
+ if (prevValue)
676
+ value = [].concat(prevValue).concat(value);
677
+
678
+ objectResult[propName] = value;
679
+
680
+ // Semicolons and commas can be optional
681
+ skip(",", true);
682
+ skip(";", true);
683
+ }
684
+
685
+ return objectResult;
686
+ }
687
+
688
+ var simpleValue = readValue(true);
689
+ setOption(parent, name, simpleValue);
690
+ return simpleValue;
691
+ // Does not enforce a delimiter to be universal
692
+ }
693
+
694
+ function setOption(parent, name, value) {
695
+ if (parent.setOption)
696
+ parent.setOption(name, value);
697
+ }
698
+
699
+ function setParsedOption(parent, name, value, propName) {
700
+ if (parent.setParsedOption)
701
+ parent.setParsedOption(name, value, propName);
702
+ }
703
+
704
+ function parseInlineOptions(parent) {
705
+ if (skip("[", true)) {
706
+ do {
707
+ parseOption(parent, "option");
708
+ } while (skip(",", true));
709
+ skip("]");
710
+ }
711
+ return parent;
712
+ }
713
+
714
+ function parseService(parent, token) {
715
+
716
+ /* istanbul ignore if */
717
+ if (!nameRe.test(token = next()))
718
+ throw illegal(token, "service name");
719
+
720
+ var service = new Service(token);
721
+ ifBlock(service, function parseService_block(token) {
722
+ if (parseCommon(service, token))
723
+ return;
724
+
725
+ /* istanbul ignore else */
726
+ if (token === "rpc")
727
+ parseMethod(service, token);
728
+ else
729
+ throw illegal(token);
730
+ });
731
+ parent.add(service);
732
+ }
733
+
734
+ function parseMethod(parent, token) {
735
+ // Get the comment of the preceding line now (if one exists) in case the
736
+ // method is defined across multiple lines.
737
+ var commentText = cmnt();
738
+
739
+ var type = token;
740
+
741
+ /* istanbul ignore if */
742
+ if (!nameRe.test(token = next()))
743
+ throw illegal(token, "name");
744
+
745
+ var name = token,
746
+ requestType, requestStream,
747
+ responseType, responseStream;
748
+
749
+ skip("(");
750
+ if (skip("stream", true))
751
+ requestStream = true;
752
+
753
+ /* istanbul ignore if */
754
+ if (!typeRefRe.test(token = next()))
755
+ throw illegal(token);
756
+
757
+ requestType = token;
758
+ skip(")"); skip("returns"); skip("(");
759
+ if (skip("stream", true))
760
+ responseStream = true;
761
+
762
+ /* istanbul ignore if */
763
+ if (!typeRefRe.test(token = next()))
764
+ throw illegal(token);
765
+
766
+ responseType = token;
767
+ skip(")");
768
+
769
+ var method = new Method(name, type, requestType, responseType, requestStream, responseStream);
770
+ method.comment = commentText;
771
+ ifBlock(method, function parseMethod_block(token) {
772
+
773
+ /* istanbul ignore else */
774
+ if (token === "option") {
775
+ parseOption(method, token);
776
+ skip(";");
777
+ } else
778
+ throw illegal(token);
779
+
780
+ });
781
+ parent.add(method);
782
+ }
783
+
784
+ function parseExtension(parent, token) {
785
+
786
+ /* istanbul ignore if */
787
+ if (!typeRefRe.test(token = next()))
788
+ throw illegal(token, "reference");
789
+
790
+ var reference = token;
791
+ ifBlock(null, function parseExtension_block(token) {
792
+ switch (token) {
793
+
794
+ case "required":
795
+ case "repeated":
796
+ parseField(parent, token, reference);
797
+ break;
798
+
799
+ case "optional":
800
+ /* istanbul ignore if */
801
+ if (isProto3) {
802
+ parseField(parent, "proto3_optional", reference);
803
+ } else {
804
+ parseField(parent, "optional", reference);
805
+ }
806
+ break;
807
+
808
+ default:
809
+ /* istanbul ignore if */
810
+ if (!isProto3 || !typeRefRe.test(token))
811
+ throw illegal(token);
812
+ push(token);
813
+ parseField(parent, "optional", reference);
814
+ break;
815
+ }
816
+ });
817
+ }
818
+
819
+ var token;
820
+ while ((token = next()) !== null) {
821
+ switch (token) {
822
+
823
+ case "package":
824
+
825
+ /* istanbul ignore if */
826
+ if (!head)
827
+ throw illegal(token);
828
+
829
+ parsePackage();
830
+ break;
831
+
832
+ case "import":
833
+
834
+ /* istanbul ignore if */
835
+ if (!head)
836
+ throw illegal(token);
837
+
838
+ parseImport();
839
+ break;
840
+
841
+ case "syntax":
842
+
843
+ /* istanbul ignore if */
844
+ if (!head)
845
+ throw illegal(token);
846
+
847
+ parseSyntax();
848
+ break;
849
+
850
+ case "option":
851
+
852
+ parseOption(ptr, token);
853
+ skip(";");
854
+ break;
855
+
856
+ default:
857
+
858
+ /* istanbul ignore else */
859
+ if (parseCommon(ptr, token)) {
860
+ head = false;
861
+ continue;
862
+ }
863
+
864
+ /* istanbul ignore next */
865
+ throw illegal(token);
866
+ }
867
+ }
868
+
869
+ parse.filename = null;
870
+ return {
871
+ "package" : pkg,
872
+ "imports" : imports,
873
+ weakImports : weakImports,
874
+ syntax : syntax,
875
+ root : root
876
+ };
877
+ }
878
+
879
+ /**
880
+ * Parses the given .proto source and returns an object with the parsed contents.
881
+ * @name parse
882
+ * @function
883
+ * @param {string} source Source contents
884
+ * @param {IParseOptions} [options] Parse options. Defaults to {@link parse.defaults} when omitted.
885
+ * @returns {IParserResult} Parser result
886
+ * @property {string} filename=null Currently processing file name for error reporting, if known
887
+ * @property {IParseOptions} defaults Default {@link IParseOptions}
888
+ * @variation 2
889
+ */