@aws-sdk/util-user-agent-node 3.972.12 → 3.973.0
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 +51 -8
- package/dist-es/defaultUserAgent.js +7 -2
- package/dist-es/getRuntimeUserAgentPair.js +1 -1
- package/dist-es/getTypeScriptPackageJsonPath.js +14 -0
- package/dist-es/getTypeScriptUserAgentPair.js +24 -0
- package/dist-types/getTypeScriptPackageJsonPath.d.ts +9 -0
- package/dist-types/getTypeScriptUserAgentPair.d.ts +6 -0
- package/dist-types/is-crt-available.d.ts +1 -1
- package/dist-types/nodeAppIdConfigOptions.d.ts +1 -1
- package/dist-types/ts3.4/getTypeScriptPackageJsonPath.d.ts +1 -0
- package/dist-types/ts3.4/getTypeScriptUserAgentPair.d.ts +4 -0
- package/package.json +8 -6
package/dist-cjs/index.js
CHANGED
|
@@ -1,17 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var node_os = require('node:os');
|
|
4
|
+
var node_process = require('node:process');
|
|
5
|
+
var promises = require('node:fs/promises');
|
|
6
|
+
var node_path = require('node:path');
|
|
5
7
|
var middlewareUserAgent = require('@aws-sdk/middleware-user-agent');
|
|
6
8
|
|
|
7
9
|
const getRuntimeUserAgentPair = () => {
|
|
8
10
|
const runtimesToCheck = ["deno", "bun", "llrt"];
|
|
9
11
|
for (const runtime of runtimesToCheck) {
|
|
10
|
-
if (
|
|
11
|
-
return [`md/${runtime}`,
|
|
12
|
+
if (node_process.versions[runtime]) {
|
|
13
|
+
return [`md/${runtime}`, node_process.versions[runtime]];
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
|
-
return ["md/nodejs",
|
|
16
|
+
return ["md/nodejs", node_process.versions.node];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getTypeScriptPackageJsonPath = (dirname = "") => {
|
|
20
|
+
let nodeModulesPath;
|
|
21
|
+
const normalizedPath = node_path.normalize(dirname);
|
|
22
|
+
const parts = normalizedPath.split(node_path.sep);
|
|
23
|
+
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
24
|
+
if (nodeModulesIndex !== -1) {
|
|
25
|
+
nodeModulesPath = parts.slice(0, nodeModulesIndex).join(node_path.sep);
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
nodeModulesPath = dirname;
|
|
29
|
+
}
|
|
30
|
+
return node_path.join(nodeModulesPath, "node_modules", "typescript", "package.json");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
let tscVersion;
|
|
34
|
+
const getTypeScriptUserAgentPair = async () => {
|
|
35
|
+
if (tscVersion === null) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
else if (typeof tscVersion === "string") {
|
|
39
|
+
return ["md/tsc", tscVersion];
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const packageJson = await promises.readFile(getTypeScriptPackageJsonPath(__dirname), "utf-8");
|
|
43
|
+
const { version } = JSON.parse(packageJson);
|
|
44
|
+
if (typeof version !== "string") {
|
|
45
|
+
tscVersion = null;
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
tscVersion = version;
|
|
49
|
+
return ["md/tsc", tscVersion];
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
tscVersion = null;
|
|
53
|
+
}
|
|
15
54
|
};
|
|
16
55
|
|
|
17
56
|
const crtAvailability = {
|
|
@@ -31,10 +70,14 @@ const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
|
31
70
|
const sections = [
|
|
32
71
|
["aws-sdk-js", clientVersion],
|
|
33
72
|
["ua", "2.1"],
|
|
34
|
-
[`os/${
|
|
73
|
+
[`os/${node_os.platform()}`, node_os.release()],
|
|
35
74
|
["lang/js"],
|
|
36
75
|
runtimeUserAgentPair,
|
|
37
76
|
];
|
|
77
|
+
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
78
|
+
if (typescriptUserAgentPair) {
|
|
79
|
+
sections.push(typescriptUserAgentPair);
|
|
80
|
+
}
|
|
38
81
|
const crtAvailable = isCrtAvailable();
|
|
39
82
|
if (crtAvailable) {
|
|
40
83
|
sections.push(crtAvailable);
|
|
@@ -42,8 +85,8 @@ const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
|
42
85
|
if (serviceId) {
|
|
43
86
|
sections.push([`api/${serviceId}`, clientVersion]);
|
|
44
87
|
}
|
|
45
|
-
if (
|
|
46
|
-
sections.push([`exec-env/${
|
|
88
|
+
if (node_process.env.AWS_EXECUTION_ENV) {
|
|
89
|
+
sections.push([`exec-env/${node_process.env.AWS_EXECUTION_ENV}`]);
|
|
47
90
|
}
|
|
48
91
|
const appId = await config?.userAgentAppId?.();
|
|
49
92
|
const resolvedUserAgent = appId ? [...sections, [`app/${appId}`]] : [...sections];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { platform, release } from "os";
|
|
2
|
-
import { env } from "process";
|
|
1
|
+
import { platform, release } from "node:os";
|
|
2
|
+
import { env } from "node:process";
|
|
3
3
|
import { getRuntimeUserAgentPair } from "./getRuntimeUserAgentPair";
|
|
4
|
+
import { getTypeScriptUserAgentPair } from "./getTypeScriptUserAgentPair";
|
|
4
5
|
import { isCrtAvailable } from "./is-crt-available";
|
|
5
6
|
export { crtAvailability } from "./crt-availability";
|
|
6
7
|
export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) => {
|
|
@@ -13,6 +14,10 @@ export const createDefaultUserAgentProvider = ({ serviceId, clientVersion }) =>
|
|
|
13
14
|
["lang/js"],
|
|
14
15
|
runtimeUserAgentPair,
|
|
15
16
|
];
|
|
17
|
+
const typescriptUserAgentPair = await getTypeScriptUserAgentPair();
|
|
18
|
+
if (typescriptUserAgentPair) {
|
|
19
|
+
sections.push(typescriptUserAgentPair);
|
|
20
|
+
}
|
|
16
21
|
const crtAvailable = isCrtAvailable();
|
|
17
22
|
if (crtAvailable) {
|
|
18
23
|
sections.push(crtAvailable);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { join, normalize, sep } from "node:path";
|
|
2
|
+
export const getTypeScriptPackageJsonPath = (dirname = "") => {
|
|
3
|
+
let nodeModulesPath;
|
|
4
|
+
const normalizedPath = normalize(dirname);
|
|
5
|
+
const parts = normalizedPath.split(sep);
|
|
6
|
+
const nodeModulesIndex = parts.indexOf("node_modules");
|
|
7
|
+
if (nodeModulesIndex !== -1) {
|
|
8
|
+
nodeModulesPath = parts.slice(0, nodeModulesIndex).join(sep);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
nodeModulesPath = dirname;
|
|
12
|
+
}
|
|
13
|
+
return join(nodeModulesPath, "node_modules", "typescript", "package.json");
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { getTypeScriptPackageJsonPath } from "./getTypeScriptPackageJsonPath";
|
|
3
|
+
let tscVersion;
|
|
4
|
+
export const getTypeScriptUserAgentPair = async () => {
|
|
5
|
+
if (tscVersion === null) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
else if (typeof tscVersion === "string") {
|
|
9
|
+
return ["md/tsc", tscVersion];
|
|
10
|
+
}
|
|
11
|
+
try {
|
|
12
|
+
const packageJson = await readFile(getTypeScriptPackageJsonPath(__dirname), "utf-8");
|
|
13
|
+
const { version } = JSON.parse(packageJson);
|
|
14
|
+
if (typeof version !== "string") {
|
|
15
|
+
tscVersion = null;
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
tscVersion = version;
|
|
19
|
+
return ["md/tsc", tscVersion];
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
tscVersion = null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the path to the TypeScript package.json file relative to the given directory.
|
|
3
|
+
*
|
|
4
|
+
* @param dirname - The directory path to resolve from.
|
|
5
|
+
* @returns The path to the TypeScript package.json file.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare const getTypeScriptPackageJsonPath: (dirname?: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getTypeScriptPackageJsonPath: (dirname?: string) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-sdk/util-user-agent-node",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.973.0",
|
|
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",
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
11
11
|
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
12
12
|
"test": "yarn g:vitest run",
|
|
13
|
-
"test:
|
|
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"
|
|
14
16
|
},
|
|
15
17
|
"main": "./dist-cjs/index.js",
|
|
16
18
|
"module": "./dist-es/index.js",
|
|
@@ -22,10 +24,10 @@
|
|
|
22
24
|
},
|
|
23
25
|
"license": "Apache-2.0",
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@aws-sdk/middleware-user-agent": "^3.972.
|
|
26
|
-
"@aws-sdk/types": "^3.973.
|
|
27
|
-
"@smithy/node-config-provider": "^4.3.
|
|
28
|
-
"@smithy/types": "^4.
|
|
27
|
+
"@aws-sdk/middleware-user-agent": "^3.972.15",
|
|
28
|
+
"@aws-sdk/types": "^3.973.4",
|
|
29
|
+
"@smithy/node-config-provider": "^4.3.10",
|
|
30
|
+
"@smithy/types": "^4.13.0",
|
|
29
31
|
"tslib": "^2.6.2"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|