@krutai/db-service 1.0.1 → 1.0.3

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
@@ -19,7 +19,7 @@ import { DbService } from '@krutai/db-service';
19
19
 
20
20
  const client = new DbService({
21
21
  apiKey: process.env.KRUTAI_API_KEY!,
22
- serverUrl: 'http://localhost:8000', // optional
22
+ serverUrl: 'http://localhost:8000',
23
23
  });
24
24
 
25
25
  await client.initialize();
@@ -49,7 +49,7 @@ console.log(config.dbUrl); // postgres connection URL
49
49
  `DbServiceConfig` fields:
50
50
 
51
51
  - `apiKey` (string, required)
52
- - `serverUrl` (string, optional, default: `http://localhost:8000`)
52
+ - `serverUrl` (string, required)
53
53
  - `validateOnInit` (boolean, optional, default: `true`)
54
54
 
55
55
  ## Errors
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- declare class DbServiceKeyValidationError extends Error {
2
- constructor(message: string);
3
- }
1
+ export { KrutAIKeyValidationError } from 'krutai';
2
+
4
3
  interface DbServiceConfig {
5
4
  apiKey: string;
6
5
  serverUrl?: string;
@@ -15,8 +14,6 @@ interface DbConfigResponse {
15
14
  }
16
15
  declare const DEFAULT_SERVER_URL = "http://localhost:8000";
17
16
  declare const DEFAULT_DB_MANAGE_PREFIX = "/db-manage";
18
- declare function validateApiKeyFormat(apiKey?: string): void;
19
- declare function validateApiKeyWithService(apiKey?: string, serverUrl?: string): Promise<boolean>;
20
17
  declare class DbService {
21
18
  private readonly apiKey;
22
19
  private readonly serverUrl;
@@ -34,4 +31,4 @@ declare class DbService {
34
31
  declare function dbService(config: DbServiceConfig): DbService;
35
32
  declare const VERSION = "0.1.0";
36
33
 
37
- export { DEFAULT_DB_MANAGE_PREFIX, DEFAULT_SERVER_URL, type DbConfigRequest, type DbConfigResponse, DbService, type DbServiceConfig, DbServiceKeyValidationError, VERSION, dbService, validateApiKeyFormat, validateApiKeyWithService };
34
+ export { DEFAULT_DB_MANAGE_PREFIX, DEFAULT_SERVER_URL, type DbConfigRequest, type DbConfigResponse, DbService, type DbServiceConfig, VERSION, dbService };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
- declare class DbServiceKeyValidationError extends Error {
2
- constructor(message: string);
3
- }
1
+ export { KrutAIKeyValidationError } from 'krutai';
2
+
4
3
  interface DbServiceConfig {
5
4
  apiKey: string;
6
5
  serverUrl?: string;
@@ -15,8 +14,6 @@ interface DbConfigResponse {
15
14
  }
16
15
  declare const DEFAULT_SERVER_URL = "http://localhost:8000";
17
16
  declare const DEFAULT_DB_MANAGE_PREFIX = "/db-manage";
18
- declare function validateApiKeyFormat(apiKey?: string): void;
19
- declare function validateApiKeyWithService(apiKey?: string, serverUrl?: string): Promise<boolean>;
20
17
  declare class DbService {
21
18
  private readonly apiKey;
22
19
  private readonly serverUrl;
@@ -34,4 +31,4 @@ declare class DbService {
34
31
  declare function dbService(config: DbServiceConfig): DbService;
35
32
  declare const VERSION = "0.1.0";
36
33
 
37
- export { DEFAULT_DB_MANAGE_PREFIX, DEFAULT_SERVER_URL, type DbConfigRequest, type DbConfigResponse, DbService, type DbServiceConfig, DbServiceKeyValidationError, VERSION, dbService, validateApiKeyFormat, validateApiKeyWithService };
34
+ export { DEFAULT_DB_MANAGE_PREFIX, DEFAULT_SERVER_URL, type DbConfigRequest, type DbConfigResponse, DbService, type DbServiceConfig, VERSION, dbService };
package/dist/index.js CHANGED
@@ -23,69 +23,14 @@ __export(index_exports, {
23
23
  DEFAULT_DB_MANAGE_PREFIX: () => DEFAULT_DB_MANAGE_PREFIX,
24
24
  DEFAULT_SERVER_URL: () => DEFAULT_SERVER_URL,
25
25
  DbService: () => DbService,
26
- DbServiceKeyValidationError: () => DbServiceKeyValidationError,
26
+ KrutAIKeyValidationError: () => import_krutai.KrutAIKeyValidationError,
27
27
  VERSION: () => VERSION,
28
- dbService: () => dbService,
29
- validateApiKeyFormat: () => validateApiKeyFormat,
30
- validateApiKeyWithService: () => validateApiKeyWithService
28
+ dbService: () => dbService
31
29
  });
32
30
  module.exports = __toCommonJS(index_exports);
33
- var DbServiceKeyValidationError = class extends Error {
34
- constructor(message) {
35
- super(message);
36
- this.name = "DbServiceKeyValidationError";
37
- }
38
- };
31
+ var import_krutai = require("krutai");
39
32
  var DEFAULT_SERVER_URL = "http://localhost:8000";
40
33
  var DEFAULT_DB_MANAGE_PREFIX = "/db-manage";
41
- function validateApiKeyFormat(apiKey) {
42
- const key = apiKey || process.env.KRUTAI_API_KEY;
43
- if (!key || typeof key !== "string") {
44
- throw new DbServiceKeyValidationError("API key must be a non-empty string");
45
- }
46
- if (key.trim().length === 0) {
47
- throw new DbServiceKeyValidationError("API key cannot be empty or whitespace");
48
- }
49
- }
50
- async function validateApiKeyWithService(apiKey, serverUrl = DEFAULT_SERVER_URL) {
51
- const key = apiKey || process.env.KRUTAI_API_KEY;
52
- if (!key) {
53
- throw new DbServiceKeyValidationError("API key is required");
54
- }
55
- validateApiKeyFormat(key);
56
- try {
57
- const url = `${serverUrl.replace(/\/$/, "")}/validate`;
58
- const response = await fetch(url, {
59
- method: "POST",
60
- headers: {
61
- "Content-Type": "application/json",
62
- "x-api-key": key
63
- },
64
- body: JSON.stringify({ apiKey: key })
65
- });
66
- let data = {};
67
- try {
68
- data = await response.json();
69
- } catch {
70
- }
71
- if (!response.ok) {
72
- throw new DbServiceKeyValidationError(
73
- data.error || data.message || `API key validation failed: server responded with HTTP ${response.status}`
74
- );
75
- }
76
- if (data.valid === false) {
77
- throw new DbServiceKeyValidationError(
78
- data.error ?? data.message ?? "API key rejected by server"
79
- );
80
- }
81
- return true;
82
- } catch (error) {
83
- if (error instanceof DbServiceKeyValidationError) throw error;
84
- throw new DbServiceKeyValidationError(
85
- `Failed to reach validation endpoint: ${error instanceof Error ? error.message : "Unknown error"}`
86
- );
87
- }
88
- }
89
34
  var DbService = class {
90
35
  apiKey;
91
36
  serverUrl;
@@ -97,7 +42,7 @@ var DbService = class {
97
42
  this.apiKey = config.apiKey || process.env.KRUTAI_API_KEY || "";
98
43
  this.serverUrl = (config.serverUrl ?? DEFAULT_SERVER_URL).replace(/\/$/, "");
99
44
  this.dbManagePrefix = DEFAULT_DB_MANAGE_PREFIX.replace(/\/$/, "");
100
- validateApiKeyFormat(this.apiKey);
45
+ (0, import_krutai.validateApiKeyFormat)(this.apiKey);
101
46
  if (config.validateOnInit === false) {
102
47
  this.initialized = true;
103
48
  }
@@ -105,7 +50,7 @@ var DbService = class {
105
50
  async initialize() {
106
51
  if (this.initialized) return;
107
52
  if (this.config.validateOnInit !== false) {
108
- await validateApiKeyWithService(this.apiKey, this.serverUrl);
53
+ await (0, import_krutai.validateApiKey)(this.apiKey, this.serverUrl);
109
54
  }
110
55
  this.initialized = true;
111
56
  }
@@ -167,10 +112,8 @@ var VERSION = "0.1.0";
167
112
  DEFAULT_DB_MANAGE_PREFIX,
168
113
  DEFAULT_SERVER_URL,
169
114
  DbService,
170
- DbServiceKeyValidationError,
115
+ KrutAIKeyValidationError,
171
116
  VERSION,
172
- dbService,
173
- validateApiKeyFormat,
174
- validateApiKeyWithService
117
+ dbService
175
118
  });
176
119
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export class DbServiceKeyValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DbServiceKeyValidationError';\n }\n}\n\nexport interface DbServiceConfig {\n apiKey: string;\n serverUrl?: string;\n validateOnInit?: boolean;\n}\n\nexport interface DbConfigRequest {\n projectId: string;\n dbName: string;\n}\n\nexport interface DbConfigResponse {\n dbUrl: string;\n}\n\nexport const DEFAULT_SERVER_URL = 'http://localhost:8000';\nexport const DEFAULT_DB_MANAGE_PREFIX = '/db-manage';\n\nexport function validateApiKeyFormat(apiKey?: string): void {\n const key = apiKey || process.env.KRUTAI_API_KEY;\n\n if (!key || typeof key !== 'string') {\n throw new DbServiceKeyValidationError('API key must be a non-empty string');\n }\n\n if (key.trim().length === 0) {\n throw new DbServiceKeyValidationError('API key cannot be empty or whitespace');\n }\n}\n\nexport async function validateApiKeyWithService(\n apiKey?: string,\n serverUrl: string = DEFAULT_SERVER_URL\n): Promise<boolean> {\n const key = apiKey || process.env.KRUTAI_API_KEY;\n if (!key) {\n throw new DbServiceKeyValidationError('API key is required');\n }\n\n validateApiKeyFormat(key);\n\n try {\n const url = `${serverUrl.replace(/\\/$/, '')}/validate`;\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': key,\n },\n body: JSON.stringify({ apiKey: key }),\n });\n\n let data: { valid?: boolean; message?: string; error?: string } = {};\n try {\n data = (await response.json()) as {\n valid?: boolean;\n message?: string;\n error?: string;\n };\n } catch {\n // Ignore parsing errors for non-JSON responses\n }\n\n if (!response.ok) {\n throw new DbServiceKeyValidationError(\n data.error ||\n data.message ||\n `API key validation failed: server responded with HTTP ${response.status}`\n );\n }\n\n if (data.valid === false) {\n throw new DbServiceKeyValidationError(\n data.error ?? data.message ?? 'API key rejected by server'\n );\n }\n\n return true;\n } catch (error) {\n if (error instanceof DbServiceKeyValidationError) throw error;\n throw new DbServiceKeyValidationError(\n `Failed to reach validation endpoint: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n}\n\nexport class DbService {\n private readonly apiKey: string;\n private readonly serverUrl: string;\n private readonly dbManagePrefix: string;\n private readonly config: DbServiceConfig;\n private initialized = false;\n\n constructor(config: DbServiceConfig) {\n this.config = config;\n this.apiKey = config.apiKey || process.env.KRUTAI_API_KEY || '';\n this.serverUrl = (config.serverUrl ?? DEFAULT_SERVER_URL).replace(/\\/$/, '');\n this.dbManagePrefix = DEFAULT_DB_MANAGE_PREFIX.replace(/\\/$/, '');\n\n validateApiKeyFormat(this.apiKey);\n\n if (config.validateOnInit === false) {\n this.initialized = true;\n }\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey, this.serverUrl);\n }\n\n this.initialized = true;\n }\n\n isInitialized(): boolean {\n return this.initialized;\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'DbService not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n 'x-api-key': this.apiKey,\n };\n }\n\n private url(path: string): string {\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return `${this.serverUrl}${this.dbManagePrefix}${cleanPath}`;\n }\n\n async getDbConfig(request: DbConfigRequest): Promise<DbConfigResponse> {\n this.assertInitialized();\n\n if (!request.projectId || request.projectId.trim().length === 0) {\n throw new Error('projectId is required');\n }\n\n if (!request.dbName || request.dbName.trim().length === 0) {\n throw new Error('dbName is required');\n }\n\n const response = await fetch(this.url('/config'), {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify({\n projectId: request.projectId,\n dbName: request.dbName,\n }),\n });\n\n if (!response.ok) {\n let message = `DB service returned HTTP ${response.status} for /config`;\n try {\n const errorData = (await response.json()) as {\n message?: string;\n error?: string;\n };\n message = errorData.error ?? errorData.message ?? message;\n } catch {\n // ignore malformed error payloads\n }\n throw new Error(message);\n }\n\n return (await response.json()) as DbConfigResponse;\n }\n}\n\nexport function dbService(config: DbServiceConfig): DbService {\n return new DbService(config);\n}\n\nexport const VERSION = '0.1.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACnD,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EAChB;AACJ;AAiBO,IAAM,qBAAqB;AAC3B,IAAM,2BAA2B;AAEjC,SAAS,qBAAqB,QAAuB;AACxD,QAAM,MAAM,UAAU,QAAQ,IAAI;AAElC,MAAI,CAA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AS,GAAG;AAAA,MAC9C,QAAQ;AAAA,MACR,SAAS,KAAK,QAAQ;AAAA,MACtB,MAAM,KAAK,UAAU;AAAA,QACjB,WAAW,QAAQ;AAAA,QACnB,QAAQ,QAAQ;AAAA,MACpB,CAAC;AAAA,IACL,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AACd,UAAI,UAAU,4BAA4B,SAAS,MAAM;AACzD,UAAI;AACA,cAAM,YAAa,MAAM,SAAS,KAAK;AAIvC,kBAAU,UAAU,SAAS,UAAU,WAAW;AAAA,MACtD,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAChC;AACJ;AAEO,SAAS,UAAU,QAAoC;AAC1D,SAAO,IAAI,UAAU,MAAM;AAC/B;AAEO,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n validateApiKey,\n validateApiKeyFormat,\n KrutAIKeyValidationError,\n} from 'krutai';\n\nexport { KrutAIKeyValidationError };\n\nexport interface DbServiceConfig {\n apiKey: string;\n serverUrl?: string;\n validateOnInit?: boolean;\n}\n\nexport interface DbConfigRequest {\n projectId: string;\n dbName: string;\n}\n\nexport interface DbConfigResponse {\n dbUrl: string;\n}\n\nexport const DEFAULT_SERVER_URL = 'http://localhost:8000';\nexport const DEFAULT_DB_MANAGE_PREFIX = '/db-manage';\n\nexport class DbService {\n private readonly apiKey: string;\n private readonly serverUrl: string;\n private readonly dbManagePrefix: string;\n private readonly config: DbServiceConfig;\n private initialized = false;\n\n constructor(config: DbServiceConfig) {\n this.config = config;\n this.apiKey = config.apiKey || process.env.KRUTAI_API_KEY || '';\n this.serverUrl = (config.serverUrl ?? DEFAULT_SERVER_URL).replace(/\\/$/, '');\n this.dbManagePrefix = DEFAULT_DB_MANAGE_PREFIX.replace(/\\/$/, '');\n\n validateApiKeyFormat(this.apiKey);\n\n if (config.validateOnInit === false) {\n this.initialized = true;\n }\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n\n if (this.config.validateOnInit !== false) {\n await validateApiKey(this.apiKey, this.serverUrl);\n }\n\n this.initialized = true;\n }\n\n isInitialized(): boolean {\n return this.initialized;\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'DbService not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n 'x-api-key': this.apiKey,\n };\n }\n\n private url(path: string): string {\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return `${this.serverUrl}${this.dbManagePrefix}${cleanPath}`;\n }\n\n async getDbConfig(request: DbConfigRequest): Promise<DbConfigResponse> {\n this.assertInitialized();\n\n if (!request.projectId || request.projectId.trim().length === 0) {\n throw new Error('projectId is required');\n }\n\n if (!request.dbName || request.dbName.trim().length === 0) {\n throw new Error('dbName is required');\n }\n\n const response = await fetch(this.url('/config'), {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify({\n projectId: request.projectId,\n dbName: request.dbName,\n }),\n });\n\n if (!response.ok) {\n let message = `DB service returned HTTP ${response.status} for /config`;\n try {\n const errorData = (await response.json()) as {\n message?: string;\n error?: string;\n };\n message = errorData.error ?? errorData.message ?? message;\n } catch {\n // ignore malformed error payloads\n }\n throw new Error(message);\n }\n\n return (await response.json()) as DbConfigResponse;\n }\n}\n\nexport function dbService(config: DbServiceConfig): DbService {\n return new DbService(config);\n}\n\nexport const VERSION = '0.1.0';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAIO;AAmBA,IAAM,qBAAqB;AAC3B,IAAM,2BAA2B;AAEjC,IAAM,YAAN,MAAgB;AAAA,EACF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACT,cAAc;AAAA,EAEtB,YAAY,QAA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,MAAM,KAAK,IAAI,SAAS,GAAG;AAAA,MAC9C,QAAQ;AAAA,MACR,SAAS,KAAK,QAAQ;AAAA,MACtB,MAAM,KAAK,UAAU;AAAA,QACjB,WAAW,QAAQ;AAAA,QACnB,QAAQ,QAAQ;AAAA,MACpB,CAAC;AAAA,IACL,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AACd,UAAI,UAAU,4BAA4B,SAAS,MAAM;AACzD,UAAI;AACA,cAAM,YAAa,MAAM,SAAS,KAAK;AAIvC,kBAAU,UAAU,SAAS,UAAU,WAAW;AAAA,MACtD,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAChC;AACJ;AAEO,SAAS,UAAU,QAAoC;AAC1D,SAAO,IAAI,UAAU,MAAM;AAC/B;AAEO,IAAM,UAAU;","names":[]}
package/dist/index.mjs CHANGED
@@ -1,60 +1,11 @@
1
1
  // src/index.ts
2
- var DbServiceKeyValidationError = class extends Error {
3
- constructor(message) {
4
- super(message);
5
- this.name = "DbServiceKeyValidationError";
6
- }
7
- };
2
+ import {
3
+ validateApiKey,
4
+ validateApiKeyFormat,
5
+ KrutAIKeyValidationError
6
+ } from "krutai";
8
7
  var DEFAULT_SERVER_URL = "http://localhost:8000";
9
8
  var DEFAULT_DB_MANAGE_PREFIX = "/db-manage";
10
- function validateApiKeyFormat(apiKey) {
11
- const key = apiKey || process.env.KRUTAI_API_KEY;
12
- if (!key || typeof key !== "string") {
13
- throw new DbServiceKeyValidationError("API key must be a non-empty string");
14
- }
15
- if (key.trim().length === 0) {
16
- throw new DbServiceKeyValidationError("API key cannot be empty or whitespace");
17
- }
18
- }
19
- async function validateApiKeyWithService(apiKey, serverUrl = DEFAULT_SERVER_URL) {
20
- const key = apiKey || process.env.KRUTAI_API_KEY;
21
- if (!key) {
22
- throw new DbServiceKeyValidationError("API key is required");
23
- }
24
- validateApiKeyFormat(key);
25
- try {
26
- const url = `${serverUrl.replace(/\/$/, "")}/validate`;
27
- const response = await fetch(url, {
28
- method: "POST",
29
- headers: {
30
- "Content-Type": "application/json",
31
- "x-api-key": key
32
- },
33
- body: JSON.stringify({ apiKey: key })
34
- });
35
- let data = {};
36
- try {
37
- data = await response.json();
38
- } catch {
39
- }
40
- if (!response.ok) {
41
- throw new DbServiceKeyValidationError(
42
- data.error || data.message || `API key validation failed: server responded with HTTP ${response.status}`
43
- );
44
- }
45
- if (data.valid === false) {
46
- throw new DbServiceKeyValidationError(
47
- data.error ?? data.message ?? "API key rejected by server"
48
- );
49
- }
50
- return true;
51
- } catch (error) {
52
- if (error instanceof DbServiceKeyValidationError) throw error;
53
- throw new DbServiceKeyValidationError(
54
- `Failed to reach validation endpoint: ${error instanceof Error ? error.message : "Unknown error"}`
55
- );
56
- }
57
- }
58
9
  var DbService = class {
59
10
  apiKey;
60
11
  serverUrl;
@@ -74,7 +25,7 @@ var DbService = class {
74
25
  async initialize() {
75
26
  if (this.initialized) return;
76
27
  if (this.config.validateOnInit !== false) {
77
- await validateApiKeyWithService(this.apiKey, this.serverUrl);
28
+ await validateApiKey(this.apiKey, this.serverUrl);
78
29
  }
79
30
  this.initialized = true;
80
31
  }
@@ -135,10 +86,8 @@ export {
135
86
  DEFAULT_DB_MANAGE_PREFIX,
136
87
  DEFAULT_SERVER_URL,
137
88
  DbService,
138
- DbServiceKeyValidationError,
89
+ KrutAIKeyValidationError,
139
90
  VERSION,
140
- dbService,
141
- validateApiKeyFormat,
142
- validateApiKeyWithService
91
+ dbService
143
92
  };
144
93
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export class DbServiceKeyValidationError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DbServiceKeyValidationError';\n }\n}\n\nexport interface DbServiceConfig {\n apiKey: string;\n serverUrl?: string;\n validateOnInit?: boolean;\n}\n\nexport interface DbConfigRequest {\n projectId: string;\n dbName: string;\n}\n\nexport interface DbConfigResponse {\n dbUrl: string;\n}\n\nexport const DEFAULT_SERVER_URL = 'http://localhost:8000';\nexport const DEFAULT_DB_MANAGE_PREFIX = '/db-manage';\n\nexport function validateApiKeyFormat(apiKey?: string): void {\n const key = apiKey || process.env.KRUTAI_API_KEY;\n\n if (!key || typeof key !== 'string') {\n throw new DbServiceKeyValidationError('API key must be a non-empty string');\n }\n\n if (key.trim().length === 0) {\n throw new DbServiceKeyValidationError('API key cannot be empty or whitespace');\n }\n}\n\nexport async function validateApiKeyWithService(\n apiKey?: string,\n serverUrl: string = DEFAULT_SERVER_URL\n): Promise<boolean> {\n const key = apiKey || process.env.KRUTAI_API_KEY;\n if (!key) {\n throw new DbServiceKeyValidationError('API key is required');\n }\n\n validateApiKeyFormat(key);\n\n try {\n const url = `${serverUrl.replace(/\\/$/, '')}/validate`;\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'x-api-key': key,\n },\n body: JSON.stringify({ apiKey: key }),\n });\n\n let data: { valid?: boolean; message?: string; error?: string } = {};\n try {\n data = (await response.json()) as {\n valid?: boolean;\n message?: string;\n error?: string;\n };\n } catch {\n // Ignore parsing errors for non-JSON responses\n }\n\n if (!response.ok) {\n throw new DbServiceKeyValidationError(\n data.error ||\n data.message ||\n `API key validation failed: server responded with HTTP ${response.status}`\n );\n }\n\n if (data.valid === false) {\n throw new DbServiceKeyValidationError(\n data.error ?? data.message ?? 'API key rejected by server'\n );\n }\n\n return true;\n } catch (error) {\n if (error instanceof DbServiceKeyValidationError) throw error;\n throw new DbServiceKeyValidationError(\n `Failed to reach validation endpoint: ${error instanceof Error ? error.message : 'Unknown error'}`\n );\n }\n}\n\nexport class DbService {\n private readonly apiKey: string;\n private readonly serverUrl: string;\n private readonly dbManagePrefix: string;\n private readonly config: DbServiceConfig;\n private initialized = false;\n\n constructor(config: DbServiceConfig) {\n this.config = config;\n this.apiKey = config.apiKey || process.env.KRUTAI_API_KEY || '';\n this.serverUrl = (config.serverUrl ?? DEFAULT_SERVER_URL).replace(/\\/$/, '');\n this.dbManagePrefix = DEFAULT_DB_MANAGE_PREFIX.replace(/\\/$/, '');\n\n validateApiKeyFormat(this.apiKey);\n\n if (config.validateOnInit === false) {\n this.initialized = true;\n }\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n\n if (this.config.validateOnInit !== false) {\n await validateApiKeyWithService(this.apiKey, this.serverUrl);\n }\n\n this.initialized = true;\n }\n\n isInitialized(): boolean {\n return this.initialized;\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'DbService not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n 'x-api-key': this.apiKey,\n };\n }\n\n private url(path: string): string {\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return `${this.serverUrl}${this.dbManagePrefix}${cleanPath}`;\n }\n\n async getDbConfig(request: DbConfigRequest): Promise<DbConfigResponse> {\n this.assertInitialized();\n\n if (!request.projectId || request.projectId.trim().length === 0) {\n throw new Error('projectId is required');\n }\n\n if (!request.dbName || request.dbName.trim().length === 0) {\n throw new Error('dbName is required');\n }\n\n const response = await fetch(this.url('/config'), {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify({\n projectId: request.projectId,\n dbName: request.dbName,\n }),\n });\n\n if (!response.ok) {\n let message = `DB service returned HTTP ${response.status} for /config`;\n try {\n const errorData = (await response.json()) as {\n message?: string;\n error?: string;\n };\n message = errorData.error ?? errorData.message ?? message;\n } catch {\n // ignore malformed error payloads\n }\n throw new Error(message);\n }\n\n return (await response.json()) as DbConfigResponse;\n }\n}\n\nexport function dbService(config: DbServiceConfig): DbService {\n return new DbService(config);\n}\n\nexport const VERSION = '0.1.0';\n"],"mappings":";AAAO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACnD,YAAY,SAAiB;AACzB,UAAM,OAAO;AACb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AEA,QAAI,CAAC,QAAQ,UAAU,QAAQ,OAAO,KAAK,EAAE,WAAW,GAAG;AACvD,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACxC;AAEA,UAAM,WAAW,MAAM,MAAM,KAAK,IAAI,SAAS,GAAG;AAAA,MAC9C,QAAQ;AAAA,MACR,SAAS,KAAK,QAAQ;AAAA,MACtB,MAAM,KAAK,UAAU;AAAA,QACjB,WAAW,QAAQ;AAAA,QACnB,QAAQ,QAAQ;AAAA,MACpB,CAAC;AAAA,IACL,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AACd,UAAI,UAAU,4BAA4B,SAAS,MAAM;AACzD,UAAI;AACA,cAAM,YAAa,MAAM,SAAS,KAAK;AAIvC,kBAAU,UAAU,SAAS,UAAU,WAAW;AAAA,MACtD,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAChC;AACJ;AAEO,SAAS,UAAU,QAAoC;AAC1D,SAAO,IAAI,UAAU,MAAM;AAC/B;AAEO,IAAM,UAAU;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import {\n validateApiKey,\n validateApiKeyFormat,\n KrutAIKeyValidationError,\n} from 'krutai';\n\nexport { KrutAIKeyValidationError };\n\nexport interface DbServiceConfig {\n apiKey: string;\n serverUrl?: string;\n validateOnInit?: boolean;\n}\n\nexport interface DbConfigRequest {\n projectId: string;\n dbName: string;\n}\n\nexport interface DbConfigResponse {\n dbUrl: string;\n}\n\nexport const DEFAULT_SERVER_URL = 'http://localhost:8000';\nexport const DEFAULT_DB_MANAGE_PREFIX = '/db-manage';\n\nexport class DbService {\n private readonly apiKey: string;\n private readonly serverUrl: string;\n private readonly dbManagePrefix: string;\n private readonly config: DbServiceConfig;\n private initialized = false;\n\n constructor(config: DbServiceConfig) {\n this.config = config;\n this.apiKey = config.apiKey || process.env.KRUTAI_API_KEY || '';\n this.serverUrl = (config.serverUrl ?? DEFAULT_SERVER_URL).replace(/\\/$/, '');\n this.dbManagePrefix = DEFAULT_DB_MANAGE_PREFIX.replace(/\\/$/, '');\n\n validateApiKeyFormat(this.apiKey);\n\n if (config.validateOnInit === false) {\n this.initialized = true;\n }\n }\n\n async initialize(): Promise<void> {\n if (this.initialized) return;\n\n if (this.config.validateOnInit !== false) {\n await validateApiKey(this.apiKey, this.serverUrl);\n }\n\n this.initialized = true;\n }\n\n isInitialized(): boolean {\n return this.initialized;\n }\n\n private assertInitialized(): void {\n if (!this.initialized) {\n throw new Error(\n 'DbService not initialized. Call initialize() first or set validateOnInit to false.'\n );\n }\n }\n\n private headers(): Record<string, string> {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.apiKey}`,\n 'x-api-key': this.apiKey,\n };\n }\n\n private url(path: string): string {\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return `${this.serverUrl}${this.dbManagePrefix}${cleanPath}`;\n }\n\n async getDbConfig(request: DbConfigRequest): Promise<DbConfigResponse> {\n this.assertInitialized();\n\n if (!request.projectId || request.projectId.trim().length === 0) {\n throw new Error('projectId is required');\n }\n\n if (!request.dbName || request.dbName.trim().length === 0) {\n throw new Error('dbName is required');\n }\n\n const response = await fetch(this.url('/config'), {\n method: 'POST',\n headers: this.headers(),\n body: JSON.stringify({\n projectId: request.projectId,\n dbName: request.dbName,\n }),\n });\n\n if (!response.ok) {\n let message = `DB service returned HTTP ${response.status} for /config`;\n try {\n const errorData = (await response.json()) as {\n message?: string;\n error?: string;\n };\n message = errorData.error ?? errorData.message ?? message;\n } catch {\n // ignore malformed error payloads\n }\n throw new Error(message);\n }\n\n return (await response.json()) as DbConfigResponse;\n }\n}\n\nexport function dbService(config: DbServiceConfig): DbService {\n return new DbService(config);\n}\n\nexport const VERSION = '0.1.0';\n"],"mappings":";AAAA;AAAA,EACI;AAAA,EACA;AAAA,EACA;AAAA,OACG;AAmBA,IAAM,qBAAqB;AAC3B,IAAM,2BAA2B;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U,QAAQ,OAAO,KAAK,EAAE,WAAW,GAAG;AACvD,YAAM,IAAI,MAAM,oBAAoB;AAAA,IACxC;AAEA,UAAM,WAAW,MAAM,MAAM,KAAK,IAAI,SAAS,GAAG;AAAA,MAC9C,QAAQ;AAAA,MACR,SAAS,KAAK,QAAQ;AAAA,MACtB,MAAM,KAAK,UAAU;AAAA,QACjB,WAAW,QAAQ;AAAA,QACnB,QAAQ,QAAQ;AAAA,MACpB,CAAC;AAAA,IACL,CAAC;AAED,QAAI,CAAC,SAAS,IAAI;AACd,UAAI,UAAU,4BAA4B,SAAS,MAAM;AACzD,UAAI;AACA,cAAM,YAAa,MAAM,SAAS,KAAK;AAIvC,kBAAU,UAAU,SAAS,UAAU,WAAW;AAAA,MACtD,QAAQ;AAAA,MAER;AACA,YAAM,IAAI,MAAM,OAAO;AAAA,IAC3B;AAEA,WAAQ,MAAM,SAAS,KAAK;AAAA,EAChC;AACJ;AAEO,SAAS,UAAU,QAAoC;AAC1D,SAAO,IAAI,UAAU,MAAM;AAC/B;AAEO,IAAM,UAAU;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krutai/db-service",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "DB service client for KrutAI",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -29,6 +29,12 @@
29
29
  ],
30
30
  "author": "",
31
31
  "license": "MIT",
32
+ "dependencies": {
33
+ "krutai": ">=0.1.5"
34
+ },
35
+ "peerDependencies": {
36
+ "krutai": ">=0.1.5"
37
+ },
32
38
  "devDependencies": {
33
39
  "@types/node": "^20.11.0",
34
40
  "tsup": "^8.0.1",
@@ -42,4 +48,4 @@
42
48
  "url": "git+https://github.com/AccountantAIOrg/krut_packages.git",
43
49
  "directory": "packages/db-service"
44
50
  }
45
- }
51
+ }