@aws-sdk/util-user-agent-node 3.973.25 → 3.973.27
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/dist-cjs/index.js +7 -180
- package/dist-es/index.js +1 -2
- package/dist-types/index.d.ts +2 -2
- package/package.json +3 -28
- package/dist-es/crt-availability.js +0 -3
- package/dist-es/defaultUserAgent.js +0 -36
- package/dist-es/getNodeModulesParentDirs.js +0 -15
- package/dist-es/getRuntimeUserAgentPair.js +0 -10
- package/dist-es/getSanitizedDevTypeScriptVersion.js +0 -14
- package/dist-es/getSanitizedTypeScriptVersion.js +0 -9
- package/dist-es/getTypeScriptUserAgentPair.js +0 -75
- package/dist-es/is-crt-available.js +0 -7
- package/dist-es/nodeAppIdConfigOptions.js +0 -9
- package/dist-types/crt-availability.d.ts +0 -8
- package/dist-types/defaultUserAgent.d.ts +0 -28
- package/dist-types/getNodeModulesParentDirs.d.ts +0 -10
- package/dist-types/getRuntimeUserAgentPair.d.ts +0 -6
- package/dist-types/getSanitizedDevTypeScriptVersion.d.ts +0 -8
- package/dist-types/getSanitizedTypeScriptVersion.d.ts +0 -8
- package/dist-types/getTypeScriptUserAgentPair.d.ts +0 -6
- package/dist-types/is-crt-available.d.ts +0 -5
- package/dist-types/nodeAppIdConfigOptions.d.ts +0 -13
- package/dist-types/ts3.4/crt-availability.d.ts +0 -3
- package/dist-types/ts3.4/defaultUserAgent.d.ts +0 -21
- package/dist-types/ts3.4/getNodeModulesParentDirs.d.ts +0 -1
- package/dist-types/ts3.4/getRuntimeUserAgentPair.d.ts +0 -2
- package/dist-types/ts3.4/getSanitizedDevTypeScriptVersion.d.ts +0 -3
- package/dist-types/ts3.4/getSanitizedTypeScriptVersion.d.ts +0 -3
- package/dist-types/ts3.4/getTypeScriptUserAgentPair.d.ts +0 -4
- package/dist-types/ts3.4/index.d.ts +0 -2
- package/dist-types/ts3.4/is-crt-available.d.ts +0 -2
- package/dist-types/ts3.4/nodeAppIdConfigOptions.d.ts +0 -6
package/dist-cjs/index.js
CHANGED
|
@@ -1,185 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var node_process = require('node:process');
|
|
5
|
-
var config = require('@smithy/core/config');
|
|
6
|
-
var promises = require('node:fs/promises');
|
|
7
|
-
var node_path = require('node:path');
|
|
8
|
-
var middlewareUserAgent = require('@aws-sdk/middleware-user-agent');
|
|
3
|
+
var client = require('@aws-sdk/core/client');
|
|
9
4
|
|
|
10
|
-
const getRuntimeUserAgentPair = () => {
|
|
11
|
-
const runtimesToCheck = ["deno", "bun", "llrt"];
|
|
12
|
-
for (const runtime of runtimesToCheck) {
|
|
13
|
-
if (node_process.versions[runtime]) {
|
|
14
|
-
return [`md/${runtime}`, node_process.versions[runtime]];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return ["md/nodejs", node_process.versions.node];
|
|
18
|
-
};
|
|
19
5
|
|
|
20
|
-
const getNodeModulesParentDirs = (dirname) => {
|
|
21
|
-
const cwd = process.cwd();
|
|
22
|
-
if (!dirname) {
|
|
23
|
-
return [cwd];
|
|
24
|
-
}
|
|
25
|
-
const normalizedPath = node_path.normalize(dirname);
|
|
26
|
-
const parts = normalizedPath.split(node_path.sep);
|
|
27
|
-
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
28
|
-
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(node_path.sep) : normalizedPath;
|
|
29
|
-
if (cwd === parentDir) {
|
|
30
|
-
return [cwd];
|
|
31
|
-
}
|
|
32
|
-
return [parentDir, cwd];
|
|
33
|
-
};
|
|
34
6
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
|
42
|
-
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
|
|
46
|
-
const ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
|
|
47
|
-
const getSanitizedDevTypeScriptVersion = (version = "") => {
|
|
48
|
-
if (ALLOWED_DIST_TAGS.includes(version)) {
|
|
49
|
-
return version;
|
|
50
|
-
}
|
|
51
|
-
const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
|
|
52
|
-
const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
|
|
53
|
-
if (!sanitizedTypeScriptVersion) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
return `${prefix}${sanitizedTypeScriptVersion}`;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
let tscVersion;
|
|
60
|
-
const TS_PACKAGE_JSON = node_path.join("node_modules", "typescript", "package.json");
|
|
61
|
-
const getTypeScriptUserAgentPair = async () => {
|
|
62
|
-
if (tscVersion === null) {
|
|
63
|
-
return undefined;
|
|
64
|
-
}
|
|
65
|
-
else if (typeof tscVersion === "string") {
|
|
66
|
-
return ["md/tsc", tscVersion];
|
|
67
|
-
}
|
|
68
|
-
let isTypeScriptDetectionDisabled = false;
|
|
69
|
-
try {
|
|
70
|
-
isTypeScriptDetectionDisabled =
|
|
71
|
-
config.booleanSelector(process.env, "AWS_SDK_JS_TYPESCRIPT_DETECTION_DISABLED", config.SelectorType.ENV) || false;
|
|
72
|
-
}
|
|
73
|
-
catch { }
|
|
74
|
-
if (isTypeScriptDetectionDisabled) {
|
|
75
|
-
tscVersion = null;
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
|
79
|
-
const nodeModulesParentDirs = getNodeModulesParentDirs(dirname);
|
|
80
|
-
let versionFromApp;
|
|
81
|
-
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
82
|
-
try {
|
|
83
|
-
const appPackageJsonPath = node_path.join(nodeModulesParentDir, "package.json");
|
|
84
|
-
const packageJson = await promises.readFile(appPackageJsonPath, "utf-8");
|
|
85
|
-
const { dependencies, devDependencies } = JSON.parse(packageJson);
|
|
86
|
-
const version = devDependencies?.typescript ?? dependencies?.typescript;
|
|
87
|
-
if (typeof version !== "string") {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
versionFromApp = version;
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
catch {
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (!versionFromApp) {
|
|
97
|
-
tscVersion = null;
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
let versionFromNodeModules;
|
|
101
|
-
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
102
|
-
try {
|
|
103
|
-
const tsPackageJsonPath = node_path.join(nodeModulesParentDir, TS_PACKAGE_JSON);
|
|
104
|
-
const packageJson = await promises.readFile(tsPackageJsonPath, "utf-8");
|
|
105
|
-
const { version } = JSON.parse(packageJson);
|
|
106
|
-
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
|
107
|
-
if (typeof sanitizedVersion !== "string") {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
versionFromNodeModules = sanitizedVersion;
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (versionFromNodeModules) {
|
|
117
|
-
tscVersion = versionFromNodeModules;
|
|
118
|
-
return ["md/tsc", tscVersion];
|
|
119
|
-
}
|
|
120
|
-
const sanitizedVersion = getSanitizedDevTypeScriptVersion(versionFromApp);
|
|
121
|
-
if (typeof sanitizedVersion !== "string") {
|
|
122
|
-
tscVersion = null;
|
|
123
|
-
return undefined;
|
|
124
|
-
}
|
|
125
|
-
tscVersion = `dev_${sanitizedVersion}`;
|
|
126
|
-
return ["md/tsc", tscVersion];
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const crtAvailability = {
|
|
130
|
-
isCrtAvailable: false,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const isCrtAvailable = () => {
|
|
134
|
-
if (crtAvailability.isCrtAvailable) {
|
|
135
|
-
return ["md/crt-avail"];
|
|
136
|
-
}
|
|
137
|
-
return null;
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
141
|
-
const runtimeUserAgentPair = getRuntimeUserAgentPair();
|
|
142
|
-
return async (config) => {
|
|
143
|
-
const sections = [
|
|
144
|
-
["aws-sdk-js", clientVersion],
|
|
145
|
-
["ua", "2.1"],
|
|
146
|
-
[`os/${node_os.platform()}`, node_os.release()],
|
|
147
|
-
["lang/js"],
|
|
148
|
-
runtimeUserAgentPair,
|
|
149
|
-
];
|
|
150
|
-
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
151
|
-
if (typescriptUserAgentPair) {
|
|
152
|
-
sections.push(typescriptUserAgentPair);
|
|
153
|
-
}
|
|
154
|
-
const crtAvailable = isCrtAvailable();
|
|
155
|
-
if (crtAvailable) {
|
|
156
|
-
sections.push(crtAvailable);
|
|
157
|
-
}
|
|
158
|
-
if (serviceId) {
|
|
159
|
-
sections.push([`api/${serviceId}`, clientVersion]);
|
|
160
|
-
}
|
|
161
|
-
if (node_process.env.AWS_EXECUTION_ENV) {
|
|
162
|
-
sections.push([`exec-env/${node_process.env.AWS_EXECUTION_ENV}`]);
|
|
163
|
-
}
|
|
164
|
-
const appId = await config?.userAgentAppId?.();
|
|
165
|
-
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
|
166
|
-
return resolvedUserAgent;
|
|
167
|
-
};
|
|
168
|
-
};
|
|
169
|
-
const defaultUserAgent = createDefaultUserAgentProvider;
|
|
170
|
-
|
|
171
|
-
const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
|
172
|
-
const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
|
173
|
-
const UA_APP_ID_INI_NAME_DEPRECATED = "sdk-ua-app-id";
|
|
174
|
-
const NODE_APP_ID_CONFIG_OPTIONS = {
|
|
175
|
-
environmentVariableSelector: (env) => env[UA_APP_ID_ENV_NAME],
|
|
176
|
-
configFileSelector: (profile) => profile[UA_APP_ID_INI_NAME] ?? profile[UA_APP_ID_INI_NAME_DEPRECATED],
|
|
177
|
-
default: middlewareUserAgent.DEFAULT_UA_APP_ID,
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
exports.NODE_APP_ID_CONFIG_OPTIONS = NODE_APP_ID_CONFIG_OPTIONS;
|
|
181
|
-
exports.UA_APP_ID_ENV_NAME = UA_APP_ID_ENV_NAME;
|
|
182
|
-
exports.UA_APP_ID_INI_NAME = UA_APP_ID_INI_NAME;
|
|
183
|
-
exports.createDefaultUserAgentProvider = createDefaultUserAgentProvider;
|
|
184
|
-
exports.crtAvailability = crtAvailability;
|
|
185
|
-
exports.defaultUserAgent = defaultUserAgent;
|
|
7
|
+
exports.NODE_APP_ID_CONFIG_OPTIONS = client.NODE_APP_ID_CONFIG_OPTIONS;
|
|
8
|
+
exports.UA_APP_ID_ENV_NAME = client.UA_APP_ID_ENV_NAME;
|
|
9
|
+
exports.UA_APP_ID_INI_NAME = client.UA_APP_ID_INI_NAME;
|
|
10
|
+
exports.createDefaultUserAgentProvider = client.createDefaultUserAgentProvider;
|
|
11
|
+
exports.crtAvailability = client.crtAvailability;
|
|
12
|
+
exports.defaultUserAgent = client.defaultUserAgent;
|
package/dist-es/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from "./nodeAppIdConfigOptions";
|
|
1
|
+
export { createDefaultUserAgentProvider, defaultUserAgent, crtAvailability, NODE_APP_ID_CONFIG_OPTIONS, UA_APP_ID_ENV_NAME, UA_APP_ID_INI_NAME, } from "@aws-sdk/core/client";
|
package/dist-types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { createDefaultUserAgentProvider, defaultUserAgent, crtAvailability, NODE_APP_ID_CONFIG_OPTIONS, UA_APP_ID_ENV_NAME, UA_APP_ID_INI_NAME, } from "@aws-sdk/core/client";
|
|
2
|
+
export type { DefaultUserAgentOptions, PreviouslyResolved } from "@aws-sdk/core/client";
|
package/package.json
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/util-user-agent-node",
|
|
3
|
-
"version": "3.973.
|
|
3
|
+
"version": "3.973.27",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline util-user-agent-node",
|
|
7
7
|
"build:es": "tsc -p tsconfig.es.json",
|
|
8
8
|
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
9
9
|
"build:types": "tsc -p tsconfig.types.json",
|
|
10
|
-
"
|
|
11
|
-
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
12
|
-
"test": "yarn g:vitest run",
|
|
13
|
-
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
|
|
14
|
-
"test:watch": "yarn g:vitest watch",
|
|
15
|
-
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
|
|
10
|
+
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo"
|
|
16
11
|
},
|
|
17
12
|
"main": "./dist-cjs/index.js",
|
|
18
13
|
"module": "./dist-es/index.js",
|
|
@@ -24,38 +19,18 @@
|
|
|
24
19
|
},
|
|
25
20
|
"license": "Apache-2.0",
|
|
26
21
|
"dependencies": {
|
|
27
|
-
"@aws-sdk/
|
|
28
|
-
"@aws-sdk/types": "^3.973.8",
|
|
29
|
-
"@smithy/core": "^3.24.1",
|
|
30
|
-
"@smithy/types": "^4.14.1",
|
|
22
|
+
"@aws-sdk/core": "^3.974.11",
|
|
31
23
|
"tslib": "^2.6.2"
|
|
32
24
|
},
|
|
33
25
|
"devDependencies": {
|
|
34
26
|
"@tsconfig/recommended": "1.0.1",
|
|
35
|
-
"@types/node": "^20.14.8",
|
|
36
27
|
"concurrently": "7.0.0",
|
|
37
|
-
"downlevel-dts": "0.10.1",
|
|
38
28
|
"premove": "4.0.0",
|
|
39
29
|
"typescript": "~5.8.3"
|
|
40
30
|
},
|
|
41
|
-
"peerDependencies": {
|
|
42
|
-
"aws-crt": ">=1.0.0"
|
|
43
|
-
},
|
|
44
|
-
"peerDependenciesMeta": {
|
|
45
|
-
"aws-crt": {
|
|
46
|
-
"optional": true
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
31
|
"engines": {
|
|
50
32
|
"node": ">=20.0.0"
|
|
51
33
|
},
|
|
52
|
-
"typesVersions": {
|
|
53
|
-
"<4.5": {
|
|
54
|
-
"dist-types/*": [
|
|
55
|
-
"dist-types/ts3.4/*"
|
|
56
|
-
]
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
34
|
"files": [
|
|
60
35
|
"dist-*/**"
|
|
61
36
|
],
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { platform, release } from "node:os";
|
|
2
|
-
import { env } from "node:process";
|
|
3
|
-
import { getRuntimeUserAgentPair } from "./getRuntimeUserAgentPair";
|
|
4
|
-
import { getTypeScriptUserAgentPair } from "./getTypeScriptUserAgentPair";
|
|
5
|
-
import { isCrtAvailable } from "./is-crt-available";
|
|
6
|
-
export { crtAvailability } from "./crt-availability";
|
|
7
|
-
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
8
|
-
const runtimeUserAgentPair = getRuntimeUserAgentPair();
|
|
9
|
-
return async (config) => {
|
|
10
|
-
const sections = [
|
|
11
|
-
["aws-sdk-js", clientVersion],
|
|
12
|
-
["ua", "2.1"],
|
|
13
|
-
[`os/${platform()}`, release()],
|
|
14
|
-
["lang/js"],
|
|
15
|
-
runtimeUserAgentPair,
|
|
16
|
-
];
|
|
17
|
-
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
18
|
-
if (typescriptUserAgentPair) {
|
|
19
|
-
sections.push(typescriptUserAgentPair);
|
|
20
|
-
}
|
|
21
|
-
const crtAvailable = isCrtAvailable();
|
|
22
|
-
if (crtAvailable) {
|
|
23
|
-
sections.push(crtAvailable);
|
|
24
|
-
}
|
|
25
|
-
if (serviceId) {
|
|
26
|
-
sections.push([`api/${serviceId}`, clientVersion]);
|
|
27
|
-
}
|
|
28
|
-
if (env.AWS_EXECUTION_ENV) {
|
|
29
|
-
sections.push([`exec-env/${env.AWS_EXECUTION_ENV}`]);
|
|
30
|
-
}
|
|
31
|
-
const appId = await config?.userAgentAppId?.();
|
|
32
|
-
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
|
33
|
-
return resolvedUserAgent;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export const defaultUserAgent = createDefaultUserAgentProvider;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { normalize, sep } from "node:path";
|
|
2
|
-
export const getNodeModulesParentDirs = (dirname) => {
|
|
3
|
-
const cwd = process.cwd();
|
|
4
|
-
if (!dirname) {
|
|
5
|
-
return [cwd];
|
|
6
|
-
}
|
|
7
|
-
const normalizedPath = normalize(dirname);
|
|
8
|
-
const parts = normalizedPath.split(sep);
|
|
9
|
-
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
10
|
-
const parentDir = nodeModulesIndex !== -1 ? parts.slice(0, nodeModulesIndex).join(sep) : normalizedPath;
|
|
11
|
-
if (cwd === parentDir) {
|
|
12
|
-
return [cwd];
|
|
13
|
-
}
|
|
14
|
-
return [parentDir, cwd];
|
|
15
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { versions } from "node:process";
|
|
2
|
-
export const getRuntimeUserAgentPair = () => {
|
|
3
|
-
const runtimesToCheck = ["deno", "bun", "llrt"];
|
|
4
|
-
for (const runtime of runtimesToCheck) {
|
|
5
|
-
if (versions[runtime]) {
|
|
6
|
-
return [`md/${runtime}`, versions[runtime]];
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
return ["md/nodejs", versions.node];
|
|
10
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
|
|
2
|
-
const ALLOWED_PREFIXES = ["^", "~", ">=", "<=", ">", "<"];
|
|
3
|
-
const ALLOWED_DIST_TAGS = ["latest", "beta", "dev", "rc", "insiders", "next"];
|
|
4
|
-
export const getSanitizedDevTypeScriptVersion = (version = "") => {
|
|
5
|
-
if (ALLOWED_DIST_TAGS.includes(version)) {
|
|
6
|
-
return version;
|
|
7
|
-
}
|
|
8
|
-
const prefix = ALLOWED_PREFIXES.find((p) => version.startsWith(p)) ?? "";
|
|
9
|
-
const sanitizedTypeScriptVersion = getSanitizedTypeScriptVersion(version.slice(prefix.length));
|
|
10
|
-
if (!sanitizedTypeScriptVersion) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
return `${prefix}${sanitizedTypeScriptVersion}`;
|
|
14
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const SEMVER_REGEX = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
|
|
2
|
-
export const getSanitizedTypeScriptVersion = (version = "") => {
|
|
3
|
-
const match = version.match(SEMVER_REGEX);
|
|
4
|
-
if (!match) {
|
|
5
|
-
return undefined;
|
|
6
|
-
}
|
|
7
|
-
const [major, minor, patch, prerelease] = [match[1], match[2], match[3], match[4]];
|
|
8
|
-
return prerelease ? `${major}.${minor}.${patch}-${prerelease}` : `${major}.${minor}.${patch}`;
|
|
9
|
-
};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { booleanSelector, SelectorType } from "@smithy/core/config";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
import { getNodeModulesParentDirs } from "./getNodeModulesParentDirs";
|
|
5
|
-
import { getSanitizedDevTypeScriptVersion } from "./getSanitizedDevTypeScriptVersion";
|
|
6
|
-
import { getSanitizedTypeScriptVersion } from "./getSanitizedTypeScriptVersion";
|
|
7
|
-
let tscVersion;
|
|
8
|
-
const TS_PACKAGE_JSON = join("node_modules", "typescript", "package.json");
|
|
9
|
-
export const getTypeScriptUserAgentPair = async () => {
|
|
10
|
-
if (tscVersion === null) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
else if (typeof tscVersion === "string") {
|
|
14
|
-
return ["md/tsc", tscVersion];
|
|
15
|
-
}
|
|
16
|
-
let isTypeScriptDetectionDisabled = false;
|
|
17
|
-
try {
|
|
18
|
-
isTypeScriptDetectionDisabled =
|
|
19
|
-
booleanSelector(process.env, "AWS_SDK_JS_TYPESCRIPT_DETECTION_DISABLED", SelectorType.ENV) || false;
|
|
20
|
-
}
|
|
21
|
-
catch { }
|
|
22
|
-
if (isTypeScriptDetectionDisabled) {
|
|
23
|
-
tscVersion = null;
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : undefined;
|
|
27
|
-
const nodeModulesParentDirs = getNodeModulesParentDirs(dirname);
|
|
28
|
-
let versionFromApp;
|
|
29
|
-
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
30
|
-
try {
|
|
31
|
-
const appPackageJsonPath = join(nodeModulesParentDir, "package.json");
|
|
32
|
-
const packageJson = await readFile(appPackageJsonPath, "utf-8");
|
|
33
|
-
const { dependencies, devDependencies } = JSON.parse(packageJson);
|
|
34
|
-
const version = devDependencies?.typescript ?? dependencies?.typescript;
|
|
35
|
-
if (typeof version !== "string") {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
versionFromApp = version;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!versionFromApp) {
|
|
45
|
-
tscVersion = null;
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
let versionFromNodeModules;
|
|
49
|
-
for (const nodeModulesParentDir of nodeModulesParentDirs) {
|
|
50
|
-
try {
|
|
51
|
-
const tsPackageJsonPath = join(nodeModulesParentDir, TS_PACKAGE_JSON);
|
|
52
|
-
const packageJson = await readFile(tsPackageJsonPath, "utf-8");
|
|
53
|
-
const { version } = JSON.parse(packageJson);
|
|
54
|
-
const sanitizedVersion = getSanitizedTypeScriptVersion(version);
|
|
55
|
-
if (typeof sanitizedVersion !== "string") {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
versionFromNodeModules = sanitizedVersion;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
if (versionFromNodeModules) {
|
|
65
|
-
tscVersion = versionFromNodeModules;
|
|
66
|
-
return ["md/tsc", tscVersion];
|
|
67
|
-
}
|
|
68
|
-
const sanitizedVersion = getSanitizedDevTypeScriptVersion(versionFromApp);
|
|
69
|
-
if (typeof sanitizedVersion !== "string") {
|
|
70
|
-
tscVersion = null;
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
tscVersion = `dev_${sanitizedVersion}`;
|
|
74
|
-
return ["md/tsc", tscVersion];
|
|
75
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DEFAULT_UA_APP_ID } from "@aws-sdk/middleware-user-agent";
|
|
2
|
-
export const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
|
3
|
-
export const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
|
4
|
-
const UA_APP_ID_INI_NAME_DEPRECATED = "sdk-ua-app-id";
|
|
5
|
-
export const NODE_APP_ID_CONFIG_OPTIONS = {
|
|
6
|
-
environmentVariableSelector: (env) => env[UA_APP_ID_ENV_NAME],
|
|
7
|
-
configFileSelector: (profile) => profile[UA_APP_ID_INI_NAME] ?? profile[UA_APP_ID_INI_NAME_DEPRECATED],
|
|
8
|
-
default: DEFAULT_UA_APP_ID,
|
|
9
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Provider, UserAgent } from "@smithy/types";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export { crtAvailability } from "./crt-availability";
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export interface DefaultUserAgentOptions {
|
|
10
|
-
serviceId?: string;
|
|
11
|
-
clientVersion: string;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export interface PreviouslyResolved {
|
|
17
|
-
userAgentAppId: Provider<string | undefined>;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Collect metrics from runtime to put into user agent.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare const createDefaultUserAgentProvider: ({ serviceId, clientVersion }: DefaultUserAgentOptions) => (config?: PreviouslyResolved) => Promise<UserAgent>;
|
|
24
|
-
/**
|
|
25
|
-
* @internal
|
|
26
|
-
* @deprecated use createDefaultUserAgentProvider
|
|
27
|
-
*/
|
|
28
|
-
export declare const defaultUserAgent: ({ serviceId, clientVersion }: DefaultUserAgentOptions) => (config?: PreviouslyResolved) => Promise<UserAgent>;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns candidate paths to the node_modules parent directories based on current
|
|
3
|
-
* working directory and, if provided, from the given directory.
|
|
4
|
-
*
|
|
5
|
-
* @param dirname - Optional directory path to derive an additional candidate path from.
|
|
6
|
-
* @returns An array of unique candidate paths to the TypeScript package.json file.
|
|
7
|
-
*
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export declare const getNodeModulesParentDirs: (dirname?: string) => string[];
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Sanitizes a TypeScript version string for user-agent reporting.
|
|
3
|
-
* Handles dist tags (e.g., "latest", "beta"), version prefixes (e.g., "^", "~"),
|
|
4
|
-
* and semver strings. Returns undefined if the version is invalid.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare const getSanitizedDevTypeScriptVersion: (version?: string) => string | undefined;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates a semver string (with optional pre-release and/or build metadata).
|
|
3
|
-
* If valid, returns the version string with build metadata stripped.
|
|
4
|
-
* Returns undefined if the string is not a valid semver.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
*/
|
|
8
|
-
export declare const getSanitizedTypeScriptVersion: (version?: string) => string | undefined;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { LoadedConfigSelectors } from "@smithy/core/config";
|
|
2
|
-
/**
|
|
3
|
-
* @internal
|
|
4
|
-
*/
|
|
5
|
-
export declare const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
|
-
export declare const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
|
10
|
-
/**
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
export declare const NODE_APP_ID_CONFIG_OPTIONS: LoadedConfigSelectors<string | undefined>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Provider, UserAgent } from "@smithy/types";
|
|
2
|
-
export { crtAvailability } from "./crt-availability";
|
|
3
|
-
export interface DefaultUserAgentOptions {
|
|
4
|
-
serviceId?: string;
|
|
5
|
-
clientVersion: string;
|
|
6
|
-
}
|
|
7
|
-
export interface PreviouslyResolved {
|
|
8
|
-
userAgentAppId: Provider<string | undefined>;
|
|
9
|
-
}
|
|
10
|
-
export declare const createDefaultUserAgentProvider: ({
|
|
11
|
-
serviceId,
|
|
12
|
-
clientVersion,
|
|
13
|
-
}: DefaultUserAgentOptions) => (
|
|
14
|
-
config?: PreviouslyResolved
|
|
15
|
-
) => Promise<UserAgent>;
|
|
16
|
-
export declare const defaultUserAgent: ({
|
|
17
|
-
serviceId,
|
|
18
|
-
clientVersion,
|
|
19
|
-
}: DefaultUserAgentOptions) => (
|
|
20
|
-
config?: PreviouslyResolved
|
|
21
|
-
) => Promise<UserAgent>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getNodeModulesParentDirs: (dirname?: string) => string[];
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { LoadedConfigSelectors } from "@smithy/core/config";
|
|
2
|
-
export declare const UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
|
|
3
|
-
export declare const UA_APP_ID_INI_NAME = "sdk_ua_app_id";
|
|
4
|
-
export declare const NODE_APP_ID_CONFIG_OPTIONS: LoadedConfigSelectors<
|
|
5
|
-
string | undefined
|
|
6
|
-
>;
|