@hasna/files 0.2.11 → 0.2.13
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/cli/index.js +40 -28
- package/dist/index.js +36 -22
- package/dist/mcp/index.js +38 -23
- package/dist/server/index.js +38 -23
- package/package.json +2 -2
package/dist/cli/index.js
CHANGED
|
@@ -2098,10 +2098,21 @@ function resolveDataDir() {
|
|
|
2098
2098
|
}
|
|
2099
2099
|
return newDir;
|
|
2100
2100
|
}
|
|
2101
|
+
function getDataDir() {
|
|
2102
|
+
const dir = resolveDataDir();
|
|
2103
|
+
mkdirSync(dir, { recursive: true });
|
|
2104
|
+
return dir;
|
|
2105
|
+
}
|
|
2106
|
+
function getDbPath() {
|
|
2107
|
+
return process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join(getDataDir(), "files.db");
|
|
2108
|
+
}
|
|
2101
2109
|
function getDb() {
|
|
2102
|
-
|
|
2110
|
+
const dbPath = getDbPath();
|
|
2111
|
+
if (_db && _dbPath === dbPath)
|
|
2103
2112
|
return _db;
|
|
2104
|
-
_db
|
|
2113
|
+
_db?.close();
|
|
2114
|
+
_db = new Database(dbPath, { create: true });
|
|
2115
|
+
_dbPath = dbPath;
|
|
2105
2116
|
_db.exec("PRAGMA busy_timeout=5000");
|
|
2106
2117
|
_db.exec("PRAGMA journal_mode=WAL");
|
|
2107
2118
|
_db.exec("PRAGMA foreign_keys=ON");
|
|
@@ -2147,7 +2158,7 @@ function migrate(db) {
|
|
|
2147
2158
|
})();
|
|
2148
2159
|
}
|
|
2149
2160
|
}
|
|
2150
|
-
var
|
|
2161
|
+
var _db = null, _dbPath = null, DB_PATH, migration_v1 = `
|
|
2151
2162
|
CREATE TABLE IF NOT EXISTS machines (
|
|
2152
2163
|
id TEXT PRIMARY KEY,
|
|
2153
2164
|
name TEXT NOT NULL,
|
|
@@ -2472,9 +2483,7 @@ var DATA_DIR, DB_PATH, _db = null, migration_v1 = `
|
|
|
2472
2483
|
ON google_drive_imported_objects(destination_source_id);
|
|
2473
2484
|
`;
|
|
2474
2485
|
var init_database = __esm(() => {
|
|
2475
|
-
|
|
2476
|
-
mkdirSync(DATA_DIR, { recursive: true });
|
|
2477
|
-
DB_PATH = process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join(DATA_DIR, "files.db");
|
|
2486
|
+
DB_PATH = getDbPath();
|
|
2478
2487
|
});
|
|
2479
2488
|
|
|
2480
2489
|
// node_modules/nanoid/url-alphabet/index.js
|
|
@@ -133798,8 +133807,9 @@ function resolveDataDir2() {
|
|
|
133798
133807
|
}
|
|
133799
133808
|
return newDir;
|
|
133800
133809
|
}
|
|
133801
|
-
|
|
133802
|
-
|
|
133810
|
+
function getConfigPath() {
|
|
133811
|
+
return join2(resolveDataDir2(), "config.json");
|
|
133812
|
+
}
|
|
133803
133813
|
var DEFAULTS = {
|
|
133804
133814
|
auto_watch: false,
|
|
133805
133815
|
hash_skip_bytes: 0,
|
|
@@ -133808,17 +133818,19 @@ var DEFAULTS = {
|
|
|
133808
133818
|
google_drive_default_destination_source_id: ""
|
|
133809
133819
|
};
|
|
133810
133820
|
function loadConfig() {
|
|
133811
|
-
|
|
133821
|
+
const configPath = getConfigPath();
|
|
133822
|
+
if (!existsSync2(configPath))
|
|
133812
133823
|
return { ...DEFAULTS };
|
|
133813
133824
|
try {
|
|
133814
|
-
return { ...DEFAULTS, ...JSON.parse(readFileSync(
|
|
133825
|
+
return { ...DEFAULTS, ...JSON.parse(readFileSync(configPath, "utf8")) };
|
|
133815
133826
|
} catch {
|
|
133816
133827
|
return { ...DEFAULTS };
|
|
133817
133828
|
}
|
|
133818
133829
|
}
|
|
133819
133830
|
function saveConfig(cfg) {
|
|
133820
|
-
|
|
133821
|
-
|
|
133831
|
+
const dataDir = resolveDataDir2();
|
|
133832
|
+
mkdirSync2(dataDir, { recursive: true });
|
|
133833
|
+
writeFileSync(getConfigPath(), JSON.stringify(cfg, null, 2) + `
|
|
133822
133834
|
`);
|
|
133823
133835
|
}
|
|
133824
133836
|
function setConfigValue(key, value) {
|
|
@@ -133838,7 +133850,7 @@ function setConfigValue(key, value) {
|
|
|
133838
133850
|
}
|
|
133839
133851
|
saveConfig(cfg);
|
|
133840
133852
|
}
|
|
133841
|
-
var CONFIG_PATH_EXPORT =
|
|
133853
|
+
var CONFIG_PATH_EXPORT = getConfigPath();
|
|
133842
133854
|
|
|
133843
133855
|
// src/lib/indexer.ts
|
|
133844
133856
|
init_mime_types();
|
|
@@ -149312,7 +149324,7 @@ function extractGoogleError(body) {
|
|
|
149312
149324
|
}
|
|
149313
149325
|
var package_default2 = {
|
|
149314
149326
|
name: "@hasna/connectors",
|
|
149315
|
-
version: "1.3.
|
|
149327
|
+
version: "1.3.29",
|
|
149316
149328
|
description: "Open source connector library - Install API connectors with a single command",
|
|
149317
149329
|
type: "module",
|
|
149318
149330
|
bin: {
|
|
@@ -158560,13 +158572,13 @@ var init_zod = __esm2(() => {
|
|
|
158560
158572
|
init_external();
|
|
158561
158573
|
init_external();
|
|
158562
158574
|
});
|
|
158563
|
-
function
|
|
158575
|
+
function getDataDir2(serviceName) {
|
|
158564
158576
|
const dir = join42(HASNA_DIR, serviceName);
|
|
158565
158577
|
mkdirSync32(dir, { recursive: true });
|
|
158566
158578
|
return dir;
|
|
158567
158579
|
}
|
|
158568
|
-
function
|
|
158569
|
-
const dir =
|
|
158580
|
+
function getDbPath2(serviceName) {
|
|
158581
|
+
const dir = getDataDir2(serviceName);
|
|
158570
158582
|
return join42(dir, `${serviceName}.db`);
|
|
158571
158583
|
}
|
|
158572
158584
|
var HASNA_DIR;
|
|
@@ -158577,7 +158589,7 @@ var exports_config = {};
|
|
|
158577
158589
|
__export22(exports_config, {
|
|
158578
158590
|
saveCloudConfig: () => saveCloudConfig,
|
|
158579
158591
|
getConnectionString: () => getConnectionString,
|
|
158580
|
-
getConfigPath: () =>
|
|
158592
|
+
getConfigPath: () => getConfigPath2,
|
|
158581
158593
|
getConfigDir: () => getConfigDir,
|
|
158582
158594
|
getCloudConfig: () => getCloudConfig,
|
|
158583
158595
|
createDatabase: () => createDatabase,
|
|
@@ -158586,15 +158598,15 @@ __export22(exports_config, {
|
|
|
158586
158598
|
function getConfigDir() {
|
|
158587
158599
|
return CONFIG_DIR;
|
|
158588
158600
|
}
|
|
158589
|
-
function
|
|
158590
|
-
return
|
|
158601
|
+
function getConfigPath2() {
|
|
158602
|
+
return CONFIG_PATH;
|
|
158591
158603
|
}
|
|
158592
158604
|
function getCloudConfig() {
|
|
158593
|
-
if (!existsSync222(
|
|
158605
|
+
if (!existsSync222(CONFIG_PATH)) {
|
|
158594
158606
|
return CloudConfigSchema.parse({});
|
|
158595
158607
|
}
|
|
158596
158608
|
try {
|
|
158597
|
-
const raw = readFileSync32(
|
|
158609
|
+
const raw = readFileSync32(CONFIG_PATH, "utf-8");
|
|
158598
158610
|
return CloudConfigSchema.parse(JSON.parse(raw));
|
|
158599
158611
|
} catch {
|
|
158600
158612
|
return CloudConfigSchema.parse({});
|
|
@@ -158602,7 +158614,7 @@ function getCloudConfig() {
|
|
|
158602
158614
|
}
|
|
158603
158615
|
function saveCloudConfig(config9) {
|
|
158604
158616
|
mkdirSync222(CONFIG_DIR, { recursive: true });
|
|
158605
|
-
writeFileSync3(
|
|
158617
|
+
writeFileSync3(CONFIG_PATH, JSON.stringify(config9, null, 2) + `
|
|
158606
158618
|
`, "utf-8");
|
|
158607
158619
|
}
|
|
158608
158620
|
function getConnectionString(dbName) {
|
|
@@ -158625,12 +158637,12 @@ function createDatabase(options) {
|
|
|
158625
158637
|
const connStr = options.pgConnectionString ?? getConnectionString(options.service);
|
|
158626
158638
|
return new PgAdapter(connStr);
|
|
158627
158639
|
}
|
|
158628
|
-
const dbPath = options.sqlitePath ??
|
|
158640
|
+
const dbPath = options.sqlitePath ?? getDbPath2(options.service);
|
|
158629
158641
|
return new SqliteAdapter(dbPath);
|
|
158630
158642
|
}
|
|
158631
158643
|
var CloudConfigSchema;
|
|
158632
158644
|
var CONFIG_DIR;
|
|
158633
|
-
var
|
|
158645
|
+
var CONFIG_PATH;
|
|
158634
158646
|
var init_config = __esm2(() => {
|
|
158635
158647
|
init_zod();
|
|
158636
158648
|
init_adapter();
|
|
@@ -158651,7 +158663,7 @@ var init_config = __esm2(() => {
|
|
|
158651
158663
|
}).default({})
|
|
158652
158664
|
});
|
|
158653
158665
|
CONFIG_DIR = join222(homedir222(), ".hasna", "cloud");
|
|
158654
|
-
|
|
158666
|
+
CONFIG_PATH = join222(CONFIG_DIR, "config.json");
|
|
158655
158667
|
});
|
|
158656
158668
|
var exports_discover = {};
|
|
158657
158669
|
__export22(exports_discover, {
|
|
@@ -168778,7 +168790,7 @@ var config9 = program2.command("config").description("Manage configuration");
|
|
|
168778
168790
|
config9.command("list").alias("ls").description("Show all config values").action(() => {
|
|
168779
168791
|
const cfg = loadConfig();
|
|
168780
168792
|
console.log(chalk.bold(`
|
|
168781
|
-
Config: ${
|
|
168793
|
+
Config: ${getConfigPath()}
|
|
168782
168794
|
`));
|
|
168783
168795
|
for (const [k3, v2] of Object.entries(cfg)) {
|
|
168784
168796
|
console.log(` ${chalk.cyan(k3.padEnd(24))} ${JSON.stringify(v2)}`);
|
|
@@ -168803,7 +168815,7 @@ config9.command("set <key> <value>").description("Set a config value (auto_watch
|
|
|
168803
168815
|
process.exit(1);
|
|
168804
168816
|
}
|
|
168805
168817
|
});
|
|
168806
|
-
program2.command("db").description("Show database path").action(() => console.log(
|
|
168818
|
+
program2.command("db").description("Show database path").action(() => console.log(getDbPath()));
|
|
168807
168819
|
function getOpenCommand(fullPath) {
|
|
168808
168820
|
if (process.platform === "darwin")
|
|
168809
168821
|
return ["open", fullPath];
|
package/dist/index.js
CHANGED
|
@@ -128628,14 +128628,24 @@ function resolveDataDir() {
|
|
|
128628
128628
|
}
|
|
128629
128629
|
return newDir;
|
|
128630
128630
|
}
|
|
128631
|
-
|
|
128632
|
-
|
|
128633
|
-
|
|
128631
|
+
function getDataDir() {
|
|
128632
|
+
const dir = resolveDataDir();
|
|
128633
|
+
mkdirSync(dir, { recursive: true });
|
|
128634
|
+
return dir;
|
|
128635
|
+
}
|
|
128636
|
+
function getDbPath() {
|
|
128637
|
+
return process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join(getDataDir(), "files.db");
|
|
128638
|
+
}
|
|
128634
128639
|
var _db = null;
|
|
128640
|
+
var _dbPath = null;
|
|
128641
|
+
var DB_PATH = getDbPath();
|
|
128635
128642
|
function getDb() {
|
|
128636
|
-
|
|
128643
|
+
const dbPath = getDbPath();
|
|
128644
|
+
if (_db && _dbPath === dbPath)
|
|
128637
128645
|
return _db;
|
|
128638
|
-
_db
|
|
128646
|
+
_db?.close();
|
|
128647
|
+
_db = new Database(dbPath, { create: true });
|
|
128648
|
+
_dbPath = dbPath;
|
|
128639
128649
|
_db.exec("PRAGMA busy_timeout=5000");
|
|
128640
128650
|
_db.exec("PRAGMA journal_mode=WAL");
|
|
128641
128651
|
_db.exec("PRAGMA foreign_keys=ON");
|
|
@@ -130662,8 +130672,9 @@ function resolveDataDir2() {
|
|
|
130662
130672
|
}
|
|
130663
130673
|
return newDir;
|
|
130664
130674
|
}
|
|
130665
|
-
|
|
130666
|
-
|
|
130675
|
+
function getConfigPath() {
|
|
130676
|
+
return join4(resolveDataDir2(), "config.json");
|
|
130677
|
+
}
|
|
130667
130678
|
var DEFAULTS = {
|
|
130668
130679
|
auto_watch: false,
|
|
130669
130680
|
hash_skip_bytes: 0,
|
|
@@ -130672,14 +130683,16 @@ var DEFAULTS = {
|
|
|
130672
130683
|
google_drive_default_destination_source_id: ""
|
|
130673
130684
|
};
|
|
130674
130685
|
function loadConfig() {
|
|
130675
|
-
|
|
130686
|
+
const configPath = getConfigPath();
|
|
130687
|
+
if (!existsSync4(configPath))
|
|
130676
130688
|
return { ...DEFAULTS };
|
|
130677
130689
|
try {
|
|
130678
|
-
return { ...DEFAULTS, ...JSON.parse(readFileSync3(
|
|
130690
|
+
return { ...DEFAULTS, ...JSON.parse(readFileSync3(configPath, "utf8")) };
|
|
130679
130691
|
} catch {
|
|
130680
130692
|
return { ...DEFAULTS };
|
|
130681
130693
|
}
|
|
130682
130694
|
}
|
|
130695
|
+
var CONFIG_PATH_EXPORT = getConfigPath();
|
|
130683
130696
|
|
|
130684
130697
|
// node_modules/@aws-sdk/middleware-expect-continue/dist-es/index.js
|
|
130685
130698
|
var import_protocol_http = __toESM(require_dist_cjs2(), 1);
|
|
@@ -145901,7 +145914,7 @@ function extractGoogleError(body) {
|
|
|
145901
145914
|
}
|
|
145902
145915
|
var package_default2 = {
|
|
145903
145916
|
name: "@hasna/connectors",
|
|
145904
|
-
version: "1.3.
|
|
145917
|
+
version: "1.3.29",
|
|
145905
145918
|
description: "Open source connector library - Install API connectors with a single command",
|
|
145906
145919
|
type: "module",
|
|
145907
145920
|
bin: {
|
|
@@ -155149,13 +155162,13 @@ var init_zod = __esm2(() => {
|
|
|
155149
155162
|
init_external();
|
|
155150
155163
|
init_external();
|
|
155151
155164
|
});
|
|
155152
|
-
function
|
|
155165
|
+
function getDataDir2(serviceName) {
|
|
155153
155166
|
const dir = join42(HASNA_DIR, serviceName);
|
|
155154
155167
|
mkdirSync32(dir, { recursive: true });
|
|
155155
155168
|
return dir;
|
|
155156
155169
|
}
|
|
155157
|
-
function
|
|
155158
|
-
const dir =
|
|
155170
|
+
function getDbPath2(serviceName) {
|
|
155171
|
+
const dir = getDataDir2(serviceName);
|
|
155159
155172
|
return join42(dir, `${serviceName}.db`);
|
|
155160
155173
|
}
|
|
155161
155174
|
var HASNA_DIR;
|
|
@@ -155166,7 +155179,7 @@ var exports_config = {};
|
|
|
155166
155179
|
__export22(exports_config, {
|
|
155167
155180
|
saveCloudConfig: () => saveCloudConfig,
|
|
155168
155181
|
getConnectionString: () => getConnectionString,
|
|
155169
|
-
getConfigPath: () =>
|
|
155182
|
+
getConfigPath: () => getConfigPath2,
|
|
155170
155183
|
getConfigDir: () => getConfigDir,
|
|
155171
155184
|
getCloudConfig: () => getCloudConfig,
|
|
155172
155185
|
createDatabase: () => createDatabase,
|
|
@@ -155175,15 +155188,15 @@ __export22(exports_config, {
|
|
|
155175
155188
|
function getConfigDir() {
|
|
155176
155189
|
return CONFIG_DIR;
|
|
155177
155190
|
}
|
|
155178
|
-
function
|
|
155179
|
-
return
|
|
155191
|
+
function getConfigPath2() {
|
|
155192
|
+
return CONFIG_PATH;
|
|
155180
155193
|
}
|
|
155181
155194
|
function getCloudConfig() {
|
|
155182
|
-
if (!existsSync222(
|
|
155195
|
+
if (!existsSync222(CONFIG_PATH)) {
|
|
155183
155196
|
return CloudConfigSchema.parse({});
|
|
155184
155197
|
}
|
|
155185
155198
|
try {
|
|
155186
|
-
const raw = readFileSync32(
|
|
155199
|
+
const raw = readFileSync32(CONFIG_PATH, "utf-8");
|
|
155187
155200
|
return CloudConfigSchema.parse(JSON.parse(raw));
|
|
155188
155201
|
} catch {
|
|
155189
155202
|
return CloudConfigSchema.parse({});
|
|
@@ -155191,7 +155204,7 @@ function getCloudConfig() {
|
|
|
155191
155204
|
}
|
|
155192
155205
|
function saveCloudConfig(config9) {
|
|
155193
155206
|
mkdirSync222(CONFIG_DIR, { recursive: true });
|
|
155194
|
-
writeFileSync3(
|
|
155207
|
+
writeFileSync3(CONFIG_PATH, JSON.stringify(config9, null, 2) + `
|
|
155195
155208
|
`, "utf-8");
|
|
155196
155209
|
}
|
|
155197
155210
|
function getConnectionString(dbName) {
|
|
@@ -155214,12 +155227,12 @@ function createDatabase(options) {
|
|
|
155214
155227
|
const connStr = options.pgConnectionString ?? getConnectionString(options.service);
|
|
155215
155228
|
return new PgAdapter(connStr);
|
|
155216
155229
|
}
|
|
155217
|
-
const dbPath = options.sqlitePath ??
|
|
155230
|
+
const dbPath = options.sqlitePath ?? getDbPath2(options.service);
|
|
155218
155231
|
return new SqliteAdapter(dbPath);
|
|
155219
155232
|
}
|
|
155220
155233
|
var CloudConfigSchema;
|
|
155221
155234
|
var CONFIG_DIR;
|
|
155222
|
-
var
|
|
155235
|
+
var CONFIG_PATH;
|
|
155223
155236
|
var init_config = __esm2(() => {
|
|
155224
155237
|
init_zod();
|
|
155225
155238
|
init_adapter();
|
|
@@ -155240,7 +155253,7 @@ var init_config = __esm2(() => {
|
|
|
155240
155253
|
}).default({})
|
|
155241
155254
|
});
|
|
155242
155255
|
CONFIG_DIR = join222(homedir222(), ".hasna", "cloud");
|
|
155243
|
-
|
|
155256
|
+
CONFIG_PATH = join222(CONFIG_DIR, "config.json");
|
|
155244
155257
|
});
|
|
155245
155258
|
var exports_discover = {};
|
|
155246
155259
|
__export22(exports_discover, {
|
|
@@ -166245,6 +166258,7 @@ export {
|
|
|
166245
166258
|
getFileHistory,
|
|
166246
166259
|
getFileByPath,
|
|
166247
166260
|
getFile,
|
|
166261
|
+
getDbPath,
|
|
166248
166262
|
getDb,
|
|
166249
166263
|
getCurrentMachine,
|
|
166250
166264
|
getCollection,
|
package/dist/mcp/index.js
CHANGED
|
@@ -50,7 +50,9 @@ var __require = import.meta.require;
|
|
|
50
50
|
// src/db/database.ts
|
|
51
51
|
var exports_database = {};
|
|
52
52
|
__export(exports_database, {
|
|
53
|
+
getDbPath: () => getDbPath2,
|
|
53
54
|
getDb: () => getDb,
|
|
55
|
+
getDataDir: () => getDataDir2,
|
|
54
56
|
closeDb: () => closeDb,
|
|
55
57
|
DB_PATH: () => DB_PATH
|
|
56
58
|
});
|
|
@@ -70,10 +72,21 @@ function resolveDataDir() {
|
|
|
70
72
|
}
|
|
71
73
|
return newDir;
|
|
72
74
|
}
|
|
75
|
+
function getDataDir2() {
|
|
76
|
+
const dir = resolveDataDir();
|
|
77
|
+
mkdirSync3(dir, { recursive: true });
|
|
78
|
+
return dir;
|
|
79
|
+
}
|
|
80
|
+
function getDbPath2() {
|
|
81
|
+
return process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join5(getDataDir2(), "files.db");
|
|
82
|
+
}
|
|
73
83
|
function getDb() {
|
|
74
|
-
|
|
84
|
+
const dbPath = getDbPath2();
|
|
85
|
+
if (_db && _dbPath === dbPath)
|
|
75
86
|
return _db;
|
|
76
|
-
_db
|
|
87
|
+
_db?.close();
|
|
88
|
+
_db = new Database2(dbPath, { create: true });
|
|
89
|
+
_dbPath = dbPath;
|
|
77
90
|
_db.exec("PRAGMA busy_timeout=5000");
|
|
78
91
|
_db.exec("PRAGMA journal_mode=WAL");
|
|
79
92
|
_db.exec("PRAGMA foreign_keys=ON");
|
|
@@ -122,8 +135,9 @@ function migrate(db) {
|
|
|
122
135
|
function closeDb() {
|
|
123
136
|
_db?.close();
|
|
124
137
|
_db = null;
|
|
138
|
+
_dbPath = null;
|
|
125
139
|
}
|
|
126
|
-
var
|
|
140
|
+
var _db = null, _dbPath = null, DB_PATH, migration_v1 = `
|
|
127
141
|
CREATE TABLE IF NOT EXISTS machines (
|
|
128
142
|
id TEXT PRIMARY KEY,
|
|
129
143
|
name TEXT NOT NULL,
|
|
@@ -448,9 +462,7 @@ var DATA_DIR, DB_PATH, _db = null, migration_v1 = `
|
|
|
448
462
|
ON google_drive_imported_objects(destination_source_id);
|
|
449
463
|
`;
|
|
450
464
|
var init_database = __esm(() => {
|
|
451
|
-
|
|
452
|
-
mkdirSync3(DATA_DIR, { recursive: true });
|
|
453
|
-
DB_PATH = process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join5(DATA_DIR, "files.db");
|
|
465
|
+
DB_PATH = getDbPath2();
|
|
454
466
|
});
|
|
455
467
|
|
|
456
468
|
// node_modules/nanoid/url-alphabet/index.js
|
|
@@ -159076,8 +159088,9 @@ function resolveDataDir2() {
|
|
|
159076
159088
|
}
|
|
159077
159089
|
return newDir;
|
|
159078
159090
|
}
|
|
159079
|
-
|
|
159080
|
-
|
|
159091
|
+
function getConfigPath2() {
|
|
159092
|
+
return join9(resolveDataDir2(), "config.json");
|
|
159093
|
+
}
|
|
159081
159094
|
var DEFAULTS = {
|
|
159082
159095
|
auto_watch: false,
|
|
159083
159096
|
hash_skip_bytes: 0,
|
|
@@ -159086,14 +159099,16 @@ var DEFAULTS = {
|
|
|
159086
159099
|
google_drive_default_destination_source_id: ""
|
|
159087
159100
|
};
|
|
159088
159101
|
function loadConfig() {
|
|
159089
|
-
|
|
159102
|
+
const configPath = getConfigPath2();
|
|
159103
|
+
if (!existsSync8(configPath))
|
|
159090
159104
|
return { ...DEFAULTS };
|
|
159091
159105
|
try {
|
|
159092
|
-
return { ...DEFAULTS, ...JSON.parse(readFileSync4(
|
|
159106
|
+
return { ...DEFAULTS, ...JSON.parse(readFileSync4(configPath, "utf8")) };
|
|
159093
159107
|
} catch {
|
|
159094
159108
|
return { ...DEFAULTS };
|
|
159095
159109
|
}
|
|
159096
159110
|
}
|
|
159111
|
+
var CONFIG_PATH_EXPORT = getConfigPath2();
|
|
159097
159112
|
|
|
159098
159113
|
// src/lib/google-drive.ts
|
|
159099
159114
|
init_s3();
|
|
@@ -164838,7 +164853,7 @@ function extractGoogleError(body) {
|
|
|
164838
164853
|
}
|
|
164839
164854
|
var package_default2 = {
|
|
164840
164855
|
name: "@hasna/connectors",
|
|
164841
|
-
version: "1.3.
|
|
164856
|
+
version: "1.3.29",
|
|
164842
164857
|
description: "Open source connector library - Install API connectors with a single command",
|
|
164843
164858
|
type: "module",
|
|
164844
164859
|
bin: {
|
|
@@ -174086,13 +174101,13 @@ var init_zod2 = __esm3(() => {
|
|
|
174086
174101
|
init_external2();
|
|
174087
174102
|
init_external2();
|
|
174088
174103
|
});
|
|
174089
|
-
function
|
|
174104
|
+
function getDataDir3(serviceName) {
|
|
174090
174105
|
const dir = join42(HASNA_DIR2, serviceName);
|
|
174091
174106
|
mkdirSync32(dir, { recursive: true });
|
|
174092
174107
|
return dir;
|
|
174093
174108
|
}
|
|
174094
|
-
function
|
|
174095
|
-
const dir =
|
|
174109
|
+
function getDbPath3(serviceName) {
|
|
174110
|
+
const dir = getDataDir3(serviceName);
|
|
174096
174111
|
return join42(dir, `${serviceName}.db`);
|
|
174097
174112
|
}
|
|
174098
174113
|
var HASNA_DIR2;
|
|
@@ -174103,7 +174118,7 @@ var exports_config2 = {};
|
|
|
174103
174118
|
__export22(exports_config2, {
|
|
174104
174119
|
saveCloudConfig: () => saveCloudConfig2,
|
|
174105
174120
|
getConnectionString: () => getConnectionString2,
|
|
174106
|
-
getConfigPath: () =>
|
|
174121
|
+
getConfigPath: () => getConfigPath3,
|
|
174107
174122
|
getConfigDir: () => getConfigDir2,
|
|
174108
174123
|
getCloudConfig: () => getCloudConfig2,
|
|
174109
174124
|
createDatabase: () => createDatabase2,
|
|
@@ -174112,15 +174127,15 @@ __export22(exports_config2, {
|
|
|
174112
174127
|
function getConfigDir2() {
|
|
174113
174128
|
return CONFIG_DIR3;
|
|
174114
174129
|
}
|
|
174115
|
-
function
|
|
174116
|
-
return
|
|
174130
|
+
function getConfigPath3() {
|
|
174131
|
+
return CONFIG_PATH2;
|
|
174117
174132
|
}
|
|
174118
174133
|
function getCloudConfig2() {
|
|
174119
|
-
if (!existsSync222(
|
|
174134
|
+
if (!existsSync222(CONFIG_PATH2)) {
|
|
174120
174135
|
return CloudConfigSchema2.parse({});
|
|
174121
174136
|
}
|
|
174122
174137
|
try {
|
|
174123
|
-
const raw = readFileSync32(
|
|
174138
|
+
const raw = readFileSync32(CONFIG_PATH2, "utf-8");
|
|
174124
174139
|
return CloudConfigSchema2.parse(JSON.parse(raw));
|
|
174125
174140
|
} catch {
|
|
174126
174141
|
return CloudConfigSchema2.parse({});
|
|
@@ -174128,7 +174143,7 @@ function getCloudConfig2() {
|
|
|
174128
174143
|
}
|
|
174129
174144
|
function saveCloudConfig2(config9) {
|
|
174130
174145
|
mkdirSync222(CONFIG_DIR3, { recursive: true });
|
|
174131
|
-
writeFileSync32(
|
|
174146
|
+
writeFileSync32(CONFIG_PATH2, JSON.stringify(config9, null, 2) + `
|
|
174132
174147
|
`, "utf-8");
|
|
174133
174148
|
}
|
|
174134
174149
|
function getConnectionString2(dbName) {
|
|
@@ -174151,12 +174166,12 @@ function createDatabase2(options) {
|
|
|
174151
174166
|
const connStr = options.pgConnectionString ?? getConnectionString2(options.service);
|
|
174152
174167
|
return new PgAdapter2(connStr);
|
|
174153
174168
|
}
|
|
174154
|
-
const dbPath = options.sqlitePath ??
|
|
174169
|
+
const dbPath = options.sqlitePath ?? getDbPath3(options.service);
|
|
174155
174170
|
return new SqliteAdapter2(dbPath);
|
|
174156
174171
|
}
|
|
174157
174172
|
var CloudConfigSchema2;
|
|
174158
174173
|
var CONFIG_DIR3;
|
|
174159
|
-
var
|
|
174174
|
+
var CONFIG_PATH2;
|
|
174160
174175
|
var init_config2 = __esm3(() => {
|
|
174161
174176
|
init_zod2();
|
|
174162
174177
|
init_adapter2();
|
|
@@ -174177,7 +174192,7 @@ var init_config2 = __esm3(() => {
|
|
|
174177
174192
|
}).default({})
|
|
174178
174193
|
});
|
|
174179
174194
|
CONFIG_DIR3 = join222(homedir222(), ".hasna", "cloud");
|
|
174180
|
-
|
|
174195
|
+
CONFIG_PATH2 = join222(CONFIG_DIR3, "config.json");
|
|
174181
174196
|
});
|
|
174182
174197
|
var exports_discover2 = {};
|
|
174183
174198
|
__export22(exports_discover2, {
|
package/dist/server/index.js
CHANGED
|
@@ -50,7 +50,9 @@ var __require = import.meta.require;
|
|
|
50
50
|
// src/db/database.ts
|
|
51
51
|
var exports_database = {};
|
|
52
52
|
__export(exports_database, {
|
|
53
|
+
getDbPath: () => getDbPath,
|
|
53
54
|
getDb: () => getDb,
|
|
55
|
+
getDataDir: () => getDataDir,
|
|
54
56
|
closeDb: () => closeDb,
|
|
55
57
|
DB_PATH: () => DB_PATH
|
|
56
58
|
});
|
|
@@ -70,10 +72,21 @@ function resolveDataDir() {
|
|
|
70
72
|
}
|
|
71
73
|
return newDir;
|
|
72
74
|
}
|
|
75
|
+
function getDataDir() {
|
|
76
|
+
const dir = resolveDataDir();
|
|
77
|
+
mkdirSync(dir, { recursive: true });
|
|
78
|
+
return dir;
|
|
79
|
+
}
|
|
80
|
+
function getDbPath() {
|
|
81
|
+
return process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join(getDataDir(), "files.db");
|
|
82
|
+
}
|
|
73
83
|
function getDb() {
|
|
74
|
-
|
|
84
|
+
const dbPath = getDbPath();
|
|
85
|
+
if (_db && _dbPath === dbPath)
|
|
75
86
|
return _db;
|
|
76
|
-
_db
|
|
87
|
+
_db?.close();
|
|
88
|
+
_db = new Database(dbPath, { create: true });
|
|
89
|
+
_dbPath = dbPath;
|
|
77
90
|
_db.exec("PRAGMA busy_timeout=5000");
|
|
78
91
|
_db.exec("PRAGMA journal_mode=WAL");
|
|
79
92
|
_db.exec("PRAGMA foreign_keys=ON");
|
|
@@ -122,8 +135,9 @@ function migrate(db) {
|
|
|
122
135
|
function closeDb() {
|
|
123
136
|
_db?.close();
|
|
124
137
|
_db = null;
|
|
138
|
+
_dbPath = null;
|
|
125
139
|
}
|
|
126
|
-
var
|
|
140
|
+
var _db = null, _dbPath = null, DB_PATH, migration_v1 = `
|
|
127
141
|
CREATE TABLE IF NOT EXISTS machines (
|
|
128
142
|
id TEXT PRIMARY KEY,
|
|
129
143
|
name TEXT NOT NULL,
|
|
@@ -448,9 +462,7 @@ var DATA_DIR, DB_PATH, _db = null, migration_v1 = `
|
|
|
448
462
|
ON google_drive_imported_objects(destination_source_id);
|
|
449
463
|
`;
|
|
450
464
|
var init_database = __esm(() => {
|
|
451
|
-
|
|
452
|
-
mkdirSync(DATA_DIR, { recursive: true });
|
|
453
|
-
DB_PATH = process.env.HASNA_FILES_DB_PATH ?? process.env.FILES_DB_PATH ?? join(DATA_DIR, "files.db");
|
|
465
|
+
DB_PATH = getDbPath();
|
|
454
466
|
});
|
|
455
467
|
|
|
456
468
|
// node_modules/nanoid/url-alphabet/index.js
|
|
@@ -130477,8 +130489,9 @@ function resolveDataDir2() {
|
|
|
130477
130489
|
}
|
|
130478
130490
|
return newDir;
|
|
130479
130491
|
}
|
|
130480
|
-
|
|
130481
|
-
|
|
130492
|
+
function getConfigPath() {
|
|
130493
|
+
return join4(resolveDataDir2(), "config.json");
|
|
130494
|
+
}
|
|
130482
130495
|
var DEFAULTS = {
|
|
130483
130496
|
auto_watch: false,
|
|
130484
130497
|
hash_skip_bytes: 0,
|
|
@@ -130487,14 +130500,16 @@ var DEFAULTS = {
|
|
|
130487
130500
|
google_drive_default_destination_source_id: ""
|
|
130488
130501
|
};
|
|
130489
130502
|
function loadConfig() {
|
|
130490
|
-
|
|
130503
|
+
const configPath = getConfigPath();
|
|
130504
|
+
if (!existsSync4(configPath))
|
|
130491
130505
|
return { ...DEFAULTS };
|
|
130492
130506
|
try {
|
|
130493
|
-
return { ...DEFAULTS, ...JSON.parse(readFileSync3(
|
|
130507
|
+
return { ...DEFAULTS, ...JSON.parse(readFileSync3(configPath, "utf8")) };
|
|
130494
130508
|
} catch {
|
|
130495
130509
|
return { ...DEFAULTS };
|
|
130496
130510
|
}
|
|
130497
130511
|
}
|
|
130512
|
+
var CONFIG_PATH_EXPORT = getConfigPath();
|
|
130498
130513
|
|
|
130499
130514
|
// node_modules/@aws-sdk/middleware-expect-continue/dist-es/index.js
|
|
130500
130515
|
var import_protocol_http = __toESM(require_dist_cjs2(), 1);
|
|
@@ -145658,7 +145673,7 @@ function extractGoogleError(body) {
|
|
|
145658
145673
|
}
|
|
145659
145674
|
var package_default2 = {
|
|
145660
145675
|
name: "@hasna/connectors",
|
|
145661
|
-
version: "1.3.
|
|
145676
|
+
version: "1.3.29",
|
|
145662
145677
|
description: "Open source connector library - Install API connectors with a single command",
|
|
145663
145678
|
type: "module",
|
|
145664
145679
|
bin: {
|
|
@@ -154906,13 +154921,13 @@ var init_zod = __esm2(() => {
|
|
|
154906
154921
|
init_external();
|
|
154907
154922
|
init_external();
|
|
154908
154923
|
});
|
|
154909
|
-
function
|
|
154924
|
+
function getDataDir2(serviceName) {
|
|
154910
154925
|
const dir = join42(HASNA_DIR, serviceName);
|
|
154911
154926
|
mkdirSync32(dir, { recursive: true });
|
|
154912
154927
|
return dir;
|
|
154913
154928
|
}
|
|
154914
|
-
function
|
|
154915
|
-
const dir =
|
|
154929
|
+
function getDbPath2(serviceName) {
|
|
154930
|
+
const dir = getDataDir2(serviceName);
|
|
154916
154931
|
return join42(dir, `${serviceName}.db`);
|
|
154917
154932
|
}
|
|
154918
154933
|
var HASNA_DIR;
|
|
@@ -154923,7 +154938,7 @@ var exports_config = {};
|
|
|
154923
154938
|
__export22(exports_config, {
|
|
154924
154939
|
saveCloudConfig: () => saveCloudConfig,
|
|
154925
154940
|
getConnectionString: () => getConnectionString,
|
|
154926
|
-
getConfigPath: () =>
|
|
154941
|
+
getConfigPath: () => getConfigPath2,
|
|
154927
154942
|
getConfigDir: () => getConfigDir,
|
|
154928
154943
|
getCloudConfig: () => getCloudConfig,
|
|
154929
154944
|
createDatabase: () => createDatabase,
|
|
@@ -154932,15 +154947,15 @@ __export22(exports_config, {
|
|
|
154932
154947
|
function getConfigDir() {
|
|
154933
154948
|
return CONFIG_DIR;
|
|
154934
154949
|
}
|
|
154935
|
-
function
|
|
154936
|
-
return
|
|
154950
|
+
function getConfigPath2() {
|
|
154951
|
+
return CONFIG_PATH;
|
|
154937
154952
|
}
|
|
154938
154953
|
function getCloudConfig() {
|
|
154939
|
-
if (!existsSync222(
|
|
154954
|
+
if (!existsSync222(CONFIG_PATH)) {
|
|
154940
154955
|
return CloudConfigSchema.parse({});
|
|
154941
154956
|
}
|
|
154942
154957
|
try {
|
|
154943
|
-
const raw = readFileSync32(
|
|
154958
|
+
const raw = readFileSync32(CONFIG_PATH, "utf-8");
|
|
154944
154959
|
return CloudConfigSchema.parse(JSON.parse(raw));
|
|
154945
154960
|
} catch {
|
|
154946
154961
|
return CloudConfigSchema.parse({});
|
|
@@ -154948,7 +154963,7 @@ function getCloudConfig() {
|
|
|
154948
154963
|
}
|
|
154949
154964
|
function saveCloudConfig(config9) {
|
|
154950
154965
|
mkdirSync222(CONFIG_DIR, { recursive: true });
|
|
154951
|
-
writeFileSync3(
|
|
154966
|
+
writeFileSync3(CONFIG_PATH, JSON.stringify(config9, null, 2) + `
|
|
154952
154967
|
`, "utf-8");
|
|
154953
154968
|
}
|
|
154954
154969
|
function getConnectionString(dbName) {
|
|
@@ -154971,12 +154986,12 @@ function createDatabase(options) {
|
|
|
154971
154986
|
const connStr = options.pgConnectionString ?? getConnectionString(options.service);
|
|
154972
154987
|
return new PgAdapter(connStr);
|
|
154973
154988
|
}
|
|
154974
|
-
const dbPath = options.sqlitePath ??
|
|
154989
|
+
const dbPath = options.sqlitePath ?? getDbPath2(options.service);
|
|
154975
154990
|
return new SqliteAdapter(dbPath);
|
|
154976
154991
|
}
|
|
154977
154992
|
var CloudConfigSchema;
|
|
154978
154993
|
var CONFIG_DIR;
|
|
154979
|
-
var
|
|
154994
|
+
var CONFIG_PATH;
|
|
154980
154995
|
var init_config = __esm2(() => {
|
|
154981
154996
|
init_zod();
|
|
154982
154997
|
init_adapter();
|
|
@@ -154997,7 +155012,7 @@ var init_config = __esm2(() => {
|
|
|
154997
155012
|
}).default({})
|
|
154998
155013
|
});
|
|
154999
155014
|
CONFIG_DIR = join222(homedir222(), ".hasna", "cloud");
|
|
155000
|
-
|
|
155015
|
+
CONFIG_PATH = join222(CONFIG_DIR, "config.json");
|
|
155001
155016
|
});
|
|
155002
155017
|
var exports_discover = {};
|
|
155003
155018
|
__export22(exports_discover, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/files",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "Agent-first file management — index local folders and S3 buckets, sync Google Drive, tag, search, and retrieve files via CLI + MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@aws-sdk/lib-storage": "^3.744.0",
|
|
67
67
|
"@aws-sdk/s3-request-presigner": "^3.1009.0",
|
|
68
68
|
"@hasna/cloud": "^0.1.24",
|
|
69
|
-
"@hasna/connectors": "^1.3.
|
|
69
|
+
"@hasna/connectors": "^1.3.29",
|
|
70
70
|
"@modelcontextprotocol/sdk": "^1.10.1",
|
|
71
71
|
"@noble/hashes": "^1.7.2",
|
|
72
72
|
"chalk": "^5.4.1",
|