@typespec/ts-http-runtime 1.0.0-alpha.20240226.1 → 1.0.0-alpha.20240228.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/dist/browser/auth/keyCredential.d.ts +6 -0
  2. package/dist/browser/auth/keyCredential.d.ts.map +1 -1
  3. package/dist/browser/auth/keyCredential.js +9 -1
  4. package/dist/browser/auth/keyCredential.js.map +1 -1
  5. package/dist/browser/client/clientHelpers.d.ts.map +1 -1
  6. package/dist/browser/client/clientHelpers.js +1 -3
  7. package/dist/browser/client/clientHelpers.js.map +1 -1
  8. package/dist/browser/client/getClient.d.ts.map +1 -1
  9. package/dist/browser/client/getClient.js +5 -7
  10. package/dist/browser/client/getClient.js.map +1 -1
  11. package/dist/browser/client/sendRequest.d.ts +1 -14
  12. package/dist/browser/client/sendRequest.d.ts.map +1 -1
  13. package/dist/browser/client/sendRequest.js +50 -51
  14. package/dist/browser/client/sendRequest.js.map +1 -1
  15. package/dist/browser/index.d.ts +1 -1
  16. package/dist/browser/index.d.ts.map +1 -1
  17. package/dist/browser/index.js +1 -0
  18. package/dist/browser/index.js.map +1 -1
  19. package/dist/browser/nodeHttpClient.js.map +1 -1
  20. package/dist/browser/policies/formDataPolicy.js +5 -3
  21. package/dist/browser/policies/formDataPolicy.js.map +1 -1
  22. package/dist/browser/policies/multipartPolicy.d.ts.map +1 -1
  23. package/dist/browser/policies/multipartPolicy.js +5 -5
  24. package/dist/browser/policies/multipartPolicy.js.map +1 -1
  25. package/dist/browser/util/concat-browser.d.mts.map +1 -0
  26. package/dist/browser/util/concat-browser.mjs.map +1 -0
  27. package/dist/browser/util/concat.d.ts +19 -0
  28. package/dist/browser/util/concat.js +45 -0
  29. package/dist/browser/util/file.d.ts +8 -0
  30. package/dist/browser/util/file.d.ts.map +1 -1
  31. package/dist/browser/util/file.js +59 -12
  32. package/dist/browser/util/file.js.map +1 -1
  33. package/dist/commonjs/auth/keyCredential.d.ts +6 -0
  34. package/dist/commonjs/auth/keyCredential.d.ts.map +1 -1
  35. package/dist/commonjs/auth/keyCredential.js +11 -0
  36. package/dist/commonjs/auth/keyCredential.js.map +1 -1
  37. package/dist/commonjs/client/clientHelpers.d.ts.map +1 -1
  38. package/dist/commonjs/client/clientHelpers.js +2 -4
  39. package/dist/commonjs/client/clientHelpers.js.map +1 -1
  40. package/dist/commonjs/client/getClient.d.ts.map +1 -1
  41. package/dist/commonjs/client/getClient.js +4 -6
  42. package/dist/commonjs/client/getClient.js.map +1 -1
  43. package/dist/commonjs/client/sendRequest.d.ts +1 -14
  44. package/dist/commonjs/client/sendRequest.d.ts.map +1 -1
  45. package/dist/commonjs/client/sendRequest.js +51 -53
  46. package/dist/commonjs/client/sendRequest.js.map +1 -1
  47. package/dist/commonjs/index.d.ts +1 -1
  48. package/dist/commonjs/index.d.ts.map +1 -1
  49. package/dist/commonjs/index.js +4 -2
  50. package/dist/commonjs/index.js.map +1 -1
  51. package/dist/commonjs/nodeHttpClient.js.map +1 -1
  52. package/dist/commonjs/policies/formDataPolicy.js +5 -3
  53. package/dist/commonjs/policies/formDataPolicy.js.map +1 -1
  54. package/dist/commonjs/policies/multipartPolicy.d.ts.map +1 -1
  55. package/dist/commonjs/policies/multipartPolicy.js +5 -5
  56. package/dist/commonjs/policies/multipartPolicy.js.map +1 -1
  57. package/dist/commonjs/tsdoc-metadata.json +1 -1
  58. package/dist/commonjs/util/concat.d.ts +18 -0
  59. package/dist/commonjs/util/concat.d.ts.map +1 -0
  60. package/dist/commonjs/util/concat.js +74 -0
  61. package/dist/commonjs/util/concat.js.map +1 -0
  62. package/dist/commonjs/util/file.d.ts +8 -0
  63. package/dist/commonjs/util/file.d.ts.map +1 -1
  64. package/dist/commonjs/util/file.js +61 -13
  65. package/dist/commonjs/util/file.js.map +1 -1
  66. package/dist/esm/auth/keyCredential.d.ts +6 -0
  67. package/dist/esm/auth/keyCredential.d.ts.map +1 -1
  68. package/dist/esm/auth/keyCredential.js +9 -1
  69. package/dist/esm/auth/keyCredential.js.map +1 -1
  70. package/dist/esm/client/clientHelpers.d.ts.map +1 -1
  71. package/dist/esm/client/clientHelpers.js +1 -3
  72. package/dist/esm/client/clientHelpers.js.map +1 -1
  73. package/dist/esm/client/getClient.d.ts.map +1 -1
  74. package/dist/esm/client/getClient.js +5 -7
  75. package/dist/esm/client/getClient.js.map +1 -1
  76. package/dist/esm/client/sendRequest.d.ts +1 -14
  77. package/dist/esm/client/sendRequest.d.ts.map +1 -1
  78. package/dist/esm/client/sendRequest.js +50 -51
  79. package/dist/esm/client/sendRequest.js.map +1 -1
  80. package/dist/esm/index.d.ts +1 -1
  81. package/dist/esm/index.d.ts.map +1 -1
  82. package/dist/esm/index.js +1 -0
  83. package/dist/esm/index.js.map +1 -1
  84. package/dist/esm/nodeHttpClient.js.map +1 -1
  85. package/dist/esm/policies/formDataPolicy.js +5 -3
  86. package/dist/esm/policies/formDataPolicy.js.map +1 -1
  87. package/dist/esm/policies/multipartPolicy.d.ts.map +1 -1
  88. package/dist/esm/policies/multipartPolicy.js +5 -5
  89. package/dist/esm/policies/multipartPolicy.js.map +1 -1
  90. package/dist/esm/util/concat.d.ts +18 -0
  91. package/dist/esm/util/concat.d.ts.map +1 -0
  92. package/dist/esm/util/concat.js +70 -0
  93. package/dist/esm/util/concat.js.map +1 -0
  94. package/dist/esm/util/file.d.ts +8 -0
  95. package/dist/esm/util/file.d.ts.map +1 -1
  96. package/dist/esm/util/file.js +59 -12
  97. package/dist/esm/util/file.js.map +1 -1
  98. package/dist/react-native/auth/keyCredential.d.ts +6 -0
  99. package/dist/react-native/auth/keyCredential.d.ts.map +1 -1
  100. package/dist/react-native/auth/keyCredential.js +9 -1
  101. package/dist/react-native/auth/keyCredential.js.map +1 -1
  102. package/dist/react-native/client/clientHelpers.d.ts.map +1 -1
  103. package/dist/react-native/client/clientHelpers.js +1 -3
  104. package/dist/react-native/client/clientHelpers.js.map +1 -1
  105. package/dist/react-native/client/getClient.d.ts.map +1 -1
  106. package/dist/react-native/client/getClient.js +5 -7
  107. package/dist/react-native/client/getClient.js.map +1 -1
  108. package/dist/react-native/client/sendRequest.d.ts +1 -14
  109. package/dist/react-native/client/sendRequest.d.ts.map +1 -1
  110. package/dist/react-native/client/sendRequest.js +50 -51
  111. package/dist/react-native/client/sendRequest.js.map +1 -1
  112. package/dist/react-native/index.d.ts +1 -1
  113. package/dist/react-native/index.d.ts.map +1 -1
  114. package/dist/react-native/index.js +1 -0
  115. package/dist/react-native/index.js.map +1 -1
  116. package/dist/react-native/nodeHttpClient.js.map +1 -1
  117. package/dist/react-native/policies/formDataPolicy.js +5 -3
  118. package/dist/react-native/policies/formDataPolicy.js.map +1 -1
  119. package/dist/react-native/policies/multipartPolicy.d.ts.map +1 -1
  120. package/dist/react-native/policies/multipartPolicy.js +5 -5
  121. package/dist/react-native/policies/multipartPolicy.js.map +1 -1
  122. package/dist/react-native/util/concat.d.ts +18 -0
  123. package/dist/react-native/util/concat.d.ts.map +1 -0
  124. package/dist/react-native/util/concat.js +70 -0
  125. package/dist/react-native/util/concat.js.map +1 -0
  126. package/dist/react-native/util/file.d.ts +8 -0
  127. package/dist/react-native/util/file.d.ts.map +1 -1
  128. package/dist/react-native/util/file.js +59 -12
  129. package/dist/react-native/util/file.js.map +1 -1
  130. package/dist/react-native/util/userAgentPlatform-react-native.d.mts.map +1 -1
  131. package/dist/react-native/util/userAgentPlatform-react-native.mjs.map +1 -1
  132. package/dist/react-native/util/userAgentPlatform.js +1 -3
  133. package/dist/ts-http-runtime.d.ts +7 -0
  134. package/package.json +5 -5
  135. package/dist/browser/client/helpers/getBinaryBody.d.ts +0 -5
  136. package/dist/browser/client/helpers/getBinaryBody.d.ts.map +0 -1
  137. package/dist/browser/client/helpers/getBinaryBody.js +0 -13
  138. package/dist/browser/client/helpers/getBinaryBody.js.map +0 -1
  139. package/dist/browser/util/stream-browser.d.mts.map +0 -1
  140. package/dist/browser/util/stream-browser.mjs.map +0 -1
  141. package/dist/browser/util/stream.d.ts +0 -5
  142. package/dist/browser/util/stream.js +0 -62
  143. package/dist/commonjs/client/helpers/getBinaryBody.d.ts +0 -5
  144. package/dist/commonjs/client/helpers/getBinaryBody.d.ts.map +0 -1
  145. package/dist/commonjs/client/helpers/getBinaryBody.js +0 -17
  146. package/dist/commonjs/client/helpers/getBinaryBody.js.map +0 -1
  147. package/dist/commonjs/util/stream.d.ts +0 -5
  148. package/dist/commonjs/util/stream.d.ts.map +0 -1
  149. package/dist/commonjs/util/stream.js +0 -69
  150. package/dist/commonjs/util/stream.js.map +0 -1
  151. package/dist/esm/client/helpers/getBinaryBody.d.ts +0 -5
  152. package/dist/esm/client/helpers/getBinaryBody.d.ts.map +0 -1
  153. package/dist/esm/client/helpers/getBinaryBody.js +0 -13
  154. package/dist/esm/client/helpers/getBinaryBody.js.map +0 -1
  155. package/dist/esm/util/stream.d.ts +0 -5
  156. package/dist/esm/util/stream.d.ts.map +0 -1
  157. package/dist/esm/util/stream.js +0 -63
  158. package/dist/esm/util/stream.js.map +0 -1
  159. package/dist/react-native/client/helpers/getBinaryBody.d.ts +0 -5
  160. package/dist/react-native/client/helpers/getBinaryBody.d.ts.map +0 -1
  161. package/dist/react-native/client/helpers/getBinaryBody.js +0 -13
  162. package/dist/react-native/client/helpers/getBinaryBody.js.map +0 -1
  163. package/dist/react-native/util/stream.d.ts +0 -5
  164. package/dist/react-native/util/stream.d.ts.map +0 -1
  165. package/dist/react-native/util/stream.js +0 -63
  166. package/dist/react-native/util/stream.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- import { toWebStream } from "./stream.js";
3
+ import { isNode } from "./checkEnvironment.js";
4
+ import { isNodeReadableStream } from "./typeGuards.js";
4
5
  const unimplementedMethods = {
5
6
  arrayBuffer: () => {
6
7
  throw new Error("Not implemented");
@@ -12,6 +13,39 @@ const unimplementedMethods = {
12
13
  throw new Error("Not implemented");
13
14
  },
14
15
  };
16
+ /**
17
+ * Private symbol used as key on objects created using createFile containing the
18
+ * original source of the file object.
19
+ *
20
+ * This is used in Node to access the original Node stream without using Blob#stream, which
21
+ * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and
22
+ * Readable#to/fromWeb in Node versions we support:
23
+ * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)
24
+ * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)
25
+ *
26
+ * Once these versions are no longer supported, we may be able to stop doing this.
27
+ *
28
+ * @internal
29
+ */
30
+ const rawContent = Symbol("rawContent");
31
+ function hasRawContent(x) {
32
+ return typeof x[rawContent] === "function";
33
+ }
34
+ /**
35
+ * Extract the raw content from a given blob-like object. If the input was created using createFile
36
+ * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.
37
+ * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.
38
+ *
39
+ * @internal
40
+ */
41
+ export function getRawContent(blob) {
42
+ if (hasRawContent(blob)) {
43
+ return blob[rawContent]();
44
+ }
45
+ else {
46
+ return blob.stream();
47
+ }
48
+ }
15
49
  /**
16
50
  * Create an object that implements the File interface. This object is intended to be
17
51
  * passed into RequestBodyType.formData, and is not guaranteed to work as expected in
@@ -37,7 +71,14 @@ export function createFileFromStream(stream, name, options = {}) {
37
71
  webkitRelativePath: options.webkitRelativePath ?? "",
38
72
  size: options.size ?? -1,
39
73
  name,
40
- stream: () => toWebStream(stream()),
74
+ stream: () => {
75
+ const s = stream();
76
+ if (isNodeReadableStream(s)) {
77
+ throw new Error("Not supported: a Node stream was provided as input to createFileFromStream.");
78
+ }
79
+ return s;
80
+ },
81
+ [rawContent]: stream,
41
82
  };
42
83
  }
43
84
  /**
@@ -52,15 +93,21 @@ export function createFileFromStream(stream, name, options = {}) {
52
93
  * @param options - optional metadata about the file, e.g. file name, file size, MIME type.
53
94
  */
54
95
  export function createFile(content, name, options = {}) {
55
- return {
56
- ...unimplementedMethods,
57
- type: options.type ?? "",
58
- lastModified: options.lastModified ?? new Date().getTime(),
59
- webkitRelativePath: options.webkitRelativePath ?? "",
60
- size: content.byteLength,
61
- name,
62
- arrayBuffer: async () => content.buffer,
63
- stream: () => new Blob([content]).stream(),
64
- };
96
+ if (isNode) {
97
+ return {
98
+ ...unimplementedMethods,
99
+ type: options.type ?? "",
100
+ lastModified: options.lastModified ?? new Date().getTime(),
101
+ webkitRelativePath: options.webkitRelativePath ?? "",
102
+ size: content.byteLength,
103
+ name,
104
+ arrayBuffer: async () => content.buffer,
105
+ stream: () => new Blob([content]).stream(),
106
+ [rawContent]: () => content,
107
+ };
108
+ }
109
+ else {
110
+ return new File([content], name, options);
111
+ }
65
112
  }
66
113
  //# sourceMappingURL=file.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAoC1C,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAgE,EAChE,IAAY,EACZ,UAAuC,EAAE;IAEzC,OAAO;QACL,GAAG,oBAAoB;QACvB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;QACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;QAC1D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;QACpD,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;QACxB,IAAI;QACJ,MAAM,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB,EACnB,IAAY,EACZ,UAA6B,EAAE;IAE/B,OAAO;QACL,GAAG,oBAAoB;QACvB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;QACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;QAC1D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;QACpD,IAAI,EAAE,OAAO,CAAC,UAAU;QACxB,IAAI;QACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM;QACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE;KAC3C,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { toWebStream } from \"./stream.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => toWebStream(stream()),\n };\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n };\n}\n"]}
1
+ {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../src/util/file.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAoCvD,MAAM,oBAAoB,GAAG;IAC3B,WAAW,EAAE,GAAG,EAAE;QAChB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,KAAK,EAAE,GAAG,EAAE;QACV,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;IACD,IAAI,EAAE,GAAG,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AASvD,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAgB,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAU;IAEV,IAAI,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAgE,EAChE,IAAY,EACZ,UAAuC,EAAE;IAEzC,OAAO;QACL,GAAG,oBAAoB;QACvB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;QACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;QAC1D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;QACpD,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;QACxB,IAAI;QACJ,MAAM,EAAE,GAAG,EAAE;YACX,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC;YACnB,IAAI,oBAAoB,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CACb,6EAA6E,CAC9E,CAAC;YACJ,CAAC;YAED,OAAO,CAAC,CAAC;QACX,CAAC;QACD,CAAC,UAAU,CAAC,EAAE,MAAM;KACA,CAAC;AACzB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CACxB,OAAmB,EACnB,IAAY,EACZ,UAA6B,EAAE;IAE/B,IAAI,MAAM,EAAE,CAAC;QACX,OAAO;YACL,GAAG,oBAAoB;YACvB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,EAAE;YACxB,YAAY,EAAE,OAAO,CAAC,YAAY,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE;YAC1D,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,EAAE;YACpD,IAAI,EAAE,OAAO,CAAC,UAAU;YACxB,IAAI;YACJ,WAAW,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM;YACvC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE;YAC1C,CAAC,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC,OAAO;SACP,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,IAAI,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isNode } from \"./checkEnvironment.js\";\nimport { isNodeReadableStream } from \"./typeGuards.js\";\n\n/**\n * Options passed into createFile specifying metadata about the file.\n */\nexport interface CreateFileOptions {\n /**\n * The MIME type of the file.\n */\n type?: string;\n\n /**\n * Last modified time of the file as a UNIX timestamp.\n * This will default to the current date.\n */\n lastModified?: number;\n\n /**\n * relative path of this file when uploading a directory.\n */\n webkitRelativePath?: string;\n}\n\n/**\n * Extra options for createFile when a stream is being passed in.\n */\nexport interface CreateFileFromStreamOptions extends CreateFileOptions {\n /**\n * Size of the file represented by the stream in bytes.\n *\n * This will be used by the pipeline when calculating the Content-Length header\n * for the overall request.\n */\n size?: number;\n}\n\nconst unimplementedMethods = {\n arrayBuffer: () => {\n throw new Error(\"Not implemented\");\n },\n slice: () => {\n throw new Error(\"Not implemented\");\n },\n text: () => {\n throw new Error(\"Not implemented\");\n },\n};\n\n/**\n * Private symbol used as key on objects created using createFile containing the\n * original source of the file object.\n *\n * This is used in Node to access the original Node stream without using Blob#stream, which\n * returns a web stream. This is done to avoid a couple of bugs to do with Blob#stream and\n * Readable#to/fromWeb in Node versions we support:\n * - https://github.com/nodejs/node/issues/42694 (fixed in Node 18.14)\n * - https://github.com/nodejs/node/issues/48916 (fixed in Node 20.6)\n *\n * Once these versions are no longer supported, we may be able to stop doing this.\n *\n * @internal\n */\nconst rawContent: unique symbol = Symbol(\"rawContent\");\n\n/**\n * Type signature of a blob-like object with a raw content property.\n */\ninterface RawContent {\n [rawContent](): Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array>;\n}\n\nfunction hasRawContent(x: unknown): x is RawContent {\n return typeof (x as RawContent)[rawContent] === \"function\";\n}\n\n/**\n * Extract the raw content from a given blob-like object. If the input was created using createFile\n * or createFileFromStream, the exact content passed into createFile/createFileFromStream will be used.\n * For true instances of Blob and File, returns the blob's content as a Web ReadableStream<Uint8Array>.\n *\n * @internal\n */\nexport function getRawContent(\n blob: Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> | Uint8Array {\n if (hasRawContent(blob)) {\n return blob[rawContent]();\n } else {\n return blob.stream();\n }\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function to:\n * - Create a File object for use in RequestBodyType.formData in environments where the\n * global File object is unavailable.\n * - Create a File-like object from a readable stream without reading the stream into memory.\n *\n * @param stream - the content of the file as a callback returning a stream. When a File object made using createFile is\n * passed in a request's form data map, the stream will not be read into memory\n * and instead will be streamed when the request is made. In the event of a retry, the\n * stream needs to be read again, so this callback SHOULD return a fresh stream if possible.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFileFromStream(\n stream: () => ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n name: string,\n options: CreateFileFromStreamOptions = {},\n): File {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: options.size ?? -1,\n name,\n stream: () => {\n const s = stream();\n if (isNodeReadableStream(s)) {\n throw new Error(\n \"Not supported: a Node stream was provided as input to createFileFromStream.\",\n );\n }\n\n return s;\n },\n [rawContent]: stream,\n } as File & RawContent;\n}\n\n/**\n * Create an object that implements the File interface. This object is intended to be\n * passed into RequestBodyType.formData, and is not guaranteed to work as expected in\n * other situations.\n *\n * Use this function create a File object for use in RequestBodyType.formData in environments where the global File object is unavailable.\n *\n * @param content - the content of the file as a Uint8Array in memory.\n * @param name - the name of the file.\n * @param options - optional metadata about the file, e.g. file name, file size, MIME type.\n */\nexport function createFile(\n content: Uint8Array,\n name: string,\n options: CreateFileOptions = {},\n): File {\n if (isNode) {\n return {\n ...unimplementedMethods,\n type: options.type ?? \"\",\n lastModified: options.lastModified ?? new Date().getTime(),\n webkitRelativePath: options.webkitRelativePath ?? \"\",\n size: content.byteLength,\n name,\n arrayBuffer: async () => content.buffer,\n stream: () => new Blob([content]).stream(),\n [rawContent]: () => content,\n } as File & RawContent;\n } else {\n return new File([content], name, options);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAUA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAMtE"}
1
+ {"version":3,"file":"userAgentPlatform-react-native.d.mts","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAOA;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAMtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"userAgentPlatform-react-native.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AAEH,gBAAgB;AAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAwB;IAC9D,IAAI,QAAQ,CAAC,SAAS,EAAE,kBAAkB,EAAE,CAAC;QAC3C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACtE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/*\n * NOTE: When moving this file, please update \"react-native\" section in package.json.\n */\n\n/* @ts-ignore */\nconst { Platform } = await import(\"react-native\");\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\n/**\n * @internal\n */\nexport function setPlatformSpecificData(map: Map<string, string>): void {\n if (Platform.constants?.reactNativeVersion) {\n const { major, minor, patch } = Platform.constants.reactNativeVersion;\n map.set(\"react-native\", `${major}.${minor}.${patch}`);\n }\n map.set(\"OS\", `${Platform.OS}-${Platform.Version}`);\n}\n"]}
1
+ {"version":3,"file":"userAgentPlatform-react-native.mjs","sourceRoot":"","sources":["../../../src/util/userAgentPlatform-react-native.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,6DAA6D;AAC7D,gBAAgB;AAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,GAAwB;IAC9D,IAAI,QAAQ,CAAC,SAAS,EAAE,kBAAkB,EAAE,CAAC;QAC3C,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,kBAAkB,CAAC;QACtE,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,GAAG,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n// eslint-disable-next-line @typescript-eslint/ban-ts-comment\n/* @ts-ignore */\nconst { Platform } = await import(\"react-native\");\n\n/**\n * @internal\n */\nexport function getHeaderName(): string {\n return \"x-ms-useragent\";\n}\n\n/**\n * @internal\n */\nexport function setPlatformSpecificData(map: Map<string, string>): void {\n if (Platform.constants?.reactNativeVersion) {\n const { major, minor, patch } = Platform.constants.reactNativeVersion;\n map.set(\"react-native\", `${major}.${minor}.${patch}`);\n }\n map.set(\"OS\", `${Platform.OS}-${Platform.Version}`);\n}\n"]}
@@ -1,8 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
- /*
4
- * NOTE: When moving this file, please update "react-native" section in package.json.
5
- */
3
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
6
4
  /* @ts-ignore */
7
5
  const { Platform } = await import("react-native");
8
6
  /**
@@ -899,6 +899,13 @@ export declare const isDeno: boolean;
899
899
  */
900
900
  export declare function isError(e: unknown): e is Error;
901
901
 
902
+ /**
903
+ * Tests an object to determine whether it implements KeyCredential.
904
+ *
905
+ * @param credential - The assumed KeyCredential to be tested.
906
+ */
907
+ export declare function isKeyCredential(credential: unknown): credential is KeyCredential;
908
+
902
909
  /**
903
910
  * A constant that indicates whether the environment the code is running is Node.JS.
904
911
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typespec/ts-http-runtime",
3
- "version": "1.0.0-alpha.20240226.1",
3
+ "version": "1.0.0-alpha.20240228.1",
4
4
  "description": "Isomorphic client library for making HTTP requests in node.js and browser.",
5
5
  "sdk-type": "client",
6
6
  "type": "module",
@@ -52,16 +52,16 @@
52
52
  "build:samples": "echo Obsolete",
53
53
  "build:test": "npm run clean && tshy && dev-tool run build-test",
54
54
  "build": "npm run clean && tshy && api-extractor run --local",
55
- "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
55
+ "check-format": "dev-tool run vendored prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
56
56
  "clean": "rimraf --glob dist dist-* temp types *.tgz *.log",
57
57
  "execute:samples": "echo skipped",
58
58
  "extract-api": "tshy && api-extractor run --local",
59
- "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
59
+ "format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.{ts,cts,mts}\" \"test/**/*.{ts,cts,mts}\" \"*.{js,cjs,mjs,json}\"",
60
60
  "integration-test:browser": "echo skipped",
61
61
  "integration-test:node": "echo skipped",
62
62
  "integration-test": "npm run integration-test:node && npm run integration-test:browser",
63
- "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
64
- "lint": "eslint package.json api-extractor.json src test --ext .ts",
63
+ "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --ext .cts --ext .mts --fix --fix-type [problem,suggestion]",
64
+ "lint": "eslint package.json api-extractor.json src test --ext .ts --ext .cts --ext .mts",
65
65
  "pack": "npm pack 2>&1",
66
66
  "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser && npm run integration-test:browser",
67
67
  "test:node": "npm run clean && tshy && npm run unit-test:node && npm run integration-test:node",
@@ -1,5 +0,0 @@
1
- /**
2
- * Converts binary content to its string representation
3
- */
4
- export declare function binaryArrayToString(content: Uint8Array): string;
5
- //# sourceMappingURL=getBinaryBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO/D"}
@@ -1,13 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * Converts binary content to its string representation
5
- */
6
- export function binaryArrayToString(content) {
7
- let decodedBody = "";
8
- for (const element of content) {
9
- decodedBody += String.fromCharCode(element);
10
- }
11
- return decodedBody;
12
- }
13
- //# sourceMappingURL=getBinaryBody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.js","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmB;IACrD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-browser.d.mts","sourceRoot":"","sources":["../../../src/util/stream-browser.mts"],"names":[],"mappings":";AAKA,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,UAAU,GAAG,IAAI,GAC7E,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAYpD;AAED,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GACzD,cAAc,CAAC,UAAU,CAAC,CAM5B;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,GACpC,cAAc,CAAC,UAAU,CAAC,CAuC5B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream-browser.mjs","sourceRoot":"","sources":["../../../src/util/stream-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE9D,MAAM,UAAU,QAAQ,CACtB,MAA8E;IAE9E,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QACjC,OAAO,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC;SAAM,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QACvC,OAAO,MAAM,CAAC;IAChB,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,MAA0D;IAE1D,IAAI,mBAAmB,CAAC,MAAM,CAAC,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAqC;IAErC,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,MAAM,GAAG,gBAAgB,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC;IAEnD,KAAK,UAAU,MAAM,CAAC,UAAuD;QAC3E,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,UAAU,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,IAAI,KAA6B,CAAC;QAClC,IAAI,IAAyB,CAAC;QAE9B,IAAI,CAAC;YACH,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACpB,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,GAAG,gBAAgB,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC;YAC/C,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,OAAO,IAAI,cAAc,CAAa;QACpC,IAAI,CAAC,UAAU;YACb,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5B,CAAC;QAED,MAAM,CAAC,MAAM;YACX,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { isBlob, isWebReadableStream } from \"./typeGuards.js\";\n\nexport function toStream(\n source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob,\n): ReadableStream<Uint8Array> | NodeJS.ReadableStream {\n if (source instanceof Uint8Array) {\n return new Blob([source]).stream();\n } else if (isWebReadableStream(source)) {\n return source;\n } else if (isBlob(source)) {\n return source.stream();\n } else {\n throw new Error(\n \"Unsupported type. Only ReadableStream, Uint8Array and Blob are supported in browser\",\n );\n }\n}\n\nexport function toWebStream(\n stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n): ReadableStream<Uint8Array> {\n if (isWebReadableStream(stream)) {\n return stream;\n } else {\n throw new Error(\"Did not expect a Node stream in browser environment\");\n }\n}\n\nexport function concatenateStreams(\n streams: ReadableStream<Uint8Array>[],\n): ReadableStream<Uint8Array> {\n const remainingStreams = Array.from(streams);\n let reader = remainingStreams.shift()?.getReader();\n\n async function doPull(controller: ReadableStreamDefaultController<Uint8Array>): Promise<void> {\n if (!reader) {\n controller.close();\n return;\n }\n\n let value: Uint8Array | undefined;\n let done: boolean | undefined;\n\n try {\n ({ value, done } = await reader.read());\n } catch (e) {\n controller.error(e);\n reader.releaseLock();\n return;\n }\n\n if (done) {\n reader.releaseLock();\n reader = remainingStreams.shift()?.getReader();\n await doPull(controller);\n } else {\n controller.enqueue(value);\n }\n }\n\n return new ReadableStream<Uint8Array>({\n pull(controller) {\n return doPull(controller);\n },\n\n cancel(reason) {\n reader?.cancel(reason);\n },\n });\n}\n"]}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- export declare function toStream(source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob): ReadableStream<Uint8Array> | NodeJS.ReadableStream;
3
- export declare function toWebStream(stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream): ReadableStream<Uint8Array>;
4
- export declare function concatenateStreams(streams: ReadableStream<Uint8Array>[]): ReadableStream<Uint8Array>;
5
- //# sourceMappingURL=stream-browser.d.mts.map
@@ -1,62 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { isBlob, isWebReadableStream } from "./typeGuards.js";
4
- export function toStream(source) {
5
- if (source instanceof Uint8Array) {
6
- return new Blob([source]).stream();
7
- }
8
- else if (isWebReadableStream(source)) {
9
- return source;
10
- }
11
- else if (isBlob(source)) {
12
- return source.stream();
13
- }
14
- else {
15
- throw new Error("Unsupported type. Only ReadableStream, Uint8Array and Blob are supported in browser");
16
- }
17
- }
18
- export function toWebStream(stream) {
19
- if (isWebReadableStream(stream)) {
20
- return stream;
21
- }
22
- else {
23
- throw new Error("Did not expect a Node stream in browser environment");
24
- }
25
- }
26
- export function concatenateStreams(streams) {
27
- const remainingStreams = Array.from(streams);
28
- let reader = remainingStreams.shift()?.getReader();
29
- async function doPull(controller) {
30
- if (!reader) {
31
- controller.close();
32
- return;
33
- }
34
- let value;
35
- let done;
36
- try {
37
- ({ value, done } = await reader.read());
38
- }
39
- catch (e) {
40
- controller.error(e);
41
- reader.releaseLock();
42
- return;
43
- }
44
- if (done) {
45
- reader.releaseLock();
46
- reader = remainingStreams.shift()?.getReader();
47
- await doPull(controller);
48
- }
49
- else {
50
- controller.enqueue(value);
51
- }
52
- }
53
- return new ReadableStream({
54
- pull(controller) {
55
- return doPull(controller);
56
- },
57
- cancel(reason) {
58
- reader?.cancel(reason);
59
- },
60
- });
61
- }
62
- //# sourceMappingURL=stream-browser.mjs.map
@@ -1,5 +0,0 @@
1
- /**
2
- * Converts binary content to its string representation
3
- */
4
- export declare function binaryArrayToString(content: Uint8Array): string;
5
- //# sourceMappingURL=getBinaryBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO/D"}
@@ -1,17 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT license.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.binaryArrayToString = void 0;
6
- /**
7
- * Converts binary content to its string representation
8
- */
9
- function binaryArrayToString(content) {
10
- let decodedBody = "";
11
- for (const element of content) {
12
- decodedBody += String.fromCharCode(element);
13
- }
14
- return decodedBody;
15
- }
16
- exports.binaryArrayToString = binaryArrayToString;
17
- //# sourceMappingURL=getBinaryBody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.js","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAAmB;IACrD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAPD,kDAOC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n"]}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- export declare function toWebStream(stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream): ReadableStream<Uint8Array>;
3
- export declare function toStream(source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob): NodeJS.ReadableStream | ReadableStream<Uint8Array>;
4
- export declare function concatenateStreams(sources: (ReadableStream<Uint8Array> | NodeJS.ReadableStream)[]): ReadableStream<Uint8Array> | NodeJS.ReadableStream;
5
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/util/stream.ts"],"names":[],"mappings":";AAwCA,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GACzD,cAAc,CAAC,UAAU,CAAC,CAI5B;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,UAAU,GAAG,IAAI,GAC7E,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAUpD;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,GAC9D,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAcpD"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT license.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.concatenateStreams = exports.toStream = exports.toWebStream = void 0;
6
- const node_stream_1 = require("node:stream");
7
- const typeGuards_js_1 = require("./typeGuards.js");
8
- async function* streamAsyncIterator() {
9
- const reader = this.getReader();
10
- try {
11
- while (true) {
12
- const { done, value } = await reader.read();
13
- if (done) {
14
- return;
15
- }
16
- yield value;
17
- }
18
- }
19
- finally {
20
- reader.releaseLock();
21
- }
22
- }
23
- function makeAsyncIterable(webStream) {
24
- if (!webStream[Symbol.asyncIterator]) {
25
- webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);
26
- }
27
- if (!webStream.values) {
28
- webStream.values = streamAsyncIterator.bind(webStream);
29
- }
30
- }
31
- function nodeStreamFromWebStream(webStream) {
32
- makeAsyncIterable(webStream);
33
- return node_stream_1.Readable.fromWeb(webStream);
34
- }
35
- function toWebStream(stream) {
36
- return (0, typeGuards_js_1.isWebReadableStream)(stream)
37
- ? stream
38
- : node_stream_1.Readable.toWeb(node_stream_1.Readable.from(stream));
39
- }
40
- exports.toWebStream = toWebStream;
41
- function toStream(source) {
42
- if (source instanceof Uint8Array) {
43
- return node_stream_1.Readable.from(Buffer.from(source));
44
- }
45
- else if ((0, typeGuards_js_1.isBlob)(source)) {
46
- return nodeStreamFromWebStream(source.stream());
47
- }
48
- else if ((0, typeGuards_js_1.isNodeReadableStream)(source)) {
49
- return source;
50
- }
51
- else {
52
- return nodeStreamFromWebStream(source);
53
- }
54
- }
55
- exports.toStream = toStream;
56
- function concatenateStreams(sources) {
57
- if (sources.some(typeGuards_js_1.isWebReadableStream)) {
58
- throw new Error("Was not expecting a Web stream here");
59
- }
60
- return node_stream_1.Readable.from((async function* () {
61
- for (const stream of sources) {
62
- for await (const chunk of stream) {
63
- yield chunk;
64
- }
65
- }
66
- })());
67
- }
68
- exports.concatenateStreams = concatenateStreams;
69
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/util/stream.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,6CAAuC;AAEvC,mDAAoF;AAEpF,KAAK,SAAS,CAAC,CAAC,mBAAmB;IAGjC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO;YACT,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAI,SAAc;IAC1C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACtB,SAAS,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAqC;IACpE,iBAAiB,CAAa,SAAS,CAAC,CAAC;IACzC,OAAO,sBAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,SAAgB,WAAW,CACzB,MAA0D;IAE1D,OAAO,IAAA,mCAAmB,EAAC,MAAM,CAAC;QAChC,CAAC,CAAC,MAAM;QACR,CAAC,CAAE,sBAAQ,CAAC,KAAK,CAAC,sBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAgC,CAAC;AAC5E,CAAC;AAND,kCAMC;AAED,SAAgB,QAAQ,CACtB,MAA8E;IAE9E,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QACjC,OAAO,sBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,IAAA,sBAAM,EAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,uBAAuB,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,IAAA,oCAAoB,EAAC,MAAM,CAAC,EAAE,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAZD,4BAYC;AAED,SAAgB,kBAAkB,CAChC,OAA+D;IAE/D,IAAI,OAAO,CAAC,IAAI,CAAC,mCAAmB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,sBAAQ,CAAC,IAAI,CAClB,CAAC,KAAK,SAAS,CAAC;QACd,KAAK,MAAM,MAAM,IAAI,OAAkC,EAAE,CAAC;YACxD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBACjC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CACL,CAAC;AACJ,CAAC;AAhBD,gDAgBC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Readable } from \"node:stream\";\nimport { ReadableStream as AsyncIterableReadableStream } from \"node:stream/web\";\nimport { isBlob, isNodeReadableStream, isWebReadableStream } from \"./typeGuards.js\";\n\nasync function* streamAsyncIterator(\n this: ReadableStream<Uint8Array>,\n): AsyncIterableIterator<Uint8Array> {\n const reader = this.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n return;\n }\n\n yield value;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction makeAsyncIterable<T>(webStream: any): asserts webStream is AsyncIterableReadableStream<T> {\n if (!webStream[Symbol.asyncIterator]) {\n webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);\n }\n\n if (!webStream.values) {\n webStream.values = streamAsyncIterator.bind(webStream);\n }\n}\n\nfunction nodeStreamFromWebStream(webStream: ReadableStream<Uint8Array>): NodeJS.ReadableStream {\n makeAsyncIterable<Uint8Array>(webStream);\n return Readable.fromWeb(webStream);\n}\n\nexport function toWebStream(\n stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n): ReadableStream<Uint8Array> {\n return isWebReadableStream(stream)\n ? stream\n : (Readable.toWeb(Readable.from(stream)) as ReadableStream<Uint8Array>);\n}\n\nexport function toStream(\n source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> {\n if (source instanceof Uint8Array) {\n return Readable.from(Buffer.from(source));\n } else if (isBlob(source)) {\n return nodeStreamFromWebStream(source.stream());\n } else if (isNodeReadableStream(source)) {\n return source;\n } else {\n return nodeStreamFromWebStream(source);\n }\n}\n\nexport function concatenateStreams(\n sources: (ReadableStream<Uint8Array> | NodeJS.ReadableStream)[],\n): ReadableStream<Uint8Array> | NodeJS.ReadableStream {\n if (sources.some(isWebReadableStream)) {\n throw new Error(\"Was not expecting a Web stream here\");\n }\n\n return Readable.from(\n (async function* () {\n for (const stream of sources as NodeJS.ReadableStream[]) {\n for await (const chunk of stream) {\n yield chunk;\n }\n }\n })(),\n );\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Converts binary content to its string representation
3
- */
4
- export declare function binaryArrayToString(content: Uint8Array): string;
5
- //# sourceMappingURL=getBinaryBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO/D"}
@@ -1,13 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * Converts binary content to its string representation
5
- */
6
- export function binaryArrayToString(content) {
7
- let decodedBody = "";
8
- for (const element of content) {
9
- decodedBody += String.fromCharCode(element);
10
- }
11
- return decodedBody;
12
- }
13
- //# sourceMappingURL=getBinaryBody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.js","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmB;IACrD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n"]}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- export declare function toWebStream(stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream): ReadableStream<Uint8Array>;
3
- export declare function toStream(source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob): NodeJS.ReadableStream | ReadableStream<Uint8Array>;
4
- export declare function concatenateStreams(sources: (ReadableStream<Uint8Array> | NodeJS.ReadableStream)[]): ReadableStream<Uint8Array> | NodeJS.ReadableStream;
5
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/util/stream.ts"],"names":[],"mappings":";AAwCA,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GACzD,cAAc,CAAC,UAAU,CAAC,CAI5B;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,UAAU,GAAG,IAAI,GAC7E,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAUpD;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,GAC9D,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAcpD"}
@@ -1,63 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- import { Readable } from "node:stream";
4
- import { isBlob, isNodeReadableStream, isWebReadableStream } from "./typeGuards.js";
5
- async function* streamAsyncIterator() {
6
- const reader = this.getReader();
7
- try {
8
- while (true) {
9
- const { done, value } = await reader.read();
10
- if (done) {
11
- return;
12
- }
13
- yield value;
14
- }
15
- }
16
- finally {
17
- reader.releaseLock();
18
- }
19
- }
20
- function makeAsyncIterable(webStream) {
21
- if (!webStream[Symbol.asyncIterator]) {
22
- webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);
23
- }
24
- if (!webStream.values) {
25
- webStream.values = streamAsyncIterator.bind(webStream);
26
- }
27
- }
28
- function nodeStreamFromWebStream(webStream) {
29
- makeAsyncIterable(webStream);
30
- return Readable.fromWeb(webStream);
31
- }
32
- export function toWebStream(stream) {
33
- return isWebReadableStream(stream)
34
- ? stream
35
- : Readable.toWeb(Readable.from(stream));
36
- }
37
- export function toStream(source) {
38
- if (source instanceof Uint8Array) {
39
- return Readable.from(Buffer.from(source));
40
- }
41
- else if (isBlob(source)) {
42
- return nodeStreamFromWebStream(source.stream());
43
- }
44
- else if (isNodeReadableStream(source)) {
45
- return source;
46
- }
47
- else {
48
- return nodeStreamFromWebStream(source);
49
- }
50
- }
51
- export function concatenateStreams(sources) {
52
- if (sources.some(isWebReadableStream)) {
53
- throw new Error("Was not expecting a Web stream here");
54
- }
55
- return Readable.from((async function* () {
56
- for (const stream of sources) {
57
- for await (const chunk of stream) {
58
- yield chunk;
59
- }
60
- }
61
- })());
62
- }
63
- //# sourceMappingURL=stream.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../src/util/stream.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEpF,KAAK,SAAS,CAAC,CAAC,mBAAmB;IAGjC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;IAChC,IAAI,CAAC;QACH,OAAO,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;YAC5C,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO;YACT,CAAC;YAED,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,WAAW,EAAE,CAAC;IACvB,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAI,SAAc;IAC1C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;QACrC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxE,CAAC;IAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACtB,SAAS,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,SAAqC;IACpE,iBAAiB,CAAa,SAAS,CAAC,CAAC;IACzC,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AACrC,CAAC;AAED,MAAM,UAAU,WAAW,CACzB,MAA0D;IAE1D,OAAO,mBAAmB,CAAC,MAAM,CAAC;QAChC,CAAC,CAAC,MAAM;QACR,CAAC,CAAE,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAgC,CAAC;AAC5E,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,MAA8E;IAE9E,IAAI,MAAM,YAAY,UAAU,EAAE,CAAC;QACjC,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QAC1B,OAAO,uBAAuB,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,oBAAoB,CAAC,MAAM,CAAC,EAAE,CAAC;QACxC,OAAO,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAA+D;IAE/D,IAAI,OAAO,CAAC,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAClB,CAAC,KAAK,SAAS,CAAC;QACd,KAAK,MAAM,MAAM,IAAI,OAAkC,EAAE,CAAC;YACxD,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;gBACjC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;IACH,CAAC,CAAC,EAAE,CACL,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Readable } from \"node:stream\";\nimport { ReadableStream as AsyncIterableReadableStream } from \"node:stream/web\";\nimport { isBlob, isNodeReadableStream, isWebReadableStream } from \"./typeGuards.js\";\n\nasync function* streamAsyncIterator(\n this: ReadableStream<Uint8Array>,\n): AsyncIterableIterator<Uint8Array> {\n const reader = this.getReader();\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n return;\n }\n\n yield value;\n }\n } finally {\n reader.releaseLock();\n }\n}\n\nfunction makeAsyncIterable<T>(webStream: any): asserts webStream is AsyncIterableReadableStream<T> {\n if (!webStream[Symbol.asyncIterator]) {\n webStream[Symbol.asyncIterator] = streamAsyncIterator.bind(webStream);\n }\n\n if (!webStream.values) {\n webStream.values = streamAsyncIterator.bind(webStream);\n }\n}\n\nfunction nodeStreamFromWebStream(webStream: ReadableStream<Uint8Array>): NodeJS.ReadableStream {\n makeAsyncIterable<Uint8Array>(webStream);\n return Readable.fromWeb(webStream);\n}\n\nexport function toWebStream(\n stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream,\n): ReadableStream<Uint8Array> {\n return isWebReadableStream(stream)\n ? stream\n : (Readable.toWeb(Readable.from(stream)) as ReadableStream<Uint8Array>);\n}\n\nexport function toStream(\n source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob,\n): NodeJS.ReadableStream | ReadableStream<Uint8Array> {\n if (source instanceof Uint8Array) {\n return Readable.from(Buffer.from(source));\n } else if (isBlob(source)) {\n return nodeStreamFromWebStream(source.stream());\n } else if (isNodeReadableStream(source)) {\n return source;\n } else {\n return nodeStreamFromWebStream(source);\n }\n}\n\nexport function concatenateStreams(\n sources: (ReadableStream<Uint8Array> | NodeJS.ReadableStream)[],\n): ReadableStream<Uint8Array> | NodeJS.ReadableStream {\n if (sources.some(isWebReadableStream)) {\n throw new Error(\"Was not expecting a Web stream here\");\n }\n\n return Readable.from(\n (async function* () {\n for (const stream of sources as NodeJS.ReadableStream[]) {\n for await (const chunk of stream) {\n yield chunk;\n }\n }\n })(),\n );\n}\n"]}
@@ -1,5 +0,0 @@
1
- /**
2
- * Converts binary content to its string representation
3
- */
4
- export declare function binaryArrayToString(content: Uint8Array): string;
5
- //# sourceMappingURL=getBinaryBody.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.d.ts","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,UAAU,GAAG,MAAM,CAO/D"}
@@ -1,13 +0,0 @@
1
- // Copyright (c) Microsoft Corporation.
2
- // Licensed under the MIT license.
3
- /**
4
- * Converts binary content to its string representation
5
- */
6
- export function binaryArrayToString(content) {
7
- let decodedBody = "";
8
- for (const element of content) {
9
- decodedBody += String.fromCharCode(element);
10
- }
11
- return decodedBody;
12
- }
13
- //# sourceMappingURL=getBinaryBody.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"getBinaryBody.js","sourceRoot":"","sources":["../../../../src/client/helpers/getBinaryBody.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;GAEG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAmB;IACrD,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,WAAW,IAAI,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Converts binary content to its string representation\n */\nexport function binaryArrayToString(content: Uint8Array): string {\n let decodedBody = \"\";\n for (const element of content) {\n decodedBody += String.fromCharCode(element);\n }\n\n return decodedBody;\n}\n"]}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- export declare function toWebStream(stream: ReadableStream<Uint8Array> | NodeJS.ReadableStream): ReadableStream<Uint8Array>;
3
- export declare function toStream(source: ReadableStream<Uint8Array> | NodeJS.ReadableStream | Uint8Array | Blob): NodeJS.ReadableStream | ReadableStream<Uint8Array>;
4
- export declare function concatenateStreams(sources: (ReadableStream<Uint8Array> | NodeJS.ReadableStream)[]): ReadableStream<Uint8Array> | NodeJS.ReadableStream;
5
- //# sourceMappingURL=stream.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/util/stream.ts"],"names":[],"mappings":";AAwCA,wBAAgB,WAAW,CACzB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GACzD,cAAc,CAAC,UAAU,CAAC,CAI5B;AAED,wBAAgB,QAAQ,CACtB,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,GAAG,UAAU,GAAG,IAAI,GAC7E,MAAM,CAAC,cAAc,GAAG,cAAc,CAAC,UAAU,CAAC,CAUpD;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,CAAC,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,GAC9D,cAAc,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,cAAc,CAcpD"}