@typespec/ts-http-runtime 0.2.1-alpha.20250404.1 → 0.2.1-alpha.20250417.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/browser/util/checkEnvironment.d.ts +0 -5
- package/dist/browser/util/checkEnvironment.js +0 -5
- package/dist/browser/util/checkEnvironment.js.map +1 -1
- package/dist/browser/util/delay.d.ts +0 -13
- package/dist/browser/util/delay.js +0 -19
- package/dist/browser/util/delay.js.map +1 -1
- package/dist/browser/util/error.d.ts +0 -7
- package/dist/browser/util/error.js +0 -26
- package/dist/browser/util/error.js.map +1 -1
- package/dist/browser/util/internal.d.ts +9 -0
- package/dist/browser/util/internal.js +11 -0
- package/dist/browser/util/internal.js.map +1 -0
- package/dist/browser/util/typeGuards.d.ts +0 -17
- package/dist/browser/util/typeGuards.js +0 -31
- package/dist/browser/util/typeGuards.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +1 -1
- package/dist/commonjs/util/checkEnvironment.d.ts +0 -5
- package/dist/commonjs/util/checkEnvironment.js +1 -6
- package/dist/commonjs/util/checkEnvironment.js.map +1 -1
- package/dist/commonjs/util/delay.d.ts +0 -13
- package/dist/commonjs/util/delay.js +0 -20
- package/dist/commonjs/util/delay.js.map +1 -1
- package/dist/commonjs/util/error.d.ts +0 -7
- package/dist/commonjs/util/error.js +0 -27
- package/dist/commonjs/util/error.js.map +1 -1
- package/dist/commonjs/util/internal.d.ts +9 -0
- package/dist/commonjs/util/internal.js +30 -0
- package/dist/commonjs/util/internal.js.map +1 -0
- package/dist/commonjs/util/typeGuards.d.ts +0 -17
- package/dist/commonjs/util/typeGuards.js +0 -34
- package/dist/commonjs/util/typeGuards.js.map +1 -1
- package/dist/esm/util/checkEnvironment.d.ts +0 -5
- package/dist/esm/util/checkEnvironment.js +0 -5
- package/dist/esm/util/checkEnvironment.js.map +1 -1
- package/dist/esm/util/delay.d.ts +0 -13
- package/dist/esm/util/delay.js +0 -19
- package/dist/esm/util/delay.js.map +1 -1
- package/dist/esm/util/error.d.ts +0 -7
- package/dist/esm/util/error.js +0 -26
- package/dist/esm/util/error.js.map +1 -1
- package/dist/esm/util/internal.d.ts +9 -0
- package/dist/esm/util/internal.js +11 -0
- package/dist/esm/util/internal.js.map +1 -0
- package/dist/esm/util/typeGuards.d.ts +0 -17
- package/dist/esm/util/typeGuards.js +0 -31
- package/dist/esm/util/typeGuards.js.map +1 -1
- package/dist/react-native/util/checkEnvironment.d.ts +0 -5
- package/dist/react-native/util/checkEnvironment.js +0 -5
- package/dist/react-native/util/checkEnvironment.js.map +1 -1
- package/dist/react-native/util/delay.d.ts +0 -13
- package/dist/react-native/util/delay.js +0 -19
- package/dist/react-native/util/delay.js.map +1 -1
- package/dist/react-native/util/error.d.ts +0 -7
- package/dist/react-native/util/error.js +0 -26
- package/dist/react-native/util/error.js.map +1 -1
- package/dist/react-native/util/internal.d.ts +9 -0
- package/dist/react-native/util/internal.js +11 -0
- package/dist/react-native/util/internal.js.map +1 -0
- package/dist/react-native/util/typeGuards.d.ts +0 -17
- package/dist/react-native/util/typeGuards.js +0 -31
- package/dist/react-native/util/typeGuards.js.map +1 -1
- package/package.json +22 -3
- package/dist/browser/util/aborterUtils.d.ts +0 -26
- package/dist/browser/util/aborterUtils.js +0 -21
- package/dist/browser/util/aborterUtils.js.map +0 -1
- package/dist/browser/util/createAbortablePromise.d.ts +0 -16
- package/dist/browser/util/createAbortablePromise.js +0 -42
- package/dist/browser/util/createAbortablePromise.js.map +0 -1
- package/dist/commonjs/util/aborterUtils.d.ts +0 -26
- package/dist/commonjs/util/aborterUtils.js +0 -24
- package/dist/commonjs/util/aborterUtils.js.map +0 -1
- package/dist/commonjs/util/createAbortablePromise.d.ts +0 -16
- package/dist/commonjs/util/createAbortablePromise.js +0 -45
- package/dist/commonjs/util/createAbortablePromise.js.map +0 -1
- package/dist/esm/util/aborterUtils.d.ts +0 -26
- package/dist/esm/util/aborterUtils.js +0 -21
- package/dist/esm/util/aborterUtils.js.map +0 -1
- package/dist/esm/util/createAbortablePromise.d.ts +0 -16
- package/dist/esm/util/createAbortablePromise.js +0 -42
- package/dist/esm/util/createAbortablePromise.js.map +0 -1
- package/dist/react-native/util/aborterUtils.d.ts +0 -26
- package/dist/react-native/util/aborterUtils.js +0 -21
- package/dist/react-native/util/aborterUtils.js.map +0 -1
- package/dist/react-native/util/createAbortablePromise.d.ts +0 -16
- package/dist/react-native/util/createAbortablePromise.js +0 -42
- package/dist/react-native/util/createAbortablePromise.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUP
|
|
|
15
15
|
|
|
16
16
|
### Installation
|
|
17
17
|
|
|
18
|
-
This package is primarily used in generated code and not meant to be consumed directly by end users.
|
|
18
|
+
This package is primarily used in generated code and not meant to be consumed directly by end users. Only top-level exports from this package should be used. Any exports under the `internal` subpath are for private use and stability is not guaranteed.
|
|
19
19
|
|
|
20
20
|
## Key concepts
|
|
21
21
|
|
|
@@ -18,11 +18,6 @@ export declare const isBun: boolean;
|
|
|
18
18
|
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
19
19
|
*/
|
|
20
20
|
export declare const isNodeLike: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
23
|
-
* @deprecated Use `isNodeLike` instead.
|
|
24
|
-
*/
|
|
25
|
-
export declare const isNode: boolean;
|
|
26
21
|
/**
|
|
27
22
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
28
23
|
*/
|
|
@@ -30,11 +30,6 @@ export const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undef
|
|
|
30
30
|
export const isNodeLike = typeof globalThis.process !== "undefined" &&
|
|
31
31
|
Boolean(globalThis.process.version) &&
|
|
32
32
|
Boolean((_d = globalThis.process.versions) === null || _d === void 0 ? void 0 : _d.node);
|
|
33
|
-
/**
|
|
34
|
-
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
35
|
-
* @deprecated Use `isNodeLike` instead.
|
|
36
|
-
*/
|
|
37
|
-
export const isNode = isNodeLike;
|
|
38
33
|
/**
|
|
39
34
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
40
35
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAmClC;;GAEG;AACH,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,KAAK,UAAU;IACzC,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,4BAA4B;QACtD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,0BAA0B;QACrD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,MAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAmClC;;GAEG;AACH,yDAAyD;AACzD,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,KAAK,UAAU;IACzC,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,4BAA4B;QACtD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,0BAA0B;QACrD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GACrB,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,MAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;AAE7C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,UAAU,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC;AAE7D;;GAEG;AACH,4GAA4G;AAC5G,MAAM,CAAC,MAAM,aAAa,GACxB,OAAO,SAAS,KAAK,WAAW,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,MAAK,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ninterface Window {\n document: unknown;\n}\n\ninterface DedicatedWorkerGlobalScope {\n constructor: {\n name: string;\n };\n\n importScripts: (...paths: string[]) => void;\n}\n\ninterface Navigator {\n product: string;\n}\n\ninterface DenoGlobal {\n version: {\n deno: string;\n };\n}\n\ninterface BunGlobal {\n version: string;\n}\n\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\ndeclare const window: Window;\ndeclare const self: DedicatedWorkerGlobalScope;\ndeclare const Deno: DenoGlobal;\ndeclare const Bun: BunGlobal;\ndeclare const navigator: Navigator;\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Browser.\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\nexport const isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Worker.\n */\nexport const isWebWorker =\n typeof self === \"object\" &&\n typeof self?.importScripts === \"function\" &&\n (self.constructor?.name === \"DedicatedWorkerGlobalScope\" ||\n self.constructor?.name === \"ServiceWorkerGlobalScope\" ||\n self.constructor?.name === \"SharedWorkerGlobalScope\");\n\n/**\n * A constant that indicates whether the environment the code is running is Deno.\n */\nexport const isDeno =\n typeof Deno !== \"undefined\" &&\n typeof Deno.version !== \"undefined\" &&\n typeof Deno.version.deno !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is Bun.sh.\n */\nexport const isBun = typeof Bun !== \"undefined\" && typeof Bun.version !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Node.js compatible environment.\n */\nexport const isNodeLike =\n typeof globalThis.process !== \"undefined\" &&\n Boolean(globalThis.process.version) &&\n Boolean(globalThis.process.versions?.node);\n\n/**\n * A constant that indicates whether the environment the code is running is Node.JS.\n */\nexport const isNodeRuntime = isNodeLike && !isBun && !isDeno;\n\n/**\n * A constant that indicates whether the environment the code is running is in React-Native.\n */\n// https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js\nexport const isReactNative =\n typeof navigator !== \"undefined\" && navigator?.product === \"ReactNative\";\n"]}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import type { AbortOptions } from "./aborterUtils.js";
|
|
2
|
-
/**
|
|
3
|
-
* Options for support abort functionality for the delay method
|
|
4
|
-
*/
|
|
5
|
-
export interface DelayOptions extends AbortOptions {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.
|
|
9
|
-
* @param timeInMs - The number of milliseconds to be delayed.
|
|
10
|
-
* @param options - The options for delay - currently abort options
|
|
11
|
-
* @returns Promise that is resolved after timeInMs
|
|
12
|
-
*/
|
|
13
|
-
export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
|
|
14
1
|
/**
|
|
15
2
|
* Calculates the delay interval for retry attempts using exponential delay with jitter.
|
|
16
3
|
* @param retryAttempt - The current retry attempt number.
|
|
@@ -1,25 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { createAbortablePromise } from "./createAbortablePromise.js";
|
|
4
3
|
import { getRandomIntegerInclusive } from "./random.js";
|
|
5
|
-
const StandardAbortMessage = "The delay was aborted.";
|
|
6
|
-
/**
|
|
7
|
-
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.
|
|
8
|
-
* @param timeInMs - The number of milliseconds to be delayed.
|
|
9
|
-
* @param options - The options for delay - currently abort options
|
|
10
|
-
* @returns Promise that is resolved after timeInMs
|
|
11
|
-
*/
|
|
12
|
-
export function delay(timeInMs, options) {
|
|
13
|
-
let token;
|
|
14
|
-
const { abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
|
|
15
|
-
return createAbortablePromise((resolve) => {
|
|
16
|
-
token = setTimeout(resolve, timeInMs);
|
|
17
|
-
}, {
|
|
18
|
-
cleanupBeforeAbort: () => clearTimeout(token),
|
|
19
|
-
abortSignal,
|
|
20
|
-
abortErrorMsg: abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : StandardAbortMessage,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
4
|
/**
|
|
24
5
|
* Calculates the delay interval for retry attempts using exponential delay with jitter.
|
|
25
6
|
* @param retryAttempt - The current retry attempt number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAExD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAoB,EACpB,MAGC;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAE3E,yCAAyC;IACzC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;IAE1E,gFAAgF;IAChF,mEAAmE;IACnE,MAAM,cAAc,GAAG,YAAY,GAAG,CAAC,GAAG,yBAAyB,CAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAEzF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getRandomIntegerInclusive } from \"./random.js\";\n\n/**\n * Calculates the delay interval for retry attempts using exponential delay with jitter.\n * @param retryAttempt - The current retry attempt number.\n * @param config - The exponential retry configuration.\n * @returns An object containing the calculated retry delay.\n */\nexport function calculateRetryDelay(\n retryAttempt: number,\n config: {\n retryDelayInMs: number;\n maxRetryDelayInMs: number;\n },\n): { retryAfterInMs: number } {\n // Exponentially increase the delay each time\n const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);\n\n // Don't let the delay exceed the maximum\n const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);\n\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);\n\n return { retryAfterInMs };\n}\n"]}
|
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* @param e - Something caught by a catch clause.
|
|
4
4
|
*/
|
|
5
5
|
export declare function isError(e: unknown): e is Error;
|
|
6
|
-
/**
|
|
7
|
-
* Given what is thought to be an error object, return the message if possible.
|
|
8
|
-
* If the message is missing, returns a stringified version of the input.
|
|
9
|
-
* @param e - Something thrown from a try block
|
|
10
|
-
* @returns The error message or a string of the input
|
|
11
|
-
*/
|
|
12
|
-
export declare function getErrorMessage(e: unknown): string;
|
|
13
6
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -13,30 +13,4 @@ export function isError(e) {
|
|
|
13
13
|
}
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Given what is thought to be an error object, return the message if possible.
|
|
18
|
-
* If the message is missing, returns a stringified version of the input.
|
|
19
|
-
* @param e - Something thrown from a try block
|
|
20
|
-
* @returns The error message or a string of the input
|
|
21
|
-
*/
|
|
22
|
-
export function getErrorMessage(e) {
|
|
23
|
-
if (isError(e)) {
|
|
24
|
-
return e.message;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
let stringified;
|
|
28
|
-
try {
|
|
29
|
-
if (typeof e === "object" && e) {
|
|
30
|
-
stringified = JSON.stringify(e);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
stringified = String(e);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
catch (err) {
|
|
37
|
-
stringified = "[unable to stringify input]";
|
|
38
|
-
}
|
|
39
|
-
return `Unknown error ${stringified}`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
16
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC;QACjD,OAAO,OAAO,IAAI,UAAU,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC;QACjD,OAAO,OAAO,IAAI,UAAU,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isObject } from \"./object.js\";\n\n/**\n * Typeguard for an error object shape (has name and message)\n * @param e - Something caught by a catch clause.\n */\nexport function isError(e: unknown): e is Error {\n if (isObject(e)) {\n const hasName = typeof e.name === \"string\";\n const hasMessage = typeof e.message === \"string\";\n return hasName && hasMessage;\n }\n return false;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { calculateRetryDelay } from "./delay.js";
|
|
2
|
+
export { getRandomIntegerInclusive } from "./random.js";
|
|
3
|
+
export { isObject, type UnknownObject } from "./object.js";
|
|
4
|
+
export { isError } from "./error.js";
|
|
5
|
+
export { computeSha256Hash, computeSha256Hmac } from "./sha256.js";
|
|
6
|
+
export { randomUUID } from "./uuidUtils.js";
|
|
7
|
+
export { isBrowser, isBun, isNodeLike, isNodeRuntime, isDeno, isReactNative, isWebWorker, } from "./checkEnvironment.js";
|
|
8
|
+
export { stringToUint8Array, uint8ArrayToString, type EncodingType } from "./bytesEncoding.js";
|
|
9
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
export { calculateRetryDelay } from "./delay.js";
|
|
4
|
+
export { getRandomIntegerInclusive } from "./random.js";
|
|
5
|
+
export { isObject } from "./object.js";
|
|
6
|
+
export { isError } from "./error.js";
|
|
7
|
+
export { computeSha256Hash, computeSha256Hmac } from "./sha256.js";
|
|
8
|
+
export { randomUUID } from "./uuidUtils.js";
|
|
9
|
+
export { isBrowser, isBun, isNodeLike, isNodeRuntime, isDeno, isReactNative, isWebWorker, } from "./checkEnvironment.js";
|
|
10
|
+
export { stringToUint8Array, uint8ArrayToString } from "./bytesEncoding.js";
|
|
11
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/util/internal.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAsB,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,KAAK,EACL,UAAU,EACV,aAAa,EACb,MAAM,EACN,aAAa,EACb,WAAW,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAqB,MAAM,oBAAoB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { calculateRetryDelay } from \"./delay.js\";\nexport { getRandomIntegerInclusive } from \"./random.js\";\nexport { isObject, type UnknownObject } from \"./object.js\";\nexport { isError } from \"./error.js\";\nexport { computeSha256Hash, computeSha256Hmac } from \"./sha256.js\";\nexport { randomUUID } from \"./uuidUtils.js\";\nexport {\n isBrowser,\n isBun,\n isNodeLike,\n isNodeRuntime,\n isDeno,\n isReactNative,\n isWebWorker,\n} from \"./checkEnvironment.js\";\nexport { stringToUint8Array, uint8ArrayToString, type EncodingType } from \"./bytesEncoding.js\";\n"]}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper TypeGuard that checks if something is defined or not.
|
|
3
|
-
* @param thing - Anything
|
|
4
|
-
*/
|
|
5
|
-
export declare function isDefined<T>(thing: T | undefined | null): thing is T;
|
|
6
|
-
/**
|
|
7
|
-
* Helper TypeGuard that checks if the input is an object with the specified properties.
|
|
8
|
-
* @param thing - Anything.
|
|
9
|
-
* @param properties - The name of the properties that should appear in the object.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isObjectWithProperties<Thing, PropertyName extends string>(thing: Thing, properties: PropertyName[]): thing is Thing & Record<PropertyName, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Helper TypeGuard that checks if the input is an object with the specified property.
|
|
14
|
-
* @param thing - Any object.
|
|
15
|
-
* @param property - The name of the property that should appear in the object.
|
|
16
|
-
*/
|
|
17
|
-
export declare function objectHasProperty<Thing, PropertyName extends string>(thing: Thing, property: PropertyName): thing is Thing & Record<PropertyName, unknown>;
|
|
18
1
|
export declare function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream;
|
|
19
2
|
export declare function isWebReadableStream(x: unknown): x is ReadableStream;
|
|
20
3
|
export declare function isBinaryBody(body: unknown): body is Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array> | (() => NodeJS.ReadableStream) | (() => ReadableStream<Uint8Array>) | Blob;
|
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
/**
|
|
4
|
-
* Helper TypeGuard that checks if something is defined or not.
|
|
5
|
-
* @param thing - Anything
|
|
6
|
-
*/
|
|
7
|
-
export function isDefined(thing) {
|
|
8
|
-
return typeof thing !== "undefined" && thing !== null;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Helper TypeGuard that checks if the input is an object with the specified properties.
|
|
12
|
-
* @param thing - Anything.
|
|
13
|
-
* @param properties - The name of the properties that should appear in the object.
|
|
14
|
-
*/
|
|
15
|
-
export function isObjectWithProperties(thing, properties) {
|
|
16
|
-
if (!isDefined(thing) || typeof thing !== "object") {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
for (const property of properties) {
|
|
20
|
-
if (!objectHasProperty(thing, property)) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Helper TypeGuard that checks if the input is an object with the specified property.
|
|
28
|
-
* @param thing - Any object.
|
|
29
|
-
* @param property - The name of the property that should appear in the object.
|
|
30
|
-
*/
|
|
31
|
-
export function objectHasProperty(thing, property) {
|
|
32
|
-
return (isDefined(thing) && typeof thing === "object" && property in thing);
|
|
33
|
-
}
|
|
34
3
|
export function isNodeReadableStream(x) {
|
|
35
4
|
return Boolean(x && typeof x["pipe"] === "function");
|
|
36
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,UAAU,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACC,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAClD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,IAAa;IAQb,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,YAAY,UAAU;YACzB,gBAAgB,CAAC,IAAI,CAAC;YACtB,OAAO,IAAI,KAAK,UAAU;YAC1B,IAAI,YAAY,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAClD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return Boolean(\n x &&\n typeof (x as ReadableStream).getReader === \"function\" &&\n typeof (x as ReadableStream).tee === \"function\",\n );\n}\n\nexport function isBinaryBody(\n body: unknown,\n): body is\n | Uint8Array\n | NodeJS.ReadableStream\n | ReadableStream<Uint8Array>\n | (() => NodeJS.ReadableStream)\n | (() => ReadableStream<Uint8Array>)\n | Blob {\n return (\n body !== undefined &&\n (body instanceof Uint8Array ||\n isReadableStream(body) ||\n typeof body === \"function\" ||\n body instanceof Blob)\n );\n}\n\nexport function isReadableStream(x: unknown): x is ReadableStream | NodeJS.ReadableStream {\n return isNodeReadableStream(x) || isWebReadableStream(x);\n}\n\nexport function isBlob(x: unknown): x is Blob {\n return typeof (x as Blob).stream === \"function\";\n}\n"]}
|
|
@@ -18,11 +18,6 @@ export declare const isBun: boolean;
|
|
|
18
18
|
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
19
19
|
*/
|
|
20
20
|
export declare const isNodeLike: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
23
|
-
* @deprecated Use `isNodeLike` instead.
|
|
24
|
-
*/
|
|
25
|
-
export declare const isNode: boolean;
|
|
26
21
|
/**
|
|
27
22
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
28
23
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
var _a, _b, _c, _d;
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isReactNative = exports.isNodeRuntime = exports.
|
|
6
|
+
exports.isReactNative = exports.isNodeRuntime = exports.isNodeLike = exports.isBun = exports.isDeno = exports.isWebWorker = exports.isBrowser = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
9
9
|
*/
|
|
@@ -33,11 +33,6 @@ exports.isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined"
|
|
|
33
33
|
exports.isNodeLike = typeof globalThis.process !== "undefined" &&
|
|
34
34
|
Boolean(globalThis.process.version) &&
|
|
35
35
|
Boolean((_d = globalThis.process.versions) === null || _d === void 0 ? void 0 : _d.node);
|
|
36
|
-
/**
|
|
37
|
-
* A constant that indicates whether the environment the code is running is a Node.js compatible environment.
|
|
38
|
-
* @deprecated Use `isNodeLike` instead.
|
|
39
|
-
*/
|
|
40
|
-
exports.isNode = exports.isNodeLike;
|
|
41
36
|
/**
|
|
42
37
|
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
43
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAmClC;;GAEG;AACH,yDAAyD;AAC5C,QAAA,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACU,QAAA,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,KAAK,UAAU;IACzC,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,4BAA4B;QACtD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,0BAA0B;QACrD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACU,QAAA,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACU,QAAA,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACU,QAAA,UAAU,GACrB,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,MAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"checkEnvironment.js","sourceRoot":"","sources":["../../../src/util/checkEnvironment.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAmClC;;GAEG;AACH,yDAAyD;AAC5C,QAAA,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AAEjG;;GAEG;AACU,QAAA,WAAW,GACtB,OAAO,IAAI,KAAK,QAAQ;IACxB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,CAAA,KAAK,UAAU;IACzC,CAAC,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,4BAA4B;QACtD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,0BAA0B;QACrD,CAAA,MAAA,IAAI,CAAC,WAAW,0CAAE,IAAI,MAAK,yBAAyB,CAAC,CAAC;AAE1D;;GAEG;AACU,QAAA,MAAM,GACjB,OAAO,IAAI,KAAK,WAAW;IAC3B,OAAO,IAAI,CAAC,OAAO,KAAK,WAAW;IACnC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;AAE3C;;GAEG;AACU,QAAA,KAAK,GAAG,OAAO,GAAG,KAAK,WAAW,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,WAAW,CAAC;AAEtF;;GAEG;AACU,QAAA,UAAU,GACrB,OAAO,UAAU,CAAC,OAAO,KAAK,WAAW;IACzC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC;IACnC,OAAO,CAAC,MAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,0CAAE,IAAI,CAAC,CAAC;AAE7C;;GAEG;AACU,QAAA,aAAa,GAAG,kBAAU,IAAI,CAAC,aAAK,IAAI,CAAC,cAAM,CAAC;AAE7D;;GAEG;AACH,4GAA4G;AAC/F,QAAA,aAAa,GACxB,OAAO,SAAS,KAAK,WAAW,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,OAAO,MAAK,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\ninterface Window {\n document: unknown;\n}\n\ninterface DedicatedWorkerGlobalScope {\n constructor: {\n name: string;\n };\n\n importScripts: (...paths: string[]) => void;\n}\n\ninterface Navigator {\n product: string;\n}\n\ninterface DenoGlobal {\n version: {\n deno: string;\n };\n}\n\ninterface BunGlobal {\n version: string;\n}\n\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\ndeclare const window: Window;\ndeclare const self: DedicatedWorkerGlobalScope;\ndeclare const Deno: DenoGlobal;\ndeclare const Bun: BunGlobal;\ndeclare const navigator: Navigator;\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Browser.\n */\n// eslint-disable-next-line @azure/azure-sdk/ts-no-window\nexport const isBrowser = typeof window !== \"undefined\" && typeof window.document !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Web Worker.\n */\nexport const isWebWorker =\n typeof self === \"object\" &&\n typeof self?.importScripts === \"function\" &&\n (self.constructor?.name === \"DedicatedWorkerGlobalScope\" ||\n self.constructor?.name === \"ServiceWorkerGlobalScope\" ||\n self.constructor?.name === \"SharedWorkerGlobalScope\");\n\n/**\n * A constant that indicates whether the environment the code is running is Deno.\n */\nexport const isDeno =\n typeof Deno !== \"undefined\" &&\n typeof Deno.version !== \"undefined\" &&\n typeof Deno.version.deno !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is Bun.sh.\n */\nexport const isBun = typeof Bun !== \"undefined\" && typeof Bun.version !== \"undefined\";\n\n/**\n * A constant that indicates whether the environment the code is running is a Node.js compatible environment.\n */\nexport const isNodeLike =\n typeof globalThis.process !== \"undefined\" &&\n Boolean(globalThis.process.version) &&\n Boolean(globalThis.process.versions?.node);\n\n/**\n * A constant that indicates whether the environment the code is running is Node.JS.\n */\nexport const isNodeRuntime = isNodeLike && !isBun && !isDeno;\n\n/**\n * A constant that indicates whether the environment the code is running is in React-Native.\n */\n// https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js\nexport const isReactNative =\n typeof navigator !== \"undefined\" && navigator?.product === \"ReactNative\";\n"]}
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
import type { AbortOptions } from "./aborterUtils.js";
|
|
2
|
-
/**
|
|
3
|
-
* Options for support abort functionality for the delay method
|
|
4
|
-
*/
|
|
5
|
-
export interface DelayOptions extends AbortOptions {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.
|
|
9
|
-
* @param timeInMs - The number of milliseconds to be delayed.
|
|
10
|
-
* @param options - The options for delay - currently abort options
|
|
11
|
-
* @returns Promise that is resolved after timeInMs
|
|
12
|
-
*/
|
|
13
|
-
export declare function delay(timeInMs: number, options?: DelayOptions): Promise<void>;
|
|
14
1
|
/**
|
|
15
2
|
* Calculates the delay interval for retry attempts using exponential delay with jitter.
|
|
16
3
|
* @param retryAttempt - The current retry attempt number.
|
|
@@ -2,28 +2,8 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.delay = delay;
|
|
6
5
|
exports.calculateRetryDelay = calculateRetryDelay;
|
|
7
|
-
const createAbortablePromise_js_1 = require("./createAbortablePromise.js");
|
|
8
6
|
const random_js_1 = require("./random.js");
|
|
9
|
-
const StandardAbortMessage = "The delay was aborted.";
|
|
10
|
-
/**
|
|
11
|
-
* A wrapper for setTimeout that resolves a promise after timeInMs milliseconds.
|
|
12
|
-
* @param timeInMs - The number of milliseconds to be delayed.
|
|
13
|
-
* @param options - The options for delay - currently abort options
|
|
14
|
-
* @returns Promise that is resolved after timeInMs
|
|
15
|
-
*/
|
|
16
|
-
function delay(timeInMs, options) {
|
|
17
|
-
let token;
|
|
18
|
-
const { abortSignal, abortErrorMsg } = options !== null && options !== void 0 ? options : {};
|
|
19
|
-
return (0, createAbortablePromise_js_1.createAbortablePromise)((resolve) => {
|
|
20
|
-
token = setTimeout(resolve, timeInMs);
|
|
21
|
-
}, {
|
|
22
|
-
cleanupBeforeAbort: () => clearTimeout(token),
|
|
23
|
-
abortSignal,
|
|
24
|
-
abortErrorMsg: abortErrorMsg !== null && abortErrorMsg !== void 0 ? abortErrorMsg : StandardAbortMessage,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
7
|
/**
|
|
28
8
|
* Calculates the delay interval for retry attempts using exponential delay with jitter.
|
|
29
9
|
* @param retryAttempt - The current retry attempt number.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../../src/util/delay.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAUlC,kDAkBC;AA1BD,2CAAwD;AAExD;;;;;GAKG;AACH,SAAgB,mBAAmB,CACjC,YAAoB,EACpB,MAGC;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAE3E,yCAAyC;IACzC,MAAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;IAE1E,gFAAgF;IAChF,mEAAmE;IACnE,MAAM,cAAc,GAAG,YAAY,GAAG,CAAC,GAAG,IAAA,qCAAyB,EAAC,CAAC,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAEzF,OAAO,EAAE,cAAc,EAAE,CAAC;AAC5B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getRandomIntegerInclusive } from \"./random.js\";\n\n/**\n * Calculates the delay interval for retry attempts using exponential delay with jitter.\n * @param retryAttempt - The current retry attempt number.\n * @param config - The exponential retry configuration.\n * @returns An object containing the calculated retry delay.\n */\nexport function calculateRetryDelay(\n retryAttempt: number,\n config: {\n retryDelayInMs: number;\n maxRetryDelayInMs: number;\n },\n): { retryAfterInMs: number } {\n // Exponentially increase the delay each time\n const exponentialDelay = config.retryDelayInMs * Math.pow(2, retryAttempt);\n\n // Don't let the delay exceed the maximum\n const clampedDelay = Math.min(config.maxRetryDelayInMs, exponentialDelay);\n\n // Allow the final value to have some \"jitter\" (within 50% of the delay size) so\n // that retries across multiple clients don't occur simultaneously.\n const retryAfterInMs = clampedDelay / 2 + getRandomIntegerInclusive(0, clampedDelay / 2);\n\n return { retryAfterInMs };\n}\n"]}
|
|
@@ -3,11 +3,4 @@
|
|
|
3
3
|
* @param e - Something caught by a catch clause.
|
|
4
4
|
*/
|
|
5
5
|
export declare function isError(e: unknown): e is Error;
|
|
6
|
-
/**
|
|
7
|
-
* Given what is thought to be an error object, return the message if possible.
|
|
8
|
-
* If the message is missing, returns a stringified version of the input.
|
|
9
|
-
* @param e - Something thrown from a try block
|
|
10
|
-
* @returns The error message or a string of the input
|
|
11
|
-
*/
|
|
12
|
-
export declare function getErrorMessage(e: unknown): string;
|
|
13
6
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.isError = isError;
|
|
6
|
-
exports.getErrorMessage = getErrorMessage;
|
|
7
6
|
const object_js_1 = require("./object.js");
|
|
8
7
|
/**
|
|
9
8
|
* Typeguard for an error object shape (has name and message)
|
|
@@ -17,30 +16,4 @@ function isError(e) {
|
|
|
17
16
|
}
|
|
18
17
|
return false;
|
|
19
18
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Given what is thought to be an error object, return the message if possible.
|
|
22
|
-
* If the message is missing, returns a stringified version of the input.
|
|
23
|
-
* @param e - Something thrown from a try block
|
|
24
|
-
* @returns The error message or a string of the input
|
|
25
|
-
*/
|
|
26
|
-
function getErrorMessage(e) {
|
|
27
|
-
if (isError(e)) {
|
|
28
|
-
return e.message;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
let stringified;
|
|
32
|
-
try {
|
|
33
|
-
if (typeof e === "object" && e) {
|
|
34
|
-
stringified = JSON.stringify(e);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
stringified = String(e);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (err) {
|
|
41
|
-
stringified = "[unable to stringify input]";
|
|
42
|
-
}
|
|
43
|
-
return `Unknown error ${stringified}`;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
19
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAQlC,0BAOC;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/util/error.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAQlC,0BAOC;AAbD,2CAAuC;AAEvC;;;GAGG;AACH,SAAgB,OAAO,CAAC,CAAU;IAChC,IAAI,IAAA,oBAAQ,EAAC,CAAC,CAAC,EAAE,CAAC;QAChB,MAAM,OAAO,GAAG,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC;QAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,OAAO,KAAK,QAAQ,CAAC;QACjD,OAAO,OAAO,IAAI,UAAU,CAAC;IAC/B,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { isObject } from \"./object.js\";\n\n/**\n * Typeguard for an error object shape (has name and message)\n * @param e - Something caught by a catch clause.\n */\nexport function isError(e: unknown): e is Error {\n if (isObject(e)) {\n const hasName = typeof e.name === \"string\";\n const hasMessage = typeof e.message === \"string\";\n return hasName && hasMessage;\n }\n return false;\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { calculateRetryDelay } from "./delay.js";
|
|
2
|
+
export { getRandomIntegerInclusive } from "./random.js";
|
|
3
|
+
export { isObject, type UnknownObject } from "./object.js";
|
|
4
|
+
export { isError } from "./error.js";
|
|
5
|
+
export { computeSha256Hash, computeSha256Hmac } from "./sha256.js";
|
|
6
|
+
export { randomUUID } from "./uuidUtils.js";
|
|
7
|
+
export { isBrowser, isBun, isNodeLike, isNodeRuntime, isDeno, isReactNative, isWebWorker, } from "./checkEnvironment.js";
|
|
8
|
+
export { stringToUint8Array, uint8ArrayToString, type EncodingType } from "./bytesEncoding.js";
|
|
9
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.uint8ArrayToString = exports.stringToUint8Array = exports.isWebWorker = exports.isReactNative = exports.isDeno = exports.isNodeRuntime = exports.isNodeLike = exports.isBun = exports.isBrowser = exports.randomUUID = exports.computeSha256Hmac = exports.computeSha256Hash = exports.isError = exports.isObject = exports.getRandomIntegerInclusive = exports.calculateRetryDelay = void 0;
|
|
6
|
+
var delay_js_1 = require("./delay.js");
|
|
7
|
+
Object.defineProperty(exports, "calculateRetryDelay", { enumerable: true, get: function () { return delay_js_1.calculateRetryDelay; } });
|
|
8
|
+
var random_js_1 = require("./random.js");
|
|
9
|
+
Object.defineProperty(exports, "getRandomIntegerInclusive", { enumerable: true, get: function () { return random_js_1.getRandomIntegerInclusive; } });
|
|
10
|
+
var object_js_1 = require("./object.js");
|
|
11
|
+
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return object_js_1.isObject; } });
|
|
12
|
+
var error_js_1 = require("./error.js");
|
|
13
|
+
Object.defineProperty(exports, "isError", { enumerable: true, get: function () { return error_js_1.isError; } });
|
|
14
|
+
var sha256_js_1 = require("./sha256.js");
|
|
15
|
+
Object.defineProperty(exports, "computeSha256Hash", { enumerable: true, get: function () { return sha256_js_1.computeSha256Hash; } });
|
|
16
|
+
Object.defineProperty(exports, "computeSha256Hmac", { enumerable: true, get: function () { return sha256_js_1.computeSha256Hmac; } });
|
|
17
|
+
var uuidUtils_js_1 = require("./uuidUtils.js");
|
|
18
|
+
Object.defineProperty(exports, "randomUUID", { enumerable: true, get: function () { return uuidUtils_js_1.randomUUID; } });
|
|
19
|
+
var checkEnvironment_js_1 = require("./checkEnvironment.js");
|
|
20
|
+
Object.defineProperty(exports, "isBrowser", { enumerable: true, get: function () { return checkEnvironment_js_1.isBrowser; } });
|
|
21
|
+
Object.defineProperty(exports, "isBun", { enumerable: true, get: function () { return checkEnvironment_js_1.isBun; } });
|
|
22
|
+
Object.defineProperty(exports, "isNodeLike", { enumerable: true, get: function () { return checkEnvironment_js_1.isNodeLike; } });
|
|
23
|
+
Object.defineProperty(exports, "isNodeRuntime", { enumerable: true, get: function () { return checkEnvironment_js_1.isNodeRuntime; } });
|
|
24
|
+
Object.defineProperty(exports, "isDeno", { enumerable: true, get: function () { return checkEnvironment_js_1.isDeno; } });
|
|
25
|
+
Object.defineProperty(exports, "isReactNative", { enumerable: true, get: function () { return checkEnvironment_js_1.isReactNative; } });
|
|
26
|
+
Object.defineProperty(exports, "isWebWorker", { enumerable: true, get: function () { return checkEnvironment_js_1.isWebWorker; } });
|
|
27
|
+
var bytesEncoding_js_1 = require("./bytesEncoding.js");
|
|
28
|
+
Object.defineProperty(exports, "stringToUint8Array", { enumerable: true, get: function () { return bytesEncoding_js_1.stringToUint8Array; } });
|
|
29
|
+
Object.defineProperty(exports, "uint8ArrayToString", { enumerable: true, get: function () { return bytesEncoding_js_1.uint8ArrayToString; } });
|
|
30
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../../../src/util/internal.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,uCAAiD;AAAxC,+GAAA,mBAAmB,OAAA;AAC5B,yCAAwD;AAA/C,sHAAA,yBAAyB,OAAA;AAClC,yCAA2D;AAAlD,qGAAA,QAAQ,OAAA;AACjB,uCAAqC;AAA5B,mGAAA,OAAO,OAAA;AAChB,yCAAmE;AAA1D,8GAAA,iBAAiB,OAAA;AAAE,8GAAA,iBAAiB,OAAA;AAC7C,+CAA4C;AAAnC,0GAAA,UAAU,OAAA;AACnB,6DAQ+B;AAP7B,gHAAA,SAAS,OAAA;AACT,4GAAA,KAAK,OAAA;AACL,iHAAA,UAAU,OAAA;AACV,oHAAA,aAAa,OAAA;AACb,6GAAA,MAAM,OAAA;AACN,oHAAA,aAAa,OAAA;AACb,kHAAA,WAAW,OAAA;AAEb,uDAA+F;AAAtF,sHAAA,kBAAkB,OAAA;AAAE,sHAAA,kBAAkB,OAAA","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport { calculateRetryDelay } from \"./delay.js\";\nexport { getRandomIntegerInclusive } from \"./random.js\";\nexport { isObject, type UnknownObject } from \"./object.js\";\nexport { isError } from \"./error.js\";\nexport { computeSha256Hash, computeSha256Hmac } from \"./sha256.js\";\nexport { randomUUID } from \"./uuidUtils.js\";\nexport {\n isBrowser,\n isBun,\n isNodeLike,\n isNodeRuntime,\n isDeno,\n isReactNative,\n isWebWorker,\n} from \"./checkEnvironment.js\";\nexport { stringToUint8Array, uint8ArrayToString, type EncodingType } from \"./bytesEncoding.js\";\n"]}
|
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helper TypeGuard that checks if something is defined or not.
|
|
3
|
-
* @param thing - Anything
|
|
4
|
-
*/
|
|
5
|
-
export declare function isDefined<T>(thing: T | undefined | null): thing is T;
|
|
6
|
-
/**
|
|
7
|
-
* Helper TypeGuard that checks if the input is an object with the specified properties.
|
|
8
|
-
* @param thing - Anything.
|
|
9
|
-
* @param properties - The name of the properties that should appear in the object.
|
|
10
|
-
*/
|
|
11
|
-
export declare function isObjectWithProperties<Thing, PropertyName extends string>(thing: Thing, properties: PropertyName[]): thing is Thing & Record<PropertyName, unknown>;
|
|
12
|
-
/**
|
|
13
|
-
* Helper TypeGuard that checks if the input is an object with the specified property.
|
|
14
|
-
* @param thing - Any object.
|
|
15
|
-
* @param property - The name of the property that should appear in the object.
|
|
16
|
-
*/
|
|
17
|
-
export declare function objectHasProperty<Thing, PropertyName extends string>(thing: Thing, property: PropertyName): thing is Thing & Record<PropertyName, unknown>;
|
|
18
1
|
export declare function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream;
|
|
19
2
|
export declare function isWebReadableStream(x: unknown): x is ReadableStream;
|
|
20
3
|
export declare function isBinaryBody(body: unknown): body is Uint8Array | NodeJS.ReadableStream | ReadableStream<Uint8Array> | (() => NodeJS.ReadableStream) | (() => ReadableStream<Uint8Array>) | Blob;
|
|
@@ -2,45 +2,11 @@
|
|
|
2
2
|
// Copyright (c) Microsoft Corporation.
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.isDefined = isDefined;
|
|
6
|
-
exports.isObjectWithProperties = isObjectWithProperties;
|
|
7
|
-
exports.objectHasProperty = objectHasProperty;
|
|
8
5
|
exports.isNodeReadableStream = isNodeReadableStream;
|
|
9
6
|
exports.isWebReadableStream = isWebReadableStream;
|
|
10
7
|
exports.isBinaryBody = isBinaryBody;
|
|
11
8
|
exports.isReadableStream = isReadableStream;
|
|
12
9
|
exports.isBlob = isBlob;
|
|
13
|
-
/**
|
|
14
|
-
* Helper TypeGuard that checks if something is defined or not.
|
|
15
|
-
* @param thing - Anything
|
|
16
|
-
*/
|
|
17
|
-
function isDefined(thing) {
|
|
18
|
-
return typeof thing !== "undefined" && thing !== null;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Helper TypeGuard that checks if the input is an object with the specified properties.
|
|
22
|
-
* @param thing - Anything.
|
|
23
|
-
* @param properties - The name of the properties that should appear in the object.
|
|
24
|
-
*/
|
|
25
|
-
function isObjectWithProperties(thing, properties) {
|
|
26
|
-
if (!isDefined(thing) || typeof thing !== "object") {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
for (const property of properties) {
|
|
30
|
-
if (!objectHasProperty(thing, property)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Helper TypeGuard that checks if the input is an object with the specified property.
|
|
38
|
-
* @param thing - Any object.
|
|
39
|
-
* @param property - The name of the property that should appear in the object.
|
|
40
|
-
*/
|
|
41
|
-
function objectHasProperty(thing, property) {
|
|
42
|
-
return (isDefined(thing) && typeof thing === "object" && property in thing);
|
|
43
|
-
}
|
|
44
10
|
function isNodeReadableStream(x) {
|
|
45
11
|
return Boolean(x && typeof x["pipe"] === "function");
|
|
46
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;
|
|
1
|
+
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/util/typeGuards.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,oDAEC;AAED,kDAMC;AAED,oCAgBC;AAED,4CAEC;AAED,wBAEC;AApCD,SAAgB,oBAAoB,CAAC,CAAU;IAC7C,OAAO,OAAO,CAAC,CAAC,IAAI,OAAQ,CAA2B,CAAC,MAAM,CAAC,KAAK,UAAU,CAAC,CAAC;AAClF,CAAC;AAED,SAAgB,mBAAmB,CAAC,CAAU;IAC5C,OAAO,OAAO,CACZ,CAAC;QACC,OAAQ,CAAoB,CAAC,SAAS,KAAK,UAAU;QACrD,OAAQ,CAAoB,CAAC,GAAG,KAAK,UAAU,CAClD,CAAC;AACJ,CAAC;AAED,SAAgB,YAAY,CAC1B,IAAa;IAQb,OAAO,CACL,IAAI,KAAK,SAAS;QAClB,CAAC,IAAI,YAAY,UAAU;YACzB,gBAAgB,CAAC,IAAI,CAAC;YACtB,OAAO,IAAI,KAAK,UAAU;YAC1B,IAAI,YAAY,IAAI,CAAC,CACxB,CAAC;AACJ,CAAC;AAED,SAAgB,gBAAgB,CAAC,CAAU;IACzC,OAAO,oBAAoB,CAAC,CAAC,CAAC,IAAI,mBAAmB,CAAC,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,MAAM,CAAC,CAAU;IAC/B,OAAO,OAAQ,CAAU,CAAC,MAAM,KAAK,UAAU,CAAC;AAClD,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nexport function isNodeReadableStream(x: unknown): x is NodeJS.ReadableStream {\n return Boolean(x && typeof (x as NodeJS.ReadableStream)[\"pipe\"] === \"function\");\n}\n\nexport function isWebReadableStream(x: unknown): x is ReadableStream {\n return Boolean(\n x &&\n typeof (x as ReadableStream).getReader === \"function\" &&\n typeof (x as ReadableStream).tee === \"function\",\n );\n}\n\nexport function isBinaryBody(\n body: unknown,\n): body is\n | Uint8Array\n | NodeJS.ReadableStream\n | ReadableStream<Uint8Array>\n | (() => NodeJS.ReadableStream)\n | (() => ReadableStream<Uint8Array>)\n | Blob {\n return (\n body !== undefined &&\n (body instanceof Uint8Array ||\n isReadableStream(body) ||\n typeof body === \"function\" ||\n body instanceof Blob)\n );\n}\n\nexport function isReadableStream(x: unknown): x is ReadableStream | NodeJS.ReadableStream {\n return isNodeReadableStream(x) || isWebReadableStream(x);\n}\n\nexport function isBlob(x: unknown): x is Blob {\n return typeof (x as Blob).stream === \"function\";\n}\n"]}
|