@smithery/api 0.1.0-alpha.4
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/CHANGELOG.md +213 -0
- package/LICENSE +201 -0
- package/README.md +389 -0
- package/api-promise.d.mts +2 -0
- package/api-promise.d.mts.map +1 -0
- package/api-promise.d.ts +2 -0
- package/api-promise.d.ts.map +1 -0
- package/api-promise.js +6 -0
- package/api-promise.js.map +1 -0
- package/api-promise.mjs +2 -0
- package/api-promise.mjs.map +1 -0
- package/client.d.mts +192 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +192 -0
- package/client.d.ts.map +1 -0
- package/client.js +475 -0
- package/client.js.map +1 -0
- package/client.mjs +471 -0
- package/client.mjs.map +1 -0
- package/core/api-promise.d.mts +46 -0
- package/core/api-promise.d.mts.map +1 -0
- package/core/api-promise.d.ts +46 -0
- package/core/api-promise.d.ts.map +1 -0
- package/core/api-promise.js +74 -0
- package/core/api-promise.js.map +1 -0
- package/core/api-promise.mjs +70 -0
- package/core/api-promise.mjs.map +1 -0
- package/core/error.d.mts +46 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +46 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +113 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +97 -0
- package/core/error.mjs.map +1 -0
- package/core/pagination.d.mts +62 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +62 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +99 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +93 -0
- package/core/pagination.mjs.map +1 -0
- package/core/resource.d.mts +6 -0
- package/core/resource.d.mts.map +1 -0
- package/core/resource.d.ts +6 -0
- package/core/resource.d.ts.map +1 -0
- package/core/resource.js +11 -0
- package/core/resource.js.map +1 -0
- package/core/resource.mjs +7 -0
- package/core/resource.mjs.map +1 -0
- package/core/uploads.d.mts +3 -0
- package/core/uploads.d.mts.map +1 -0
- package/core/uploads.d.ts +3 -0
- package/core/uploads.d.ts.map +1 -0
- package/core/uploads.js +6 -0
- package/core/uploads.js.map +1 -0
- package/core/uploads.mjs +2 -0
- package/core/uploads.mjs.map +1 -0
- package/error.d.mts +2 -0
- package/error.d.mts.map +1 -0
- package/error.d.ts +2 -0
- package/error.d.ts.map +1 -0
- package/error.js +6 -0
- package/error.js.map +1 -0
- package/error.mjs +2 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +7 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +7 -0
- package/index.d.ts.map +1 -0
- package/index.js +32 -0
- package/index.js.map +1 -0
- package/index.mjs +8 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/detect-platform.d.mts +15 -0
- package/internal/detect-platform.d.mts.map +1 -0
- package/internal/detect-platform.d.ts +15 -0
- package/internal/detect-platform.d.ts.map +1 -0
- package/internal/detect-platform.js +162 -0
- package/internal/detect-platform.js.map +1 -0
- package/internal/detect-platform.mjs +157 -0
- package/internal/detect-platform.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +20 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +20 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +12 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +12 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +35 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +32 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/request-options.d.mts +75 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +75 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +91 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +88 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/tslib.js +81 -0
- package/internal/tslib.mjs +17 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +141 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +131 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +85 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +79 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +18 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +18 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +112 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +94 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +7 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +7 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +11 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +8 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +147 -0
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resource.d.mts +2 -0
- package/resource.d.mts.map +1 -0
- package/resource.d.ts +2 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +6 -0
- package/resource.js.map +1 -0
- package/resource.mjs +2 -0
- package/resource.mjs.map +1 -0
- package/resources/health.d.mts +17 -0
- package/resources/health.d.mts.map +1 -0
- package/resources/health.d.ts +17 -0
- package/resources/health.d.ts.map +1 -0
- package/resources/health.js +15 -0
- package/resources/health.js.map +1 -0
- package/resources/health.mjs +11 -0
- package/resources/health.mjs.map +1 -0
- package/resources/index.d.mts +4 -0
- package/resources/index.d.mts.map +1 -0
- package/resources/index.d.ts +4 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +11 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +5 -0
- package/resources/index.mjs.map +1 -0
- package/resources/servers/deployments.d.mts +87 -0
- package/resources/servers/deployments.d.mts.map +1 -0
- package/resources/servers/deployments.d.ts +87 -0
- package/resources/servers/deployments.d.ts.map +1 -0
- package/resources/servers/deployments.js +37 -0
- package/resources/servers/deployments.js.map +1 -0
- package/resources/servers/deployments.mjs +33 -0
- package/resources/servers/deployments.mjs.map +1 -0
- package/resources/servers/index.d.mts +4 -0
- package/resources/servers/index.d.mts.map +1 -0
- package/resources/servers/index.d.ts +4 -0
- package/resources/servers/index.d.ts.map +1 -0
- package/resources/servers/index.js +11 -0
- package/resources/servers/index.js.map +1 -0
- package/resources/servers/index.mjs +5 -0
- package/resources/servers/index.mjs.map +1 -0
- package/resources/servers/logs.d.mts +71 -0
- package/resources/servers/logs.d.mts.map +1 -0
- package/resources/servers/logs.d.ts +71 -0
- package/resources/servers/logs.d.ts.map +1 -0
- package/resources/servers/logs.js +17 -0
- package/resources/servers/logs.js.map +1 -0
- package/resources/servers/logs.mjs +13 -0
- package/resources/servers/logs.mjs.map +1 -0
- package/resources/servers/servers.d.mts +87 -0
- package/resources/servers/servers.d.mts.map +1 -0
- package/resources/servers/servers.d.ts +87 -0
- package/resources/servers/servers.d.ts.map +1 -0
- package/resources/servers/servers.js +35 -0
- package/resources/servers/servers.js.map +1 -0
- package/resources/servers/servers.mjs +30 -0
- package/resources/servers/servers.mjs.map +1 -0
- package/resources/servers.d.mts +2 -0
- package/resources/servers.d.mts.map +1 -0
- package/resources/servers.d.ts +2 -0
- package/resources/servers.d.ts.map +1 -0
- package/resources/servers.js +6 -0
- package/resources/servers.js.map +1 -0
- package/resources/servers.mjs +3 -0
- package/resources/servers.mjs.map +1 -0
- package/resources/uplink.d.mts +17 -0
- package/resources/uplink.d.mts.map +1 -0
- package/resources/uplink.d.ts +17 -0
- package/resources/uplink.d.ts.map +1 -0
- package/resources/uplink.js +15 -0
- package/resources/uplink.js.map +1 -0
- package/resources/uplink.mjs +11 -0
- package/resources/uplink.mjs.map +1 -0
- package/resources.d.mts +2 -0
- package/resources.d.mts.map +1 -0
- package/resources.d.ts +2 -0
- package/resources.d.ts.map +1 -0
- package/resources.js +5 -0
- package/resources.js.map +1 -0
- package/resources.mjs +2 -0
- package/resources.mjs.map +1 -0
- package/src/api-promise.ts +2 -0
- package/src/client.ts +772 -0
- package/src/core/README.md +3 -0
- package/src/core/api-promise.ts +92 -0
- package/src/core/error.ts +130 -0
- package/src/core/pagination.ts +167 -0
- package/src/core/resource.ts +11 -0
- package/src/core/uploads.ts +2 -0
- package/src/error.ts +2 -0
- package/src/index.ts +23 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +97 -0
- package/src/internal/parse.ts +50 -0
- package/src/internal/request-options.ts +91 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/to-file.ts +154 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +187 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +126 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +105 -0
- package/src/internal/utils.ts +8 -0
- package/src/lib/.keep +4 -0
- package/src/pagination.ts +2 -0
- package/src/resource.ts +2 -0
- package/src/resources/health.ts +24 -0
- package/src/resources/index.ts +11 -0
- package/src/resources/servers/deployments.ts +157 -0
- package/src/resources/servers/index.ts +20 -0
- package/src/resources/servers/logs.ts +106 -0
- package/src/resources/servers/servers.ts +157 -0
- package/src/resources/servers.ts +3 -0
- package/src/resources/uplink.ts +24 -0
- package/src/resources.ts +1 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +2 -0
- package/src/version.ts +1 -0
- package/uploads.d.mts +2 -0
- package/uploads.d.mts.map +1 -0
- package/uploads.d.ts +2 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +6 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +2 -0
- package/uploads.mjs.map +1 -0
- package/version.d.mts +2 -0
- package/version.d.mts.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getPlatformHeaders = exports.isRunningInBrowser = void 0;
|
|
5
|
+
const version_1 = require("../version.js");
|
|
6
|
+
const isRunningInBrowser = () => {
|
|
7
|
+
return (
|
|
8
|
+
// @ts-ignore
|
|
9
|
+
typeof window !== 'undefined' &&
|
|
10
|
+
// @ts-ignore
|
|
11
|
+
typeof window.document !== 'undefined' &&
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
typeof navigator !== 'undefined');
|
|
14
|
+
};
|
|
15
|
+
exports.isRunningInBrowser = isRunningInBrowser;
|
|
16
|
+
/**
|
|
17
|
+
* Note this does not detect 'browser'; for that, use getBrowserInfo().
|
|
18
|
+
*/
|
|
19
|
+
function getDetectedPlatform() {
|
|
20
|
+
if (typeof Deno !== 'undefined' && Deno.build != null) {
|
|
21
|
+
return 'deno';
|
|
22
|
+
}
|
|
23
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
24
|
+
return 'edge';
|
|
25
|
+
}
|
|
26
|
+
if (Object.prototype.toString.call(typeof globalThis.process !== 'undefined' ? globalThis.process : 0) === '[object process]') {
|
|
27
|
+
return 'node';
|
|
28
|
+
}
|
|
29
|
+
return 'unknown';
|
|
30
|
+
}
|
|
31
|
+
const getPlatformProperties = () => {
|
|
32
|
+
const detectedPlatform = getDetectedPlatform();
|
|
33
|
+
if (detectedPlatform === 'deno') {
|
|
34
|
+
return {
|
|
35
|
+
'X-Stainless-Lang': 'js',
|
|
36
|
+
'X-Stainless-Package-Version': version_1.VERSION,
|
|
37
|
+
'X-Stainless-OS': normalizePlatform(Deno.build.os),
|
|
38
|
+
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
|
|
39
|
+
'X-Stainless-Runtime': 'deno',
|
|
40
|
+
'X-Stainless-Runtime-Version': typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
44
|
+
return {
|
|
45
|
+
'X-Stainless-Lang': 'js',
|
|
46
|
+
'X-Stainless-Package-Version': version_1.VERSION,
|
|
47
|
+
'X-Stainless-OS': 'Unknown',
|
|
48
|
+
'X-Stainless-Arch': `other:${EdgeRuntime}`,
|
|
49
|
+
'X-Stainless-Runtime': 'edge',
|
|
50
|
+
'X-Stainless-Runtime-Version': globalThis.process.version,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Check if Node.js
|
|
54
|
+
if (detectedPlatform === 'node') {
|
|
55
|
+
return {
|
|
56
|
+
'X-Stainless-Lang': 'js',
|
|
57
|
+
'X-Stainless-Package-Version': version_1.VERSION,
|
|
58
|
+
'X-Stainless-OS': normalizePlatform(globalThis.process.platform ?? 'unknown'),
|
|
59
|
+
'X-Stainless-Arch': normalizeArch(globalThis.process.arch ?? 'unknown'),
|
|
60
|
+
'X-Stainless-Runtime': 'node',
|
|
61
|
+
'X-Stainless-Runtime-Version': globalThis.process.version ?? 'unknown',
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const browserInfo = getBrowserInfo();
|
|
65
|
+
if (browserInfo) {
|
|
66
|
+
return {
|
|
67
|
+
'X-Stainless-Lang': 'js',
|
|
68
|
+
'X-Stainless-Package-Version': version_1.VERSION,
|
|
69
|
+
'X-Stainless-OS': 'Unknown',
|
|
70
|
+
'X-Stainless-Arch': 'unknown',
|
|
71
|
+
'X-Stainless-Runtime': `browser:${browserInfo.browser}`,
|
|
72
|
+
'X-Stainless-Runtime-Version': browserInfo.version,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// TODO add support for Cloudflare workers, etc.
|
|
76
|
+
return {
|
|
77
|
+
'X-Stainless-Lang': 'js',
|
|
78
|
+
'X-Stainless-Package-Version': version_1.VERSION,
|
|
79
|
+
'X-Stainless-OS': 'Unknown',
|
|
80
|
+
'X-Stainless-Arch': 'unknown',
|
|
81
|
+
'X-Stainless-Runtime': 'unknown',
|
|
82
|
+
'X-Stainless-Runtime-Version': 'unknown',
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
|
|
86
|
+
function getBrowserInfo() {
|
|
87
|
+
if (typeof navigator === 'undefined' || !navigator) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
// NOTE: The order matters here!
|
|
91
|
+
const browserPatterns = [
|
|
92
|
+
{ key: 'edge', pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
93
|
+
{ key: 'ie', pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
94
|
+
{ key: 'ie', pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
95
|
+
{ key: 'chrome', pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
96
|
+
{ key: 'firefox', pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
97
|
+
{ key: 'safari', pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ },
|
|
98
|
+
];
|
|
99
|
+
// Find the FIRST matching browser
|
|
100
|
+
for (const { key, pattern } of browserPatterns) {
|
|
101
|
+
const match = pattern.exec(navigator.userAgent);
|
|
102
|
+
if (match) {
|
|
103
|
+
const major = match[1] || 0;
|
|
104
|
+
const minor = match[2] || 0;
|
|
105
|
+
const patch = match[3] || 0;
|
|
106
|
+
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
const normalizeArch = (arch) => {
|
|
112
|
+
// Node docs:
|
|
113
|
+
// - https://nodejs.org/api/process.html#processarch
|
|
114
|
+
// Deno docs:
|
|
115
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
116
|
+
if (arch === 'x32')
|
|
117
|
+
return 'x32';
|
|
118
|
+
if (arch === 'x86_64' || arch === 'x64')
|
|
119
|
+
return 'x64';
|
|
120
|
+
if (arch === 'arm')
|
|
121
|
+
return 'arm';
|
|
122
|
+
if (arch === 'aarch64' || arch === 'arm64')
|
|
123
|
+
return 'arm64';
|
|
124
|
+
if (arch)
|
|
125
|
+
return `other:${arch}`;
|
|
126
|
+
return 'unknown';
|
|
127
|
+
};
|
|
128
|
+
const normalizePlatform = (platform) => {
|
|
129
|
+
// Node platforms:
|
|
130
|
+
// - https://nodejs.org/api/process.html#processplatform
|
|
131
|
+
// Deno platforms:
|
|
132
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
133
|
+
// - https://github.com/denoland/deno/issues/14799
|
|
134
|
+
platform = platform.toLowerCase();
|
|
135
|
+
// NOTE: this iOS check is untested and may not work
|
|
136
|
+
// Node does not work natively on IOS, there is a fork at
|
|
137
|
+
// https://github.com/nodejs-mobile/nodejs-mobile
|
|
138
|
+
// however it is unknown at the time of writing how to detect if it is running
|
|
139
|
+
if (platform.includes('ios'))
|
|
140
|
+
return 'iOS';
|
|
141
|
+
if (platform === 'android')
|
|
142
|
+
return 'Android';
|
|
143
|
+
if (platform === 'darwin')
|
|
144
|
+
return 'MacOS';
|
|
145
|
+
if (platform === 'win32')
|
|
146
|
+
return 'Windows';
|
|
147
|
+
if (platform === 'freebsd')
|
|
148
|
+
return 'FreeBSD';
|
|
149
|
+
if (platform === 'openbsd')
|
|
150
|
+
return 'OpenBSD';
|
|
151
|
+
if (platform === 'linux')
|
|
152
|
+
return 'Linux';
|
|
153
|
+
if (platform)
|
|
154
|
+
return `Other:${platform}`;
|
|
155
|
+
return 'Unknown';
|
|
156
|
+
};
|
|
157
|
+
let _platformHeaders;
|
|
158
|
+
const getPlatformHeaders = () => {
|
|
159
|
+
return (_platformHeaders ?? (_platformHeaders = getPlatformProperties()));
|
|
160
|
+
};
|
|
161
|
+
exports.getPlatformHeaders = getPlatformHeaders;
|
|
162
|
+
//# sourceMappingURL=detect-platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-platform.js","sourceRoot":"","sources":["../src/internal/detect-platform.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,2CAAqC;AAE9B,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO;IACL,aAAa;IACb,OAAO,MAAM,KAAK,WAAW;QAC7B,aAAa;QACb,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;QACtC,aAAa;QACb,OAAO,SAAS,KAAK,WAAW,CACjC,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B;AAIF;;GAEG;AACH,SAAS,mBAAmB;IAC1B,IAAI,OAAO,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;QACtD,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,WAA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CAAC,QAAgB,EAAgB,EAAE;IAC3D,kBAAkB;IAClB,wDAAwD;IACxD,kBAAkB;IAClB,mDAAmD;IACnD,kDAAkD;IAElD,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IAElC,oDAAoD;IACpD,yDAAyD;IACzD,iDAAiD;IACjD,8EAA8E;IAC9E,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAC;IAC1C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,OAAO,CAAC;IACzC,IAAI,QAAQ;QAAE,OAAO,SAAS,QAAQ,EAAE,CAAC;IACzC,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,IAAI,gBAAoC,CAAC;AAClC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO,CAAC,gBAAgB,KAAhB,gBAAgB,GAAK,qBAAqB,EAAE,EAAC,CAAC;AACxD,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
import { VERSION } from "../version.mjs";
|
|
3
|
+
export const isRunningInBrowser = () => {
|
|
4
|
+
return (
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
typeof window !== 'undefined' &&
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
typeof window.document !== 'undefined' &&
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
typeof navigator !== 'undefined');
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Note this does not detect 'browser'; for that, use getBrowserInfo().
|
|
14
|
+
*/
|
|
15
|
+
function getDetectedPlatform() {
|
|
16
|
+
if (typeof Deno !== 'undefined' && Deno.build != null) {
|
|
17
|
+
return 'deno';
|
|
18
|
+
}
|
|
19
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
20
|
+
return 'edge';
|
|
21
|
+
}
|
|
22
|
+
if (Object.prototype.toString.call(typeof globalThis.process !== 'undefined' ? globalThis.process : 0) === '[object process]') {
|
|
23
|
+
return 'node';
|
|
24
|
+
}
|
|
25
|
+
return 'unknown';
|
|
26
|
+
}
|
|
27
|
+
const getPlatformProperties = () => {
|
|
28
|
+
const detectedPlatform = getDetectedPlatform();
|
|
29
|
+
if (detectedPlatform === 'deno') {
|
|
30
|
+
return {
|
|
31
|
+
'X-Stainless-Lang': 'js',
|
|
32
|
+
'X-Stainless-Package-Version': VERSION,
|
|
33
|
+
'X-Stainless-OS': normalizePlatform(Deno.build.os),
|
|
34
|
+
'X-Stainless-Arch': normalizeArch(Deno.build.arch),
|
|
35
|
+
'X-Stainless-Runtime': 'deno',
|
|
36
|
+
'X-Stainless-Runtime-Version': typeof Deno.version === 'string' ? Deno.version : Deno.version?.deno ?? 'unknown',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
if (typeof EdgeRuntime !== 'undefined') {
|
|
40
|
+
return {
|
|
41
|
+
'X-Stainless-Lang': 'js',
|
|
42
|
+
'X-Stainless-Package-Version': VERSION,
|
|
43
|
+
'X-Stainless-OS': 'Unknown',
|
|
44
|
+
'X-Stainless-Arch': `other:${EdgeRuntime}`,
|
|
45
|
+
'X-Stainless-Runtime': 'edge',
|
|
46
|
+
'X-Stainless-Runtime-Version': globalThis.process.version,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Check if Node.js
|
|
50
|
+
if (detectedPlatform === 'node') {
|
|
51
|
+
return {
|
|
52
|
+
'X-Stainless-Lang': 'js',
|
|
53
|
+
'X-Stainless-Package-Version': VERSION,
|
|
54
|
+
'X-Stainless-OS': normalizePlatform(globalThis.process.platform ?? 'unknown'),
|
|
55
|
+
'X-Stainless-Arch': normalizeArch(globalThis.process.arch ?? 'unknown'),
|
|
56
|
+
'X-Stainless-Runtime': 'node',
|
|
57
|
+
'X-Stainless-Runtime-Version': globalThis.process.version ?? 'unknown',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const browserInfo = getBrowserInfo();
|
|
61
|
+
if (browserInfo) {
|
|
62
|
+
return {
|
|
63
|
+
'X-Stainless-Lang': 'js',
|
|
64
|
+
'X-Stainless-Package-Version': VERSION,
|
|
65
|
+
'X-Stainless-OS': 'Unknown',
|
|
66
|
+
'X-Stainless-Arch': 'unknown',
|
|
67
|
+
'X-Stainless-Runtime': `browser:${browserInfo.browser}`,
|
|
68
|
+
'X-Stainless-Runtime-Version': browserInfo.version,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// TODO add support for Cloudflare workers, etc.
|
|
72
|
+
return {
|
|
73
|
+
'X-Stainless-Lang': 'js',
|
|
74
|
+
'X-Stainless-Package-Version': VERSION,
|
|
75
|
+
'X-Stainless-OS': 'Unknown',
|
|
76
|
+
'X-Stainless-Arch': 'unknown',
|
|
77
|
+
'X-Stainless-Runtime': 'unknown',
|
|
78
|
+
'X-Stainless-Runtime-Version': 'unknown',
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
// Note: modified from https://github.com/JS-DevTools/host-environment/blob/b1ab79ecde37db5d6e163c050e54fe7d287d7c92/src/isomorphic.browser.ts
|
|
82
|
+
function getBrowserInfo() {
|
|
83
|
+
if (typeof navigator === 'undefined' || !navigator) {
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
// NOTE: The order matters here!
|
|
87
|
+
const browserPatterns = [
|
|
88
|
+
{ key: 'edge', pattern: /Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
89
|
+
{ key: 'ie', pattern: /MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
90
|
+
{ key: 'ie', pattern: /Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
91
|
+
{ key: 'chrome', pattern: /Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
92
|
+
{ key: 'firefox', pattern: /Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/ },
|
|
93
|
+
{ key: 'safari', pattern: /(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/ },
|
|
94
|
+
];
|
|
95
|
+
// Find the FIRST matching browser
|
|
96
|
+
for (const { key, pattern } of browserPatterns) {
|
|
97
|
+
const match = pattern.exec(navigator.userAgent);
|
|
98
|
+
if (match) {
|
|
99
|
+
const major = match[1] || 0;
|
|
100
|
+
const minor = match[2] || 0;
|
|
101
|
+
const patch = match[3] || 0;
|
|
102
|
+
return { browser: key, version: `${major}.${minor}.${patch}` };
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
const normalizeArch = (arch) => {
|
|
108
|
+
// Node docs:
|
|
109
|
+
// - https://nodejs.org/api/process.html#processarch
|
|
110
|
+
// Deno docs:
|
|
111
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
112
|
+
if (arch === 'x32')
|
|
113
|
+
return 'x32';
|
|
114
|
+
if (arch === 'x86_64' || arch === 'x64')
|
|
115
|
+
return 'x64';
|
|
116
|
+
if (arch === 'arm')
|
|
117
|
+
return 'arm';
|
|
118
|
+
if (arch === 'aarch64' || arch === 'arm64')
|
|
119
|
+
return 'arm64';
|
|
120
|
+
if (arch)
|
|
121
|
+
return `other:${arch}`;
|
|
122
|
+
return 'unknown';
|
|
123
|
+
};
|
|
124
|
+
const normalizePlatform = (platform) => {
|
|
125
|
+
// Node platforms:
|
|
126
|
+
// - https://nodejs.org/api/process.html#processplatform
|
|
127
|
+
// Deno platforms:
|
|
128
|
+
// - https://doc.deno.land/deno/stable/~/Deno.build
|
|
129
|
+
// - https://github.com/denoland/deno/issues/14799
|
|
130
|
+
platform = platform.toLowerCase();
|
|
131
|
+
// NOTE: this iOS check is untested and may not work
|
|
132
|
+
// Node does not work natively on IOS, there is a fork at
|
|
133
|
+
// https://github.com/nodejs-mobile/nodejs-mobile
|
|
134
|
+
// however it is unknown at the time of writing how to detect if it is running
|
|
135
|
+
if (platform.includes('ios'))
|
|
136
|
+
return 'iOS';
|
|
137
|
+
if (platform === 'android')
|
|
138
|
+
return 'Android';
|
|
139
|
+
if (platform === 'darwin')
|
|
140
|
+
return 'MacOS';
|
|
141
|
+
if (platform === 'win32')
|
|
142
|
+
return 'Windows';
|
|
143
|
+
if (platform === 'freebsd')
|
|
144
|
+
return 'FreeBSD';
|
|
145
|
+
if (platform === 'openbsd')
|
|
146
|
+
return 'OpenBSD';
|
|
147
|
+
if (platform === 'linux')
|
|
148
|
+
return 'Linux';
|
|
149
|
+
if (platform)
|
|
150
|
+
return `Other:${platform}`;
|
|
151
|
+
return 'Unknown';
|
|
152
|
+
};
|
|
153
|
+
let _platformHeaders;
|
|
154
|
+
export const getPlatformHeaders = () => {
|
|
155
|
+
return (_platformHeaders ?? (_platformHeaders = getPlatformProperties()));
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=detect-platform.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-platform.mjs","sourceRoot":"","sources":["../src/internal/detect-platform.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,OAAO,EAAE;AAElB,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,OAAO;IACL,aAAa;IACb,OAAO,MAAM,KAAK,WAAW;QAC7B,aAAa;QACb,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;QACtC,aAAa;QACb,OAAO,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Y,CAAC,GAAG,EAAE,OAAO,WASxC;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,KAmBtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/internal/errors.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,WASxC;AAED,eAAO,MAAM,WAAW,GAAI,KAAK,GAAG,KAAG,KAmBtC,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.castToError = void 0;
|
|
5
|
+
exports.isAbortError = isAbortError;
|
|
6
|
+
function isAbortError(err) {
|
|
7
|
+
return (typeof err === 'object' &&
|
|
8
|
+
err !== null &&
|
|
9
|
+
// Spec-compliant fetch implementations
|
|
10
|
+
(('name' in err && err.name === 'AbortError') ||
|
|
11
|
+
// Expo fetch
|
|
12
|
+
('message' in err && String(err.message).includes('FetchRequestCanceledException'))));
|
|
13
|
+
}
|
|
14
|
+
const castToError = (err) => {
|
|
15
|
+
if (err instanceof Error)
|
|
16
|
+
return err;
|
|
17
|
+
if (typeof err === 'object' && err !== null) {
|
|
18
|
+
try {
|
|
19
|
+
if (Object.prototype.toString.call(err) === '[object Error]') {
|
|
20
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
21
|
+
const error = new Error(err.message, err.cause ? { cause: err.cause } : {});
|
|
22
|
+
if (err.stack)
|
|
23
|
+
error.stack = err.stack;
|
|
24
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
25
|
+
if (err.cause && !error.cause)
|
|
26
|
+
error.cause = err.cause;
|
|
27
|
+
if (err.name)
|
|
28
|
+
error.name = err.name;
|
|
29
|
+
return error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
try {
|
|
34
|
+
return new Error(JSON.stringify(err));
|
|
35
|
+
}
|
|
36
|
+
catch { }
|
|
37
|
+
}
|
|
38
|
+
return new Error(err);
|
|
39
|
+
};
|
|
40
|
+
exports.castToError = castToError;
|
|
41
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/internal/errors.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oCASC;AATD,SAAgB,YAAY,CAAC,GAAY;IACvC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,uCAAuC;QACvC,CAAC,CAAC,MAAM,IAAI,GAAG,IAAK,GAAW,CAAC,IAAI,KAAK,YAAY,CAAC;YACpD,aAAa;YACb,CAAC,SAAS,IAAI,GAAG,IAAI,MAAM,CAAE,GAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAChG,CAAC;AACJ,CAAC;AAEM,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAS,EAAE;IAC7C,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,EAAE,CAAC;gBAC7D,8DAA8D;gBAC9D,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5E,IAAI,GAAG,CAAC,KAAK;oBAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACvC,8DAA8D;gBAC9D,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK;oBAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACvD,IAAI,GAAG,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;gBACpC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC;YACH,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC;AAnBW,QAAA,WAAW,eAmBtB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
export function isAbortError(err) {
|
|
3
|
+
return (typeof err === 'object' &&
|
|
4
|
+
err !== null &&
|
|
5
|
+
// Spec-compliant fetch implementations
|
|
6
|
+
(('name' in err && err.name === 'AbortError') ||
|
|
7
|
+
// Expo fetch
|
|
8
|
+
('message' in err && String(err.message).includes('FetchRequestCanceledException'))));
|
|
9
|
+
}
|
|
10
|
+
export const castToError = (err) => {
|
|
11
|
+
if (err instanceof Error)
|
|
12
|
+
return err;
|
|
13
|
+
if (typeof err === 'object' && err !== null) {
|
|
14
|
+
try {
|
|
15
|
+
if (Object.prototype.toString.call(err) === '[object Error]') {
|
|
16
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
17
|
+
const error = new Error(err.message, err.cause ? { cause: err.cause } : {});
|
|
18
|
+
if (err.stack)
|
|
19
|
+
error.stack = err.stack;
|
|
20
|
+
// @ts-ignore - not all envs have native support for cause yet
|
|
21
|
+
if (err.cause && !error.cause)
|
|
22
|
+
error.cause = err.cause;
|
|
23
|
+
if (err.name)
|
|
24
|
+
error.name = err.name;
|
|
25
|
+
return error;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
catch { }
|
|
29
|
+
try {
|
|
30
|
+
return new Error(JSON.stringify(err));
|
|
31
|
+
}
|
|
32
|
+
catch { }
|
|
33
|
+
}
|
|
34
|
+
return new Error(err);
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=errors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.mjs","sourceRoot":"","sources":["../src/internal/errors.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF,MAAM,UAAU,YAAY,CAAC,GAAY;IACvC,OAAO,CACL,OAAO,GAAG,KAAK,QAAQ;QACvB,GAAG,KAAK,IAAI;QACZ,uCAAuC;QACvC,CAAC,CAAC,MAAM,IAAI,GAAG,IAAK,GAAW,CAAC,IAAI,KAAK,YAAY,CAAC;YACpD,aAAa;YACb,CAAC,SAAS,IAAI,GAAG,IAAI,MAAM,CAAE,GAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC,CAAC,CAAC,CAChG,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAS,EAAE;IAC7C,IAAI,GAAG,YAAY,KAAK;QAAE,OAAO,GAAG,CAAC;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC;YACH,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,gBAAgB,EAAE,CAAC;gBAC7D,8DAA8D;gBAC9D,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC5E,IAAI,GAAG,CAAC,KAAK;oBAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACvC,8DAA8D;gBAC9D,IAAI,GAAG,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,KAAK;oBAAE,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC;gBACvD,IAAI,GAAG,CAAC,IAAI;oBAAE,KAAK,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;gBACpC,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QACV,IAAI,CAAC;YACH,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;QACxC,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC;AACxB,CAAC,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type HeaderValue = string | undefined | null;
|
|
2
|
+
export type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | NullableHeaders;
|
|
3
|
+
declare const brand_privateNullableHeaders: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Users can pass explicit nulls to unset default headers. When we parse them
|
|
7
|
+
* into a standard headers type we need to preserve that information.
|
|
8
|
+
*/
|
|
9
|
+
export type NullableHeaders = {
|
|
10
|
+
/** Brand check, prevent users from creating a NullableHeaders. */
|
|
11
|
+
[brand_privateNullableHeaders]: true;
|
|
12
|
+
/** Parsed headers. */
|
|
13
|
+
values: Headers;
|
|
14
|
+
/** Set of lowercase header names explicitly set to null. */
|
|
15
|
+
nulls: Set<string>;
|
|
16
|
+
};
|
|
17
|
+
export declare const buildHeaders: (newHeaders: HeadersLike[]) => NullableHeaders;
|
|
18
|
+
export declare const isEmptyHeaders: (headers: HeadersLike) => boolean;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=headers.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.mts","sourceRoot":"","sources":["../src/internal/headers.ts"],"names":[],"mappings":"AAIA,KAAK,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAC7C,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,SAAS,WAAW,EAAE,EAAE,GACxB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,WAAW,EAAE,CAAC,GACpD,SAAS,GACT,IAAI,GACJ,eAAe,CAAC;AAEpB,QAAA,MAAM,4BAA4B,eAAyD,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,kEAAkE;IAClE,CAAC,4BAA4B,CAAC,EAAE,IAAI,CAAC;IACrC,sBAAsB;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpB,CAAC;AA2CF,eAAO,MAAM,YAAY,GAAI,YAAY,WAAW,EAAE,KAAG,eAqBxD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,YAGlD,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type HeaderValue = string | undefined | null;
|
|
2
|
+
export type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | NullableHeaders;
|
|
3
|
+
declare const brand_privateNullableHeaders: unique symbol;
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Users can pass explicit nulls to unset default headers. When we parse them
|
|
7
|
+
* into a standard headers type we need to preserve that information.
|
|
8
|
+
*/
|
|
9
|
+
export type NullableHeaders = {
|
|
10
|
+
/** Brand check, prevent users from creating a NullableHeaders. */
|
|
11
|
+
[brand_privateNullableHeaders]: true;
|
|
12
|
+
/** Parsed headers. */
|
|
13
|
+
values: Headers;
|
|
14
|
+
/** Set of lowercase header names explicitly set to null. */
|
|
15
|
+
nulls: Set<string>;
|
|
16
|
+
};
|
|
17
|
+
export declare const buildHeaders: (newHeaders: HeadersLike[]) => NullableHeaders;
|
|
18
|
+
export declare const isEmptyHeaders: (headers: HeadersLike) => boolean;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/internal/headers.ts"],"names":[],"mappings":"AAIA,KAAK,WAAW,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAC7C,MAAM,MAAM,WAAW,GACnB,OAAO,GACP,SAAS,WAAW,EAAE,EAAE,GACxB,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,WAAW,EAAE,CAAC,GACpD,SAAS,GACT,IAAI,GACJ,eAAe,CAAC;AAEpB,QAAA,MAAM,4BAA4B,eAAyD,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,kEAAkE;IAClE,CAAC,4BAA4B,CAAC,EAAE,IAAI,CAAC;IACrC,sBAAsB;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,4DAA4D;IAC5D,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACpB,CAAC;AA2CF,eAAO,MAAM,YAAY,GAAI,YAAY,WAAW,EAAE,KAAG,eAqBxD,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS,WAAW,YAGlD,CAAC"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isEmptyHeaders = exports.buildHeaders = void 0;
|
|
5
|
+
const values_1 = require("./utils/values.js");
|
|
6
|
+
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
7
|
+
function* iterateHeaders(headers) {
|
|
8
|
+
if (!headers)
|
|
9
|
+
return;
|
|
10
|
+
if (brand_privateNullableHeaders in headers) {
|
|
11
|
+
const { values, nulls } = headers;
|
|
12
|
+
yield* values.entries();
|
|
13
|
+
for (const name of nulls) {
|
|
14
|
+
yield [name, null];
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
let shouldClear = false;
|
|
19
|
+
let iter;
|
|
20
|
+
if (headers instanceof Headers) {
|
|
21
|
+
iter = headers.entries();
|
|
22
|
+
}
|
|
23
|
+
else if ((0, values_1.isReadonlyArray)(headers)) {
|
|
24
|
+
iter = headers;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
shouldClear = true;
|
|
28
|
+
iter = Object.entries(headers ?? {});
|
|
29
|
+
}
|
|
30
|
+
for (let row of iter) {
|
|
31
|
+
const name = row[0];
|
|
32
|
+
if (typeof name !== 'string')
|
|
33
|
+
throw new TypeError('expected header name to be a string');
|
|
34
|
+
const values = (0, values_1.isReadonlyArray)(row[1]) ? row[1] : [row[1]];
|
|
35
|
+
let didClear = false;
|
|
36
|
+
for (const value of values) {
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
continue;
|
|
39
|
+
// Objects keys always overwrite older headers, they never append.
|
|
40
|
+
// Yield a null to clear the header before adding the new values.
|
|
41
|
+
if (shouldClear && !didClear) {
|
|
42
|
+
didClear = true;
|
|
43
|
+
yield [name, null];
|
|
44
|
+
}
|
|
45
|
+
yield [name, value];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const buildHeaders = (newHeaders) => {
|
|
50
|
+
const targetHeaders = new Headers();
|
|
51
|
+
const nullHeaders = new Set();
|
|
52
|
+
for (const headers of newHeaders) {
|
|
53
|
+
const seenHeaders = new Set();
|
|
54
|
+
for (const [name, value] of iterateHeaders(headers)) {
|
|
55
|
+
const lowerName = name.toLowerCase();
|
|
56
|
+
if (!seenHeaders.has(lowerName)) {
|
|
57
|
+
targetHeaders.delete(name);
|
|
58
|
+
seenHeaders.add(lowerName);
|
|
59
|
+
}
|
|
60
|
+
if (value === null) {
|
|
61
|
+
targetHeaders.delete(name);
|
|
62
|
+
nullHeaders.add(lowerName);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
targetHeaders.append(name, value);
|
|
66
|
+
nullHeaders.delete(lowerName);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
71
|
+
};
|
|
72
|
+
exports.buildHeaders = buildHeaders;
|
|
73
|
+
const isEmptyHeaders = (headers) => {
|
|
74
|
+
for (const _ of iterateHeaders(headers))
|
|
75
|
+
return false;
|
|
76
|
+
return true;
|
|
77
|
+
};
|
|
78
|
+
exports.isEmptyHeaders = isEmptyHeaders;
|
|
79
|
+
//# sourceMappingURL=headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.js","sourceRoot":"","sources":["../src/internal/headers.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,8CAAiD;AAWjD,MAAM,4BAA4B,GAAG,eAAe,CAAC,MAAM,CAAC,8BAA8B,CAAC,CAAC;AAgB5F,QAAQ,CAAC,CAAC,cAAc,CAAC,OAAoB;IAC3C,IAAI,CAAC,OAAO;QAAE,OAAO;IAErB,IAAI,4BAA4B,IAAI,OAAO,EAAE,CAAC;QAC5C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAClC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACxB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QACrB,CAAC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ING.md for details.
|
|
2
|
+
import { isReadonlyArray } from "./utils/values.mjs";
|
|
3
|
+
const brand_privateNullableHeaders = /* @__PURE__ */ Symbol('brand.privateNullableHeaders');
|
|
4
|
+
function* iterateHeaders(headers) {
|
|
5
|
+
if (!headers)
|
|
6
|
+
return;
|
|
7
|
+
if (brand_privateNullableHeaders in headers) {
|
|
8
|
+
const { values, nulls } = headers;
|
|
9
|
+
yield* values.entries();
|
|
10
|
+
for (const name of nulls) {
|
|
11
|
+
yield [name, null];
|
|
12
|
+
}
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let shouldClear = false;
|
|
16
|
+
let iter;
|
|
17
|
+
if (headers instanceof Headers) {
|
|
18
|
+
iter = headers.entries();
|
|
19
|
+
}
|
|
20
|
+
else if (isReadonlyArray(headers)) {
|
|
21
|
+
iter = headers;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
shouldClear = true;
|
|
25
|
+
iter = Object.entries(headers ?? {});
|
|
26
|
+
}
|
|
27
|
+
for (let row of iter) {
|
|
28
|
+
const name = row[0];
|
|
29
|
+
if (typeof name !== 'string')
|
|
30
|
+
throw new TypeError('expected header name to be a string');
|
|
31
|
+
const values = isReadonlyArray(row[1]) ? row[1] : [row[1]];
|
|
32
|
+
let didClear = false;
|
|
33
|
+
for (const value of values) {
|
|
34
|
+
if (value === undefined)
|
|
35
|
+
continue;
|
|
36
|
+
// Objects keys always overwrite older headers, they never append.
|
|
37
|
+
// Yield a null to clear the header before adding the new values.
|
|
38
|
+
if (shouldClear && !didClear) {
|
|
39
|
+
didClear = true;
|
|
40
|
+
yield [name, null];
|
|
41
|
+
}
|
|
42
|
+
yield [name, value];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export const buildHeaders = (newHeaders) => {
|
|
47
|
+
const targetHeaders = new Headers();
|
|
48
|
+
const nullHeaders = new Set();
|
|
49
|
+
for (const headers of newHeaders) {
|
|
50
|
+
const seenHeaders = new Set();
|
|
51
|
+
for (const [name, value] of iterateHeaders(headers)) {
|
|
52
|
+
const lowerName = name.toLowerCase();
|
|
53
|
+
if (!seenHeaders.has(lowerName)) {
|
|
54
|
+
targetHeaders.delete(name);
|
|
55
|
+
seenHeaders.add(lowerName);
|
|
56
|
+
}
|
|
57
|
+
if (value === null) {
|
|
58
|
+
targetHeaders.delete(name);
|
|
59
|
+
nullHeaders.add(lowerName);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
targetHeaders.append(name, value);
|
|
63
|
+
nullHeaders.delete(lowerName);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return { [brand_privateNullableHeaders]: true, values: targetHeaders, nulls: nullHeaders };
|
|
68
|
+
};
|
|
69
|
+
export const isEmptyHeaders = (headers) => {
|
|
70
|
+
for (const _ of iterateHeaders(headers))
|
|
71
|
+
return false;
|
|
72
|
+
return true;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=headers.mjs.map
|