@superblocksteam/sdk 2.0.83-next.1 → 2.0.83
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/.turbo/turbo-build.log +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts +6 -0
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +27 -5
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +217 -260
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/dev-utils/dev-server.mjs +115 -133
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/telemetry/index.d.ts +4 -4
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +64 -92
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/util.d.ts +2 -1
- package/dist/telemetry/util.d.ts.map +1 -1
- package/dist/telemetry/util.js +4 -26
- package/dist/telemetry/util.js.map +1 -1
- package/package.json +5 -6
- package/src/cli-replacement/automatic-upgrades.ts +42 -10
- package/src/cli-replacement/dev.mts +281 -336
- package/src/dev-utils/dev-server.mts +127 -149
- package/src/telemetry/index.ts +83 -105
- package/src/telemetry/util.ts +4 -27
- package/tsconfig.tsbuildinfo +1 -1
- package/turbo.json +2 -20
- package/dist/cli-replacement/version-detection.d.ts +0 -71
- package/dist/cli-replacement/version-detection.d.ts.map +0 -1
- package/dist/cli-replacement/version-detection.js +0 -186
- package/dist/cli-replacement/version-detection.js.map +0 -1
- package/dist/cli-replacement/version-detection.test.d.ts +0 -5
- package/dist/cli-replacement/version-detection.test.d.ts.map +0 -1
- package/dist/cli-replacement/version-detection.test.js +0 -257
- package/dist/cli-replacement/version-detection.test.js.map +0 -1
- package/dist/telemetry/index.test.d.ts +0 -2
- package/dist/telemetry/index.test.d.ts.map +0 -1
- package/dist/telemetry/index.test.js +0 -93
- package/dist/telemetry/index.test.js.map +0 -1
- package/dist/telemetry/local-obs.d.ts +0 -73
- package/dist/telemetry/local-obs.d.ts.map +0 -1
- package/dist/telemetry/local-obs.js +0 -107
- package/dist/telemetry/local-obs.js.map +0 -1
- package/src/cli-replacement/version-detection.test.ts +0 -336
- package/src/cli-replacement/version-detection.ts +0 -220
- package/src/telemetry/index.test.ts +0 -130
- package/src/telemetry/local-obs.ts +0 -138
package/dist/telemetry/util.js
CHANGED
|
@@ -1,34 +1,11 @@
|
|
|
1
1
|
import { getLocalTokenWithUrl } from "@superblocksteam/util";
|
|
2
2
|
export const SERVICE_NAME = "sdk-dev-server";
|
|
3
|
-
/**
|
|
4
|
-
* Get the OTLP base URL for telemetry export.
|
|
5
|
-
*
|
|
6
|
-
* Priority:
|
|
7
|
-
* 1. SUPERBLOCKS_OTEL_COLLECTOR_URL env var (for local obs mode)
|
|
8
|
-
* 2. Superblocks API endpoint derived from base URL
|
|
9
|
-
*
|
|
10
|
-
* When SUPERBLOCKS_OTEL_COLLECTOR_URL is set (e.g., http://localhost:24318),
|
|
11
|
-
* telemetry is sent directly to the local OTEL collector.
|
|
12
|
-
*
|
|
13
|
-
* Note: This returns the BASE URL. The telemetry library appends /v1/traces,
|
|
14
|
-
* /v1/metrics, /v1/logs to this URL.
|
|
15
|
-
*/
|
|
16
|
-
function getOtlpBaseUrl(superblocksBaseUrl) {
|
|
17
|
-
const localOtelUrl = process.env.SUPERBLOCKS_OTEL_COLLECTOR_URL;
|
|
18
|
-
if (localOtelUrl) {
|
|
19
|
-
// Remove trailing /v1/traces etc. if present (just use base URL)
|
|
20
|
-
return localOtelUrl.replace(/\/v1\/(traces|metrics|logs)$/, "");
|
|
21
|
-
}
|
|
22
|
-
// Default: Superblocks API proxies OTLP requests
|
|
23
|
-
// The server expects /api/v1/traces but the telemetry lib adds /v1/traces,
|
|
24
|
-
// so we return /api and let telemetry lib append /v1/traces
|
|
25
|
-
return superblocksBaseUrl.origin + "/api";
|
|
26
|
-
}
|
|
27
3
|
export async function getConfiguration() {
|
|
28
4
|
try {
|
|
29
5
|
const tokenWithUrl = await getLocalTokenWithUrl();
|
|
30
6
|
const superblocksBaseUrl = new URL(tokenWithUrl.superblocksBaseUrl);
|
|
31
|
-
const
|
|
7
|
+
const superblocksTracesUrl = superblocksBaseUrl.origin + "/api/v1/traces";
|
|
8
|
+
const superblocksLogsUrl = superblocksBaseUrl.origin + "/api/v1/logs";
|
|
32
9
|
const superblocksHostname = superblocksBaseUrl.hostname;
|
|
33
10
|
let token = "";
|
|
34
11
|
if ("token" in tokenWithUrl) {
|
|
@@ -36,7 +13,8 @@ export async function getConfiguration() {
|
|
|
36
13
|
}
|
|
37
14
|
return {
|
|
38
15
|
superblocksBaseUrl,
|
|
39
|
-
|
|
16
|
+
superblocksTracesUrl,
|
|
17
|
+
superblocksLogsUrl,
|
|
40
18
|
superblocksHostname,
|
|
41
19
|
serviceName: SERVICE_NAME,
|
|
42
20
|
token,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/telemetry/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAE7C
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/telemetry/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,MAAM,oBAAoB,EAAE,CAAC;QAClD,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACpE,MAAM,oBAAoB,GAAG,kBAAkB,CAAC,MAAM,GAAG,gBAAgB,CAAC;QAC1E,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,MAAM,GAAG,cAAc,CAAC;QACtE,MAAM,mBAAmB,GAAG,kBAAkB,CAAC,QAAQ,CAAC;QACxD,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,OAAO,IAAI,YAAY,EAAE,CAAC;YAC5B,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO;YACL,kBAAkB;YAClB,oBAAoB;YACpB,kBAAkB;YAClB,mBAAmB;YACnB,WAAW,EAAE,YAAY;YACzB,KAAK;SACN,CAAC;IACJ,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACX,4FAA4F,EAC5F,CAAC,CACF,CAAC;QACF,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/sdk",
|
|
3
|
-
"version": "2.0.83
|
|
3
|
+
"version": "2.0.83",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Superblocks JS SDK",
|
|
6
6
|
"homepage": "https://www.superblocks.com",
|
|
@@ -53,11 +53,10 @@
|
|
|
53
53
|
"vite-tsconfig-paths": "^6.0.4",
|
|
54
54
|
"winston": "^3.17.0",
|
|
55
55
|
"yaml": "^2.7.1",
|
|
56
|
-
"@superblocksteam/library-shared": "2.0.83
|
|
57
|
-
"@superblocksteam/shared": "0.
|
|
58
|
-
"@superblocksteam/
|
|
59
|
-
"@superblocksteam/
|
|
60
|
-
"@superblocksteam/vite-plugin-file-sync": "2.0.83-next.1"
|
|
56
|
+
"@superblocksteam/library-shared": "2.0.83",
|
|
57
|
+
"@superblocksteam/shared": "0.9562.5",
|
|
58
|
+
"@superblocksteam/util": "2.0.83",
|
|
59
|
+
"@superblocksteam/vite-plugin-file-sync": "2.0.83"
|
|
61
60
|
},
|
|
62
61
|
"optionalDependencies": {
|
|
63
62
|
"@rollup/rollup-darwin-arm64": "^4.34.9",
|
|
@@ -10,10 +10,6 @@ import gt from "semver/functions/gt.js";
|
|
|
10
10
|
import valid from "semver/functions/valid.js";
|
|
11
11
|
import { getTracer } from "../telemetry/index.js";
|
|
12
12
|
import { getErrorMeta, getLogger } from "../telemetry/logging.js";
|
|
13
|
-
import {
|
|
14
|
-
getCurrentCliVersion,
|
|
15
|
-
clearCliVersionCache,
|
|
16
|
-
} from "./version-detection.js";
|
|
17
13
|
import type { ResponseMeta } from "../socket/handlers.js";
|
|
18
14
|
import type { ApplicationConfigWithTokenConfigAndUserInfo } from "../types/common.js";
|
|
19
15
|
import type { LockService } from "@superblocksteam/vite-plugin-file-sync/lock-service";
|
|
@@ -28,6 +24,11 @@ interface Versions {
|
|
|
28
24
|
[pkg: string]: string;
|
|
29
25
|
}
|
|
30
26
|
|
|
27
|
+
interface PackageVersionInfo {
|
|
28
|
+
version: string;
|
|
29
|
+
alias?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
31
32
|
interface CheckVersionsErrorResponse {
|
|
32
33
|
responseMeta: ResponseMeta;
|
|
33
34
|
}
|
|
@@ -72,6 +73,43 @@ async function getRemoteVersions(
|
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
export async function getCurrentCliVersion(): Promise<
|
|
77
|
+
PackageVersionInfo | undefined
|
|
78
|
+
> {
|
|
79
|
+
try {
|
|
80
|
+
const command = process.platform === "win32" ? "where" : "which";
|
|
81
|
+
const { stdout } = await exec(`${command} superblocks`);
|
|
82
|
+
const superblocksPath = stdout.trim();
|
|
83
|
+
|
|
84
|
+
if (!superblocksPath) return undefined;
|
|
85
|
+
|
|
86
|
+
const { stdout: versionOutput } = await exec(
|
|
87
|
+
`${superblocksPath} version --json`,
|
|
88
|
+
);
|
|
89
|
+
const json = JSON.parse(versionOutput) as Record<string, string>;
|
|
90
|
+
// Extract version from string like "@superblocksteam/cli/2.0.0-next.1" or "@superblocksteam/cli-ephemeral/2.0.0-SNAPSHOT.ebd2b86d643331f5"
|
|
91
|
+
const version = json.cliVersion?.replace(
|
|
92
|
+
/@superblocksteam\/cli(-ephemeral)?\//,
|
|
93
|
+
"",
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const aliasMatch = json.cliVersion?.match(/@superblocksteam\/([^\/]+)/);
|
|
97
|
+
if (aliasMatch && aliasMatch[1] !== "cli") {
|
|
98
|
+
return {
|
|
99
|
+
version: version,
|
|
100
|
+
alias: `@superblocksteam/${aliasMatch[1]}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return { version };
|
|
105
|
+
} catch (error) {
|
|
106
|
+
if (isNativeError(error)) {
|
|
107
|
+
logger.error(`Error getting CLI version: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
75
113
|
async function upgradeCliWithOclif(targetVersion: string): Promise<boolean> {
|
|
76
114
|
try {
|
|
77
115
|
const command = process.platform === "win32" ? "where" : "which";
|
|
@@ -147,9 +185,6 @@ async function upgradeCliWithPackageManager(
|
|
|
147
185
|
// Wait for the install to complete, then validate the version
|
|
148
186
|
await promise;
|
|
149
187
|
|
|
150
|
-
// Clear cache to force actual version detection (not just returning cached value)
|
|
151
|
-
clearCliVersionCache();
|
|
152
|
-
|
|
153
188
|
const currentCliInfo = await getCurrentCliVersion();
|
|
154
189
|
if (!currentCliInfo) {
|
|
155
190
|
throw new Error("Could not get validate CLI version post-install");
|
|
@@ -161,9 +196,6 @@ async function upgradeCliWithPackageManager(
|
|
|
161
196
|
);
|
|
162
197
|
}
|
|
163
198
|
|
|
164
|
-
// Now that we've validated, cache the correct version (avoids re-detection on next call)
|
|
165
|
-
clearCliVersionCache({ version: targetVersion, alias });
|
|
166
|
-
|
|
167
199
|
// This log line is used to end the upgrade spinner
|
|
168
200
|
logger.info(`Successfully upgraded packages to ${targetVersion}`);
|
|
169
201
|
}
|