@epochcore/qaas-sdk 1.0.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/index.mjs ADDED
@@ -0,0 +1,198 @@
1
+ // src/index.ts
2
+ var QaaSClient = class {
3
+ constructor(config = {}) {
4
+ this.baseUrl = config.baseUrl || "https://api.qaas.epochcoreqcs.com";
5
+ this.apiKey = config.apiKey;
6
+ this.timeout = config.timeout || 3e4;
7
+ }
8
+ async request(path, options = {}) {
9
+ const headers = {
10
+ "Content-Type": "application/json",
11
+ ...options.headers || {}
12
+ };
13
+ if (this.apiKey) {
14
+ headers["X-API-Key"] = this.apiKey;
15
+ }
16
+ const controller = new AbortController();
17
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
18
+ try {
19
+ const response = await fetch(`${this.baseUrl}${path}`, {
20
+ ...options,
21
+ headers,
22
+ signal: controller.signal
23
+ });
24
+ if (!response.ok) {
25
+ const error = await response.json().catch(() => ({ error: "Unknown error" }));
26
+ throw new QaaSError(
27
+ error.error || `Request failed with status ${response.status}`,
28
+ response.status,
29
+ error
30
+ );
31
+ }
32
+ return await response.json();
33
+ } finally {
34
+ clearTimeout(timeoutId);
35
+ }
36
+ }
37
+ /**
38
+ * Check API health and status
39
+ */
40
+ async health() {
41
+ return this.request("/health");
42
+ }
43
+ /**
44
+ * Get pricing information for all tiers
45
+ */
46
+ async getPricing() {
47
+ return this.request("/api/pricing");
48
+ }
49
+ /**
50
+ * Get available algorithms for your tier
51
+ */
52
+ async getAlgorithms() {
53
+ return this.request("/api/quantum/algorithms");
54
+ }
55
+ /**
56
+ * Get algorithms filtered by category
57
+ */
58
+ async getAlgorithmsByCategory(category) {
59
+ const response = await this.getAlgorithms();
60
+ return response.algorithms.filter((algo) => algo.category === category);
61
+ }
62
+ /**
63
+ * Run a quantum algorithm
64
+ */
65
+ async runAlgorithm(request) {
66
+ return this.request("/api/quantum/run", {
67
+ method: "POST",
68
+ body: JSON.stringify(request)
69
+ });
70
+ }
71
+ /**
72
+ * Get current usage statistics
73
+ */
74
+ async getUsage() {
75
+ return this.request("/api/quantum/usage");
76
+ }
77
+ // ==========================================
78
+ // Convenience methods for common algorithms
79
+ // ==========================================
80
+ /**
81
+ * Run Markowitz portfolio optimization (QAOA)
82
+ */
83
+ async optimizePortfolio(params) {
84
+ return this.runAlgorithm({
85
+ algorithm_id: "QAOA_PORT_001",
86
+ parameters: {
87
+ assets: params.assets,
88
+ returns: params.returns,
89
+ covariance: params.covariance,
90
+ risk_tolerance: params.risk_tolerance ?? 0.5
91
+ },
92
+ backend: params.backend || "simulator"
93
+ });
94
+ }
95
+ /**
96
+ * Run Value at Risk (VaR) estimation
97
+ */
98
+ async estimateVaR(params) {
99
+ return this.runAlgorithm({
100
+ algorithm_id: "AE_PROB_004",
101
+ parameters: {
102
+ portfolio_value: params.portfolio_value,
103
+ returns_history: params.returns_history,
104
+ confidence_level: params.confidence_level ?? 0.95
105
+ },
106
+ backend: params.backend || "simulator"
107
+ });
108
+ }
109
+ /**
110
+ * Run Grover search for arbitrage opportunities
111
+ */
112
+ async findArbitrage(params) {
113
+ return this.runAlgorithm({
114
+ algorithm_id: "GROVER_BOOL_003",
115
+ parameters: {
116
+ price_matrix: params.price_matrix,
117
+ threshold: params.threshold ?? 1e-3
118
+ },
119
+ backend: params.backend || "simulator"
120
+ });
121
+ }
122
+ /**
123
+ * Solve a QUBO problem
124
+ */
125
+ async solveQUBO(params) {
126
+ return this.runAlgorithm({
127
+ algorithm_id: "QAOA_QUBO_001",
128
+ parameters: {
129
+ Q: params.Q_matrix,
130
+ num_reads: params.num_reads ?? 1e3
131
+ },
132
+ backend: params.backend || "simulator"
133
+ });
134
+ }
135
+ /**
136
+ * Run Monte Carlo amplitude estimation
137
+ */
138
+ async monteCarloEstimate(params) {
139
+ return this.runAlgorithm({
140
+ algorithm_id: "AE_PROB_002",
141
+ parameters: {
142
+ target_function: params.target_function,
143
+ num_samples: params.num_samples ?? 1e4,
144
+ epsilon: params.epsilon ?? 0.01
145
+ },
146
+ backend: params.backend || "simulator"
147
+ });
148
+ }
149
+ };
150
+ var QaaSError = class extends Error {
151
+ constructor(message, statusCode, response) {
152
+ super(message);
153
+ this.statusCode = statusCode;
154
+ this.response = response;
155
+ this.name = "QaaSError";
156
+ }
157
+ };
158
+ var qaas = new QaaSClient();
159
+ var ALGORITHMS = {
160
+ // Amplitude Estimation
161
+ AMPLITUDE_ESTIMATION: {
162
+ PROB_001: "AE_PROB_001",
163
+ PROB_002: "AE_PROB_002",
164
+ PROB_003: "AE_PROB_003",
165
+ VAR: "AE_PROB_004",
166
+ CVAR: "AE_PROB_005"
167
+ },
168
+ // Grover Search
169
+ GROVER: {
170
+ BOOLEAN_SAT: "GROVER_BOOL_001",
171
+ PORTFOLIO_CONSTRAINT: "GROVER_BOOL_002",
172
+ ARBITRAGE: "GROVER_BOOL_003",
173
+ COMPLIANCE: "GROVER_BOOL_004",
174
+ PATTERN: "GROVER_BOOL_005"
175
+ },
176
+ // QAOA Portfolio
177
+ QAOA_PORTFOLIO: {
178
+ MARKOWITZ: "QAOA_PORT_001",
179
+ RISK_PARITY: "QAOA_PORT_002",
180
+ MAX_SHARPE: "QAOA_PORT_003",
181
+ MIN_VARIANCE: "QAOA_PORT_004",
182
+ BLACK_LITTERMAN: "QAOA_PORT_005"
183
+ },
184
+ // QUBO
185
+ QUBO: {
186
+ GENERAL: "QAOA_QUBO_001",
187
+ MAX_CUT: "QAOA_QUBO_002",
188
+ GRAPH_COLORING: "QAOA_QUBO_003",
189
+ TSP: "QAOA_QUBO_004",
190
+ KNAPSACK: "QAOA_QUBO_005"
191
+ }
192
+ };
193
+ export {
194
+ ALGORITHMS,
195
+ QaaSClient,
196
+ QaaSError,
197
+ qaas
198
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@epochcore/qaas-sdk",
3
+ "version": "1.0.0",
4
+ "description": "Official SDK for EpochCore Quantum as a Service (QaaS) API - Access 100 quantum computing algorithms",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
17
+ "dev": "tsup src/index.ts --format cjs,esm --dts --watch",
18
+ "test": "vitest run",
19
+ "lint": "eslint src/",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md"
25
+ ],
26
+ "keywords": [
27
+ "quantum",
28
+ "quantum-computing",
29
+ "qiskit",
30
+ "cirq",
31
+ "pennylane",
32
+ "qaoa",
33
+ "grover",
34
+ "amplitude-estimation",
35
+ "fintech",
36
+ "portfolio-optimization",
37
+ "epochcore",
38
+ "qaas"
39
+ ],
40
+ "author": "EpochCore <CEO.QuantumAmazon@EpochCoreQcs.com>",
41
+ "license": "SEE LICENSE IN LICENSE",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "https://github.com/Jvryan92/qaas-sdk"
45
+ },
46
+ "bugs": {
47
+ "url": "https://github.com/Jvryan92/qaas-sdk/issues"
48
+ },
49
+ "homepage": "https://epochcoreqcs.com",
50
+ "devDependencies": {
51
+ "@types/node": "^20.0.0",
52
+ "tsup": "^8.0.0",
53
+ "typescript": "^5.0.0",
54
+ "vitest": "^1.0.0"
55
+ },
56
+ "engines": {
57
+ "node": ">=18.0.0"
58
+ }
59
+ }