@fishjam-cloud/js-server-sdk 0.29.0-rc.1 → 0.29.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.
@@ -6,10 +6,37 @@ import { GoogleGenAIOptions, GoogleGenAI } from '@google/genai';
6
6
  * This module is a separate entry point (`@fishjam-cloud/js-server-sdk/gemini`),
7
7
  * so `@google/genai` is only loaded when the consumer imports this module.
8
8
  *
9
+ * Does not verify the API key against Google — use {@link createClientAndValidate}
10
+ * or call {@link checkCredentials} afterwards for that.
11
+ *
9
12
  * @param options Configuration for the GoogleGenAI client.
10
13
  * @returns A GoogleGenAI instance.
11
14
  */
12
15
  declare const createClient: (options: GoogleGenAIOptions) => GoogleGenAI;
16
+ /**
17
+ * Verifies the API key by making a single lightweight authenticated call
18
+ * (`models.list`). Resolves on success; throws if the call fails — either
19
+ * because the key was rejected or because the request itself failed (e.g.
20
+ * network/connectivity). The original error is preserved as `cause`.
21
+ *
22
+ * Note: this catches the common cases (invalid / unauthorized / wrong-project /
23
+ * region-blocked keys). It does not guarantee the key can use a specific Live
24
+ * native-audio model — such model-specific rejections still surface only via the
25
+ * `live.connect` session callbacks (`onerror`/`onclose`).
26
+ *
27
+ * @param client A GoogleGenAI instance, e.g. from {@link createClient}.
28
+ */
29
+ declare const checkCredentials: (client: GoogleGenAI) => Promise<void>;
30
+ /**
31
+ * Creates a GoogleGenAI client and verifies the API key before returning it,
32
+ * so misconfiguration fails fast.
33
+ *
34
+ * Throws if the key is rejected (see {@link checkCredentials}).
35
+ *
36
+ * @param options Configuration for the GoogleGenAI client.
37
+ * @returns A validated GoogleGenAI instance.
38
+ */
39
+ declare const createClientAndValidate: (options: GoogleGenAIOptions) => Promise<GoogleGenAI>;
13
40
  /**
14
41
  * Predefined audio settings for the agent's output track,
15
42
  * configured for Gemini's 24kHz audio output.
@@ -32,4 +59,4 @@ declare const geminiInputAudioSettings: {
32
59
  */
33
60
  declare const inputMimeType: "audio/pcm;rate=16000";
34
61
 
35
- export { createClient, geminiInputAudioSettings, geminiOutputAudioSettings, inputMimeType };
62
+ export { checkCredentials, createClient, createClientAndValidate, geminiInputAudioSettings, geminiOutputAudioSettings, inputMimeType };
@@ -6,10 +6,37 @@ import { GoogleGenAIOptions, GoogleGenAI } from '@google/genai';
6
6
  * This module is a separate entry point (`@fishjam-cloud/js-server-sdk/gemini`),
7
7
  * so `@google/genai` is only loaded when the consumer imports this module.
8
8
  *
9
+ * Does not verify the API key against Google — use {@link createClientAndValidate}
10
+ * or call {@link checkCredentials} afterwards for that.
11
+ *
9
12
  * @param options Configuration for the GoogleGenAI client.
10
13
  * @returns A GoogleGenAI instance.
11
14
  */
12
15
  declare const createClient: (options: GoogleGenAIOptions) => GoogleGenAI;
16
+ /**
17
+ * Verifies the API key by making a single lightweight authenticated call
18
+ * (`models.list`). Resolves on success; throws if the call fails — either
19
+ * because the key was rejected or because the request itself failed (e.g.
20
+ * network/connectivity). The original error is preserved as `cause`.
21
+ *
22
+ * Note: this catches the common cases (invalid / unauthorized / wrong-project /
23
+ * region-blocked keys). It does not guarantee the key can use a specific Live
24
+ * native-audio model — such model-specific rejections still surface only via the
25
+ * `live.connect` session callbacks (`onerror`/`onclose`).
26
+ *
27
+ * @param client A GoogleGenAI instance, e.g. from {@link createClient}.
28
+ */
29
+ declare const checkCredentials: (client: GoogleGenAI) => Promise<void>;
30
+ /**
31
+ * Creates a GoogleGenAI client and verifies the API key before returning it,
32
+ * so misconfiguration fails fast.
33
+ *
34
+ * Throws if the key is rejected (see {@link checkCredentials}).
35
+ *
36
+ * @param options Configuration for the GoogleGenAI client.
37
+ * @returns A validated GoogleGenAI instance.
38
+ */
39
+ declare const createClientAndValidate: (options: GoogleGenAIOptions) => Promise<GoogleGenAI>;
13
40
  /**
14
41
  * Predefined audio settings for the agent's output track,
15
42
  * configured for Gemini's 24kHz audio output.
@@ -32,4 +59,4 @@ declare const geminiInputAudioSettings: {
32
59
  */
33
60
  declare const inputMimeType: "audio/pcm;rate=16000";
34
61
 
35
- export { createClient, geminiInputAudioSettings, geminiOutputAudioSettings, inputMimeType };
62
+ export { checkCredentials, createClient, createClientAndValidate, geminiInputAudioSettings, geminiOutputAudioSettings, inputMimeType };
@@ -20,7 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/integrations/gemini.ts
21
21
  var gemini_exports = {};
22
22
  __export(gemini_exports, {
23
+ checkCredentials: () => checkCredentials,
23
24
  createClient: () => createClient,
25
+ createClientAndValidate: () => createClientAndValidate,
24
26
  geminiInputAudioSettings: () => geminiInputAudioSettings,
25
27
  geminiOutputAudioSettings: () => geminiOutputAudioSettings,
26
28
  inputMimeType: () => inputMimeType
@@ -31,7 +33,7 @@ var import_genai = require("@google/genai");
31
33
  // package.json
32
34
  var package_default = {
33
35
  name: "@fishjam-cloud/js-server-sdk",
34
- version: "0.29.0-rc.1",
36
+ version: "0.29.0",
35
37
  description: "Fishjam server SDK for JavaScript",
36
38
  homepage: "https://github.com/fishjam-cloud/js-server-sdk",
37
39
  author: "Fishjam Team",
@@ -93,9 +95,11 @@ var package_default = {
93
95
  outDir: "dist"
94
96
  },
95
97
  dependencies: {
96
- axios: "^1.7.9",
97
98
  uuid: "^11.1.0"
98
99
  },
100
+ engines: {
101
+ node: ">=18"
102
+ },
99
103
  peerDependencies: {
100
104
  "@google/genai": "^1.0.0"
101
105
  },
@@ -120,8 +124,7 @@ var package_default = {
120
124
  "*.{js,ts,tsx,mjs,cjs}": [
121
125
  "eslint --fix --config eslint.config.mjs"
122
126
  ]
123
- },
124
- stableVersion: "0.28.1"
127
+ }
125
128
  };
126
129
 
127
130
  // src/integrations/gemini.ts
@@ -140,6 +143,21 @@ var createClient = (options) => {
140
143
  };
141
144
  return new import_genai.GoogleGenAI(finalOptions);
142
145
  };
146
+ var checkCredentials = async (client) => {
147
+ try {
148
+ await client.models.list();
149
+ } catch (error) {
150
+ throw new Error(
151
+ "Could not verify the Gemini API key. The key may be invalid/unauthorized (check the key and that the Gemini API is enabled for its project/region), or the request to Gemini failed (e.g. network connectivity). See the cause for details.",
152
+ { cause: error }
153
+ );
154
+ }
155
+ };
156
+ var createClientAndValidate = async (options) => {
157
+ const client = createClient(options);
158
+ await checkCredentials(client);
159
+ return client;
160
+ };
143
161
  var geminiOutputAudioSettings = {
144
162
  encoding: "pcm16",
145
163
  channels: 1,
@@ -152,7 +170,9 @@ var geminiInputAudioSettings = {
152
170
  var inputMimeType = "audio/pcm;rate=16000";
153
171
  // Annotate the CommonJS export names for ESM import in node:
154
172
  0 && (module.exports = {
173
+ checkCredentials,
155
174
  createClient,
175
+ createClientAndValidate,
156
176
  geminiInputAudioSettings,
157
177
  geminiOutputAudioSettings,
158
178
  inputMimeType
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  package_default
3
- } from "../chunk-VLMRJKOY.mjs";
3
+ } from "../chunk-3EYSX4WM.mjs";
4
4
 
5
5
  // src/integrations/gemini.ts
6
6
  import { GoogleGenAI } from "@google/genai";
@@ -19,6 +19,21 @@ var createClient = (options) => {
19
19
  };
20
20
  return new GoogleGenAI(finalOptions);
21
21
  };
22
+ var checkCredentials = async (client) => {
23
+ try {
24
+ await client.models.list();
25
+ } catch (error) {
26
+ throw new Error(
27
+ "Could not verify the Gemini API key. The key may be invalid/unauthorized (check the key and that the Gemini API is enabled for its project/region), or the request to Gemini failed (e.g. network connectivity). See the cause for details.",
28
+ { cause: error }
29
+ );
30
+ }
31
+ };
32
+ var createClientAndValidate = async (options) => {
33
+ const client = createClient(options);
34
+ await checkCredentials(client);
35
+ return client;
36
+ };
22
37
  var geminiOutputAudioSettings = {
23
38
  encoding: "pcm16",
24
39
  channels: 1,
@@ -30,7 +45,9 @@ var geminiInputAudioSettings = {
30
45
  };
31
46
  var inputMimeType = "audio/pcm;rate=16000";
32
47
  export {
48
+ checkCredentials,
33
49
  createClient,
50
+ createClientAndValidate,
34
51
  geminiInputAudioSettings,
35
52
  geminiOutputAudioSettings,
36
53
  inputMimeType
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishjam-cloud/js-server-sdk",
3
- "version": "0.29.0-rc.1",
3
+ "version": "0.29.0",
4
4
  "description": "Fishjam server SDK for JavaScript",
5
5
  "homepage": "https://github.com/fishjam-cloud/js-server-sdk",
6
6
  "author": "Fishjam Team",
@@ -62,9 +62,11 @@
62
62
  "outDir": "dist"
63
63
  },
64
64
  "dependencies": {
65
- "axios": "^1.7.9",
66
65
  "uuid": "^11.1.0"
67
66
  },
67
+ "engines": {
68
+ "node": ">=18"
69
+ },
68
70
  "peerDependencies": {
69
71
  "@google/genai": "^1.0.0"
70
72
  },
@@ -74,8 +76,8 @@
74
76
  }
75
77
  },
76
78
  "devDependencies": {
77
- "@fishjam-cloud/fishjam-openapi": "0.29.0-rc.1",
78
- "@fishjam-cloud/fishjam-proto": "0.29.0-rc.1",
79
+ "@fishjam-cloud/fishjam-openapi": "0.29.0",
80
+ "@fishjam-cloud/fishjam-proto": "0.29.0",
79
81
  "@openapitools/openapi-generator-cli": "^2.18.4",
80
82
  "@types/node": "^22.13.16",
81
83
  "@types/websocket": "^1.0.10",
@@ -89,6 +91,5 @@
89
91
  "*.{js,ts,tsx,mjs,cjs}": [
90
92
  "eslint --fix --config eslint.config.mjs"
91
93
  ]
92
- },
93
- "stableVersion": "0.28.1"
94
+ }
94
95
  }