flowscale 2.0.0 → 2.1.0-beta.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.d.ts CHANGED
@@ -122,3 +122,5 @@ export declare class FlowscaleAPI {
122
122
  };
123
123
  }
124
124
  export * from './types';
125
+ export { FlowscalePlatformAPI } from './platform';
126
+ export * from './platform-types';
package/dist/index.js CHANGED
@@ -73,7 +73,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
73
73
  return (mod && mod.__esModule) ? mod : { "default": mod };
74
74
  };
75
75
  Object.defineProperty(exports, "__esModule", { value: true });
76
- exports.FlowscaleAPI = void 0;
76
+ exports.FlowscalePlatformAPI = exports.FlowscaleAPI = void 0;
77
77
  var axios_1 = __importDefault(require("axios"));
78
78
  var FlowscaleAPI = /** @class */ (function () {
79
79
  function FlowscaleAPI(config) {
@@ -1294,3 +1294,7 @@ if (typeof window !== 'undefined') {
1294
1294
  }
1295
1295
  // Export all types for TypeScript consumers
1296
1296
  __exportStar(require("./types"), exports);
1297
+ // Platform API — JWT-based control of the full Flowscale platform
1298
+ var platform_1 = require("./platform");
1299
+ Object.defineProperty(exports, "FlowscalePlatformAPI", { enumerable: true, get: function () { return platform_1.FlowscalePlatformAPI; } });
1300
+ __exportStar(require("./platform-types"), exports);
@@ -0,0 +1,156 @@
1
+ export interface FlowscalePlatformConfig {
2
+ /** Flowscale JWT access token (from OAuth or login) */
3
+ token: string;
4
+ /** Team UUID — required for all team-scoped endpoints */
5
+ teamId: string;
6
+ /** Platform API base URL. Defaults to https://api.flowscale.ai */
7
+ baseUrl?: string;
8
+ /** Request timeout in ms. Default: 30000 */
9
+ timeout?: number;
10
+ }
11
+ export interface PlatformResponse<T = unknown> {
12
+ status: string;
13
+ data: T;
14
+ errors?: string;
15
+ }
16
+ export interface ProjectWorkflow {
17
+ id: string;
18
+ name: string;
19
+ description: string;
20
+ inputs: string;
21
+ outputs: string;
22
+ }
23
+ export interface Project {
24
+ _id: string;
25
+ name: string;
26
+ description?: string;
27
+ team_id: string;
28
+ cluster_url?: string;
29
+ api_key?: string;
30
+ status?: string;
31
+ created_at: string;
32
+ updated_at?: string;
33
+ }
34
+ export interface CreateProjectRequest {
35
+ name: string;
36
+ description?: string;
37
+ comfyui_version?: string;
38
+ [key: string]: unknown;
39
+ }
40
+ export interface UpdateProjectRequest {
41
+ name?: string;
42
+ description?: string;
43
+ [key: string]: unknown;
44
+ }
45
+ export interface ProjectApiKeyRequest {
46
+ name: string;
47
+ scopes?: string[];
48
+ }
49
+ export interface ProjectContentItem {
50
+ id: string;
51
+ name: string;
52
+ type: 'file' | 'folder';
53
+ path?: string;
54
+ size?: number;
55
+ created_at?: string;
56
+ }
57
+ export interface Pod {
58
+ _id: string;
59
+ name: string;
60
+ team_id: string;
61
+ project_id?: string;
62
+ status?: string;
63
+ gpu_type?: string;
64
+ budget?: number;
65
+ created_at: string;
66
+ }
67
+ export interface CreatePodRequest {
68
+ name: string;
69
+ project_id?: string;
70
+ gpu_type?: string;
71
+ budget?: number;
72
+ [key: string]: unknown;
73
+ }
74
+ export interface UpdatePodRequest {
75
+ name?: string;
76
+ budget?: number;
77
+ [key: string]: unknown;
78
+ }
79
+ export interface Cluster {
80
+ _id: string;
81
+ pod_id: string;
82
+ project_id?: string;
83
+ status: string;
84
+ created_at: string;
85
+ started_at?: string;
86
+ stopped_at?: string;
87
+ }
88
+ export interface StartClusterRequest {
89
+ pod_id: string;
90
+ project_id?: string;
91
+ [key: string]: unknown;
92
+ }
93
+ export interface ClusterLogEntry {
94
+ timestamp: string;
95
+ message: string;
96
+ level?: string;
97
+ }
98
+ export interface ClusterAnalytics {
99
+ [key: string]: unknown;
100
+ }
101
+ export interface PlatformRun {
102
+ _id: string;
103
+ team_id: string;
104
+ project_id?: string;
105
+ workflow_id?: string;
106
+ status: string;
107
+ created_at: string;
108
+ completed_at?: string;
109
+ }
110
+ export interface CreatePlatformRunRequest {
111
+ workflow_id: string;
112
+ inputs?: Record<string, unknown>;
113
+ [key: string]: unknown;
114
+ }
115
+ export interface TeamApiKey {
116
+ _id: string;
117
+ name: string;
118
+ key_preview: string;
119
+ scopes?: string[];
120
+ created_at: string;
121
+ }
122
+ export interface CreateTeamApiKeyRequest {
123
+ name: string;
124
+ scopes?: string[];
125
+ }
126
+ export interface InviteLink {
127
+ _id: string;
128
+ token: string;
129
+ url: string;
130
+ role?: string;
131
+ expires_at?: string;
132
+ created_at: string;
133
+ }
134
+ export interface CreateInviteLinkRequest {
135
+ role?: string;
136
+ expires_in_hours?: number;
137
+ }
138
+ export interface AnalyticsOverview {
139
+ total_runs: number;
140
+ total_api_calls: number;
141
+ credits_used: number;
142
+ [key: string]: unknown;
143
+ }
144
+ export interface RunsAnalytics {
145
+ [key: string]: unknown;
146
+ }
147
+ export interface ApiCallsAnalytics {
148
+ [key: string]: unknown;
149
+ }
150
+ export interface UserProfile {
151
+ username: string;
152
+ email: string;
153
+ avatar?: string;
154
+ is_active: boolean;
155
+ created_at: string;
156
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ // ============================================================
3
+ // Platform API — configuration
4
+ // ============================================================
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,29 @@
1
+ import { FlowscaleAPI } from './index';
2
+ import type { FlowscalePlatformConfig } from './platform-types';
3
+ export declare class FlowscalePlatformAPI {
4
+ private client;
5
+ private teamId;
6
+ readonly projects: ReturnType<FlowscalePlatformAPI['buildProjects']>;
7
+ readonly pods: ReturnType<FlowscalePlatformAPI['buildPods']>;
8
+ readonly clusters: ReturnType<FlowscalePlatformAPI['buildClusters']>;
9
+ readonly runs: ReturnType<FlowscalePlatformAPI['buildRuns']>;
10
+ readonly team: ReturnType<FlowscalePlatformAPI['buildTeam']>;
11
+ readonly analytics: ReturnType<FlowscalePlatformAPI['buildAnalytics']>;
12
+ readonly auth: ReturnType<FlowscalePlatformAPI['buildAuth']>;
13
+ constructor(config: FlowscalePlatformConfig);
14
+ /**
15
+ * Create a deployment-level FlowscaleAPI client for a specific project cluster.
16
+ * @param clusterUrl The cluster base URL from the project (e.g. https://cluster-xyz.flowscale.ai)
17
+ * @param apiKey A project-scoped API key from project.addApiKey()
18
+ */
19
+ getDeploymentClient(clusterUrl: string, apiKey: string): FlowscaleAPI;
20
+ private request;
21
+ private buildProjects;
22
+ private buildPods;
23
+ private buildClusters;
24
+ private buildRuns;
25
+ private buildTeam;
26
+ private buildAnalytics;
27
+ private buildAuth;
28
+ }
29
+ export * from './platform-types';
@@ -0,0 +1,380 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ var __importDefault = (this && this.__importDefault) || function (mod) {
53
+ return (mod && mod.__esModule) ? mod : { "default": mod };
54
+ };
55
+ Object.defineProperty(exports, "__esModule", { value: true });
56
+ exports.FlowscalePlatformAPI = void 0;
57
+ var axios_1 = __importDefault(require("axios"));
58
+ var index_1 = require("./index");
59
+ var DEFAULT_BASE_URL = 'https://api.flowscale.ai';
60
+ var FlowscalePlatformAPI = /** @class */ (function () {
61
+ function FlowscalePlatformAPI(config) {
62
+ var _this = this;
63
+ var _a, _b;
64
+ if (!config.token)
65
+ throw new Error('FlowscalePlatformAPI: token is required');
66
+ if (!config.teamId)
67
+ throw new Error('FlowscalePlatformAPI: teamId is required');
68
+ this.teamId = config.teamId;
69
+ this.client = axios_1.default.create({
70
+ baseURL: ((_a = config.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL).trimEnd().replace(/\/$/, ''),
71
+ timeout: (_b = config.timeout) !== null && _b !== void 0 ? _b : 30000,
72
+ });
73
+ this.client.interceptors.request.use(function (req) {
74
+ if (!req.headers)
75
+ req.headers = {};
76
+ req.headers['Authorization'] = "Bearer ".concat(config.token);
77
+ req.headers['X-Team'] = _this.teamId;
78
+ return req;
79
+ });
80
+ this.projects = this.buildProjects();
81
+ this.pods = this.buildPods();
82
+ this.clusters = this.buildClusters();
83
+ this.runs = this.buildRuns();
84
+ this.team = this.buildTeam();
85
+ this.analytics = this.buildAnalytics();
86
+ this.auth = this.buildAuth();
87
+ }
88
+ // ── Bridge to deployment client ─────────────────────────
89
+ /**
90
+ * Create a deployment-level FlowscaleAPI client for a specific project cluster.
91
+ * @param clusterUrl The cluster base URL from the project (e.g. https://cluster-xyz.flowscale.ai)
92
+ * @param apiKey A project-scoped API key from project.addApiKey()
93
+ */
94
+ FlowscalePlatformAPI.prototype.getDeploymentClient = function (clusterUrl, apiKey) {
95
+ return new index_1.FlowscaleAPI({ baseUrl: clusterUrl, apiKey: apiKey });
96
+ };
97
+ // ── Helper ───────────────────────────────────────────────
98
+ FlowscalePlatformAPI.prototype.request = function (method, path, data, params) {
99
+ return __awaiter(this, void 0, void 0, function () {
100
+ var response;
101
+ return __generator(this, function (_a) {
102
+ switch (_a.label) {
103
+ case 0: return [4 /*yield*/, this.client.request({ method: method, url: path, data: data, params: params })];
104
+ case 1:
105
+ response = _a.sent();
106
+ return [2 /*return*/, response.data];
107
+ }
108
+ });
109
+ });
110
+ };
111
+ // ── Projects ─────────────────────────────────────────────
112
+ FlowscalePlatformAPI.prototype.buildProjects = function () {
113
+ var req = this.request.bind(this);
114
+ return {
115
+ /** List all projects for the team. */
116
+ list: function () {
117
+ return req('get', '/api/v2/project');
118
+ },
119
+ /** Get a single project by ID. */
120
+ get: function (projectId) {
121
+ return req('get', "/api/v2/project/".concat(enc(projectId)));
122
+ },
123
+ /** Get a public project (no auth required — skips team header). */
124
+ getPublic: function (projectId) {
125
+ return req('get', "/api/v2/project/public/".concat(enc(projectId)));
126
+ },
127
+ /** Create a new project. */
128
+ create: function (data) {
129
+ return req('post', '/api/v2/project', data);
130
+ },
131
+ /** Update a project. */
132
+ update: function (projectId, data) {
133
+ return req('put', "/api/v2/project/".concat(enc(projectId)), data);
134
+ },
135
+ /** Delete a project. */
136
+ delete: function (projectId) {
137
+ return req('delete', "/api/v2/project/".concat(enc(projectId)));
138
+ },
139
+ /** Fork a project into the current team. */
140
+ fork: function (projectId) {
141
+ return req('post', "/api/v2/project/".concat(enc(projectId), "/fork"));
142
+ },
143
+ /** List workflows for a project. */
144
+ listWorkflows: function (projectId) {
145
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/workflows"));
146
+ },
147
+ /** Get a single workflow. */
148
+ getWorkflow: function (projectId, workflowId) {
149
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/workflows/").concat(enc(workflowId)));
150
+ },
151
+ /** Add a project-scoped API key (use with getDeploymentClient). */
152
+ addApiKey: function (projectId, data) {
153
+ return req('post', "/api/v2/project/".concat(enc(projectId), "/api_key"), data);
154
+ },
155
+ /** Delete a project-scoped API key. */
156
+ deleteApiKey: function (projectId, data) {
157
+ return req('delete', "/api/v2/project/".concat(enc(projectId), "/api_key"), data);
158
+ },
159
+ /** List files and folders in a project. */
160
+ getContents: function (projectId) {
161
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/contents"));
162
+ },
163
+ /** Create a folder inside a project. */
164
+ createFolder: function (projectId, data) {
165
+ return req('post', "/api/v2/project/".concat(enc(projectId), "/contents/folder"), data);
166
+ },
167
+ /** Download a file (returns download URL or content). */
168
+ downloadFile: function (projectId, fileId) {
169
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/contents/file/").concat(enc(fileId), "/download"));
170
+ },
171
+ /** Delete a file from a project. */
172
+ deleteFile: function (projectId, fileId) {
173
+ return req('delete', "/api/v2/project/".concat(enc(projectId), "/contents/file/").concat(enc(fileId)));
174
+ },
175
+ /** Delete a folder from a project. */
176
+ deleteFolder: function (projectId, folderId) {
177
+ return req('delete', "/api/v2/project/".concat(enc(projectId), "/contents/folder/").concat(enc(folderId)));
178
+ },
179
+ /** Get ComfyUI compute balance for a project. */
180
+ getComfyBalance: function (projectId) {
181
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/comfy/balance"));
182
+ },
183
+ /** Get storage usage analytics for a project. */
184
+ getStorageAnalytics: function (projectId) {
185
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/storage-analytics"));
186
+ },
187
+ /** Get clusters deployed for a specific project. */
188
+ getDeployedClusters: function (projectId) {
189
+ return req('get', "/api/v2/project/".concat(enc(projectId), "/clusters/deployed"));
190
+ },
191
+ };
192
+ };
193
+ // ── Pods ─────────────────────────────────────────────────
194
+ FlowscalePlatformAPI.prototype.buildPods = function () {
195
+ var req = this.request.bind(this);
196
+ return {
197
+ /** List available GPU types. */
198
+ listGpus: function () {
199
+ return req('get', '/api/v2/pod/gpus');
200
+ },
201
+ /** List all pods for the team. */
202
+ list: function () {
203
+ return req('get', '/api/v2/pod');
204
+ },
205
+ /** Get a pod by ID. */
206
+ get: function (podId) {
207
+ return req('get', "/api/v2/pod/".concat(enc(podId)));
208
+ },
209
+ /** Create a new pod. */
210
+ create: function (data) {
211
+ return req('post', '/api/v2/pod', data);
212
+ },
213
+ /** Update pod settings. */
214
+ update: function (podId, data) {
215
+ return req('put', "/api/v2/pod/".concat(enc(podId)), data);
216
+ },
217
+ /** Update pod budget. */
218
+ updateBudget: function (podId, budget) {
219
+ return req('patch', "/api/v2/pod/".concat(enc(podId), "/budget"), { budget: budget });
220
+ },
221
+ /** Stop all running clusters for a pod. */
222
+ stop: function (podId) {
223
+ return req('post', "/api/v2/pod/".concat(enc(podId), "/stop"));
224
+ },
225
+ /** Delete a pod. */
226
+ delete: function (podId) {
227
+ return req('delete', "/api/v2/pod/".concat(enc(podId)));
228
+ },
229
+ /** List workflows attached to a pod. */
230
+ listWorkflows: function (podId) {
231
+ return req('get', "/api/v2/pod/".concat(enc(podId), "/workflows"));
232
+ },
233
+ /** List all clusters for a pod. */
234
+ listClusters: function (podId) {
235
+ return req('get', "/api/v2/pod/".concat(enc(podId), "/clusters"));
236
+ },
237
+ /** Get the currently active cluster for a pod. */
238
+ getActiveCluster: function (podId) {
239
+ return req('get', "/api/v2/pod/".concat(enc(podId), "/cluster/active"));
240
+ },
241
+ };
242
+ };
243
+ // ── Clusters ─────────────────────────────────────────────
244
+ FlowscalePlatformAPI.prototype.buildClusters = function () {
245
+ var req = this.request.bind(this);
246
+ return {
247
+ /** List all clusters for the team. */
248
+ list: function () {
249
+ return req('get', '/api/v2/cluster');
250
+ },
251
+ /** Get a cluster by ID. */
252
+ get: function (clusterId) {
253
+ return req('get', "/api/v2/cluster/".concat(enc(clusterId)));
254
+ },
255
+ /** Start (deploy) a new cluster. */
256
+ start: function (data) {
257
+ return req('post', '/api/v2/cluster', data);
258
+ },
259
+ /** Stop a running cluster. */
260
+ stop: function (clusterId) {
261
+ return req('post', "/api/v2/cluster/".concat(enc(clusterId), "/stop"));
262
+ },
263
+ /** Get logs for a cluster. */
264
+ getLogs: function (clusterId) {
265
+ return req('get', "/api/v2/cluster/".concat(enc(clusterId), "/logs"));
266
+ },
267
+ /** Get usage analytics for a cluster. */
268
+ getAnalytics: function (clusterId) {
269
+ return req('get', "/api/v2/cluster/".concat(enc(clusterId), "/analytics"));
270
+ },
271
+ /** Analyze init logs with AI. */
272
+ analyzeInitLogs: function (clusterId) {
273
+ return req('post', "/api/v2/cluster/".concat(enc(clusterId), "/analyze-init-logs"));
274
+ },
275
+ /** Get temp nodes for a cluster. */
276
+ getTempNodes: function (clusterId) {
277
+ return req('get', "/api/v2/cluster/".concat(enc(clusterId), "/tempnodes"));
278
+ },
279
+ };
280
+ };
281
+ // ── Runs (platform-level) ─────────────────────────────────
282
+ FlowscalePlatformAPI.prototype.buildRuns = function () {
283
+ var req = this.request.bind(this);
284
+ return {
285
+ /** List all runs for the team. */
286
+ list: function (params) {
287
+ return req('get', '/api/v2/run', undefined, params);
288
+ },
289
+ /** Create a new run. */
290
+ create: function (data) {
291
+ return req('post', '/api/v2/run', data);
292
+ },
293
+ /** Delete a single run. */
294
+ delete: function (runId) {
295
+ return req('delete', "/api/v2/run/".concat(enc(runId)));
296
+ },
297
+ /** List output filenames for recent runs. */
298
+ listOutputs: function () {
299
+ return req('get', '/api/v2/run/outputs/list');
300
+ },
301
+ };
302
+ };
303
+ // ── Team ─────────────────────────────────────────────────
304
+ FlowscalePlatformAPI.prototype.buildTeam = function () {
305
+ var req = this.request.bind(this);
306
+ return {
307
+ /** List team-level API keys. */
308
+ listApiKeys: function () {
309
+ return req('get', '/api/v2/team/api-keys');
310
+ },
311
+ /** Create a new team-level API key. */
312
+ createApiKey: function (data) {
313
+ return req('post', '/api/v2/team/api-keys', data);
314
+ },
315
+ /** Revoke a team-level API key. */
316
+ revokeApiKey: function (keyId) {
317
+ return req('delete', "/api/v2/team/api-keys/".concat(enc(keyId)));
318
+ },
319
+ /** List active invite links. */
320
+ listInviteLinks: function () {
321
+ return req('get', '/api/v2/team/invite-links');
322
+ },
323
+ /** Create a new invite link. */
324
+ createInviteLink: function (data) {
325
+ return req('post', '/api/v2/team/invite-link', data);
326
+ },
327
+ /** Delete an invite link. */
328
+ deleteInviteLink: function (linkId) {
329
+ return req('delete', "/api/v2/team/invite-link/".concat(enc(linkId)));
330
+ },
331
+ };
332
+ };
333
+ // ── Analytics ────────────────────────────────────────────
334
+ FlowscalePlatformAPI.prototype.buildAnalytics = function () {
335
+ var req = this.request.bind(this);
336
+ return {
337
+ /** Get all analytics for the team. */
338
+ get: function (params) {
339
+ return req('get', '/api/v2/analytics', undefined, params);
340
+ },
341
+ /** Get high-level overview metrics. */
342
+ getOverview: function () {
343
+ return req('get', '/api/v2/analytics/overview');
344
+ },
345
+ /** Get run-specific analytics. */
346
+ getRuns: function (params) {
347
+ return req('get', '/api/v2/analytics/runs', undefined, params);
348
+ },
349
+ /** Get API call analytics. */
350
+ getApiCalls: function (params) {
351
+ return req('get', '/api/v2/analytics/api-calls', undefined, params);
352
+ },
353
+ };
354
+ };
355
+ // ── Auth ─────────────────────────────────────────────────
356
+ FlowscalePlatformAPI.prototype.buildAuth = function () {
357
+ var req = this.request.bind(this);
358
+ return {
359
+ /** Get the current user's profile. */
360
+ getProfile: function () {
361
+ return req('get', '/api/v2/auth/profile');
362
+ },
363
+ /** Refresh the access token using the refresh token. */
364
+ refreshToken: function (refreshToken) {
365
+ return req('post', '/api/v2/auth/refresh', { refresh_token: refreshToken });
366
+ },
367
+ /** Logout (invalidate current token). */
368
+ logout: function () {
369
+ return req('post', '/api/v2/auth/logout');
370
+ },
371
+ };
372
+ };
373
+ return FlowscalePlatformAPI;
374
+ }());
375
+ exports.FlowscalePlatformAPI = FlowscalePlatformAPI;
376
+ // ── Utility ───────────────────────────────────────────────
377
+ function enc(value) {
378
+ return encodeURIComponent(value);
379
+ }
380
+ __exportStar(require("./platform-types"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowscale",
3
- "version": "2.0.0",
3
+ "version": "2.1.0-beta.0",
4
4
  "description": "An NPM library for communicating with the Flowscale APIs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",