@blaxel/core 0.2.32-preview.74 → 0.2.32-preview.75
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.
|
@@ -7,6 +7,7 @@ export type Config = {
|
|
|
7
7
|
declare class Settings {
|
|
8
8
|
credentials: Credentials;
|
|
9
9
|
config: Config;
|
|
10
|
+
private _version;
|
|
10
11
|
constructor();
|
|
11
12
|
setConfig(config: Config): void;
|
|
12
13
|
get env(): string;
|
|
@@ -15,6 +16,7 @@ declare class Settings {
|
|
|
15
16
|
get workspace(): string;
|
|
16
17
|
get authorization(): string;
|
|
17
18
|
get token(): string;
|
|
19
|
+
get version(): string;
|
|
18
20
|
get headers(): Record<string, string>;
|
|
19
21
|
get name(): string;
|
|
20
22
|
get type(): string;
|
package/dist/common/settings.js
CHANGED
|
@@ -3,9 +3,74 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.settings = void 0;
|
|
4
4
|
const index_js_1 = require("../authentication/index.js");
|
|
5
5
|
const env_js_1 = require("../common/env.js");
|
|
6
|
+
// Function to get package version
|
|
7
|
+
function getPackageVersion() {
|
|
8
|
+
try {
|
|
9
|
+
// Try to require package.json (Node.js only, gracefully fails in browser)
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
11
|
+
const packageJson = {"version":"0.2.32-preview.75","commit":"f8c31a81d106f8be6c1ea8b4e56e4b8d7904d52f"};
|
|
12
|
+
return packageJson.version || "unknown";
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// Fallback for browser environments or if require fails
|
|
16
|
+
return "unknown";
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Function to get OS and architecture
|
|
20
|
+
function getOsArch() {
|
|
21
|
+
try {
|
|
22
|
+
// Node.js environment
|
|
23
|
+
if (typeof process !== 'undefined' && process.platform && process.arch) {
|
|
24
|
+
const platform = process.platform === 'win32' ? 'windows' :
|
|
25
|
+
process.platform === 'darwin' ? 'darwin' :
|
|
26
|
+
process.platform === 'linux' ? 'linux' : process.platform;
|
|
27
|
+
return `${platform}/${process.arch}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// Fall through to browser detection
|
|
32
|
+
}
|
|
33
|
+
// Browser environment - use fixed detection
|
|
34
|
+
try {
|
|
35
|
+
// @ts-ignore - navigator is available in browser environments
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
37
|
+
if (typeof navigator !== 'undefined' && navigator?.platform) {
|
|
38
|
+
// @ts-ignore - navigator.platform is available in browser environments
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
40
|
+
const navPlatform = navigator.platform.toLowerCase();
|
|
41
|
+
const platform = navPlatform.includes('win') ? 'windows' :
|
|
42
|
+
navPlatform.includes('mac') ? 'darwin' :
|
|
43
|
+
navPlatform.includes('linux') ? 'linux' : 'browser';
|
|
44
|
+
const arch = navPlatform.includes('64') ? 'amd64' : 'unknown';
|
|
45
|
+
return `${platform}/${arch}`;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Ignore errors
|
|
50
|
+
}
|
|
51
|
+
return "browser/unknown";
|
|
52
|
+
}
|
|
53
|
+
// Function to get commit hash
|
|
54
|
+
function getCommitHash() {
|
|
55
|
+
try {
|
|
56
|
+
// Try to require package.json and look for commit field (set during build)
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
58
|
+
const packageJson = {"version":"0.2.32-preview.75","commit":"f8c31a81d106f8be6c1ea8b4e56e4b8d7904d52f"};
|
|
59
|
+
// Check for commit in various possible locations
|
|
60
|
+
const commit = packageJson.commit || packageJson.buildInfo?.commit;
|
|
61
|
+
if (commit) {
|
|
62
|
+
return commit.length > 7 ? commit.substring(0, 7) : commit;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// Fallback for browser environments or if require fails
|
|
67
|
+
}
|
|
68
|
+
return "unknown";
|
|
69
|
+
}
|
|
6
70
|
class Settings {
|
|
7
71
|
credentials;
|
|
8
72
|
config;
|
|
73
|
+
_version = null;
|
|
9
74
|
constructor() {
|
|
10
75
|
this.credentials = (0, index_js_1.authentication)();
|
|
11
76
|
this.config = {
|
|
@@ -59,10 +124,19 @@ class Settings {
|
|
|
59
124
|
}
|
|
60
125
|
return this.credentials.token;
|
|
61
126
|
}
|
|
127
|
+
get version() {
|
|
128
|
+
if (this._version === null) {
|
|
129
|
+
this._version = getPackageVersion();
|
|
130
|
+
}
|
|
131
|
+
return this._version;
|
|
132
|
+
}
|
|
62
133
|
get headers() {
|
|
134
|
+
const osArch = getOsArch();
|
|
135
|
+
const commitHash = getCommitHash();
|
|
63
136
|
return {
|
|
64
137
|
"x-blaxel-authorization": this.authorization,
|
|
65
138
|
"x-blaxel-workspace": this.workspace || "",
|
|
139
|
+
"User-Agent": `blaxel/sdk/typescript/${this.version} (${osArch}) blaxel/${commitHash}`,
|
|
66
140
|
};
|
|
67
141
|
}
|
|
68
142
|
get name() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaxel/core",
|
|
3
|
-
"version": "0.2.32-preview.
|
|
3
|
+
"version": "0.2.32-preview.75",
|
|
4
4
|
"description": "Blaxel Core SDK for TypeScript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Blaxel, INC (https://blaxel.ai)",
|
|
@@ -76,10 +76,14 @@
|
|
|
76
76
|
"vite": "^5.2.0",
|
|
77
77
|
"vitest": "^1.5.0"
|
|
78
78
|
},
|
|
79
|
+
"commit": "f8c31a81d106f8be6c1ea8b4e56e4b8d7904d52f",
|
|
79
80
|
"scripts": {
|
|
80
81
|
"lint": "eslint src/",
|
|
81
82
|
"dev": "tsc --watch",
|
|
82
|
-
"build": "tsc",
|
|
83
|
+
"build": "npm run build:inject-commit && tsc && npm run build:replace-imports",
|
|
84
|
+
"build:clean": "tsc",
|
|
85
|
+
"build:inject-commit": "node -e \"const fs=require('fs'),pkg=require('./package.json'),{execSync}=require('child_process');try{const commit=execSync('git rev-parse HEAD',{encoding:'utf8'}).trim();pkg.commit=commit;fs.writeFileSync('./package.json',JSON.stringify(pkg,null,'\\t')+'\\n');console.log('✅ Injected commit:',commit.substring(0,7))}catch(e){console.log('⚠️ Could not inject commit:',e.message)}\"",
|
|
86
|
+
"build:replace-imports": "node -e \"const fs=require('fs'),path=require('path'),pkg=require('./package.json');const settingsPath=path.join('dist','common','settings.js');if(fs.existsSync(settingsPath)){let content=fs.readFileSync(settingsPath,'utf8');content=content.replace(/require\\(\\\".*?\\/package\\.json\\\"\\)/g,JSON.stringify({version:pkg.version,commit:pkg.commit||'unknown'}));fs.writeFileSync(settingsPath,content);console.log('✅ Replaced package.json imports in compiled JS with version:',pkg.version,'commit:',(pkg.commit||'unknown').substring(0,7));}else{console.log('⚠️ Could not find',settingsPath,'to replace imports');}\"",
|
|
83
87
|
"test": "vitest --run",
|
|
84
88
|
"test:watch": "vitest --watch"
|
|
85
89
|
}
|