@opendatalabs/personal-server-ts-core 0.0.1-canary.2eea97d → 0.0.1-canary.5bb2160

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.
@@ -1,5 +1,12 @@
1
- export declare const DEFAULT_VANA_DIR: string;
2
- export declare const DEFAULT_SERVER_DIR: string;
1
+ export declare const DEFAULT_ROOT_PATH: string;
3
2
  export declare const DEFAULT_DATA_DIR: string;
4
3
  export declare const DEFAULT_CONFIG_PATH: string;
4
+ /**
5
+ * @deprecated Use DEFAULT_ROOT_PATH instead.
6
+ */
7
+ export declare const DEFAULT_VANA_DIR: string;
8
+ /**
9
+ * @deprecated Use DEFAULT_ROOT_PATH instead.
10
+ */
11
+ export declare const DEFAULT_SERVER_DIR: string;
5
12
  //# sourceMappingURL=defaults.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,QAA2B,CAAC;AACzD,eAAO,MAAM,kBAAkB,QAAmC,CAAC;AACnE,eAAO,MAAM,gBAAgB,QAAiC,CAAC;AAC/D,eAAO,MAAM,mBAAmB,QAA0C,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,QAAqC,CAAC;AACpE,eAAO,MAAM,gBAAgB,QAAkC,CAAC;AAChE,eAAO,MAAM,mBAAmB,QAAyC,CAAC;AAE1E;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAoB,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAoB,CAAC"}
@@ -1,7 +1,14 @@
1
1
  import { join } from "node:path";
2
2
  import { homedir } from "node:os";
3
- export const DEFAULT_VANA_DIR = join(homedir(), ".vana");
4
- export const DEFAULT_SERVER_DIR = join(DEFAULT_VANA_DIR, "server");
5
- export const DEFAULT_DATA_DIR = join(DEFAULT_VANA_DIR, "data");
6
- export const DEFAULT_CONFIG_PATH = join(DEFAULT_SERVER_DIR, "config.json");
3
+ export const DEFAULT_ROOT_PATH = join(homedir(), "personal-server");
4
+ export const DEFAULT_DATA_DIR = join(DEFAULT_ROOT_PATH, "data");
5
+ export const DEFAULT_CONFIG_PATH = join(DEFAULT_ROOT_PATH, "config.json");
6
+ /**
7
+ * @deprecated Use DEFAULT_ROOT_PATH instead.
8
+ */
9
+ export const DEFAULT_VANA_DIR = DEFAULT_ROOT_PATH;
10
+ /**
11
+ * @deprecated Use DEFAULT_ROOT_PATH instead.
12
+ */
13
+ export const DEFAULT_SERVER_DIR = DEFAULT_ROOT_PATH;
7
14
  //# sourceMappingURL=defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AACzD,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,kBAAkB,EAAE,aAAa,CAAC,CAAC"}
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,iBAAiB,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;AAChE,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAE1E;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAC"}
@@ -1,3 +1,4 @@
1
- export { DEFAULT_VANA_DIR, DEFAULT_SERVER_DIR, DEFAULT_DATA_DIR, DEFAULT_CONFIG_PATH, } from "./defaults.js";
1
+ export { DEFAULT_ROOT_PATH, DEFAULT_VANA_DIR, DEFAULT_SERVER_DIR, DEFAULT_DATA_DIR, DEFAULT_CONFIG_PATH, } from "./defaults.js";
2
2
  export { loadConfig, saveConfig, type LoadConfigOptions } from "./loader.js";
3
+ export { expandHomePath, resolveRootPath } from "./paths.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -1,3 +1,4 @@
1
- export { DEFAULT_VANA_DIR, DEFAULT_SERVER_DIR, DEFAULT_DATA_DIR, DEFAULT_CONFIG_PATH, } from "./defaults.js";
1
+ export { DEFAULT_ROOT_PATH, DEFAULT_VANA_DIR, DEFAULT_SERVER_DIR, DEFAULT_DATA_DIR, DEFAULT_CONFIG_PATH, } from "./defaults.js";
2
2
  export { loadConfig, saveConfig } from "./loader.js";
3
+ export { expandHomePath, resolveRootPath } from "./paths.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,UAAU,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC"}
@@ -1,9 +1,8 @@
1
1
  import { type ServerConfig } from "../schemas/server-config.js";
2
2
  export interface LoadConfigOptions {
3
3
  configPath?: string;
4
+ rootPath?: string;
4
5
  }
5
6
  export declare function loadConfig(options?: LoadConfigOptions): Promise<ServerConfig>;
6
- export declare function saveConfig(config: ServerConfig, options?: {
7
- configPath?: string;
8
- }): Promise<void>;
7
+ export declare function saveConfig(config: ServerConfig, options?: LoadConfigOptions): Promise<void>;
9
8
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,wBAAsB,UAAU,CAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA6BvB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,IAAI,CAAC,CAIf"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAGrC,MAAM,WAAW,iBAAiB;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,CAAC,CA+BvB;AAED,wBAAsB,UAAU,CAC9B,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAMf"}
@@ -1,9 +1,10 @@
1
1
  import { readFile, writeFile, mkdir } from "node:fs/promises";
2
- import { dirname } from "node:path";
2
+ import { dirname, join } from "node:path";
3
3
  import { ServerConfigSchema, } from "../schemas/server-config.js";
4
- import { DEFAULT_CONFIG_PATH } from "./defaults.js";
4
+ import { resolveRootPath } from "./paths.js";
5
5
  export async function loadConfig(options) {
6
- const configPath = options?.configPath ?? DEFAULT_CONFIG_PATH;
6
+ const configPath = options?.configPath ??
7
+ join(resolveRootPath(options?.rootPath), "config.json");
7
8
  let raw;
8
9
  try {
9
10
  raw = await readFile(configPath, "utf-8");
@@ -29,7 +30,8 @@ export async function loadConfig(options) {
29
30
  return config;
30
31
  }
31
32
  export async function saveConfig(config, options) {
32
- const configPath = options?.configPath ?? DEFAULT_CONFIG_PATH;
33
+ const configPath = options?.configPath ??
34
+ join(resolveRootPath(options?.rootPath), "config.json");
33
35
  await mkdir(dirname(configPath), { recursive: true });
34
36
  await writeFile(configPath, JSON.stringify(config, null, 2) + "\n", "utf-8");
35
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/config/loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,kBAAkB,GAEnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAMpD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAA2B;IAE3B,MAAM,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,mBAAmB,CAAC;IAE9D,IAAI,GAAuB,CAAC;IAC5B,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,GAAY,EAAE,CAAC;QACtB,IACE,GAAG,YAAY,KAAK;YACpB,MAAM,IAAI,GAAG;YACZ,GAA6B,CAAC,IAAI,KAAK,QAAQ,EAChD,CAAC;YACD,0DAA0D;QAC5D,CAAC;aAAM,CAAC;YACN,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEhD,sEAAsE;IACtE,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GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Expands a leading "~" to the current user's home directory.
3
+ */
4
+ export declare function expandHomePath(input: string): string;
5
+ /**
6
+ * Resolves the configured root path (or default) to an absolute path.
7
+ */
8
+ export declare function resolveRootPath(input?: string): string;
9
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,22 @@
1
+ import { homedir } from "node:os";
2
+ import { resolve } from "node:path";
3
+ import { DEFAULT_ROOT_PATH } from "./defaults.js";
4
+ /**
5
+ * Expands a leading "~" to the current user's home directory.
6
+ */
7
+ export function expandHomePath(input) {
8
+ if (input === "~") {
9
+ return homedir();
10
+ }
11
+ if (input.startsWith("~/")) {
12
+ return resolve(homedir(), input.slice(2));
13
+ }
14
+ return input;
15
+ }
16
+ /**
17
+ * Resolves the configured root path (or default) to an absolute path.
18
+ */
19
+ export function resolveRootPath(input) {
20
+ return resolve(expandHomePath(input ?? DEFAULT_ROOT_PATH));
21
+ }
22
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/config/paths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,GAAG,EAAE,CAAC;QAClB,OAAO,OAAO,EAAE,CAAC;IACnB,CAAC;IACD,IAAI,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,OAAO,CAAC,cAAc,CAAC,KAAK,IAAI,iBAAiB,CAAC,CAAC,CAAC;AAC7D,CAAC"}
@@ -1,11 +1,11 @@
1
1
  export interface SyncCursor {
2
- /** Read the lastProcessedTimestamp from server.json */
2
+ /** Read the lastProcessedTimestamp from config.json */
3
3
  read(): Promise<string | null>;
4
- /** Write the lastProcessedTimestamp to server.json */
4
+ /** Write the lastProcessedTimestamp to config.json */
5
5
  write(timestamp: string): Promise<void>;
6
6
  }
7
7
  /**
8
- * Creates a cursor that reads/writes sync.lastProcessedTimestamp in server.json.
8
+ * Creates a cursor that reads/writes sync.lastProcessedTimestamp in config.json.
9
9
  * Uses loadConfig/saveConfig to preserve other config fields.
10
10
  */
11
11
  export declare function createSyncCursor(configPath: string): SyncCursor;
@@ -1,6 +1,6 @@
1
1
  import { loadConfig, saveConfig } from "../config/index.js";
2
2
  /**
3
- * Creates a cursor that reads/writes sync.lastProcessedTimestamp in server.json.
3
+ * Creates a cursor that reads/writes sync.lastProcessedTimestamp in config.json.
4
4
  * Uses loadConfig/saveConfig to preserve other config fields.
5
5
  */
6
6
  export function createSyncCursor(configPath) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/personal-server-ts-core",
3
- "version": "0.0.1-canary.2eea97d",
3
+ "version": "0.0.1-canary.5bb2160",
4
4
  "description": "Protocol logic for the Vana Personal Server — auth, grants, scopes, storage, keys",
5
5
  "license": "MIT",
6
6
  "repository": {