@pineliner/odb-client 1.0.0 → 1.0.1
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.cjs
CHANGED
|
@@ -869,8 +869,7 @@ ODBLiteClient.join;
|
|
|
869
869
|
try {
|
|
870
870
|
// Check if database already exists
|
|
871
871
|
console.log(`🔍 Checking if database exists: ${cacheKey}`);
|
|
872
|
-
const
|
|
873
|
-
const existing = databases.find((db)=>db.name === cacheKey);
|
|
872
|
+
const existing = await this.getDatabaseByName(cacheKey);
|
|
874
873
|
if (existing) {
|
|
875
874
|
console.log(`✅ Database already exists: ${cacheKey} (${existing.hash})`);
|
|
876
875
|
this.databaseCache.set(cacheKey, existing.hash);
|
|
@@ -948,6 +947,22 @@ ODBLiteClient.join;
|
|
|
948
947
|
return result.database;
|
|
949
948
|
}
|
|
950
949
|
/**
|
|
950
|
+
* Get database details by name
|
|
951
|
+
*
|
|
952
|
+
* @param name - Database name
|
|
953
|
+
* @returns Database object or null if not found
|
|
954
|
+
*/ async getDatabaseByName(name) {
|
|
955
|
+
const response = await fetch(`${this.apiUrl}/api/tenant/databases/by-name/${name}`, {
|
|
956
|
+
headers: {
|
|
957
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
if (404 === response.status) return null;
|
|
961
|
+
const result = await response.json();
|
|
962
|
+
if (!result.success) throw new Error(result.error || 'Failed to get database');
|
|
963
|
+
return result.database;
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
951
966
|
* Delete a database
|
|
952
967
|
*
|
|
953
968
|
* @param hash - Database hash to delete
|
package/dist/index.js
CHANGED
|
@@ -814,8 +814,7 @@ ODBLiteClient.join;
|
|
|
814
814
|
try {
|
|
815
815
|
// Check if database already exists
|
|
816
816
|
console.log(`🔍 Checking if database exists: ${cacheKey}`);
|
|
817
|
-
const
|
|
818
|
-
const existing = databases.find((db)=>db.name === cacheKey);
|
|
817
|
+
const existing = await this.getDatabaseByName(cacheKey);
|
|
819
818
|
if (existing) {
|
|
820
819
|
console.log(`✅ Database already exists: ${cacheKey} (${existing.hash})`);
|
|
821
820
|
this.databaseCache.set(cacheKey, existing.hash);
|
|
@@ -893,6 +892,22 @@ ODBLiteClient.join;
|
|
|
893
892
|
return result.database;
|
|
894
893
|
}
|
|
895
894
|
/**
|
|
895
|
+
* Get database details by name
|
|
896
|
+
*
|
|
897
|
+
* @param name - Database name
|
|
898
|
+
* @returns Database object or null if not found
|
|
899
|
+
*/ async getDatabaseByName(name) {
|
|
900
|
+
const response = await fetch(`${this.apiUrl}/api/tenant/databases/by-name/${name}`, {
|
|
901
|
+
headers: {
|
|
902
|
+
Authorization: `Bearer ${this.apiKey}`
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
if (404 === response.status) return null;
|
|
906
|
+
const result = await response.json();
|
|
907
|
+
if (!result.success) throw new Error(result.error || 'Failed to get database');
|
|
908
|
+
return result.database;
|
|
909
|
+
}
|
|
910
|
+
/**
|
|
896
911
|
* Delete a database
|
|
897
912
|
*
|
|
898
913
|
* @param hash - Database hash to delete
|
|
@@ -97,6 +97,13 @@ export declare class ServiceClient {
|
|
|
97
97
|
* @returns Database object
|
|
98
98
|
*/
|
|
99
99
|
getDatabase(hash: string): Promise<ODBLiteDatabase>;
|
|
100
|
+
/**
|
|
101
|
+
* Get database details by name
|
|
102
|
+
*
|
|
103
|
+
* @param name - Database name
|
|
104
|
+
* @returns Database object or null if not found
|
|
105
|
+
*/
|
|
106
|
+
getDatabaseByName(name: string): Promise<ODBLiteDatabase | null>;
|
|
100
107
|
/**
|
|
101
108
|
* Delete a database
|
|
102
109
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../../src/service/service-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,gEAAgE;IAChE,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,aAAa,CAAsB;gBAE/B,MAAM,EAAE,mBAAmB;IAMvC;;;;;;;;;;;;;;;;;;OAkBG;IACG,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"service-client.d.ts","sourceRoot":"","sources":["../../src/service/service-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,mBAAmB;IAClC,gEAAg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AAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;CAIpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pineliner/odb-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Isomorphic client for ODB-Lite with postgres.js-like template string SQL support",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/bun": "latest",
|
|
21
|
-
"@rslib/core": "
|
|
21
|
+
"@rslib/core": "0.15.0",
|
|
22
22
|
"typescript": "^5.9.2"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
@@ -97,8 +97,7 @@ export class ServiceClient {
|
|
|
97
97
|
try {
|
|
98
98
|
// Check if database already exists
|
|
99
99
|
console.log(`🔍 Checking if database exists: ${cacheKey}`);
|
|
100
|
-
const
|
|
101
|
-
const existing = databases.find(db => db.name === cacheKey);
|
|
100
|
+
const existing = await this.getDatabaseByName(cacheKey);
|
|
102
101
|
|
|
103
102
|
if (existing) {
|
|
104
103
|
console.log(`✅ Database already exists: ${cacheKey} (${existing.hash})`);
|
|
@@ -201,6 +200,31 @@ export class ServiceClient {
|
|
|
201
200
|
return result.database;
|
|
202
201
|
}
|
|
203
202
|
|
|
203
|
+
/**
|
|
204
|
+
* Get database details by name
|
|
205
|
+
*
|
|
206
|
+
* @param name - Database name
|
|
207
|
+
* @returns Database object or null if not found
|
|
208
|
+
*/
|
|
209
|
+
async getDatabaseByName(name: string): Promise<ODBLiteDatabase | null> {
|
|
210
|
+
const response = await fetch(`${this.apiUrl}/api/tenant/databases/by-name/${name}`, {
|
|
211
|
+
headers: {
|
|
212
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
if (response.status === 404) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
const result = await response.json();
|
|
221
|
+
if (!result.success) {
|
|
222
|
+
throw new Error(result.error || 'Failed to get database');
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return result.database;
|
|
226
|
+
}
|
|
227
|
+
|
|
204
228
|
/**
|
|
205
229
|
* Delete a database
|
|
206
230
|
*
|