@qbraid-core/base 0.1.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/README.md +21 -0
- package/dist/src/_version.d.ts +1 -0
- package/dist/src/_version.js +6 -0
- package/dist/src/_version.js.map +1 -0
- package/dist/src/client.d.ts +9 -0
- package/dist/src/client.js +106 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/config.d.ts +27 -0
- package/dist/src/config.js +109 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/context.d.ts +22 -0
- package/dist/src/context.js +90 -0
- package/dist/src/context.js.map +1 -0
- package/dist/src/errors.d.ts +3 -0
- package/dist/src/errors.js +18 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/index.d.ts +10 -0
- package/dist/src/index.js +15 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/session.d.ts +17 -0
- package/dist/src/session.js +69 -0
- package/dist/src/session.js.map +1 -0
- package/dist/src/user.d.ts +15 -0
- package/dist/src/user.js +3 -0
- package/dist/src/user.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @qbraid-core/base
|
|
2
|
+
|
|
3
|
+
Base API client used for authentication, requests, and other core functionality for interacting with qBraid Cloud Services.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qbraid-core/base
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage Example
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { QbraidClient } from '@qbraid-core/base';
|
|
15
|
+
|
|
16
|
+
const client = new QbraidClient();
|
|
17
|
+
|
|
18
|
+
const user = await client.getUser();
|
|
19
|
+
|
|
20
|
+
console.log(`email: ${user.email}`, `role: ${user.role}`);
|
|
21
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version = "0.1.0";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_version.js","sourceRoot":"","sources":["../../src/_version.ts"],"names":[],"mappings":";;;AAAA,qDAAqD;AACxC,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Config } from './config';
|
|
2
|
+
import { QbraidSession } from './session';
|
|
3
|
+
import { QbraidUser } from './user';
|
|
4
|
+
export declare class QbraidClient {
|
|
5
|
+
protected session: QbraidSession;
|
|
6
|
+
constructor(config?: Config);
|
|
7
|
+
getUser(): Promise<QbraidUser>;
|
|
8
|
+
runningInLab(): Promise<boolean>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.QbraidClient = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const config_1 = require("./config");
|
|
40
|
+
const session_1 = require("./session");
|
|
41
|
+
const context_1 = require("./context");
|
|
42
|
+
const config_2 = require("./config");
|
|
43
|
+
class QbraidClient {
|
|
44
|
+
session;
|
|
45
|
+
constructor(config = new config_1.ConfigLoader().config) {
|
|
46
|
+
this.session = new session_1.QbraidSession(config);
|
|
47
|
+
}
|
|
48
|
+
async getUser() {
|
|
49
|
+
const response = await this.session.request('GET', '/identity');
|
|
50
|
+
return {
|
|
51
|
+
_id: response.data._id,
|
|
52
|
+
email: response.data.email,
|
|
53
|
+
userName: response.data.userName,
|
|
54
|
+
role: response.data.role,
|
|
55
|
+
permissionsNodes: response.data.permissionsNodes,
|
|
56
|
+
metadata: response.data.metadata,
|
|
57
|
+
diskUsage: {
|
|
58
|
+
totalGB: response.data.diskUsage.totalGB,
|
|
59
|
+
quotaGB: response.data.diskUsage.quotaGB,
|
|
60
|
+
timestamp: new Date(response.data.diskUsage.timestamp),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async runningInLab() {
|
|
65
|
+
try {
|
|
66
|
+
const utcDatetime = new Date();
|
|
67
|
+
const formattedTime = utcDatetime.toISOString().replace(/[-:]/g, '').replace(/\..+/, '');
|
|
68
|
+
const configDir = path.join(config_2.USER_CONFIG_PATH, '..', 'certs');
|
|
69
|
+
const filepath = path.join(configDir, formattedTime);
|
|
70
|
+
let fileCreated = false;
|
|
71
|
+
return await (0, context_1.ensureDirectory)(configDir, false, async () => {
|
|
72
|
+
try {
|
|
73
|
+
// Create empty file with proper error handling
|
|
74
|
+
await fs.promises.writeFile(filepath, '').catch((error) => {
|
|
75
|
+
console.error(`Failed to create test file: ${error.message}`);
|
|
76
|
+
throw error;
|
|
77
|
+
});
|
|
78
|
+
fileCreated = true;
|
|
79
|
+
const response = await this.session.request('GET', `/lab/is-mounted/${formattedTime}`);
|
|
80
|
+
return Boolean(response.data?.isMounted);
|
|
81
|
+
}
|
|
82
|
+
finally {
|
|
83
|
+
if (fileCreated) {
|
|
84
|
+
try {
|
|
85
|
+
await fs.promises.unlink(filepath);
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
console.error(`Failed to cleanup test file ${filepath}: ${error.message}`);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
console.error(`Failed to cleanup test file ${filepath}: Unknown error`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
console.error('Error in runningInLab:', error instanceof Error ? error.message : 'Unknown error');
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.QbraidClient = QbraidClient;
|
|
106
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,qCAAgD;AAChD,uCAA0C;AAE1C,uCAA4C;AAC5C,qCAA4C;AAE5C,MAAa,YAAY;IACb,OAAO,CAAgB;IAEjC,Y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O,CAAC,CAAC,CAAC,eAAe,CACzD,CAAC;YACF,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AA1ED,oCA0EC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface ConfigDefaults {
|
|
2
|
+
section: string;
|
|
3
|
+
userPool: string;
|
|
4
|
+
endpointURL: string;
|
|
5
|
+
path: string;
|
|
6
|
+
}
|
|
7
|
+
export interface Config {
|
|
8
|
+
baseURL: string;
|
|
9
|
+
jupyterToken: string | null;
|
|
10
|
+
authHeaders: Record<string, string>;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_CONFIG: ConfigDefaults;
|
|
14
|
+
export declare const USER_CONFIG_PATH: string;
|
|
15
|
+
export declare class ConfigLoader {
|
|
16
|
+
private configPath;
|
|
17
|
+
private configSection;
|
|
18
|
+
private _config;
|
|
19
|
+
private readonly expandedConfigPath;
|
|
20
|
+
constructor(configPath?: string, configSection?: string);
|
|
21
|
+
get config(): Config;
|
|
22
|
+
private loadConfig;
|
|
23
|
+
private parseConfigSection;
|
|
24
|
+
private extractConfigValues;
|
|
25
|
+
private buildAuthHeaders;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ConfigLoader = exports.USER_CONFIG_PATH = exports.DEFAULT_CONFIG = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const ini = __importStar(require("ini"));
|
|
39
|
+
const os = __importStar(require("os"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
function normalizePath(path) {
|
|
42
|
+
return path.replace(/^~/, os.homedir());
|
|
43
|
+
}
|
|
44
|
+
exports.DEFAULT_CONFIG = {
|
|
45
|
+
section: 'default',
|
|
46
|
+
userPool: 'qbraid',
|
|
47
|
+
endpointURL: 'https://api.qbraid.com/api',
|
|
48
|
+
path: path.join(os.homedir(), '.qbraid', 'qbraidrc'),
|
|
49
|
+
};
|
|
50
|
+
exports.USER_CONFIG_PATH = normalizePath(process.env.QBRAID_CONFIG_FILE || exports.DEFAULT_CONFIG.path);
|
|
51
|
+
class ConfigLoader {
|
|
52
|
+
configPath;
|
|
53
|
+
configSection;
|
|
54
|
+
_config = null;
|
|
55
|
+
expandedConfigPath;
|
|
56
|
+
constructor(configPath = exports.USER_CONFIG_PATH, configSection = exports.DEFAULT_CONFIG.section) {
|
|
57
|
+
this.configPath = configPath;
|
|
58
|
+
this.configSection = configSection;
|
|
59
|
+
this.expandedConfigPath = normalizePath(this.configPath);
|
|
60
|
+
}
|
|
61
|
+
get config() {
|
|
62
|
+
return (this._config ??= this.loadConfig());
|
|
63
|
+
}
|
|
64
|
+
loadConfig(configSection = this.configSection) {
|
|
65
|
+
let section;
|
|
66
|
+
if (fs.existsSync(this.expandedConfigPath)) {
|
|
67
|
+
section = this.parseConfigSection(configSection);
|
|
68
|
+
}
|
|
69
|
+
const configValues = this.extractConfigValues(section);
|
|
70
|
+
return {
|
|
71
|
+
baseURL: configValues.baseURL,
|
|
72
|
+
jupyterToken: configValues.jupyterToken,
|
|
73
|
+
headers: { domain: configValues.userPool },
|
|
74
|
+
authHeaders: this.buildAuthHeaders(configValues),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
parseConfigSection(configSection) {
|
|
78
|
+
const parsedConfig = ini.parse(fs.readFileSync(this.expandedConfigPath, 'utf-8'));
|
|
79
|
+
const section = parsedConfig[configSection];
|
|
80
|
+
if (!section) {
|
|
81
|
+
throw new Error(`Section [${configSection}] not found in config file: ${this.expandedConfigPath}`);
|
|
82
|
+
}
|
|
83
|
+
return section;
|
|
84
|
+
}
|
|
85
|
+
extractConfigValues(section) {
|
|
86
|
+
return {
|
|
87
|
+
userPool: section?.pool ?? process.env.QBRAID_USER_POOL ?? exports.DEFAULT_CONFIG.userPool,
|
|
88
|
+
jupyterToken: section?.['jupyter-token'] ?? process.env.JUPYTERHUB_TOKEN ?? null,
|
|
89
|
+
apiKey: section?.['api-key'] ?? process.env.QBRAID_API_KEY ?? '',
|
|
90
|
+
refreshToken: section?.['refresh-token'] ?? process.env.REFRESH ?? '',
|
|
91
|
+
userEmail: section?.email ?? process.env.JUPYTERHUB_USER ?? '',
|
|
92
|
+
baseURL: section?.url ?? process.env.QBRAID_API_URL ?? exports.DEFAULT_CONFIG.endpointURL,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
buildAuthHeaders(values) {
|
|
96
|
+
if (values.userEmail && values.refreshToken) {
|
|
97
|
+
return {
|
|
98
|
+
email: values.userEmail,
|
|
99
|
+
'refresh-token': values.refreshToken,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
if (values.apiKey) {
|
|
103
|
+
return { 'api-key': values.apiKey };
|
|
104
|
+
}
|
|
105
|
+
return {};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ConfigLoader = ConfigLoader;
|
|
109
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,yCAA2B;AAC3B,uCAAyB;AACzB,2CAA6B;AAyB7B,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;AAC1C,CAAC;AAEY,QAAA,cAAc,GAAmB;IAC5C,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,QAAQ;IAClB,WAAW,EAAE,4BAA4B;IACzC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC;CACrD,CAAC;AAEW,QAAA,gBAAgB,GAAG,aAAa,CAC3C,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,sBAAc,CAAC,IAAI,CACtD,CAAC;AAEF,MAAa,YAAY;IAKb;IACA;IALF,OAAO,GAAkB,IAAI,CAAC;IACrB,kBAAkB,CAAS;IAE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C,OAAuB;QAQjD,OAAO;YACL,QAAQ,EAAE,OAAO,EAAE,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,sBAAc,CAAC,QAAQ;YAClF,YAAY,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,IAAI;YAChF,MAAM,EAAE,OAAO,EAAE,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,EAAE;YAChE,YAAY,EAAE,OAAO,EAAE,CAAC,eAAe,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE;YACrE,SAAS,EAAE,OAAO,EAAE,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,EAAE;YAC9D,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,sBAAc,CAAC,WAAW;SAClF,CAAC;IACJ,CAAC;IAEO,gBAAgB,CACtB,MAAuD;QAEvD,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YAC5C,OAAO;gBACL,KAAK,EAAE,MAAM,CAAC,SAAS;gBACvB,eAAe,EAAE,MAAM,CAAC,YAAY;aACrC,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;QACtC,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA9ED,oCA8EC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for a disposable resource that can be cleaned up
|
|
3
|
+
*/
|
|
4
|
+
interface Disposable {
|
|
5
|
+
dispose(): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Utility function to handle resource management similar to Python's context manager
|
|
9
|
+
* @param resource A disposable resource with init and dispose methods
|
|
10
|
+
* @param fn The function to execute with the managed resource
|
|
11
|
+
*/
|
|
12
|
+
export declare function using<T extends Disposable, R>(resource: T & {
|
|
13
|
+
init(): Promise<void>;
|
|
14
|
+
}, fn: (resource: T) => Promise<R>): Promise<R>;
|
|
15
|
+
/**
|
|
16
|
+
* Ensures a directory exists during the execution of a function and optionally cleans it up
|
|
17
|
+
* @param dirPath Path to the directory
|
|
18
|
+
* @param removeIfCreated Whether to remove the directory if it was created by this function
|
|
19
|
+
* @param fn Function to execute while directory is guaranteed to exist
|
|
20
|
+
*/
|
|
21
|
+
export declare function ensureDirectory<R>(dirPath: string, removeIfCreated: boolean, fn: () => Promise<R>): Promise<R>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.using = using;
|
|
37
|
+
exports.ensureDirectory = ensureDirectory;
|
|
38
|
+
const fs = __importStar(require("fs"));
|
|
39
|
+
const path = __importStar(require("path"));
|
|
40
|
+
/**
|
|
41
|
+
* Class to manage directory creation and cleanup
|
|
42
|
+
*/
|
|
43
|
+
class DirectoryManager {
|
|
44
|
+
existed;
|
|
45
|
+
path;
|
|
46
|
+
removeIfCreated;
|
|
47
|
+
constructor(dirPath, removeIfCreated) {
|
|
48
|
+
this.path = dirPath;
|
|
49
|
+
this.removeIfCreated = removeIfCreated;
|
|
50
|
+
this.existed = fs.existsSync(dirPath);
|
|
51
|
+
}
|
|
52
|
+
async init() {
|
|
53
|
+
if (!this.existed) {
|
|
54
|
+
await fs.promises.mkdir(this.path, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async dispose() {
|
|
58
|
+
if (!this.existed && this.removeIfCreated) {
|
|
59
|
+
const files = await fs.promises.readdir(this.path);
|
|
60
|
+
for (const file of files) {
|
|
61
|
+
await fs.promises.unlink(path.join(this.path, file));
|
|
62
|
+
}
|
|
63
|
+
await fs.promises.rmdir(this.path);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Utility function to handle resource management similar to Python's context manager
|
|
69
|
+
* @param resource A disposable resource with init and dispose methods
|
|
70
|
+
* @param fn The function to execute with the managed resource
|
|
71
|
+
*/
|
|
72
|
+
async function using(resource, fn) {
|
|
73
|
+
await resource.init();
|
|
74
|
+
try {
|
|
75
|
+
return await fn(resource);
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
await resource.dispose();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Ensures a directory exists during the execution of a function and optionally cleans it up
|
|
83
|
+
* @param dirPath Path to the directory
|
|
84
|
+
* @param removeIfCreated Whether to remove the directory if it was created by this function
|
|
85
|
+
* @param fn Function to execute while directory is guaranteed to exist
|
|
86
|
+
*/
|
|
87
|
+
async function ensureDirectory(dirPath, removeIfCreated, fn) {
|
|
88
|
+
return using(new DirectoryManager(dirPath, removeIfCreated), async () => await fn());
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8CA,sBAUC;AAQD,0CAMC;AAtED,uCAAyB;AACzB,2CAA6B;AAS7B;;GAEG;AACH,MAAM,gBAAgB;IACZ,OAAO,CAAU;IACjB,IAAI,CAAS;IACb,eAAe,CAAU;IAEjC,YAAY,OAAe,EAAE,eAAwB;QACnD,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC;QACpB,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1C,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;gBACzB,MAAM,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;YACvD,CAAC;YACD,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;CACF;AAED;;;;GAIG;AACI,KAAK,UAAU,KAAK,CACzB,QAAuC,EACvC,EAA+B;IAE/B,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtB,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,QAAQ,CAAC,CAAC;IAC5B,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACI,KAAK,UAAU,eAAe,CACnC,OAAe,EACf,eAAwB,EACxB,EAAoB;IAEpB,OAAO,KAAK,CAAC,IAAI,gBAAgB,CAAC,OAAO,EAAE,eAAe,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QbraidError = void 0;
|
|
4
|
+
const DEFAULT_ERROR_MESSAGE = 'An unexpected error occurred while processing your qBraid command. ' +
|
|
5
|
+
'Please check your input and try again. If the problem persists, ' +
|
|
6
|
+
'visit https://github.com/qBraid/community/issues to file a bug report.';
|
|
7
|
+
class QbraidError extends Error {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message || DEFAULT_ERROR_MESSAGE);
|
|
10
|
+
this.name = 'QbraidError';
|
|
11
|
+
// Maintains proper stack trace for where error was thrown (only available on V8)
|
|
12
|
+
if (Error.captureStackTrace) {
|
|
13
|
+
Error.captureStackTrace(this, QbraidError);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.QbraidError = QbraidError;
|
|
18
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAM,qBAAqB,GACzB,qEAAqE;IACrE,kEAAkE;IAClE,wEAAwE,CAAC;AAE3E,MAAa,WAAY,SAAQ,KAAK;IACpC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,IAAI,qBAAqB,CAAC,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAE1B,iFAAiF;QACjF,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC;CACF;AAVD,kCAUC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module base
|
|
3
|
+
*/
|
|
4
|
+
export { ConfigLoader } from './config';
|
|
5
|
+
export { QbraidClient } from './client';
|
|
6
|
+
export { QbraidSession } from './session';
|
|
7
|
+
export { QbraidError } from './errors';
|
|
8
|
+
export type { Method } from 'axios';
|
|
9
|
+
export type { QbraidUser, DiskUsage } from './user';
|
|
10
|
+
export type { Config } from './config';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QbraidError = exports.QbraidSession = exports.QbraidClient = exports.ConfigLoader = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module base
|
|
6
|
+
*/
|
|
7
|
+
var config_1 = require("./config");
|
|
8
|
+
Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_1.ConfigLoader; } });
|
|
9
|
+
var client_1 = require("./client");
|
|
10
|
+
Object.defineProperty(exports, "QbraidClient", { enumerable: true, get: function () { return client_1.QbraidClient; } });
|
|
11
|
+
var session_1 = require("./session");
|
|
12
|
+
Object.defineProperty(exports, "QbraidSession", { enumerable: true, get: function () { return session_1.QbraidSession; } });
|
|
13
|
+
var errors_1 = require("./errors");
|
|
14
|
+
Object.defineProperty(exports, "QbraidError", { enumerable: true, get: function () { return errors_1.QbraidError; } });
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,mCAAuC;AAA9B,qGAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module for making requests to the qBraid API.
|
|
3
|
+
*/
|
|
4
|
+
import { AxiosRequestConfig, AxiosResponse, Method } from 'axios';
|
|
5
|
+
import type { Config } from './config';
|
|
6
|
+
export declare class QbraidSession {
|
|
7
|
+
private readonly config;
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(config: Config);
|
|
10
|
+
private createAxiosInstance;
|
|
11
|
+
private getUserAgent;
|
|
12
|
+
addUserAgent(userAgent: string): void;
|
|
13
|
+
private joinUrl;
|
|
14
|
+
request<T>(method: Method, url: string, config?: AxiosRequestConfig): Promise<AxiosResponse<T>>;
|
|
15
|
+
private getErrorMessage;
|
|
16
|
+
private maskSensitiveData;
|
|
17
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Module for making requests to the qBraid API.
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.QbraidSession = void 0;
|
|
10
|
+
const _version_1 = require("./_version");
|
|
11
|
+
const axios_1 = __importDefault(require("axios"));
|
|
12
|
+
const https_1 = require("https");
|
|
13
|
+
const url_1 = require("url");
|
|
14
|
+
const errors_1 = require("./errors");
|
|
15
|
+
class QbraidSession {
|
|
16
|
+
config;
|
|
17
|
+
client;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
this.client = this.createAxiosInstance();
|
|
21
|
+
}
|
|
22
|
+
createAxiosInstance() {
|
|
23
|
+
const headers = {
|
|
24
|
+
...this.config.headers,
|
|
25
|
+
...this.config.authHeaders,
|
|
26
|
+
'User-Agent': this.getUserAgent(),
|
|
27
|
+
};
|
|
28
|
+
return axios_1.default.create({
|
|
29
|
+
baseURL: this.config.baseURL,
|
|
30
|
+
headers,
|
|
31
|
+
httpsAgent: new https_1.Agent({ keepAlive: true }),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
getUserAgent() {
|
|
35
|
+
return `QbraidCoreJs/${_version_1.version}`;
|
|
36
|
+
}
|
|
37
|
+
addUserAgent(userAgent) {
|
|
38
|
+
const currentUserAgent = this.client.defaults.headers['User-Agent'];
|
|
39
|
+
if (!currentUserAgent.includes(userAgent)) {
|
|
40
|
+
this.client.defaults.headers['User-Agent'] = `${currentUserAgent} ${userAgent}`.trim();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
joinUrl(baseUrl, path) {
|
|
44
|
+
const base = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
45
|
+
const relativePath = path.startsWith('/') ? path.slice(1) : path;
|
|
46
|
+
return new url_1.URL(relativePath, base).toString();
|
|
47
|
+
}
|
|
48
|
+
async request(method, url, config = {}) {
|
|
49
|
+
const fullUrl = this.config.baseURL && !url.startsWith('http') ? this.joinUrl(this.config.baseURL, url) : url;
|
|
50
|
+
try {
|
|
51
|
+
return await this.client.request({ method, url: fullUrl, ...config });
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const message = this.maskSensitiveData(this.getErrorMessage(error));
|
|
55
|
+
throw new errors_1.QbraidError(message);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
getErrorMessage(error) {
|
|
59
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
60
|
+
return `AxiosError: ${error.message}`;
|
|
61
|
+
}
|
|
62
|
+
return error instanceof Error ? error.message : String(error);
|
|
63
|
+
}
|
|
64
|
+
maskSensitiveData(message) {
|
|
65
|
+
return Object.values(this.config.authHeaders).reduce((maskedMessage, value) => maskedMessage.replace(value, '...'), message);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.QbraidSession = QbraidSession;
|
|
69
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/session.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;AAEH,yCAAqC;AACrC,kDAAwF;AACxF,iCAA8B;AAE9B,6BAA0B;AAC1B,qCAAuC;AAEvC,MAAa,aAAa;IAGK;IAFZ,MAAM,CAAgB;IAEvC,YAA6B,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QACzC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3C,CAAC;IAEO,mBAAmB;QACzB,MAAM,OAAO,GAAG;YACd,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO;YACtB,GAAG,IAAI,CAAC,MAAM,CAAC,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AAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;QAEhG,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAI,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QAC3E,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,OAAO,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;YACpE,MAAM,IAAI,oBAAW,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,KAAc;QACpC,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,eAAe,KAAK,CAAC,OAAO,EAAE,CAAC;QACxC,CAAC;QACD,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;IAEO,iBAAiB,CAAC,OAAe;QACvC,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,MAAM,CAClD,CAAC,aAAa,EAAE,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,EAC7D,OAAO,CACR,CAAC;IACJ,CAAC;CACF;AAnED,sCAmEC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface DiskUsage {
|
|
2
|
+
totalGB: number;
|
|
3
|
+
quotaGB: number;
|
|
4
|
+
timestamp: Date;
|
|
5
|
+
}
|
|
6
|
+
export interface QbraidUser {
|
|
7
|
+
_id: string;
|
|
8
|
+
email: string;
|
|
9
|
+
userName: string;
|
|
10
|
+
role: string;
|
|
11
|
+
permissionsNodes: string[];
|
|
12
|
+
diskUsage: DiskUsage;
|
|
13
|
+
metadata: Record<string, unknown>;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
package/dist/src/user.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/user.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qbraid-core/base",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "dist/src/index.js",
|
|
5
|
+
"types": "dist/src/index.d.ts",
|
|
6
|
+
"description": "Core functionality for interacting with qBraid Cloud Services.",
|
|
7
|
+
"author": "qBraid Development Team",
|
|
8
|
+
"license": "Proprietary",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/src"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"qbraid",
|
|
14
|
+
"qbraid-core",
|
|
15
|
+
"qbraid-core-js",
|
|
16
|
+
"qbraid base",
|
|
17
|
+
"qbraid cloud",
|
|
18
|
+
"qbraid api",
|
|
19
|
+
"qbraid apis",
|
|
20
|
+
"cloud",
|
|
21
|
+
"quantum",
|
|
22
|
+
"quantum computing"
|
|
23
|
+
],
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"directory": "packages/base",
|
|
27
|
+
"url": "git+https://github.com/qBraid/qbraid-core-js.git"
|
|
28
|
+
},
|
|
29
|
+
"homepage": "https://qbraid.github.io/qbraid-core-js/modules/base.html",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"axios": "^1.7.9",
|
|
32
|
+
"ini": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/ini": "^4.1.1"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"clean": "rimraf dist && rm -f tsconfig.tsbuildinfo && rimraf src/_version.ts",
|
|
39
|
+
"lint": "eslint src",
|
|
40
|
+
"lint:fix": "eslint src --fix",
|
|
41
|
+
"format": "prettier --write \"src/**/*.{ts,json}\"",
|
|
42
|
+
"format:check": "prettier --check \"src/**/*.{ts,json}\"",
|
|
43
|
+
"docs": "typedoc"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=20"
|
|
47
|
+
}
|
|
48
|
+
}
|