tauri-plugin-mongoose 0.3.13 → 0.3.14

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.d.mts CHANGED
@@ -13,12 +13,18 @@ interface SaveFileResult {
13
13
  metadata?: Record<string, unknown>;
14
14
  }
15
15
  type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
16
+ type PathObject = {
17
+ path?: unknown;
18
+ filePath?: unknown;
19
+ };
20
+ type PathLike = string | PathObject;
16
21
  declare class Files {
17
22
  name: string;
18
23
  constructor(name: string);
19
- savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
24
+ savePath(path: PathLike, options?: SaveFileOptions): Promise<SaveFileResult>;
20
25
  save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
21
26
  private toBytes;
27
+ private resolvePath;
22
28
  }
23
29
 
24
30
  declare class Time {
package/dist/index.d.ts CHANGED
@@ -13,12 +13,18 @@ interface SaveFileResult {
13
13
  metadata?: Record<string, unknown>;
14
14
  }
15
15
  type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
16
+ type PathObject = {
17
+ path?: unknown;
18
+ filePath?: unknown;
19
+ };
20
+ type PathLike = string | PathObject;
16
21
  declare class Files {
17
22
  name: string;
18
23
  constructor(name: string);
19
- savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
24
+ savePath(path: PathLike, options?: SaveFileOptions): Promise<SaveFileResult>;
20
25
  save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
21
26
  private toBytes;
27
+ private resolvePath;
22
28
  }
23
29
 
24
30
  declare class Time {
package/dist/index.js CHANGED
@@ -38,9 +38,10 @@ var Files = class {
38
38
  this.name = name;
39
39
  }
40
40
  async savePath(path, options = {}) {
41
+ const resolvedPath = this.resolvePath(path);
41
42
  return await (0, import_core.invoke)("plugin:mongoose|save_file", {
42
43
  collection: this.name,
43
- path,
44
+ path: resolvedPath,
44
45
  ...options
45
46
  });
46
47
  }
@@ -69,6 +70,22 @@ var Files = class {
69
70
  }
70
71
  throw new Error("Unsupported data type for Files.save");
71
72
  }
73
+ resolvePath(path) {
74
+ if (typeof path === "string") {
75
+ return path;
76
+ }
77
+ if (path && typeof path === "object") {
78
+ const pathValue = path.path;
79
+ if (typeof pathValue === "string" && pathValue.length > 0) {
80
+ return pathValue;
81
+ }
82
+ const filePathValue = path.filePath;
83
+ if (typeof filePathValue === "string" && filePathValue.length > 0) {
84
+ return filePathValue;
85
+ }
86
+ }
87
+ throw new Error("Files.savePath expects a string path or object with path/filePath");
88
+ }
72
89
  };
73
90
 
74
91
  // model/index.ts
package/dist/index.mjs CHANGED
@@ -8,9 +8,10 @@ var Files = class {
8
8
  this.name = name;
9
9
  }
10
10
  async savePath(path, options = {}) {
11
+ const resolvedPath = this.resolvePath(path);
11
12
  return await invoke("plugin:mongoose|save_file", {
12
13
  collection: this.name,
13
- path,
14
+ path: resolvedPath,
14
15
  ...options
15
16
  });
16
17
  }
@@ -39,6 +40,22 @@ var Files = class {
39
40
  }
40
41
  throw new Error("Unsupported data type for Files.save");
41
42
  }
43
+ resolvePath(path) {
44
+ if (typeof path === "string") {
45
+ return path;
46
+ }
47
+ if (path && typeof path === "object") {
48
+ const pathValue = path.path;
49
+ if (typeof pathValue === "string" && pathValue.length > 0) {
50
+ return pathValue;
51
+ }
52
+ const filePathValue = path.filePath;
53
+ if (typeof filePathValue === "string" && filePathValue.length > 0) {
54
+ return filePathValue;
55
+ }
56
+ }
57
+ throw new Error("Files.savePath expects a string path or object with path/filePath");
58
+ }
42
59
  };
43
60
 
44
61
  // model/index.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-mongoose",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "description": "Tauri plugin for MongoDB/Mongoose-like database operations",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",