flowscale 1.0.15 → 1.0.16

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 CHANGED
@@ -11,14 +11,14 @@ When using this SDK in a browser environment, your API key will be exposed to en
11
11
  1. Using this SDK in a Node.js backend environment
12
12
  2. Creating a proxy API that securely handles the API key server-side
13
13
 
14
- If you understand the risks and still need to use the SDK directly in the browser, you must explicitly acknowledge this by setting the `allowDangerouslyExposeApiKey` parameter:
14
+ If you understand the risks and still need to use the SDK directly in the browser, you must explicitly acknowledge this by setting the `allowDangerouslyExposeApiKey` option:
15
15
 
16
16
  ```javascript
17
- const flowscale = new FlowscaleAPI(
18
- apiKey,
19
- apiUrl,
20
- true // allowDangerouslyExposeApiKey - Only set to true if you understand the security risks
21
- );
17
+ const flowscale = new FlowscaleAPI({
18
+ apiKey: 'your-api-key',
19
+ baseUrl: 'your-api-url',
20
+ allowDangerouslyExposeApiKey: false // Only set to true if you understand the security risks
21
+ });
22
22
  ```
23
23
 
24
24
  ---
@@ -51,14 +51,18 @@ import { FlowscaleAPI } from 'flowscale';
51
51
  // Node.js Environment (Recommended)
52
52
  const apiKey = process.env.FLOWSCALE_API_KEY;
53
53
  const apiUrl = process.env.FLOWSCALE_API_URL;
54
- const flowscale = new FlowscaleAPI(apiKey, apiUrl);
54
+
55
+ const flowscale = new FlowscaleAPI({
56
+ apiKey,
57
+ baseUrl: apiUrl
58
+ });
55
59
 
56
60
  // Browser Environment (Not Recommended)
57
- const flowscale = new FlowscaleAPI(
58
- 'your-api-key', // ⚠️ WARNING: This will be exposed to users
59
- 'https://your-api-url.pod.flowscale.ai',
60
- true // Explicitly acknowledge the security risk
61
- );
61
+ const flowscale = new FlowscaleAPI({
62
+ apiKey: 'your-api-key', // ⚠️ WARNING: This will be exposed to users
63
+ baseUrl: 'https://your-api-url.pod.flowscale.ai',
64
+ allowDangerouslyExposeApiKey: true // Explicitly acknowledge the security risk
65
+ });
62
66
  ```
63
67
 
64
68
  ### Environment-Specific Considerations
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { HealthCheckResponse, QueueResponse, ExecuteWorkflowResponse, GetOutputResponse, RunDetailResponse, RunListResponse, CancelRunResponse } from './types';
1
+ import { HealthCheckResponse, QueueResponse, ExecuteWorkflowResponse, GetOutputResponse, RunDetailResponse, RunListResponse, CancelRunResponse, FlowscaleConfig } from './types';
2
2
  export declare class FlowscaleAPI {
3
3
  private apiKey;
4
4
  private baseUrl;
5
5
  private client;
6
6
  private isNode;
7
- constructor(apiKey: string, baseUrl: string, allowDangerouslyExposeApiKey?: boolean);
7
+ constructor(config: FlowscaleConfig);
8
8
  /**
9
9
  * Checks the health status of all ComfyUI instances within the specified cluster.
10
10
  */
package/dist/index.js CHANGED
@@ -42,22 +42,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
42
  exports.FlowscaleAPI = void 0;
43
43
  var axios_1 = __importDefault(require("axios"));
44
44
  var FlowscaleAPI = /** @class */ (function () {
45
- function FlowscaleAPI(apiKey, baseUrl, allowDangerouslyExposeApiKey) {
46
- if (allowDangerouslyExposeApiKey === void 0) { allowDangerouslyExposeApiKey = false; }
45
+ function FlowscaleAPI(config) {
47
46
  var _this = this;
48
47
  // Check if we're in a Node.js environment
49
48
  this.isNode = typeof process !== 'undefined' &&
50
49
  process.versions != null &&
51
50
  process.versions.node != null;
52
51
  // Warn about API key exposure in browser environment
53
- if (!this.isNode && !allowDangerouslyExposeApiKey) {
52
+ if (!this.isNode && !config.allowDangerouslyExposeApiKey) {
54
53
  throw new Error('WARNING: Using FlowscaleAPI in a browser environment will expose your API key to end users. ' +
55
54
  'This is a security risk. If you understand the risks and still want to proceed, ' +
56
55
  'set allowDangerouslyExposeApiKey to true. ' +
57
56
  'We strongly recommend using a backend proxy instead.');
58
57
  }
59
- this.apiKey = apiKey;
60
- this.baseUrl = baseUrl;
58
+ this.apiKey = config.apiKey;
59
+ this.baseUrl = config.baseUrl;
61
60
  this.client = axios_1.default.create({
62
61
  baseURL: this.baseUrl,
63
62
  });
package/dist/types.d.ts CHANGED
@@ -70,3 +70,8 @@ export interface ErrorResponse {
70
70
  status: string;
71
71
  errors: string;
72
72
  }
73
+ export interface FlowscaleConfig {
74
+ apiKey: string;
75
+ baseUrl: string;
76
+ allowDangerouslyExposeApiKey?: boolean;
77
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowscale",
3
- "version": "1.0.15",
3
+ "version": "1.0.16",
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",