@azure/storage-blob-changefeed 12.0.0-preview.3 → 12.0.0-preview.5

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 (507) hide show
  1. package/LICENSE +3 -3
  2. package/README.md +87 -47
  3. package/{types/3.1/storage-blob-changefeed/src → dist/browser}/AvroReaderFactory.d.ts +10 -9
  4. package/dist/browser/AvroReaderFactory.d.ts.map +1 -0
  5. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/AvroReaderFactory.js +2 -2
  6. package/dist/browser/AvroReaderFactory.js.map +1 -0
  7. package/dist/browser/BlobChangeFeedClient.d.ts +201 -0
  8. package/dist/browser/BlobChangeFeedClient.d.ts.map +1 -0
  9. package/dist/browser/BlobChangeFeedClient.js +242 -0
  10. package/dist/browser/BlobChangeFeedClient.js.map +1 -0
  11. package/{types/3.1/storage-blob-changefeed/src → dist/browser}/ChangeFeed.d.ts +37 -37
  12. package/dist/browser/ChangeFeed.d.ts.map +1 -0
  13. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/ChangeFeed.js +20 -32
  14. package/dist/browser/ChangeFeed.js.map +1 -0
  15. package/dist/browser/ChangeFeedFactory.d.ts +13 -0
  16. package/dist/browser/ChangeFeedFactory.d.ts.map +1 -0
  17. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/ChangeFeedFactory.js +45 -32
  18. package/dist/browser/ChangeFeedFactory.js.map +1 -0
  19. package/{types/latest/storage-blob-changefeed/src → dist/browser}/Chunk.d.ts +4 -5
  20. package/dist/browser/Chunk.d.ts.map +1 -0
  21. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/Chunk.js +13 -8
  22. package/dist/browser/Chunk.js.map +1 -0
  23. package/{types/latest/storage-blob-changefeed/src → dist/browser}/ChunkFactory.d.ts +7 -6
  24. package/dist/browser/ChunkFactory.d.ts.map +1 -0
  25. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/ChunkFactory.js +11 -7
  26. package/dist/browser/ChunkFactory.js.map +1 -0
  27. package/{types/latest/storage-blob-changefeed/src → dist/browser}/LazyLoadingBlobStream.d.ts +4 -4
  28. package/dist/browser/LazyLoadingBlobStream.d.ts.map +1 -0
  29. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/LazyLoadingBlobStream.js +25 -36
  30. package/dist/browser/LazyLoadingBlobStream.js.map +1 -0
  31. package/dist/browser/LazyLoadingBlobStreamFactory.d.ts +7 -0
  32. package/dist/browser/LazyLoadingBlobStreamFactory.d.ts.map +1 -0
  33. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/LazyLoadingBlobStreamFactory.js +2 -2
  34. package/dist/browser/LazyLoadingBlobStreamFactory.js.map +1 -0
  35. package/{types/latest/storage-blob-changefeed/src → dist/browser}/Segment.d.ts +5 -5
  36. package/dist/browser/Segment.d.ts.map +1 -0
  37. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/Segment.js +16 -19
  38. package/dist/browser/Segment.js.map +1 -0
  39. package/{types/3.1/storage-blob-changefeed/src → dist/browser}/SegmentFactory.d.ts +29 -29
  40. package/dist/browser/SegmentFactory.d.ts.map +1 -0
  41. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/SegmentFactory.js +12 -23
  42. package/dist/browser/SegmentFactory.js.map +1 -0
  43. package/{types/3.1/storage-blob-changefeed/src → dist/browser}/Shard.d.ts +28 -28
  44. package/dist/browser/Shard.d.ts.map +1 -0
  45. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/Shard.js +9 -16
  46. package/dist/browser/Shard.js.map +1 -0
  47. package/{types/latest/storage-blob-changefeed/src → dist/browser}/ShardFactory.d.ts +5 -5
  48. package/dist/browser/ShardFactory.d.ts.map +1 -0
  49. package/dist/browser/ShardFactory.js +55 -0
  50. package/dist/browser/ShardFactory.js.map +1 -0
  51. package/dist/browser/index.d.ts +4 -0
  52. package/dist/browser/index.d.ts.map +1 -0
  53. package/dist/browser/index.js +6 -0
  54. package/dist/browser/index.js.map +1 -0
  55. package/dist/browser/log.d.ts.map +1 -0
  56. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/log.js +1 -1
  57. package/dist/browser/log.js.map +1 -0
  58. package/{types/latest/storage-blob-changefeed/src → dist/browser}/models/BlobChangeFeedEvent.d.ts +5 -5
  59. package/dist/browser/models/BlobChangeFeedEvent.d.ts.map +1 -0
  60. package/dist/browser/models/BlobChangeFeedEvent.js +4 -0
  61. package/dist/browser/models/BlobChangeFeedEvent.js.map +1 -0
  62. package/dist/browser/models/ChangeFeedCursor.d.ts.map +1 -0
  63. package/dist/browser/models/ChangeFeedCursor.js +4 -0
  64. package/dist/browser/models/ChangeFeedCursor.js.map +1 -0
  65. package/{types/latest/storage-blob-changefeed/src → dist/browser}/models/models.d.ts +2 -2
  66. package/dist/browser/models/models.d.ts.map +1 -0
  67. package/dist/browser/models/models.js +4 -0
  68. package/dist/browser/models/models.js.map +1 -0
  69. package/dist/browser/package.json +3 -0
  70. package/dist/browser/utils/constants.d.ts.map +1 -0
  71. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/utils/constants.js +2 -2
  72. package/dist/browser/utils/constants.js.map +1 -0
  73. package/dist/browser/utils/tracing.d.ts +6 -0
  74. package/dist/browser/utils/tracing.d.ts.map +1 -0
  75. package/dist/browser/utils/tracing.js +14 -0
  76. package/dist/browser/utils/tracing.js.map +1 -0
  77. package/{types/latest/storage-blob-changefeed/src → dist/browser}/utils/utils.browser.d.ts +0 -1
  78. package/dist/browser/utils/utils.browser.d.ts.map +1 -0
  79. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/utils/utils.browser.js +1 -1
  80. package/dist/browser/utils/utils.browser.js.map +1 -0
  81. package/{types/latest/storage-blob-changefeed/src → dist/browser}/utils/utils.common.d.ts +3 -10
  82. package/dist/browser/utils/utils.common.d.ts.map +1 -0
  83. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/utils/utils.common.js +26 -91
  84. package/dist/browser/utils/utils.common.js.map +1 -0
  85. package/{types/latest/storage-blob-changefeed/src → dist/browser}/utils/utils.node.d.ts +1 -2
  86. package/dist/browser/utils/utils.node.d.ts.map +1 -0
  87. package/{dist-esm/storage-blob-changefeed/src → dist/browser}/utils/utils.node.js +2 -2
  88. package/dist/browser/utils/utils.node.js.map +1 -0
  89. package/{types/latest/storage-blob-changefeed/src → dist/commonjs}/AvroReaderFactory.d.ts +2 -1
  90. package/dist/commonjs/AvroReaderFactory.d.ts.map +1 -0
  91. package/dist/commonjs/AvroReaderFactory.js +21 -0
  92. package/dist/commonjs/AvroReaderFactory.js.map +1 -0
  93. package/dist/commonjs/BlobChangeFeedClient.d.ts +201 -0
  94. package/dist/commonjs/BlobChangeFeedClient.d.ts.map +1 -0
  95. package/dist/commonjs/BlobChangeFeedClient.js +248 -0
  96. package/dist/commonjs/BlobChangeFeedClient.js.map +1 -0
  97. package/{types/latest/storage-blob-changefeed/src → dist/commonjs}/ChangeFeed.d.ts +6 -6
  98. package/dist/commonjs/ChangeFeed.d.ts.map +1 -0
  99. package/dist/commonjs/ChangeFeed.js +108 -0
  100. package/dist/commonjs/ChangeFeed.js.map +1 -0
  101. package/dist/commonjs/ChangeFeedFactory.d.ts +13 -0
  102. package/dist/commonjs/ChangeFeedFactory.d.ts.map +1 -0
  103. package/dist/commonjs/ChangeFeedFactory.js +126 -0
  104. package/dist/commonjs/ChangeFeedFactory.js.map +1 -0
  105. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/Chunk.d.ts +27 -28
  106. package/dist/commonjs/Chunk.d.ts.map +1 -0
  107. package/dist/commonjs/Chunk.js +49 -0
  108. package/dist/commonjs/Chunk.js.map +1 -0
  109. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/ChunkFactory.d.ts +23 -22
  110. package/dist/commonjs/ChunkFactory.d.ts.map +1 -0
  111. package/dist/commonjs/ChunkFactory.js +37 -0
  112. package/dist/commonjs/ChunkFactory.js.map +1 -0
  113. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/LazyLoadingBlobStream.d.ts +46 -46
  114. package/dist/commonjs/LazyLoadingBlobStream.d.ts.map +1 -0
  115. package/dist/commonjs/LazyLoadingBlobStream.js +96 -0
  116. package/dist/commonjs/LazyLoadingBlobStream.js.map +1 -0
  117. package/dist/commonjs/LazyLoadingBlobStreamFactory.d.ts +7 -0
  118. package/dist/commonjs/LazyLoadingBlobStreamFactory.d.ts.map +1 -0
  119. package/dist/commonjs/LazyLoadingBlobStreamFactory.js +13 -0
  120. package/dist/commonjs/LazyLoadingBlobStreamFactory.js.map +1 -0
  121. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/Segment.d.ts +29 -29
  122. package/dist/commonjs/Segment.d.ts.map +1 -0
  123. package/dist/commonjs/Segment.js +73 -0
  124. package/dist/commonjs/Segment.js.map +1 -0
  125. package/{types/latest/storage-blob-changefeed/src → dist/commonjs}/SegmentFactory.d.ts +5 -5
  126. package/dist/commonjs/SegmentFactory.d.ts.map +1 -0
  127. package/dist/commonjs/SegmentFactory.js +51 -0
  128. package/dist/commonjs/SegmentFactory.js.map +1 -0
  129. package/{types/latest/storage-blob-changefeed/src → dist/commonjs}/Shard.d.ts +6 -6
  130. package/dist/commonjs/Shard.d.ts.map +1 -0
  131. package/dist/commonjs/Shard.js +50 -0
  132. package/dist/commonjs/Shard.js.map +1 -0
  133. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/ShardFactory.d.ts +21 -21
  134. package/dist/commonjs/ShardFactory.d.ts.map +1 -0
  135. package/dist/commonjs/ShardFactory.js +59 -0
  136. package/dist/commonjs/ShardFactory.js.map +1 -0
  137. package/dist/commonjs/index.d.ts +4 -0
  138. package/dist/commonjs/index.d.ts.map +1 -0
  139. package/dist/commonjs/index.js +9 -0
  140. package/dist/commonjs/index.js.map +1 -0
  141. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/log.d.ts +5 -5
  142. package/dist/commonjs/log.d.ts.map +1 -0
  143. package/dist/commonjs/log.js +11 -0
  144. package/dist/commonjs/log.js.map +1 -0
  145. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/models/BlobChangeFeedEvent.d.ts +233 -233
  146. package/dist/commonjs/models/BlobChangeFeedEvent.d.ts.map +1 -0
  147. package/dist/commonjs/models/BlobChangeFeedEvent.js +5 -0
  148. package/dist/commonjs/models/BlobChangeFeedEvent.js.map +1 -0
  149. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/models/ChangeFeedCursor.d.ts +17 -17
  150. package/dist/commonjs/models/ChangeFeedCursor.d.ts.map +1 -0
  151. package/dist/commonjs/models/ChangeFeedCursor.js +5 -0
  152. package/dist/commonjs/models/ChangeFeedCursor.js.map +1 -0
  153. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/models/models.d.ts +23 -23
  154. package/dist/commonjs/models/models.d.ts.map +1 -0
  155. package/dist/commonjs/models/models.js +5 -0
  156. package/dist/commonjs/models/models.js.map +1 -0
  157. package/dist/commonjs/package.json +3 -0
  158. package/{types/latest → dist/commonjs}/tsdoc-metadata.json +11 -11
  159. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/utils/constants.d.ts +9 -9
  160. package/dist/commonjs/utils/constants.d.ts.map +1 -0
  161. package/dist/commonjs/utils/constants.js +14 -0
  162. package/dist/commonjs/utils/constants.js.map +1 -0
  163. package/dist/commonjs/utils/tracing.d.ts +6 -0
  164. package/dist/commonjs/utils/tracing.d.ts.map +1 -0
  165. package/dist/commonjs/utils/tracing.js +17 -0
  166. package/dist/commonjs/utils/tracing.js.map +1 -0
  167. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/utils/utils.browser.d.ts +14 -15
  168. package/dist/commonjs/utils/utils.browser.d.ts.map +1 -0
  169. package/dist/commonjs/utils/utils.browser.js +34 -0
  170. package/dist/commonjs/utils/utils.browser.js.map +1 -0
  171. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/utils/utils.common.d.ts +37 -44
  172. package/dist/commonjs/utils/utils.common.d.ts.map +1 -0
  173. package/dist/commonjs/utils/utils.common.js +180 -0
  174. package/dist/commonjs/utils/utils.common.js.map +1 -0
  175. package/{types/3.1/storage-blob-changefeed/src → dist/commonjs}/utils/utils.node.d.ts +14 -15
  176. package/dist/commonjs/utils/utils.node.d.ts.map +1 -0
  177. package/dist/commonjs/utils/utils.node.js +32 -0
  178. package/dist/commonjs/utils/utils.node.js.map +1 -0
  179. package/dist/esm/AvroReaderFactory.d.ts +10 -0
  180. package/dist/esm/AvroReaderFactory.d.ts.map +1 -0
  181. package/dist/esm/AvroReaderFactory.js +17 -0
  182. package/dist/esm/AvroReaderFactory.js.map +1 -0
  183. package/dist/esm/BlobChangeFeedClient.d.ts +201 -0
  184. package/dist/esm/BlobChangeFeedClient.d.ts.map +1 -0
  185. package/dist/esm/BlobChangeFeedClient.js +242 -0
  186. package/dist/esm/BlobChangeFeedClient.js.map +1 -0
  187. package/dist/esm/ChangeFeed.d.ts +37 -0
  188. package/dist/esm/ChangeFeed.d.ts.map +1 -0
  189. package/dist/esm/ChangeFeed.js +104 -0
  190. package/dist/esm/ChangeFeed.js.map +1 -0
  191. package/dist/esm/ChangeFeedFactory.d.ts +13 -0
  192. package/dist/esm/ChangeFeedFactory.d.ts.map +1 -0
  193. package/dist/esm/ChangeFeedFactory.js +122 -0
  194. package/dist/esm/ChangeFeedFactory.js.map +1 -0
  195. package/dist/esm/Chunk.d.ts +27 -0
  196. package/dist/esm/Chunk.d.ts.map +1 -0
  197. package/dist/esm/Chunk.js +45 -0
  198. package/dist/esm/Chunk.js.map +1 -0
  199. package/dist/esm/ChunkFactory.d.ts +23 -0
  200. package/dist/esm/ChunkFactory.d.ts.map +1 -0
  201. package/dist/esm/ChunkFactory.js +33 -0
  202. package/dist/esm/ChunkFactory.js.map +1 -0
  203. package/dist/esm/LazyLoadingBlobStream.d.ts +46 -0
  204. package/dist/esm/LazyLoadingBlobStream.d.ts.map +1 -0
  205. package/dist/esm/LazyLoadingBlobStream.js +92 -0
  206. package/dist/esm/LazyLoadingBlobStream.js.map +1 -0
  207. package/dist/esm/LazyLoadingBlobStreamFactory.d.ts +7 -0
  208. package/dist/esm/LazyLoadingBlobStreamFactory.d.ts.map +1 -0
  209. package/dist/esm/LazyLoadingBlobStreamFactory.js +9 -0
  210. package/dist/esm/LazyLoadingBlobStreamFactory.js.map +1 -0
  211. package/dist/esm/Segment.d.ts +29 -0
  212. package/dist/esm/Segment.d.ts.map +1 -0
  213. package/dist/esm/Segment.js +69 -0
  214. package/dist/esm/Segment.js.map +1 -0
  215. package/dist/esm/SegmentFactory.d.ts +29 -0
  216. package/dist/esm/SegmentFactory.d.ts.map +1 -0
  217. package/dist/esm/SegmentFactory.js +47 -0
  218. package/dist/esm/SegmentFactory.js.map +1 -0
  219. package/dist/esm/Shard.d.ts +28 -0
  220. package/dist/esm/Shard.d.ts.map +1 -0
  221. package/dist/esm/Shard.js +46 -0
  222. package/dist/esm/Shard.js.map +1 -0
  223. package/dist/esm/ShardFactory.d.ts +21 -0
  224. package/dist/esm/ShardFactory.d.ts.map +1 -0
  225. package/dist/esm/ShardFactory.js +55 -0
  226. package/dist/esm/ShardFactory.js.map +1 -0
  227. package/dist/esm/index.d.ts +4 -0
  228. package/dist/esm/index.d.ts.map +1 -0
  229. package/dist/esm/index.js +6 -0
  230. package/dist/esm/index.js.map +1 -0
  231. package/dist/esm/log.d.ts +5 -0
  232. package/dist/esm/log.d.ts.map +1 -0
  233. package/dist/esm/log.js +8 -0
  234. package/dist/esm/log.js.map +1 -0
  235. package/dist/esm/models/BlobChangeFeedEvent.d.ts +233 -0
  236. package/dist/esm/models/BlobChangeFeedEvent.d.ts.map +1 -0
  237. package/dist/esm/models/BlobChangeFeedEvent.js +4 -0
  238. package/dist/esm/models/BlobChangeFeedEvent.js.map +1 -0
  239. package/dist/esm/models/ChangeFeedCursor.d.ts +17 -0
  240. package/dist/esm/models/ChangeFeedCursor.d.ts.map +1 -0
  241. package/dist/esm/models/ChangeFeedCursor.js +4 -0
  242. package/dist/esm/models/ChangeFeedCursor.js.map +1 -0
  243. package/dist/esm/models/models.d.ts +23 -0
  244. package/dist/esm/models/models.d.ts.map +1 -0
  245. package/dist/esm/models/models.js +4 -0
  246. package/dist/esm/models/models.js.map +1 -0
  247. package/dist/esm/package.json +3 -0
  248. package/dist/esm/utils/constants.d.ts +9 -0
  249. package/dist/esm/utils/constants.d.ts.map +1 -0
  250. package/dist/esm/utils/constants.js +11 -0
  251. package/dist/esm/utils/constants.js.map +1 -0
  252. package/dist/esm/utils/tracing.d.ts +6 -0
  253. package/dist/esm/utils/tracing.d.ts.map +1 -0
  254. package/dist/esm/utils/tracing.js +14 -0
  255. package/dist/esm/utils/tracing.js.map +1 -0
  256. package/dist/esm/utils/utils.browser.d.ts +14 -0
  257. package/dist/esm/utils/utils.browser.d.ts.map +1 -0
  258. package/dist/esm/utils/utils.browser.js +29 -0
  259. package/dist/esm/utils/utils.browser.js.map +1 -0
  260. package/dist/esm/utils/utils.common.d.ts +37 -0
  261. package/dist/esm/utils/utils.common.d.ts.map +1 -0
  262. package/dist/esm/utils/utils.common.js +170 -0
  263. package/dist/esm/utils/utils.common.js.map +1 -0
  264. package/dist/esm/utils/utils.node.d.ts +14 -0
  265. package/dist/esm/utils/utils.node.d.ts.map +1 -0
  266. package/dist/esm/utils/utils.node.js +28 -0
  267. package/dist/esm/utils/utils.node.js.map +1 -0
  268. package/dist/react-native/AvroReaderFactory.d.ts +10 -0
  269. package/dist/react-native/AvroReaderFactory.d.ts.map +1 -0
  270. package/dist/react-native/AvroReaderFactory.js +17 -0
  271. package/dist/react-native/AvroReaderFactory.js.map +1 -0
  272. package/dist/react-native/BlobChangeFeedClient.d.ts +201 -0
  273. package/dist/react-native/BlobChangeFeedClient.d.ts.map +1 -0
  274. package/dist/react-native/BlobChangeFeedClient.js +242 -0
  275. package/dist/react-native/BlobChangeFeedClient.js.map +1 -0
  276. package/dist/react-native/ChangeFeed.d.ts +37 -0
  277. package/dist/react-native/ChangeFeed.d.ts.map +1 -0
  278. package/dist/react-native/ChangeFeed.js +104 -0
  279. package/dist/react-native/ChangeFeed.js.map +1 -0
  280. package/dist/react-native/ChangeFeedFactory.d.ts +13 -0
  281. package/dist/react-native/ChangeFeedFactory.d.ts.map +1 -0
  282. package/dist/react-native/ChangeFeedFactory.js +122 -0
  283. package/dist/react-native/ChangeFeedFactory.js.map +1 -0
  284. package/dist/react-native/Chunk.d.ts +27 -0
  285. package/dist/react-native/Chunk.d.ts.map +1 -0
  286. package/dist/react-native/Chunk.js +45 -0
  287. package/dist/react-native/Chunk.js.map +1 -0
  288. package/dist/react-native/ChunkFactory.d.ts +23 -0
  289. package/dist/react-native/ChunkFactory.d.ts.map +1 -0
  290. package/dist/react-native/ChunkFactory.js +33 -0
  291. package/dist/react-native/ChunkFactory.js.map +1 -0
  292. package/dist/react-native/LazyLoadingBlobStream.d.ts +46 -0
  293. package/dist/react-native/LazyLoadingBlobStream.d.ts.map +1 -0
  294. package/dist/react-native/LazyLoadingBlobStream.js +92 -0
  295. package/dist/react-native/LazyLoadingBlobStream.js.map +1 -0
  296. package/dist/react-native/LazyLoadingBlobStreamFactory.d.ts +7 -0
  297. package/dist/react-native/LazyLoadingBlobStreamFactory.d.ts.map +1 -0
  298. package/dist/react-native/LazyLoadingBlobStreamFactory.js +9 -0
  299. package/dist/react-native/LazyLoadingBlobStreamFactory.js.map +1 -0
  300. package/dist/react-native/Segment.d.ts +29 -0
  301. package/dist/react-native/Segment.d.ts.map +1 -0
  302. package/dist/react-native/Segment.js +69 -0
  303. package/dist/react-native/Segment.js.map +1 -0
  304. package/dist/react-native/SegmentFactory.d.ts +29 -0
  305. package/dist/react-native/SegmentFactory.d.ts.map +1 -0
  306. package/dist/react-native/SegmentFactory.js +47 -0
  307. package/dist/react-native/SegmentFactory.js.map +1 -0
  308. package/dist/react-native/Shard.d.ts +28 -0
  309. package/dist/react-native/Shard.d.ts.map +1 -0
  310. package/dist/react-native/Shard.js +46 -0
  311. package/dist/react-native/Shard.js.map +1 -0
  312. package/dist/react-native/ShardFactory.d.ts +21 -0
  313. package/dist/react-native/ShardFactory.d.ts.map +1 -0
  314. package/dist/react-native/ShardFactory.js +55 -0
  315. package/dist/react-native/ShardFactory.js.map +1 -0
  316. package/dist/react-native/index.d.ts +4 -0
  317. package/dist/react-native/index.d.ts.map +1 -0
  318. package/dist/react-native/index.js +6 -0
  319. package/dist/react-native/index.js.map +1 -0
  320. package/dist/react-native/log.d.ts +5 -0
  321. package/dist/react-native/log.d.ts.map +1 -0
  322. package/dist/react-native/log.js +8 -0
  323. package/dist/react-native/log.js.map +1 -0
  324. package/dist/react-native/models/BlobChangeFeedEvent.d.ts +233 -0
  325. package/dist/react-native/models/BlobChangeFeedEvent.d.ts.map +1 -0
  326. package/dist/react-native/models/BlobChangeFeedEvent.js +4 -0
  327. package/dist/react-native/models/BlobChangeFeedEvent.js.map +1 -0
  328. package/dist/react-native/models/ChangeFeedCursor.d.ts +17 -0
  329. package/dist/react-native/models/ChangeFeedCursor.d.ts.map +1 -0
  330. package/dist/react-native/models/ChangeFeedCursor.js +4 -0
  331. package/dist/react-native/models/ChangeFeedCursor.js.map +1 -0
  332. package/dist/react-native/models/models.d.ts +23 -0
  333. package/dist/react-native/models/models.d.ts.map +1 -0
  334. package/dist/react-native/models/models.js +4 -0
  335. package/dist/react-native/models/models.js.map +1 -0
  336. package/dist/react-native/package.json +3 -0
  337. package/dist/react-native/utils/constants.d.ts +9 -0
  338. package/dist/react-native/utils/constants.d.ts.map +1 -0
  339. package/dist/react-native/utils/constants.js +11 -0
  340. package/dist/react-native/utils/constants.js.map +1 -0
  341. package/dist/react-native/utils/tracing.d.ts +6 -0
  342. package/dist/react-native/utils/tracing.d.ts.map +1 -0
  343. package/dist/react-native/utils/tracing.js +14 -0
  344. package/dist/react-native/utils/tracing.js.map +1 -0
  345. package/dist/react-native/utils/utils.browser.d.ts +14 -0
  346. package/dist/react-native/utils/utils.browser.d.ts.map +1 -0
  347. package/dist/react-native/utils/utils.browser.js +29 -0
  348. package/dist/react-native/utils/utils.browser.js.map +1 -0
  349. package/dist/react-native/utils/utils.common.d.ts +37 -0
  350. package/dist/react-native/utils/utils.common.d.ts.map +1 -0
  351. package/dist/react-native/utils/utils.common.js +170 -0
  352. package/dist/react-native/utils/utils.common.js.map +1 -0
  353. package/dist/react-native/utils/utils.node.d.ts +14 -0
  354. package/dist/react-native/utils/utils.node.d.ts.map +1 -0
  355. package/dist/react-native/utils/utils.node.js +28 -0
  356. package/dist/react-native/utils/utils.node.js.map +1 -0
  357. package/package.json +89 -104
  358. package/CHANGELOG.md +0 -15
  359. package/dist/index.js +0 -1644
  360. package/dist/index.js.map +0 -1
  361. package/dist-esm/storage-blob-changefeed/src/AvroReaderFactory.js.map +0 -1
  362. package/dist-esm/storage-blob-changefeed/src/BlobChangeFeedClient.js +0 -221
  363. package/dist-esm/storage-blob-changefeed/src/BlobChangeFeedClient.js.map +0 -1
  364. package/dist-esm/storage-blob-changefeed/src/ChangeFeed.js.map +0 -1
  365. package/dist-esm/storage-blob-changefeed/src/ChangeFeedFactory.js.map +0 -1
  366. package/dist-esm/storage-blob-changefeed/src/Chunk.js.map +0 -1
  367. package/dist-esm/storage-blob-changefeed/src/ChunkFactory.js.map +0 -1
  368. package/dist-esm/storage-blob-changefeed/src/LazyLoadingBlobStream.js.map +0 -1
  369. package/dist-esm/storage-blob-changefeed/src/LazyLoadingBlobStreamFactory.js.map +0 -1
  370. package/dist-esm/storage-blob-changefeed/src/Segment.js.map +0 -1
  371. package/dist-esm/storage-blob-changefeed/src/SegmentFactory.js.map +0 -1
  372. package/dist-esm/storage-blob-changefeed/src/Shard.js.map +0 -1
  373. package/dist-esm/storage-blob-changefeed/src/ShardFactory.js +0 -78
  374. package/dist-esm/storage-blob-changefeed/src/ShardFactory.js.map +0 -1
  375. package/dist-esm/storage-blob-changefeed/src/index.js +0 -6
  376. package/dist-esm/storage-blob-changefeed/src/index.js.map +0 -1
  377. package/dist-esm/storage-blob-changefeed/src/log.js.map +0 -1
  378. package/dist-esm/storage-blob-changefeed/src/models/BlobChangeFeedEvent.js +0 -4
  379. package/dist-esm/storage-blob-changefeed/src/models/BlobChangeFeedEvent.js.map +0 -1
  380. package/dist-esm/storage-blob-changefeed/src/models/ChangeFeedCursor.js +0 -4
  381. package/dist-esm/storage-blob-changefeed/src/models/ChangeFeedCursor.js.map +0 -1
  382. package/dist-esm/storage-blob-changefeed/src/models/models.js +0 -4
  383. package/dist-esm/storage-blob-changefeed/src/models/models.js.map +0 -1
  384. package/dist-esm/storage-blob-changefeed/src/utils/constants.js.map +0 -1
  385. package/dist-esm/storage-blob-changefeed/src/utils/tracing.js +0 -12
  386. package/dist-esm/storage-blob-changefeed/src/utils/tracing.js.map +0 -1
  387. package/dist-esm/storage-blob-changefeed/src/utils/utils.browser.js.map +0 -1
  388. package/dist-esm/storage-blob-changefeed/src/utils/utils.common.js.map +0 -1
  389. package/dist-esm/storage-blob-changefeed/src/utils/utils.node.js.map +0 -1
  390. package/dist-esm/storage-internal-avro/src/AvroConstants.js +0 -7
  391. package/dist-esm/storage-internal-avro/src/AvroConstants.js.map +0 -1
  392. package/dist-esm/storage-internal-avro/src/AvroParser.js +0 -313
  393. package/dist-esm/storage-internal-avro/src/AvroParser.js.map +0 -1
  394. package/dist-esm/storage-internal-avro/src/AvroReadable.js +0 -5
  395. package/dist-esm/storage-internal-avro/src/AvroReadable.js.map +0 -1
  396. package/dist-esm/storage-internal-avro/src/AvroReadableFromBlob.js +0 -47
  397. package/dist-esm/storage-internal-avro/src/AvroReadableFromBlob.js.map +0 -1
  398. package/dist-esm/storage-internal-avro/src/AvroReadableFromStream.js +0 -82
  399. package/dist-esm/storage-internal-avro/src/AvroReadableFromStream.js.map +0 -1
  400. package/dist-esm/storage-internal-avro/src/AvroReader.js +0 -105
  401. package/dist-esm/storage-internal-avro/src/AvroReader.js.map +0 -1
  402. package/dist-esm/storage-internal-avro/src/index.browser.js +0 -6
  403. package/dist-esm/storage-internal-avro/src/index.browser.js.map +0 -1
  404. package/dist-esm/storage-internal-avro/src/index.js +0 -6
  405. package/dist-esm/storage-internal-avro/src/index.js.map +0 -1
  406. package/dist-esm/storage-internal-avro/src/utils/utils.common.js +0 -16
  407. package/dist-esm/storage-internal-avro/src/utils/utils.common.js.map +0 -1
  408. package/types/3.1/storage-blob-changefeed/samples-dev/blobChangeFeedClient.d.ts +0 -2
  409. package/types/3.1/storage-blob-changefeed/samples-dev/resumeListChanges.d.ts +0 -2
  410. package/types/3.1/storage-blob-changefeed/src/BlobChangeFeedClient.d.ts +0 -172
  411. package/types/3.1/storage-blob-changefeed/src/ChangeFeedFactory.d.ts +0 -12
  412. package/types/3.1/storage-blob-changefeed/src/LazyLoadingBlobStreamFactory.d.ts +0 -6
  413. package/types/3.1/storage-blob-changefeed/src/index.d.ts +0 -4
  414. package/types/3.1/storage-blob-changefeed/src/utils/tracing.d.ts +0 -11
  415. package/types/3.1/storage-blob-changefeed/test/blobchangefeedclient.spec.d.ts +0 -2
  416. package/types/3.1/storage-blob-changefeed/test/changefeed.spec.d.ts +0 -2
  417. package/types/3.1/storage-blob-changefeed/test/chunk.spec.d.ts +0 -2
  418. package/types/3.1/storage-blob-changefeed/test/segment.spec.d.ts +0 -2
  419. package/types/3.1/storage-blob-changefeed/test/shard.spec.d.ts +0 -2
  420. package/types/3.1/storage-blob-changefeed/test/utils/index.d.ts +0 -13
  421. package/types/3.1/storage-blob-changefeed/test/utils/testutils.common.d.ts +0 -64
  422. package/types/3.1/storage-blob-changefeed.d.ts +0 -427
  423. package/types/3.1/storage-internal-avro/src/AvroConstants.d.ts +0 -5
  424. package/types/3.1/storage-internal-avro/src/AvroParser.d.ts +0 -57
  425. package/types/3.1/storage-internal-avro/src/AvroReadable.d.ts +0 -16
  426. package/types/3.1/storage-internal-avro/src/AvroReadableFromBlob.d.ts +0 -9
  427. package/types/3.1/storage-internal-avro/src/AvroReadableFromStream.d.ts +0 -11
  428. package/types/3.1/storage-internal-avro/src/AvroReader.d.ts +0 -33
  429. package/types/3.1/storage-internal-avro/src/index.browser.d.ts +0 -4
  430. package/types/3.1/storage-internal-avro/src/index.d.ts +0 -4
  431. package/types/3.1/storage-internal-avro/src/utils/utils.common.d.ts +0 -6
  432. package/types/3.1/storage-internal-avro/test/browser/avroreadable.spec.d.ts +0 -2
  433. package/types/3.1/storage-internal-avro/test/node/avroreadable.spec.d.ts +0 -2
  434. package/types/3.1/storage-internal-avro/test/node/avroreader.spec.d.ts +0 -2
  435. package/types/latest/storage-blob-changefeed/samples-dev/blobChangeFeedClient.d.ts +0 -2
  436. package/types/latest/storage-blob-changefeed/samples-dev/blobChangeFeedClient.d.ts.map +0 -1
  437. package/types/latest/storage-blob-changefeed/samples-dev/resumeListChanges.d.ts +0 -2
  438. package/types/latest/storage-blob-changefeed/samples-dev/resumeListChanges.d.ts.map +0 -1
  439. package/types/latest/storage-blob-changefeed/src/AvroReaderFactory.d.ts.map +0 -1
  440. package/types/latest/storage-blob-changefeed/src/BlobChangeFeedClient.d.ts +0 -172
  441. package/types/latest/storage-blob-changefeed/src/BlobChangeFeedClient.d.ts.map +0 -1
  442. package/types/latest/storage-blob-changefeed/src/ChangeFeed.d.ts.map +0 -1
  443. package/types/latest/storage-blob-changefeed/src/ChangeFeedFactory.d.ts +0 -12
  444. package/types/latest/storage-blob-changefeed/src/ChangeFeedFactory.d.ts.map +0 -1
  445. package/types/latest/storage-blob-changefeed/src/Chunk.d.ts.map +0 -1
  446. package/types/latest/storage-blob-changefeed/src/ChunkFactory.d.ts.map +0 -1
  447. package/types/latest/storage-blob-changefeed/src/LazyLoadingBlobStream.d.ts.map +0 -1
  448. package/types/latest/storage-blob-changefeed/src/LazyLoadingBlobStreamFactory.d.ts +0 -6
  449. package/types/latest/storage-blob-changefeed/src/LazyLoadingBlobStreamFactory.d.ts.map +0 -1
  450. package/types/latest/storage-blob-changefeed/src/Segment.d.ts.map +0 -1
  451. package/types/latest/storage-blob-changefeed/src/SegmentFactory.d.ts.map +0 -1
  452. package/types/latest/storage-blob-changefeed/src/Shard.d.ts.map +0 -1
  453. package/types/latest/storage-blob-changefeed/src/ShardFactory.d.ts.map +0 -1
  454. package/types/latest/storage-blob-changefeed/src/index.d.ts +0 -4
  455. package/types/latest/storage-blob-changefeed/src/index.d.ts.map +0 -1
  456. package/types/latest/storage-blob-changefeed/src/log.d.ts.map +0 -1
  457. package/types/latest/storage-blob-changefeed/src/models/BlobChangeFeedEvent.d.ts.map +0 -1
  458. package/types/latest/storage-blob-changefeed/src/models/ChangeFeedCursor.d.ts.map +0 -1
  459. package/types/latest/storage-blob-changefeed/src/models/models.d.ts.map +0 -1
  460. package/types/latest/storage-blob-changefeed/src/utils/constants.d.ts.map +0 -1
  461. package/types/latest/storage-blob-changefeed/src/utils/tracing.d.ts +0 -11
  462. package/types/latest/storage-blob-changefeed/src/utils/tracing.d.ts.map +0 -1
  463. package/types/latest/storage-blob-changefeed/src/utils/utils.browser.d.ts.map +0 -1
  464. package/types/latest/storage-blob-changefeed/src/utils/utils.common.d.ts.map +0 -1
  465. package/types/latest/storage-blob-changefeed/src/utils/utils.node.d.ts.map +0 -1
  466. package/types/latest/storage-blob-changefeed/test/blobchangefeedclient.spec.d.ts +0 -2
  467. package/types/latest/storage-blob-changefeed/test/blobchangefeedclient.spec.d.ts.map +0 -1
  468. package/types/latest/storage-blob-changefeed/test/changefeed.spec.d.ts +0 -2
  469. package/types/latest/storage-blob-changefeed/test/changefeed.spec.d.ts.map +0 -1
  470. package/types/latest/storage-blob-changefeed/test/chunk.spec.d.ts +0 -2
  471. package/types/latest/storage-blob-changefeed/test/chunk.spec.d.ts.map +0 -1
  472. package/types/latest/storage-blob-changefeed/test/segment.spec.d.ts +0 -2
  473. package/types/latest/storage-blob-changefeed/test/segment.spec.d.ts.map +0 -1
  474. package/types/latest/storage-blob-changefeed/test/shard.spec.d.ts +0 -2
  475. package/types/latest/storage-blob-changefeed/test/shard.spec.d.ts.map +0 -1
  476. package/types/latest/storage-blob-changefeed/test/utils/index.d.ts +0 -13
  477. package/types/latest/storage-blob-changefeed/test/utils/index.d.ts.map +0 -1
  478. package/types/latest/storage-blob-changefeed/test/utils/testutils.common.d.ts +0 -64
  479. package/types/latest/storage-blob-changefeed/test/utils/testutils.common.d.ts.map +0 -1
  480. package/types/latest/storage-blob-changefeed.d.ts +0 -442
  481. package/types/latest/storage-internal-avro/src/AvroConstants.d.ts +0 -5
  482. package/types/latest/storage-internal-avro/src/AvroConstants.d.ts.map +0 -1
  483. package/types/latest/storage-internal-avro/src/AvroParser.d.ts +0 -57
  484. package/types/latest/storage-internal-avro/src/AvroParser.d.ts.map +0 -1
  485. package/types/latest/storage-internal-avro/src/AvroReadable.d.ts +0 -16
  486. package/types/latest/storage-internal-avro/src/AvroReadable.d.ts.map +0 -1
  487. package/types/latest/storage-internal-avro/src/AvroReadableFromBlob.d.ts +0 -9
  488. package/types/latest/storage-internal-avro/src/AvroReadableFromBlob.d.ts.map +0 -1
  489. package/types/latest/storage-internal-avro/src/AvroReadableFromStream.d.ts +0 -11
  490. package/types/latest/storage-internal-avro/src/AvroReadableFromStream.d.ts.map +0 -1
  491. package/types/latest/storage-internal-avro/src/AvroReader.d.ts +0 -33
  492. package/types/latest/storage-internal-avro/src/AvroReader.d.ts.map +0 -1
  493. package/types/latest/storage-internal-avro/src/index.browser.d.ts +0 -4
  494. package/types/latest/storage-internal-avro/src/index.browser.d.ts.map +0 -1
  495. package/types/latest/storage-internal-avro/src/index.d.ts +0 -4
  496. package/types/latest/storage-internal-avro/src/index.d.ts.map +0 -1
  497. package/types/latest/storage-internal-avro/src/utils/utils.common.d.ts +0 -6
  498. package/types/latest/storage-internal-avro/src/utils/utils.common.d.ts.map +0 -1
  499. package/types/latest/storage-internal-avro/test/browser/avroreadable.spec.d.ts +0 -2
  500. package/types/latest/storage-internal-avro/test/browser/avroreadable.spec.d.ts.map +0 -1
  501. package/types/latest/storage-internal-avro/test/node/avroreadable.spec.d.ts +0 -2
  502. package/types/latest/storage-internal-avro/test/node/avroreadable.spec.d.ts.map +0 -1
  503. package/types/latest/storage-internal-avro/test/node/avroreader.spec.d.ts +0 -2
  504. package/types/latest/storage-internal-avro/test/node/avroreader.spec.d.ts.map +0 -1
  505. /package/{types/latest/storage-blob-changefeed/src → dist/browser}/log.d.ts +0 -0
  506. /package/{types/latest/storage-blob-changefeed/src → dist/browser}/models/ChangeFeedCursor.d.ts +0 -0
  507. /package/{types/latest/storage-blob-changefeed/src → dist/browser}/utils/constants.d.ts +0 -0
package/dist/index.js DELETED
@@ -1,1644 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib = require('tslib');
6
- var storageBlob = require('@azure/storage-blob');
7
- var coreHttp = require('@azure/core-http');
8
- var coreTracing = require('@azure/core-tracing');
9
- var abortController = require('@azure/abort-controller');
10
- require('@azure/core-paging');
11
- var stream = require('stream');
12
-
13
- // Copyright (c) Microsoft Corporation.
14
- // Licensed under the MIT license.
15
- const SDK_VERSION = "12.0.0-preview.3";
16
- const CHANGE_FEED_CONTAINER_NAME = "$blobchangefeed";
17
- const CHANGE_FEED_META_SEGMENT_PATH = "meta/segments.json";
18
- const CHANGE_FEED_SEGMENT_PREFIX = "idx/segments/";
19
- const CHANGE_FEED_INITIALIZATION_SEGMENT = "1601";
20
- const CHANGE_FEED_MAX_PAGE_SIZE = 5000; // align with rest API list operations
21
- const CHANGE_FEED_CHUNK_BLOCK_DOWNLOAD_SIZE = 16 * 1024 * 1024;
22
-
23
- // Copyright (c) Microsoft Corporation.
24
- /**
25
- * Creates a span using the global tracer.
26
- * @internal
27
- */
28
- const createSpan = coreTracing.createSpanFunction({
29
- packagePrefix: "Azure.Storage.Blob.Changefeed",
30
- namespace: "Microsoft.Storage",
31
- });
32
-
33
- // Copyright (c) Microsoft Corporation.
34
- const millisecondsInAnHour = 60 * 60 * 1000;
35
- function ceilToNearestHour(date) {
36
- if (date === undefined) {
37
- return undefined;
38
- }
39
- return new Date(Math.ceil(date.getTime() / millisecondsInAnHour) * millisecondsInAnHour);
40
- }
41
- function floorToNearestHour(date) {
42
- if (date === undefined) {
43
- return undefined;
44
- }
45
- return new Date(Math.floor(date.getTime() / millisecondsInAnHour) * millisecondsInAnHour);
46
- }
47
- /**
48
- * Get host from an URL string.
49
- *
50
- * @param url - Source URL string
51
- */
52
- function getHost(url) {
53
- const urlParsed = coreHttp.URLBuilder.parse(url);
54
- return urlParsed.getHost();
55
- }
56
- async function getYearsPaths(containerClient, options = {}) {
57
- var e_1, _a;
58
- const { span, updatedOptions } = createSpan("getYearsPaths", options);
59
- try {
60
- const years = [];
61
- try {
62
- for (var _b = tslib.__asyncValues(containerClient.listBlobsByHierarchy("/", {
63
- abortSignal: options.abortSignal,
64
- tracingOptions: updatedOptions.tracingOptions,
65
- prefix: CHANGE_FEED_SEGMENT_PREFIX,
66
- })), _c; _c = await _b.next(), !_c.done;) {
67
- const item = _c.value;
68
- if (item.kind === "prefix" && !item.name.includes(CHANGE_FEED_INITIALIZATION_SEGMENT)) {
69
- const yearStr = item.name.slice(CHANGE_FEED_SEGMENT_PREFIX.length, -1);
70
- years.push(parseInt(yearStr));
71
- }
72
- }
73
- }
74
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
75
- finally {
76
- try {
77
- if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
78
- }
79
- finally { if (e_1) throw e_1.error; }
80
- }
81
- return years.sort((a, b) => a - b);
82
- }
83
- catch (e) {
84
- span.setStatus({
85
- code: coreTracing.SpanStatusCode.ERROR,
86
- message: e.message,
87
- });
88
- throw e;
89
- }
90
- finally {
91
- span.end();
92
- }
93
- }
94
- async function getSegmentsInYear(containerClient, year, startTime, endTime, options = {}) {
95
- var e_2, _a;
96
- const { span, updatedOptions } = createSpan("getSegmentsInYear", options);
97
- try {
98
- const segments = [];
99
- const yearBeginTime = new Date(Date.UTC(year, 0));
100
- if (endTime && yearBeginTime >= endTime) {
101
- return segments;
102
- }
103
- const prefix = `${CHANGE_FEED_SEGMENT_PREFIX}${year}/`;
104
- try {
105
- for (var _b = tslib.__asyncValues(containerClient.listBlobsFlat({
106
- prefix,
107
- abortSignal: options.abortSignal,
108
- tracingOptions: updatedOptions.tracingOptions,
109
- })), _c; _c = await _b.next(), !_c.done;) {
110
- const item = _c.value;
111
- const segmentTime = parseDateFromSegmentPath(item.name);
112
- if ((startTime && segmentTime < startTime) || (endTime && segmentTime >= endTime)) {
113
- continue;
114
- }
115
- segments.push(item.name);
116
- }
117
- }
118
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
119
- finally {
120
- try {
121
- if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
122
- }
123
- finally { if (e_2) throw e_2.error; }
124
- }
125
- return segments;
126
- }
127
- catch (e) {
128
- span.setStatus({
129
- code: coreTracing.SpanStatusCode.ERROR,
130
- message: e.message,
131
- });
132
- throw e;
133
- }
134
- finally {
135
- span.end();
136
- }
137
- }
138
- function parseDateFromSegmentPath(segmentPath) {
139
- const splitPath = segmentPath.split("/");
140
- if (splitPath.length < 3) {
141
- throw new Error(`${segmentPath} is not a valid segment path.`);
142
- }
143
- const segmentTime = new Date(0);
144
- segmentTime.setUTCFullYear(parseInt(splitPath[2]));
145
- if (splitPath.length >= 4) {
146
- segmentTime.setUTCMonth(parseInt(splitPath[3]) - 1);
147
- }
148
- if (splitPath.length >= 5) {
149
- segmentTime.setUTCDate(parseInt(splitPath[4]));
150
- }
151
- if (splitPath.length >= 6) {
152
- segmentTime.setUTCHours(parseInt(splitPath[5]) / 100);
153
- }
154
- return segmentTime;
155
- }
156
- function minDate(dateA, dateB) {
157
- if (dateB && dateB < dateA) {
158
- return dateB;
159
- }
160
- return dateA;
161
- }
162
- function rawEventToBlobChangeFeedEvent(rawEvent) {
163
- if (rawEvent.eventTime) {
164
- rawEvent.eventTime = new Date(rawEvent.eventTime);
165
- }
166
- if (rawEvent.eTag) {
167
- rawEvent.etag = rawEvent.eTag;
168
- delete rawEvent.eTag;
169
- }
170
- if (rawEvent.data) {
171
- if (rawEvent.data.recursive !== undefined) {
172
- rawEvent.data.isRecursive = rawEvent.data.recursive;
173
- delete rawEvent.data.recursive;
174
- }
175
- if (rawEvent.data.previousInfo) {
176
- const previousInfo = rawEvent.data.previousInfo;
177
- if (previousInfo.SoftDeleteSnapshot) {
178
- previousInfo.softDeleteSnapshot = previousInfo.SoftDeleteSnapshot;
179
- delete previousInfo.SoftDeleteSnapshot;
180
- }
181
- if (previousInfo.WasBlobSoftDeleted) {
182
- previousInfo.isBlobSoftDeleted = previousInfo.WasBlobSoftDeleted === "true";
183
- delete previousInfo.WasBlobSoftDeleted;
184
- }
185
- if (previousInfo.BlobVersion) {
186
- previousInfo.newBlobVersion = previousInfo.BlobVersion;
187
- delete previousInfo.BlobVersion;
188
- }
189
- if (previousInfo.LastVersion) {
190
- previousInfo.oldBlobVersion = previousInfo.LastVersion;
191
- delete previousInfo.LastVersion;
192
- }
193
- if (previousInfo.PreviousTier) {
194
- previousInfo.previousTier = previousInfo.PreviousTier;
195
- delete previousInfo.PreviousTier;
196
- }
197
- rawEvent.data.previousInfo = previousInfo;
198
- }
199
- if (rawEvent.data.blobPropertiesUpdated) {
200
- const updatedBlobProperties = {};
201
- Object.entries(rawEvent.data.blobPropertiesUpdated).map((item) => {
202
- const blobPropertyChange = {
203
- propertyName: item[0],
204
- oldValue: item[1].previous,
205
- newValue: item[1].current,
206
- };
207
- updatedBlobProperties[item[0]] = blobPropertyChange;
208
- });
209
- rawEvent.data.updatedBlobProperties = updatedBlobProperties;
210
- delete rawEvent.data.blobPropertiesUpdated;
211
- }
212
- if (rawEvent.data.asyncOperationInfo) {
213
- const longRunningOperationInfo = rawEvent.data.asyncOperationInfo;
214
- if (longRunningOperationInfo.DestinationTier) {
215
- longRunningOperationInfo.destinationAccessTier = longRunningOperationInfo.DestinationTier;
216
- delete longRunningOperationInfo.DestinationTier;
217
- }
218
- if ("WasAsyncOperation" in longRunningOperationInfo) {
219
- longRunningOperationInfo.isAsync = longRunningOperationInfo.WasAsyncOperation === "true";
220
- delete longRunningOperationInfo.WasAsyncOperation;
221
- }
222
- if (longRunningOperationInfo.CopyId) {
223
- longRunningOperationInfo.copyId = longRunningOperationInfo.CopyId;
224
- delete longRunningOperationInfo.CopyId;
225
- }
226
- rawEvent.data.longRunningOperationInfo = longRunningOperationInfo;
227
- delete rawEvent.data.asyncOperationInfo;
228
- }
229
- if (rawEvent.data.blobTagsUpdated) {
230
- rawEvent.data.updatedBlobTags = {
231
- newTags: rawEvent.data.blobTagsUpdated.current,
232
- oldTags: rawEvent.data.blobTagsUpdated.previous,
233
- };
234
- delete rawEvent.data.blobTagsUpdated;
235
- }
236
- if (rawEvent.data.blobTier) {
237
- rawEvent.data.blobAccessTier = rawEvent.data.blobTier;
238
- delete rawEvent.data.blobTier;
239
- }
240
- }
241
- return rawEvent;
242
- }
243
-
244
- // Copyright (c) Microsoft Corporation.
245
- class ChangeFeed {
246
- constructor(containerClient, segmentFactory, years, segments, currentSegment, lastConsumable, startTime, endTime) {
247
- this.containerClient = containerClient;
248
- this.segmentFactory = segmentFactory;
249
- this.years = years || [];
250
- this.segments = segments || [];
251
- this.currentSegment = currentSegment;
252
- this.lastConsumable = lastConsumable;
253
- this.startTime = startTime;
254
- this.endTime = endTime;
255
- if (this.lastConsumable) {
256
- this.end = minDate(this.lastConsumable, this.endTime);
257
- }
258
- }
259
- async advanceSegmentIfNecessary(options = {}) {
260
- const { span, updatedOptions } = createSpan("ChangeFeed-advanceSegmentIfNecessary", options);
261
- try {
262
- if (!this.currentSegment) {
263
- throw new Error("Empty Change Feed shouldn't call this function.");
264
- }
265
- // If the current segment has more Events, we don't need to do anything.
266
- if (this.currentSegment.hasNext()) {
267
- return;
268
- }
269
- // If the current segment is completed, remove it
270
- if (this.segments.length > 0) {
271
- this.currentSegment = await this.segmentFactory.create(this.containerClient, this.segments.shift(), undefined, {
272
- abortSignal: options.abortSignal,
273
- tracingOptions: updatedOptions.tracingOptions,
274
- });
275
- }
276
- // If segments is empty, refill it
277
- else if (this.segments.length === 0 && this.years.length > 0) {
278
- const year = this.years.shift();
279
- this.segments = await getSegmentsInYear(this.containerClient, year, this.startTime, this.end, {
280
- abortSignal: options.abortSignal,
281
- tracingOptions: updatedOptions.tracingOptions,
282
- });
283
- if (this.segments.length > 0) {
284
- this.currentSegment = await this.segmentFactory.create(this.containerClient, this.segments.shift(), undefined, {
285
- abortSignal: options.abortSignal,
286
- tracingOptions: updatedOptions.tracingOptions,
287
- });
288
- }
289
- else {
290
- this.currentSegment = undefined;
291
- }
292
- }
293
- }
294
- catch (e) {
295
- span.setStatus({
296
- code: coreTracing.SpanStatusCode.ERROR,
297
- message: e.message,
298
- });
299
- throw e;
300
- }
301
- finally {
302
- span.end();
303
- }
304
- }
305
- hasNext() {
306
- // Empty ChangeFeed, using currentSegment as the indicator.
307
- if (!this.currentSegment) {
308
- return false;
309
- }
310
- if (this.segments.length === 0 && this.years.length === 0 && !this.currentSegment.hasNext()) {
311
- return false;
312
- }
313
- return this.currentSegment.dateTime < this.end;
314
- }
315
- async getChange(options = {}) {
316
- const { span, updatedOptions } = createSpan("ChangeFeed-getChange", options);
317
- try {
318
- let event = undefined;
319
- while (event === undefined && this.hasNext()) {
320
- event = await this.currentSegment.getChange({
321
- abortSignal: options.abortSignal,
322
- tracingOptions: updatedOptions.tracingOptions,
323
- });
324
- await this.advanceSegmentIfNecessary({
325
- abortSignal: options.abortSignal,
326
- tracingOptions: updatedOptions.tracingOptions,
327
- });
328
- }
329
- return event;
330
- }
331
- catch (e) {
332
- span.setStatus({
333
- code: coreTracing.SpanStatusCode.ERROR,
334
- message: e.message,
335
- });
336
- throw e;
337
- }
338
- finally {
339
- span.end();
340
- }
341
- }
342
- getCursor() {
343
- var _a;
344
- if (!this.currentSegment) {
345
- throw new Error("Empty Change Feed shouldn't call this function.");
346
- }
347
- return {
348
- CursorVersion: 1,
349
- UrlHost: getHost(this.containerClient.url),
350
- EndTime: (_a = this.endTime) === null || _a === void 0 ? void 0 : _a.toJSON(),
351
- CurrentSegmentCursor: this.currentSegment.getCursor(),
352
- };
353
- }
354
- }
355
-
356
- // Copyright (c) Microsoft Corporation.
357
- // Licensed under the MIT license.
358
- const AVRO_SYNC_MARKER_SIZE = 16;
359
- const AVRO_INIT_BYTES = new Uint8Array([79, 98, 106, 1]);
360
- const AVRO_CODEC_KEY = "avro.codec";
361
- const AVRO_SCHEMA_KEY = "avro.schema";
362
-
363
- // Copyright (c) Microsoft Corporation.
364
- // Licensed under the MIT license.
365
- function arraysEqual(a, b) {
366
- if (a === b)
367
- return true;
368
- if (a == null || b == null)
369
- return false;
370
- if (a.length != b.length)
371
- return false;
372
- for (let i = 0; i < a.length; ++i) {
373
- if (a[i] !== b[i])
374
- return false;
375
- }
376
- return true;
377
- }
378
-
379
- // Copyright (c) Microsoft Corporation.
380
- // Licensed under the MIT license.
381
- class AvroParser {
382
- /**
383
- * Reads a fixed number of bytes from the stream.
384
- *
385
- * @param stream -
386
- * @param length -
387
- * @param options -
388
- */
389
- static async readFixedBytes(stream, length, options = {}) {
390
- const bytes = await stream.read(length, { abortSignal: options.abortSignal });
391
- if (bytes.length != length) {
392
- throw new Error("Hit stream end.");
393
- }
394
- return bytes;
395
- }
396
- /**
397
- * Reads a single byte from the stream.
398
- *
399
- * @param stream -
400
- * @param options -
401
- */
402
- static async readByte(stream, options = {}) {
403
- const buf = await AvroParser.readFixedBytes(stream, 1, options);
404
- return buf[0];
405
- }
406
- // int and long are stored in variable-length zig-zag coding.
407
- // variable-length: https://lucene.apache.org/core/3_5_0/fileformats.html#VInt
408
- // zig-zag: https://developers.google.com/protocol-buffers/docs/encoding?csw=1#types
409
- static async readZigZagLong(stream, options = {}) {
410
- let zigZagEncoded = 0;
411
- let significanceInBit = 0;
412
- let byte, haveMoreByte, significanceInFloat;
413
- do {
414
- byte = await AvroParser.readByte(stream, options);
415
- haveMoreByte = byte & 0x80;
416
- zigZagEncoded |= (byte & 0x7f) << significanceInBit;
417
- significanceInBit += 7;
418
- } while (haveMoreByte && significanceInBit < 28); // bitwise operation only works for 32-bit integers
419
- if (haveMoreByte) {
420
- // Switch to float arithmetic
421
- zigZagEncoded = zigZagEncoded;
422
- significanceInFloat = 268435456; // 2 ** 28.
423
- do {
424
- byte = await AvroParser.readByte(stream, options);
425
- zigZagEncoded += (byte & 0x7f) * significanceInFloat;
426
- significanceInFloat *= 128; // 2 ** 7
427
- } while (byte & 0x80);
428
- const res = (zigZagEncoded % 2 ? -(zigZagEncoded + 1) : zigZagEncoded) / 2;
429
- if (res < Number.MIN_SAFE_INTEGER || res > Number.MAX_SAFE_INTEGER) {
430
- throw new Error("Integer overflow.");
431
- }
432
- return res;
433
- }
434
- return (zigZagEncoded >> 1) ^ -(zigZagEncoded & 1);
435
- }
436
- static async readLong(stream, options = {}) {
437
- return AvroParser.readZigZagLong(stream, options);
438
- }
439
- static async readInt(stream, options = {}) {
440
- return AvroParser.readZigZagLong(stream, options);
441
- }
442
- static async readNull() {
443
- return null;
444
- }
445
- static async readBoolean(stream, options = {}) {
446
- const b = await AvroParser.readByte(stream, options);
447
- if (b == 1) {
448
- return true;
449
- }
450
- else if (b == 0) {
451
- return false;
452
- }
453
- else {
454
- throw new Error("Byte was not a boolean.");
455
- }
456
- }
457
- static async readFloat(stream, options = {}) {
458
- const u8arr = await AvroParser.readFixedBytes(stream, 4, options);
459
- const view = new DataView(u8arr.buffer, u8arr.byteOffset, u8arr.byteLength);
460
- return view.getFloat32(0, true); // littleEndian = true
461
- }
462
- static async readDouble(stream, options = {}) {
463
- const u8arr = await AvroParser.readFixedBytes(stream, 8, options);
464
- const view = new DataView(u8arr.buffer, u8arr.byteOffset, u8arr.byteLength);
465
- return view.getFloat64(0, true); // littleEndian = true
466
- }
467
- static async readBytes(stream, options = {}) {
468
- const size = await AvroParser.readLong(stream, options);
469
- if (size < 0) {
470
- throw new Error("Bytes size was negative.");
471
- }
472
- return await stream.read(size, { abortSignal: options.abortSignal });
473
- }
474
- static async readString(stream, options = {}) {
475
- const u8arr = await AvroParser.readBytes(stream, options);
476
- // polyfill TextDecoder to be backward compatible with older
477
- // nodejs that doesn't expose TextDecoder as a global variable
478
- if (typeof TextDecoder === "undefined" && typeof require !== "undefined") {
479
- global.TextDecoder = require("util").TextDecoder;
480
- }
481
- // FUTURE: need TextDecoder polyfill for IE
482
- const utf8decoder = new TextDecoder();
483
- return utf8decoder.decode(u8arr);
484
- }
485
- static async readMapPair(stream, readItemMethod, options = {}) {
486
- const key = await AvroParser.readString(stream, options);
487
- // FUTURE: this won't work with readFixed (currently not supported) which needs a length as the parameter.
488
- const value = await readItemMethod(stream, options);
489
- return { key, value };
490
- }
491
- static async readMap(stream, readItemMethod, options = {}) {
492
- const readPairMethod = async (stream, options = {}) => {
493
- return await AvroParser.readMapPair(stream, readItemMethod, options);
494
- };
495
- const pairs = await AvroParser.readArray(stream, readPairMethod, options);
496
- const dict = {};
497
- for (const pair of pairs) {
498
- dict[pair.key] = pair.value;
499
- }
500
- return dict;
501
- }
502
- static async readArray(stream, readItemMethod, options = {}) {
503
- const items = [];
504
- for (let count = await AvroParser.readLong(stream, options); count != 0; count = await AvroParser.readLong(stream, options)) {
505
- if (count < 0) {
506
- // Ignore block sizes
507
- await AvroParser.readLong(stream, options);
508
- count = -count;
509
- }
510
- while (count--) {
511
- const item = await readItemMethod(stream, options);
512
- items.push(item);
513
- }
514
- }
515
- return items;
516
- }
517
- }
518
- var AvroComplex;
519
- (function (AvroComplex) {
520
- AvroComplex["RECORD"] = "record";
521
- AvroComplex["ENUM"] = "enum";
522
- AvroComplex["ARRAY"] = "array";
523
- AvroComplex["MAP"] = "map";
524
- AvroComplex["UNION"] = "union";
525
- AvroComplex["FIXED"] = "fixed";
526
- })(AvroComplex || (AvroComplex = {}));
527
- class AvroType {
528
- /**
529
- * Determines the AvroType from the Avro Schema.
530
- */
531
- static fromSchema(schema) {
532
- if (typeof schema === "string") {
533
- return AvroType.fromStringSchema(schema);
534
- }
535
- else if (Array.isArray(schema)) {
536
- return AvroType.fromArraySchema(schema);
537
- }
538
- else {
539
- return AvroType.fromObjectSchema(schema);
540
- }
541
- }
542
- static fromStringSchema(schema) {
543
- switch (schema) {
544
- case AvroPrimitive.NULL:
545
- case AvroPrimitive.BOOLEAN:
546
- case AvroPrimitive.INT:
547
- case AvroPrimitive.LONG:
548
- case AvroPrimitive.FLOAT:
549
- case AvroPrimitive.DOUBLE:
550
- case AvroPrimitive.BYTES:
551
- case AvroPrimitive.STRING:
552
- return new AvroPrimitiveType(schema);
553
- default:
554
- throw new Error(`Unexpected Avro type ${schema}`);
555
- }
556
- }
557
- static fromArraySchema(schema) {
558
- return new AvroUnionType(schema.map(AvroType.fromSchema));
559
- }
560
- static fromObjectSchema(schema) {
561
- const type = schema.type;
562
- // Primitives can be defined as strings or objects
563
- try {
564
- return AvroType.fromStringSchema(type);
565
- }
566
- catch (err) { }
567
- switch (type) {
568
- case AvroComplex.RECORD:
569
- if (schema.aliases) {
570
- throw new Error(`aliases currently is not supported, schema: ${schema}`);
571
- }
572
- if (!schema.name) {
573
- throw new Error(`Required attribute 'name' doesn't exist on schema: ${schema}`);
574
- }
575
- const fields = {};
576
- if (!schema.fields) {
577
- throw new Error(`Required attribute 'fields' doesn't exist on schema: ${schema}`);
578
- }
579
- for (const field of schema.fields) {
580
- fields[field.name] = AvroType.fromSchema(field.type);
581
- }
582
- return new AvroRecordType(fields, schema.name);
583
- case AvroComplex.ENUM:
584
- if (schema.aliases) {
585
- throw new Error(`aliases currently is not supported, schema: ${schema}`);
586
- }
587
- if (!schema.symbols) {
588
- throw new Error(`Required attribute 'symbols' doesn't exist on schema: ${schema}`);
589
- }
590
- return new AvroEnumType(schema.symbols);
591
- case AvroComplex.MAP:
592
- if (!schema.values) {
593
- throw new Error(`Required attribute 'values' doesn't exist on schema: ${schema}`);
594
- }
595
- return new AvroMapType(AvroType.fromSchema(schema.values));
596
- case AvroComplex.ARRAY: // Unused today
597
- case AvroComplex.FIXED: // Unused today
598
- default:
599
- throw new Error(`Unexpected Avro type ${type} in ${schema}`);
600
- }
601
- }
602
- }
603
- var AvroPrimitive;
604
- (function (AvroPrimitive) {
605
- AvroPrimitive["NULL"] = "null";
606
- AvroPrimitive["BOOLEAN"] = "boolean";
607
- AvroPrimitive["INT"] = "int";
608
- AvroPrimitive["LONG"] = "long";
609
- AvroPrimitive["FLOAT"] = "float";
610
- AvroPrimitive["DOUBLE"] = "double";
611
- AvroPrimitive["BYTES"] = "bytes";
612
- AvroPrimitive["STRING"] = "string";
613
- })(AvroPrimitive || (AvroPrimitive = {}));
614
- class AvroPrimitiveType extends AvroType {
615
- constructor(primitive) {
616
- super();
617
- this._primitive = primitive;
618
- }
619
- async read(stream, options = {}) {
620
- switch (this._primitive) {
621
- case AvroPrimitive.NULL:
622
- return await AvroParser.readNull();
623
- case AvroPrimitive.BOOLEAN:
624
- return await AvroParser.readBoolean(stream, options);
625
- case AvroPrimitive.INT:
626
- return await AvroParser.readInt(stream, options);
627
- case AvroPrimitive.LONG:
628
- return await AvroParser.readLong(stream, options);
629
- case AvroPrimitive.FLOAT:
630
- return await AvroParser.readFloat(stream, options);
631
- case AvroPrimitive.DOUBLE:
632
- return await AvroParser.readDouble(stream, options);
633
- case AvroPrimitive.BYTES:
634
- return await AvroParser.readBytes(stream, options);
635
- case AvroPrimitive.STRING:
636
- return await AvroParser.readString(stream, options);
637
- default:
638
- throw new Error("Unknown Avro Primitive");
639
- }
640
- }
641
- }
642
- class AvroEnumType extends AvroType {
643
- constructor(symbols) {
644
- super();
645
- this._symbols = symbols;
646
- }
647
- async read(stream, options = {}) {
648
- const value = await AvroParser.readInt(stream, options);
649
- return this._symbols[value];
650
- }
651
- }
652
- class AvroUnionType extends AvroType {
653
- constructor(types) {
654
- super();
655
- this._types = types;
656
- }
657
- async read(stream, options = {}) {
658
- const typeIndex = await AvroParser.readInt(stream, options);
659
- return await this._types[typeIndex].read(stream, options);
660
- }
661
- }
662
- class AvroMapType extends AvroType {
663
- constructor(itemType) {
664
- super();
665
- this._itemType = itemType;
666
- }
667
- async read(stream, options = {}) {
668
- const readItemMethod = async (s, options) => {
669
- return await this._itemType.read(s, options);
670
- };
671
- return await AvroParser.readMap(stream, readItemMethod, options);
672
- }
673
- }
674
- class AvroRecordType extends AvroType {
675
- constructor(fields, name) {
676
- super();
677
- this._fields = fields;
678
- this._name = name;
679
- }
680
- async read(stream, options = {}) {
681
- const record = {};
682
- record["$schema"] = this._name;
683
- for (const key in this._fields) {
684
- if (this._fields.hasOwnProperty(key)) {
685
- record[key] = await this._fields[key].read(stream, options);
686
- }
687
- }
688
- return record;
689
- }
690
- }
691
-
692
- // Copyright (c) Microsoft Corporation.
693
- class AvroReader {
694
- constructor(dataStream, headerStream, currentBlockOffset, indexWithinCurrentBlock) {
695
- this._dataStream = dataStream;
696
- this._headerStream = headerStream || dataStream;
697
- this._initialized = false;
698
- this._blockOffset = currentBlockOffset || 0;
699
- this._objectIndex = indexWithinCurrentBlock || 0;
700
- this._initialBlockOffset = currentBlockOffset || 0;
701
- }
702
- get blockOffset() {
703
- return this._blockOffset;
704
- }
705
- get objectIndex() {
706
- return this._objectIndex;
707
- }
708
- async initialize(options = {}) {
709
- const header = await AvroParser.readFixedBytes(this._headerStream, AVRO_INIT_BYTES.length, {
710
- abortSignal: options.abortSignal,
711
- });
712
- if (!arraysEqual(header, AVRO_INIT_BYTES)) {
713
- throw new Error("Stream is not an Avro file.");
714
- }
715
- // File metadata is written as if defined by the following map schema:
716
- // { "type": "map", "values": "bytes"}
717
- this._metadata = await AvroParser.readMap(this._headerStream, AvroParser.readString, {
718
- abortSignal: options.abortSignal,
719
- });
720
- // Validate codec
721
- const codec = this._metadata[AVRO_CODEC_KEY];
722
- if (!(codec == undefined || codec == "null")) {
723
- throw new Error("Codecs are not supported");
724
- }
725
- // The 16-byte, randomly-generated sync marker for this file.
726
- this._syncMarker = await AvroParser.readFixedBytes(this._headerStream, AVRO_SYNC_MARKER_SIZE, {
727
- abortSignal: options.abortSignal,
728
- });
729
- // Parse the schema
730
- const schema = JSON.parse(this._metadata[AVRO_SCHEMA_KEY]);
731
- this._itemType = AvroType.fromSchema(schema);
732
- if (this._blockOffset == 0) {
733
- this._blockOffset = this._initialBlockOffset + this._dataStream.position;
734
- }
735
- this._itemsRemainingInBlock = await AvroParser.readLong(this._dataStream, {
736
- abortSignal: options.abortSignal,
737
- });
738
- // skip block length
739
- await AvroParser.readLong(this._dataStream, { abortSignal: options.abortSignal });
740
- this._initialized = true;
741
- if (this._objectIndex && this._objectIndex > 0) {
742
- for (let i = 0; i < this._objectIndex; i++) {
743
- await this._itemType.read(this._dataStream, { abortSignal: options.abortSignal });
744
- this._itemsRemainingInBlock--;
745
- }
746
- }
747
- }
748
- hasNext() {
749
- return !this._initialized || this._itemsRemainingInBlock > 0;
750
- }
751
- parseObjects(options = {}) {
752
- return tslib.__asyncGenerator(this, arguments, function* parseObjects_1() {
753
- if (!this._initialized) {
754
- yield tslib.__await(this.initialize(options));
755
- }
756
- while (this.hasNext()) {
757
- const result = yield tslib.__await(this._itemType.read(this._dataStream, {
758
- abortSignal: options.abortSignal,
759
- }));
760
- this._itemsRemainingInBlock--;
761
- this._objectIndex++;
762
- if (this._itemsRemainingInBlock == 0) {
763
- const marker = yield tslib.__await(AvroParser.readFixedBytes(this._dataStream, AVRO_SYNC_MARKER_SIZE, {
764
- abortSignal: options.abortSignal,
765
- }));
766
- this._blockOffset = this._initialBlockOffset + this._dataStream.position;
767
- this._objectIndex = 0;
768
- if (!arraysEqual(this._syncMarker, marker)) {
769
- throw new Error("Stream is not a valid Avro file.");
770
- }
771
- try {
772
- this._itemsRemainingInBlock = yield tslib.__await(AvroParser.readLong(this._dataStream, {
773
- abortSignal: options.abortSignal,
774
- }));
775
- }
776
- catch (err) {
777
- // We hit the end of the stream.
778
- this._itemsRemainingInBlock = 0;
779
- }
780
- if (this._itemsRemainingInBlock > 0) {
781
- // Ignore block size
782
- yield tslib.__await(AvroParser.readLong(this._dataStream, { abortSignal: options.abortSignal }));
783
- }
784
- }
785
- yield yield tslib.__await(result);
786
- }
787
- });
788
- }
789
- }
790
-
791
- // Copyright (c) Microsoft Corporation.
792
- // Licensed under the MIT license.
793
- class AvroReadable {
794
- }
795
-
796
- // Copyright (c) Microsoft Corporation.
797
- const ABORT_ERROR = new abortController.AbortError("Reading from the avro stream was aborted.");
798
- class AvroReadableFromStream extends AvroReadable {
799
- constructor(readable) {
800
- super();
801
- this._readable = readable;
802
- this._position = 0;
803
- }
804
- toUint8Array(data) {
805
- if (typeof data === "string") {
806
- return Buffer.from(data);
807
- }
808
- return data;
809
- }
810
- get position() {
811
- return this._position;
812
- }
813
- async read(size, options = {}) {
814
- var _a;
815
- if ((_a = options.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
816
- throw ABORT_ERROR;
817
- }
818
- if (size < 0) {
819
- throw new Error(`size parameter should be positive: ${size}`);
820
- }
821
- if (size === 0) {
822
- return new Uint8Array();
823
- }
824
- if (!this._readable.readable) {
825
- throw new Error("Stream no longer readable.");
826
- }
827
- // See if there is already enough data.
828
- const chunk = this._readable.read(size);
829
- if (chunk) {
830
- this._position += chunk.length;
831
- // chunk.length maybe less than desired size if the stream ends.
832
- return this.toUint8Array(chunk);
833
- }
834
- else {
835
- // register callback to wait for enough data to read
836
- return new Promise((resolve, reject) => {
837
- const cleanUp = () => {
838
- this._readable.removeListener("readable", readableCallback);
839
- this._readable.removeListener("error", rejectCallback);
840
- this._readable.removeListener("end", rejectCallback);
841
- this._readable.removeListener("close", rejectCallback);
842
- if (options.abortSignal) {
843
- options.abortSignal.removeEventListener("abort", abortHandler);
844
- }
845
- };
846
- const readableCallback = () => {
847
- const chunk = this._readable.read(size);
848
- if (chunk) {
849
- this._position += chunk.length;
850
- cleanUp();
851
- // chunk.length maybe less than desired size if the stream ends.
852
- resolve(this.toUint8Array(chunk));
853
- }
854
- };
855
- const rejectCallback = () => {
856
- cleanUp();
857
- reject();
858
- };
859
- const abortHandler = () => {
860
- cleanUp();
861
- reject(ABORT_ERROR);
862
- };
863
- this._readable.on("readable", readableCallback);
864
- this._readable.once("error", rejectCallback);
865
- this._readable.once("end", rejectCallback);
866
- this._readable.once("close", rejectCallback);
867
- if (options.abortSignal) {
868
- options.abortSignal.addEventListener("abort", abortHandler);
869
- }
870
- });
871
- }
872
- }
873
- }
874
-
875
- // Copyright (c) Microsoft Corporation.
876
- /**
877
- * Read body from downloading operation methods to string.
878
- * Works in both Node.js and browsers.
879
- *
880
- * @param response - Convenience layer methods response with downloaded body
881
- * @param length - Length of Readable stream, needed for Node.js environment
882
- */
883
- async function bodyToString(response, length) {
884
- return new Promise((resolve, reject) => {
885
- response.readableStreamBody.on("readable", () => {
886
- const chunk = response.readableStreamBody.read(length);
887
- if (chunk) {
888
- resolve(chunk.toString());
889
- }
890
- });
891
- response.readableStreamBody.on("error", reject);
892
- response.readableStreamBody.on("end", () => {
893
- resolve("");
894
- });
895
- });
896
- }
897
- function streamToAvroReadable(readableStream) {
898
- return new AvroReadableFromStream(readableStream);
899
- }
900
-
901
- // Copyright (c) Microsoft Corporation.
902
- class Segment {
903
- constructor(shards, shardIndex, dateTime, manifestPath) {
904
- this.manifestPath = manifestPath;
905
- this.shards = shards;
906
- this.shardIndex = shardIndex;
907
- this._dateTime = dateTime;
908
- this.shardDone = Array(shards.length).fill(false);
909
- this.shardDoneCount = 0;
910
- }
911
- get dateTime() {
912
- return this._dateTime;
913
- }
914
- hasNext() {
915
- return this.shards.length > this.shardDoneCount;
916
- }
917
- async getChange(options = {}) {
918
- const { span, updatedOptions } = createSpan("Segment-getChange", options);
919
- try {
920
- if (this.shardIndex >= this.shards.length || this.shardIndex < 0) {
921
- throw new Error("shardIndex invalid.");
922
- }
923
- let event = undefined;
924
- while (event === undefined && this.hasNext()) {
925
- if (this.shardDone[this.shardIndex]) {
926
- this.shardIndex = (this.shardIndex + 1) % this.shards.length; // find next available shard
927
- continue;
928
- }
929
- const currentShard = this.shards[this.shardIndex];
930
- event = await currentShard.getChange({
931
- abortSignal: options.abortSignal,
932
- tracingOptions: updatedOptions.tracingOptions,
933
- });
934
- if (!currentShard.hasNext()) {
935
- this.shardDone[this.shardIndex] = true;
936
- this.shardDoneCount++;
937
- }
938
- // Round robin with shards
939
- this.shardIndex = (this.shardIndex + 1) % this.shards.length;
940
- }
941
- return event;
942
- }
943
- catch (e) {
944
- span.setStatus({
945
- code: coreTracing.SpanStatusCode.ERROR,
946
- message: e.message,
947
- });
948
- throw e;
949
- }
950
- finally {
951
- span.end();
952
- }
953
- }
954
- getCursor() {
955
- const shardCursors = [];
956
- for (const shard of this.shards) {
957
- const shardCursor = shard.getCursor();
958
- if (shardCursor) {
959
- shardCursors.push(shardCursor);
960
- }
961
- }
962
- return {
963
- SegmentPath: this.manifestPath,
964
- ShardCursors: shardCursors,
965
- CurrentShardPath: this.shards[this.shardIndex].shardPath,
966
- };
967
- }
968
- }
969
-
970
- // Copyright (c) Microsoft Corporation.
971
- class SegmentFactory {
972
- constructor(shardFactory) {
973
- this.shardFactory = shardFactory;
974
- }
975
- async create(containerClient, manifestPath, cursor, options = {}) {
976
- const { span, updatedOptions } = createSpan("SegmentFactory-create", options);
977
- try {
978
- const shards = [];
979
- const dateTime = parseDateFromSegmentPath(manifestPath);
980
- const blobClient = containerClient.getBlobClient(manifestPath);
981
- const blobDownloadRes = await blobClient.download(undefined, undefined, {
982
- abortSignal: options.abortSignal,
983
- tracingOptions: updatedOptions.tracingOptions,
984
- });
985
- const blobContent = await bodyToString(blobDownloadRes);
986
- const segmentManifest = JSON.parse(blobContent);
987
- const containerPrefixLength = CHANGE_FEED_CONTAINER_NAME.length + 1; // "$blobchangefeed/"
988
- for (const shardPath of segmentManifest.chunkFilePaths) {
989
- const shardPathSubStr = shardPath.substring(containerPrefixLength);
990
- const shardCursor = cursor === null || cursor === void 0 ? void 0 : cursor.ShardCursors.find((x) => x.CurrentChunkPath.startsWith(shardPathSubStr));
991
- const shard = await this.shardFactory.create(containerClient, shardPathSubStr, shardCursor, {
992
- abortSignal: options.abortSignal,
993
- tracingOptions: updatedOptions.tracingOptions,
994
- });
995
- if (shard.hasNext()) {
996
- shards.push(shard);
997
- }
998
- }
999
- let shardIndex = 0;
1000
- if (cursor === null || cursor === void 0 ? void 0 : cursor.CurrentShardPath) {
1001
- shardIndex = shards.findIndex((s) => s.shardPath === (cursor === null || cursor === void 0 ? void 0 : cursor.CurrentShardPath));
1002
- if (shardIndex === -1) {
1003
- shardIndex = 0;
1004
- }
1005
- }
1006
- return new Segment(shards, shardIndex, dateTime, manifestPath);
1007
- }
1008
- catch (e) {
1009
- span.setStatus({
1010
- code: coreTracing.SpanStatusCode.ERROR,
1011
- message: e.message,
1012
- });
1013
- throw e;
1014
- }
1015
- finally {
1016
- span.end();
1017
- }
1018
- }
1019
- }
1020
-
1021
- // Copyright (c) Microsoft Corporation.
1022
- class Shard {
1023
- constructor(containerClient, chunkFactory, chunks, currentChunk, shardPath) {
1024
- this.shardPath = shardPath;
1025
- this.containerClient = containerClient;
1026
- this.chunkFactory = chunkFactory;
1027
- this.chunks = chunks;
1028
- this.currentChunk = currentChunk;
1029
- }
1030
- hasNext() {
1031
- return (this.chunks.length > 0 || (this.currentChunk !== undefined && this.currentChunk.hasNext()));
1032
- }
1033
- async getChange(options = {}) {
1034
- const { span, updatedOptions } = createSpan("Shard-getChange", options);
1035
- try {
1036
- let event = undefined;
1037
- while (event === undefined && this.hasNext()) {
1038
- event = await this.currentChunk.getChange();
1039
- // Remove currentChunk if it doesn't have more events.
1040
- if (!this.currentChunk.hasNext() && this.chunks.length > 0) {
1041
- this.currentChunk = await this.chunkFactory.create(this.containerClient, this.chunks.shift(), undefined, undefined, {
1042
- abortSignal: options.abortSignal,
1043
- tracingOptions: updatedOptions.tracingOptions,
1044
- });
1045
- }
1046
- }
1047
- return event;
1048
- }
1049
- catch (e) {
1050
- span.setStatus({
1051
- code: coreTracing.SpanStatusCode.ERROR,
1052
- message: e.message,
1053
- });
1054
- throw e;
1055
- }
1056
- finally {
1057
- span.end();
1058
- }
1059
- }
1060
- getCursor() {
1061
- return this.currentChunk === undefined
1062
- ? undefined
1063
- : {
1064
- CurrentChunkPath: this.currentChunk.chunkPath,
1065
- BlockOffset: this.currentChunk.blockOffset,
1066
- EventIndex: this.currentChunk.eventIndex,
1067
- };
1068
- }
1069
- }
1070
-
1071
- // Copyright (c) Microsoft Corporation.
1072
- class ShardFactory {
1073
- constructor(chunkFactory) {
1074
- this.chunkFactory = chunkFactory;
1075
- }
1076
- async create(containerClient, shardPath, shardCursor, options = {}) {
1077
- var e_1, _a;
1078
- const { span, updatedOptions } = createSpan("ShardFactory-create", options);
1079
- try {
1080
- const chunks = [];
1081
- const blockOffset = (shardCursor === null || shardCursor === void 0 ? void 0 : shardCursor.BlockOffset) || 0;
1082
- const eventIndex = (shardCursor === null || shardCursor === void 0 ? void 0 : shardCursor.EventIndex) || 0;
1083
- try {
1084
- for (var _b = tslib.__asyncValues(containerClient.listBlobsFlat({
1085
- prefix: shardPath,
1086
- abortSignal: options.abortSignal,
1087
- tracingOptions: updatedOptions.tracingOptions,
1088
- })), _c; _c = await _b.next(), !_c.done;) {
1089
- const blobItem = _c.value;
1090
- chunks.push(blobItem.name);
1091
- }
1092
- }
1093
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1094
- finally {
1095
- try {
1096
- if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
1097
- }
1098
- finally { if (e_1) throw e_1.error; }
1099
- }
1100
- const currentChunkPath = shardCursor === null || shardCursor === void 0 ? void 0 : shardCursor.CurrentChunkPath;
1101
- let chunkIndex = -1;
1102
- let currentChunk = undefined;
1103
- // Chunks can be empty right after hour flips.
1104
- if (chunks.length !== 0) {
1105
- // Fast forward to current Chunk
1106
- if (currentChunkPath) {
1107
- for (let i = 0; i < chunks.length; i++) {
1108
- if (chunks[i] === currentChunkPath) {
1109
- chunkIndex = i;
1110
- break;
1111
- }
1112
- }
1113
- if (chunkIndex === -1) {
1114
- throw new Error(`Chunk ${currentChunkPath} not found.`);
1115
- }
1116
- }
1117
- else {
1118
- chunkIndex = 0;
1119
- }
1120
- // Fast forward to current Chunk.
1121
- if (chunkIndex > 0) {
1122
- chunks.splice(0, chunkIndex);
1123
- }
1124
- currentChunk = await this.chunkFactory.create(containerClient, chunks.shift(), blockOffset, eventIndex, {
1125
- abortSignal: options.abortSignal,
1126
- tracingOptions: updatedOptions.tracingOptions,
1127
- });
1128
- }
1129
- return new Shard(containerClient, this.chunkFactory, chunks, currentChunk, shardPath);
1130
- }
1131
- catch (e) {
1132
- span.setStatus({
1133
- code: coreTracing.SpanStatusCode.ERROR,
1134
- message: e.message,
1135
- });
1136
- throw e;
1137
- }
1138
- finally {
1139
- span.end();
1140
- }
1141
- }
1142
- }
1143
-
1144
- // Copyright (c) Microsoft Corporation.
1145
- class Chunk {
1146
- constructor(avroReader, blockOffset, eventIndex, chunkPath, avroOptions = {}) {
1147
- this.chunkPath = chunkPath;
1148
- this.avroReader = avroReader;
1149
- this._blockOffset = blockOffset;
1150
- this._eventIndex = eventIndex;
1151
- this.iter = this.avroReader.parseObjects(avroOptions);
1152
- }
1153
- get blockOffset() {
1154
- return this._blockOffset;
1155
- }
1156
- get eventIndex() {
1157
- return this._eventIndex;
1158
- }
1159
- hasNext() {
1160
- return this.avroReader.hasNext();
1161
- }
1162
- async getChange() {
1163
- if (!this.hasNext()) {
1164
- return undefined;
1165
- }
1166
- const next = await this.iter.next();
1167
- this._eventIndex = this.avroReader.objectIndex;
1168
- this._blockOffset = this.avroReader.blockOffset;
1169
- if (next.done) {
1170
- return undefined;
1171
- }
1172
- else {
1173
- const eventRaw = next.value;
1174
- if (eventRaw === null) {
1175
- return undefined;
1176
- }
1177
- return rawEventToBlobChangeFeedEvent(eventRaw);
1178
- }
1179
- }
1180
- }
1181
-
1182
- // Copyright (c) Microsoft Corporation.
1183
- class ChunkFactory {
1184
- constructor(avroReaderFactory, lazyLoadingBlobStreamFactory) {
1185
- this.avroReaderFactory = avroReaderFactory;
1186
- this.lazyLoadingBlobStreamFactory = lazyLoadingBlobStreamFactory;
1187
- }
1188
- async create(containerClient, chunkPath, blockOffset, eventIndex, options = {}) {
1189
- const blobClient = containerClient.getBlobClient(chunkPath);
1190
- blockOffset = blockOffset || 0;
1191
- eventIndex = eventIndex || 0;
1192
- const dataStream = streamToAvroReadable(this.lazyLoadingBlobStreamFactory.create(blobClient, blockOffset, CHANGE_FEED_CHUNK_BLOCK_DOWNLOAD_SIZE, options));
1193
- let avroReader;
1194
- if (blockOffset !== 0) {
1195
- const headerStream = streamToAvroReadable(this.lazyLoadingBlobStreamFactory.create(blobClient, 0, CHANGE_FEED_CHUNK_BLOCK_DOWNLOAD_SIZE, options));
1196
- avroReader = this.avroReaderFactory.create(dataStream, headerStream, blockOffset, eventIndex);
1197
- }
1198
- else {
1199
- avroReader = this.avroReaderFactory.create(dataStream);
1200
- }
1201
- return new Chunk(avroReader, blockOffset, eventIndex, chunkPath, {
1202
- abortSignal: options.abortSignal,
1203
- });
1204
- }
1205
- }
1206
-
1207
- // Copyright (c) Microsoft Corporation.
1208
- /**
1209
- * Creates AvroReaders. Allows us to inject mock AvroReaders in the Chunk unit tests.
1210
- */
1211
- class AvroReaderFactory {
1212
- create(dataStream, headerStream, blockOffset, eventIndex) {
1213
- if (headerStream) {
1214
- return new AvroReader(dataStream, headerStream, blockOffset, eventIndex);
1215
- }
1216
- else {
1217
- return new AvroReader(dataStream);
1218
- }
1219
- }
1220
- }
1221
-
1222
- // Copyright (c) Microsoft Corporation.
1223
- /**
1224
- * This class generates a readable stream from a blobClient's data.
1225
- */
1226
- class LazyLoadingBlobStream extends stream.Readable {
1227
- /**
1228
- * Creates an instance of LazyLoadingBlobStream.
1229
- *
1230
- * @param byteLength - The total length of data contained in the buffers
1231
- */
1232
- constructor(blobClient, offset, blockSize, options) {
1233
- super(options);
1234
- this.blobClient = blobClient;
1235
- this.offset = offset;
1236
- this.blockSize = blockSize;
1237
- this.lastDownloadBytes = -1;
1238
- this.blobLength = -1;
1239
- this.options = options;
1240
- }
1241
- async downloadBlock(options = {}) {
1242
- const { span, updatedOptions } = createSpan("LazyLoadingBlobStream-downloadBlock", options);
1243
- try {
1244
- const properties = await this.blobClient.getProperties({
1245
- abortSignal: options.abortSignal,
1246
- tracingOptions: updatedOptions.tracingOptions,
1247
- });
1248
- this.blobLength = properties.contentLength;
1249
- this.lastDownloadBytes = Math.min(this.blockSize, this.blobLength - this.offset);
1250
- if (this.lastDownloadBytes === 0) {
1251
- this.lastDownloadData = undefined;
1252
- return;
1253
- }
1254
- this.lastDownloadData = await this.blobClient.downloadToBuffer(this.offset, this.lastDownloadBytes, {
1255
- abortSignal: options.abortSignal,
1256
- tracingOptions: updatedOptions.tracingOptions,
1257
- });
1258
- this.offset += this.lastDownloadBytes;
1259
- }
1260
- catch (e) {
1261
- span.setStatus({
1262
- code: coreTracing.SpanStatusCode.ERROR,
1263
- message: e.message,
1264
- });
1265
- throw e;
1266
- }
1267
- finally {
1268
- span.end();
1269
- }
1270
- }
1271
- /**
1272
- * Internal _read() that will be called when the stream wants to pull more data in.
1273
- *
1274
- * @param size - Optional. The size of data to be read
1275
- */
1276
- async _read(size) {
1277
- var _a, _b, _c, _d;
1278
- const { span, updatedOptions } = createSpan("LazyLoadingBlobStream-read", this.options);
1279
- try {
1280
- if (!size) {
1281
- size = this.readableHighWaterMark;
1282
- }
1283
- let count = 0;
1284
- let chunkSize = 0;
1285
- const chunksToPush = [];
1286
- do {
1287
- if (this.lastDownloadData === undefined || ((_a = this.lastDownloadData) === null || _a === void 0 ? void 0 : _a.byteLength) === 0) {
1288
- await this.downloadBlock({
1289
- abortSignal: (_b = this.options) === null || _b === void 0 ? void 0 : _b.abortSignal,
1290
- tracingOptions: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.tracingOptions,
1291
- });
1292
- }
1293
- if ((_c = this.lastDownloadData) === null || _c === void 0 ? void 0 : _c.byteLength) {
1294
- chunkSize = Math.min(size - count, (_d = this.lastDownloadData) === null || _d === void 0 ? void 0 : _d.byteLength);
1295
- chunksToPush.push(this.lastDownloadData.slice(0, chunkSize));
1296
- this.lastDownloadData = this.lastDownloadData.slice(chunkSize);
1297
- count += chunkSize;
1298
- }
1299
- else {
1300
- chunkSize = 0;
1301
- }
1302
- } while (chunkSize > 0 && count < size);
1303
- this.push(Buffer.concat(chunksToPush));
1304
- if (count < size) {
1305
- this.push(null);
1306
- }
1307
- }
1308
- catch (e) {
1309
- span.setStatus({
1310
- code: coreTracing.SpanStatusCode.ERROR,
1311
- message: e.message,
1312
- });
1313
- this.emit("error", e);
1314
- }
1315
- finally {
1316
- span.end();
1317
- }
1318
- }
1319
- }
1320
-
1321
- // Copyright (c) Microsoft Corporation.
1322
- class LazyLoadingBlobStreamFactory {
1323
- create(blobClient, offset, blockSize, options) {
1324
- return new LazyLoadingBlobStream(blobClient, offset, blockSize, options);
1325
- }
1326
- }
1327
-
1328
- // Copyright (c) Microsoft Corporation.
1329
- class ChangeFeedFactory {
1330
- constructor(segmentFactory) {
1331
- if (segmentFactory) {
1332
- this.segmentFactory = segmentFactory;
1333
- }
1334
- else {
1335
- this.segmentFactory = new SegmentFactory(new ShardFactory(new ChunkFactory(new AvroReaderFactory(), new LazyLoadingBlobStreamFactory())));
1336
- }
1337
- }
1338
- static validateCursor(containerClient, cursor) {
1339
- if (getHost(containerClient.url) !== cursor.UrlHost) {
1340
- throw new Error("Cursor URL host does not match container URL host.");
1341
- }
1342
- if (cursor.CursorVersion !== 1) {
1343
- throw new Error("Unsupported cursor version.");
1344
- }
1345
- }
1346
- async create(blobServiceClient, continuationToken, options = {}) {
1347
- const { span, updatedOptions } = createSpan("ChangeFeedFactory-create", options);
1348
- try {
1349
- const containerClient = blobServiceClient.getContainerClient(CHANGE_FEED_CONTAINER_NAME);
1350
- let cursor = undefined;
1351
- // Create cursor.
1352
- if (continuationToken) {
1353
- cursor = JSON.parse(continuationToken);
1354
- ChangeFeedFactory.validateCursor(containerClient, cursor);
1355
- options.start = parseDateFromSegmentPath(cursor.CurrentSegmentCursor.SegmentPath);
1356
- options.end = new Date(cursor.EndTime);
1357
- }
1358
- // Round start and end time if we are not using the cursor.
1359
- else {
1360
- options.start = floorToNearestHour(options.start);
1361
- options.end = ceilToNearestHour(options.end);
1362
- }
1363
- // Check if Change Feed has been enabled for this account.
1364
- const changeFeedContainerExists = await containerClient.exists({
1365
- abortSignal: options.abortSignal,
1366
- tracingOptions: updatedOptions.tracingOptions,
1367
- });
1368
- if (!changeFeedContainerExists) {
1369
- throw new Error("Change Feed hasn't been enabled on this account, or is currently being enabled.");
1370
- }
1371
- if (options.start && options.end && options.start >= options.end) {
1372
- return new ChangeFeed();
1373
- }
1374
- // Get last consumable.
1375
- const blobClient = containerClient.getBlobClient(CHANGE_FEED_META_SEGMENT_PATH);
1376
- const blobDownloadRes = await blobClient.download(undefined, undefined, {
1377
- abortSignal: options.abortSignal,
1378
- tracingOptions: updatedOptions.tracingOptions,
1379
- });
1380
- const lastConsumable = new Date(JSON.parse(await bodyToString(blobDownloadRes)).lastConsumable);
1381
- // Get year paths
1382
- const years = await getYearsPaths(containerClient, {
1383
- abortSignal: options.abortSignal,
1384
- tracingOptions: updatedOptions.tracingOptions,
1385
- });
1386
- // Dequeue any years that occur before start time.
1387
- if (options.start) {
1388
- const startYear = options.start.getUTCFullYear();
1389
- while (years.length > 0 && years[0] < startYear) {
1390
- years.shift();
1391
- }
1392
- }
1393
- if (years.length === 0) {
1394
- return new ChangeFeed();
1395
- }
1396
- let segments = [];
1397
- while (segments.length === 0 && years.length !== 0) {
1398
- segments = await getSegmentsInYear(containerClient, years.shift(), options.start, minDate(lastConsumable, options.end), {
1399
- abortSignal: options.abortSignal,
1400
- tracingOptions: updatedOptions.tracingOptions,
1401
- });
1402
- }
1403
- if (segments.length === 0) {
1404
- return new ChangeFeed();
1405
- }
1406
- const currentSegment = await this.segmentFactory.create(containerClient, segments.shift(), cursor === null || cursor === void 0 ? void 0 : cursor.CurrentSegmentCursor, {
1407
- abortSignal: options.abortSignal,
1408
- tracingOptions: updatedOptions.tracingOptions,
1409
- });
1410
- return new ChangeFeed(containerClient, this.segmentFactory, years, segments, currentSegment, lastConsumable, options.start, options.end);
1411
- }
1412
- catch (e) {
1413
- span.setStatus({
1414
- code: coreTracing.SpanStatusCode.ERROR,
1415
- message: e.message,
1416
- });
1417
- throw e;
1418
- }
1419
- finally {
1420
- span.end();
1421
- }
1422
- }
1423
- }
1424
-
1425
- // Copyright (c) Microsoft Corporation.
1426
- /**
1427
- * Contains paged response data for the {@link BlobChangeFeedClient.listChanges} operation.
1428
- */
1429
- class BlobChangeFeedEventPage {
1430
- constructor() {
1431
- this.events = [];
1432
- this.continuationToken = "";
1433
- }
1434
- }
1435
- /**
1436
- * Creates a new Pipeline object with Credential provided.
1437
- *
1438
- * @param credential - Such as AnonymousCredential, StorageSharedKeyCredential or any credential from the `@azure/identity` package to authenticate requests to the service. You can also provide an object that implements the TokenCredential interface. If not specified, AnonymousCredential is used.
1439
- * @param pipelineOptions - Optional. Options.
1440
- * @returns A new Pipeline object.
1441
- */
1442
- function newPipeline(credential, pipelineOptions = {}) {
1443
- return newPipeline(credential, appendUserAgentPrefix(pipelineOptions));
1444
- }
1445
- function appendUserAgentPrefix(options) {
1446
- if (!options) {
1447
- options = {};
1448
- }
1449
- if (options.userAgentOptions === undefined) {
1450
- options.userAgentOptions = {};
1451
- }
1452
- if (options.userAgentOptions.userAgentPrefix === undefined) {
1453
- options.userAgentOptions.userAgentPrefix = "";
1454
- }
1455
- else if (options.userAgentOptions.userAgentPrefix !== "") {
1456
- options.userAgentOptions.userAgentPrefix += " ";
1457
- }
1458
- options.userAgentOptions.userAgentPrefix += `changefeed-js/${SDK_VERSION}`;
1459
- return options;
1460
- }
1461
- /**
1462
- * BlobChangeFeedClient.
1463
- * @see https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal
1464
- */
1465
- class BlobChangeFeedClient {
1466
- constructor(urlOrClient, credentialOrPipeline,
1467
- // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
1468
- /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
1469
- options) {
1470
- this.changeFeedFactory = new ChangeFeedFactory();
1471
- if (credentialOrPipeline instanceof storageBlob.Pipeline) {
1472
- this.blobServiceClient = new storageBlob.BlobServiceClient(urlOrClient, credentialOrPipeline);
1473
- }
1474
- else {
1475
- this.blobServiceClient = new storageBlob.BlobServiceClient(urlOrClient, credentialOrPipeline, appendUserAgentPrefix(options));
1476
- }
1477
- }
1478
- /**
1479
- *
1480
- * Creates an instance of BlobChangeFeedClient from connection string.
1481
- *
1482
- * @param connectionString - Account connection string or a SAS connection string of an Azure storage account.
1483
- * [ Note - Account connection string can only be used in NODE.JS runtime. ]
1484
- * Account connection string example -
1485
- * `DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net`
1486
- * SAS connection string example -
1487
- * `BlobEndpoint=https://myaccount.blob.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString`
1488
- * @param options - Optional. Options to configure the HTTP pipeline.
1489
- */
1490
- static fromConnectionString(connectionString,
1491
- // Legacy, no way to fix the eslint error without breaking. Disable the rule for this line.
1492
- /* eslint-disable-next-line @azure/azure-sdk/ts-naming-options */
1493
- options) {
1494
- const blobServiceClient = storageBlob.BlobServiceClient.fromConnectionString(connectionString, options);
1495
- return new BlobChangeFeedClient(blobServiceClient.url, blobServiceClient.credential, appendUserAgentPrefix(options));
1496
- }
1497
- getChange(options = {}) {
1498
- return tslib.__asyncGenerator(this, arguments, function* getChange_1() {
1499
- const changeFeed = yield tslib.__await(this.changeFeedFactory.create(this.blobServiceClient, undefined, options));
1500
- while (changeFeed.hasNext()) {
1501
- const event = yield tslib.__await(changeFeed.getChange({
1502
- abortSignal: options.abortSignal,
1503
- tracingOptions: options.tracingOptions,
1504
- }));
1505
- if (event) {
1506
- yield yield tslib.__await(event);
1507
- }
1508
- else {
1509
- return yield tslib.__await(void 0);
1510
- }
1511
- }
1512
- });
1513
- }
1514
- // start in ChangeFeedListChangesOptions will be ignored when continuationToken is specified.
1515
- getPage(continuationToken, maxPageSize, options = {}) {
1516
- return tslib.__asyncGenerator(this, arguments, function* getPage_1() {
1517
- const changeFeed = yield tslib.__await(this.changeFeedFactory.create(this.blobServiceClient, continuationToken, options));
1518
- if (!maxPageSize || maxPageSize > CHANGE_FEED_MAX_PAGE_SIZE) {
1519
- maxPageSize = CHANGE_FEED_MAX_PAGE_SIZE;
1520
- }
1521
- while (changeFeed.hasNext()) {
1522
- const eventPage = new BlobChangeFeedEventPage();
1523
- while (changeFeed.hasNext() && eventPage.events.length < maxPageSize) {
1524
- const event = yield tslib.__await(changeFeed.getChange({
1525
- abortSignal: options.abortSignal,
1526
- tracingOptions: options.tracingOptions,
1527
- }));
1528
- if (event) {
1529
- eventPage.events.push(event);
1530
- }
1531
- }
1532
- if (changeFeed.hasNext()) {
1533
- eventPage.continuationToken = JSON.stringify(changeFeed.getCursor());
1534
- }
1535
- if (eventPage.events.length > 0) {
1536
- yield yield tslib.__await(eventPage);
1537
- }
1538
- else {
1539
- return yield tslib.__await(void 0);
1540
- }
1541
- }
1542
- });
1543
- }
1544
- /**
1545
- * Returns an async iterable iterator to list all the change feed events
1546
- * in the specified account.
1547
- *
1548
- * .byPage() returns an async iterable iterator to list the change feed events in pages.
1549
- *
1550
- * Example using `for await` syntax:
1551
- *
1552
- * ```js
1553
- * let i = 1;
1554
- * for await (const event of blobChangeFeedClient.listChanges()) {
1555
- * console.log(`Event ${i++}, type: ${event.eventType}`);
1556
- * }
1557
- * ```
1558
- *
1559
- * Example using `iter.next()`:
1560
- *
1561
- * ```js
1562
- * let i = 1;
1563
- * const iter = blobChangeFeedClient.listChanges();
1564
- * let eventItem = await iter.next();
1565
- * while (!eventItem.done) {
1566
- * console.log(`Event ${i++}, type: ${eventItem.eventType}`);
1567
- * eventItem = await iter.next();
1568
- * }
1569
- * ```
1570
- *
1571
- * Example using `byPage()`:
1572
- *
1573
- * ```js
1574
- * // passing optional maxPageSize in the page settings
1575
- * let i = 1;
1576
- * for await (const eventPage of blobChangeFeedClient.listChanges().byPage({ maxPageSize: 20 })) {
1577
- * if (eventPage.events) {
1578
- * for (const event of eventPage.events) {
1579
- * console.log(`Event ${i++}, type: ${event.eventType}`);
1580
- * }
1581
- * }
1582
- * }
1583
- * ```
1584
- *
1585
- * Example using paging with a marker:
1586
- *
1587
- * ```js
1588
- * let i = 1;
1589
- * let iterator = blobChangeFeedClient.listChanges().byPage({ maxPageSize: 2 });
1590
- * let eventPage = (await iterator.next()).value;
1591
- *
1592
- * if (eventPage.events) {
1593
- * for (const container of eventPage.events) {
1594
- * console.log(`Event ${i++}, type: ${event.eventType}`);
1595
- * }
1596
- * }
1597
- *
1598
- * // Gets next marker
1599
- * let marker = eventPage.continuationToken;
1600
- * // Passing next marker as continuationToken
1601
- * iterator = blobChangeFeedClient
1602
- * .listChanges()
1603
- * .byPage({ continuationToken: marker, maxPageSize: 10 });
1604
- * eventPage = (await iterator.next()).value;
1605
- *
1606
- * if (eventPage.events) {
1607
- * for (const container of eventPage.events) {
1608
- * console.log(`Event ${i++}, type: ${event.eventType}`);
1609
- * }
1610
- * }
1611
- * ```
1612
- *
1613
- * @param options - Options to list change feed events.
1614
- * @returns An asyncIterableIterator that supports paging.
1615
- */
1616
- listChanges(options = {}) {
1617
- const iter = this.getChange(options);
1618
- return {
1619
- /**
1620
- * The next method, part of the iteration protocol
1621
- */
1622
- async next() {
1623
- return iter.next();
1624
- },
1625
- /**
1626
- * The connection to the async iterator, part of the iteration protocol
1627
- */
1628
- [Symbol.asyncIterator]() {
1629
- return this;
1630
- },
1631
- /**
1632
- * Return an AsyncIterableIterator that works a page at a time
1633
- */
1634
- byPage: (settings = {}) => {
1635
- return this.getPage(settings.continuationToken, settings.maxPageSize, options);
1636
- },
1637
- };
1638
- }
1639
- }
1640
-
1641
- exports.BlobChangeFeedClient = BlobChangeFeedClient;
1642
- exports.BlobChangeFeedEventPage = BlobChangeFeedEventPage;
1643
- exports.newPipeline = newPipeline;
1644
- //# sourceMappingURL=index.js.map