tauri-plugin-mongoose 0.3.8 → 0.3.9

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
@@ -1,3 +1,26 @@
1
+ interface SaveFileOptions {
2
+ filename?: string;
3
+ metadata?: Record<string, unknown>;
4
+ chunkSizeBytes?: number;
5
+ }
6
+ interface SaveFileResult {
7
+ _id: unknown;
8
+ filename?: string;
9
+ length?: number;
10
+ chunkSizeBytes?: number;
11
+ uploadDate?: string;
12
+ bucket: string;
13
+ metadata?: Record<string, unknown>;
14
+ }
15
+ type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
16
+ declare class Files {
17
+ name: string;
18
+ constructor(name: string);
19
+ savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
20
+ save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
21
+ private toBytes;
22
+ }
23
+
1
24
  declare class Time {
2
25
  hours: number;
3
26
  minutes: number;
@@ -68,29 +91,6 @@ declare class Model {
68
91
  }): Promise<any>;
69
92
  }
70
93
 
71
- interface SaveFileOptions {
72
- filename?: string;
73
- metadata?: Record<string, unknown>;
74
- chunkSizeBytes?: number;
75
- }
76
- interface SaveFileResult {
77
- _id: unknown;
78
- filename?: string;
79
- length?: number;
80
- chunkSizeBytes?: number;
81
- uploadDate?: string;
82
- bucket: string;
83
- metadata?: Record<string, unknown>;
84
- }
85
- type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
86
- declare class Files {
87
- name: string;
88
- constructor(name: string);
89
- savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
90
- save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
91
- private toBytes;
92
- }
93
-
94
94
  interface ConnectOptions {
95
95
  url: string;
96
96
  dbName?: string;
@@ -131,4 +131,4 @@ declare function createUser(options: CreateUserOptions): Promise<{
131
131
  ok: number;
132
132
  }>;
133
133
 
134
- export { type ConnectCallbacks, type ConnectOptions, type CreateUserOptions, Files, type InferSchemaType, type InferType, Model, type MongoDBRole, type MongoDBUser, type SaveFileOptions, type SaveFileResult, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, createUser, getUser, getUsers };
134
+ export { type ConnectCallbacks, type ConnectOptions, type CreateUserOptions, Files, type InferSchemaType, type InferType, Model, type MongoDBRole, type MongoDBUser, type SaveFileOptions, type SaveFileResult, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, createUser, Files as default, getUser, getUsers };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,26 @@
1
+ interface SaveFileOptions {
2
+ filename?: string;
3
+ metadata?: Record<string, unknown>;
4
+ chunkSizeBytes?: number;
5
+ }
6
+ interface SaveFileResult {
7
+ _id: unknown;
8
+ filename?: string;
9
+ length?: number;
10
+ chunkSizeBytes?: number;
11
+ uploadDate?: string;
12
+ bucket: string;
13
+ metadata?: Record<string, unknown>;
14
+ }
15
+ type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
16
+ declare class Files {
17
+ name: string;
18
+ constructor(name: string);
19
+ savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
20
+ save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
21
+ private toBytes;
22
+ }
23
+
1
24
  declare class Time {
2
25
  hours: number;
3
26
  minutes: number;
@@ -68,29 +91,6 @@ declare class Model {
68
91
  }): Promise<any>;
69
92
  }
70
93
 
71
- interface SaveFileOptions {
72
- filename?: string;
73
- metadata?: Record<string, unknown>;
74
- chunkSizeBytes?: number;
75
- }
76
- interface SaveFileResult {
77
- _id: unknown;
78
- filename?: string;
79
- length?: number;
80
- chunkSizeBytes?: number;
81
- uploadDate?: string;
82
- bucket: string;
83
- metadata?: Record<string, unknown>;
84
- }
85
- type BinaryLike = ArrayBuffer | ArrayBufferView | number[] | Blob;
86
- declare class Files {
87
- name: string;
88
- constructor(name: string);
89
- savePath(path: string, options?: SaveFileOptions): Promise<SaveFileResult>;
90
- save(data: BinaryLike, options?: SaveFileOptions): Promise<SaveFileResult>;
91
- private toBytes;
92
- }
93
-
94
94
  interface ConnectOptions {
95
95
  url: string;
96
96
  dbName?: string;
@@ -131,4 +131,4 @@ declare function createUser(options: CreateUserOptions): Promise<{
131
131
  ok: number;
132
132
  }>;
133
133
 
134
- export { type ConnectCallbacks, type ConnectOptions, type CreateUserOptions, Files, type InferSchemaType, type InferType, Model, type MongoDBRole, type MongoDBUser, type SaveFileOptions, type SaveFileResult, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, createUser, getUser, getUsers };
134
+ export { type ConnectCallbacks, type ConnectOptions, type CreateUserOptions, Files, type InferSchemaType, type InferType, Model, type MongoDBRole, type MongoDBUser, type SaveFileOptions, type SaveFileResult, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, createUser, Files as default, getUser, getUsers };
package/dist/index.js CHANGED
@@ -24,14 +24,55 @@ __export(index_exports, {
24
24
  Model: () => Model,
25
25
  connect: () => connect,
26
26
  createUser: () => createUser,
27
+ default: () => index_default,
27
28
  getUser: () => getUser,
28
29
  getUsers: () => getUsers
29
30
  });
30
31
  module.exports = __toCommonJS(index_exports);
31
32
  var import_core3 = require("@tauri-apps/api/core");
32
33
 
33
- // model/index.ts
34
+ // files/index.ts
34
35
  var import_core = require("@tauri-apps/api/core");
36
+ var Files = class {
37
+ constructor(name) {
38
+ this.name = name;
39
+ }
40
+ async savePath(path, options = {}) {
41
+ return await (0, import_core.invoke)("plugin:mongoose|save_file", {
42
+ collection: this.name,
43
+ path,
44
+ ...options
45
+ });
46
+ }
47
+ async save(data, options = {}) {
48
+ const bytes = await this.toBytes(data);
49
+ return await (0, import_core.invoke)("plugin:mongoose|save_file", {
50
+ collection: this.name,
51
+ data: Array.from(bytes),
52
+ ...options
53
+ });
54
+ }
55
+ async toBytes(data) {
56
+ if (data instanceof Blob) {
57
+ const buffer = await data.arrayBuffer();
58
+ return new Uint8Array(buffer);
59
+ }
60
+ if (Array.isArray(data)) {
61
+ return Uint8Array.from(data);
62
+ }
63
+ if (data instanceof ArrayBuffer) {
64
+ return new Uint8Array(data);
65
+ }
66
+ if (ArrayBuffer.isView(data)) {
67
+ const view = data;
68
+ return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
69
+ }
70
+ throw new Error("Unsupported data type for Files.save");
71
+ }
72
+ };
73
+
74
+ // model/index.ts
75
+ var import_core2 = require("@tauri-apps/api/core");
35
76
 
36
77
  // types/time.type.ts
37
78
  var Time = class _Time {
@@ -79,7 +120,7 @@ var Model = class {
79
120
  this.schema = schema;
80
121
  }
81
122
  async getById(id) {
82
- const doc = await (0, import_core.invoke)("plugin:mongoose|get_by_id", {
123
+ const doc = await (0, import_core2.invoke)("plugin:mongoose|get_by_id", {
83
124
  collection: this.name,
84
125
  id
85
126
  });
@@ -144,7 +185,7 @@ var Model = class {
144
185
  doc[key] = schemaItem.default();
145
186
  }
146
187
  if (schemaItem.unique && value !== void 0 && value !== null) {
147
- const existing = await (0, import_core.invoke)("plugin:mongoose|get_by_id", {
188
+ const existing = await (0, import_core2.invoke)("plugin:mongoose|get_by_id", {
148
189
  collection: this.name,
149
190
  id: value
150
191
  });
@@ -156,7 +197,7 @@ var Model = class {
156
197
  return doc;
157
198
  }
158
199
  async find(filter = {}, options = {}) {
159
- const docs = await (0, import_core.invoke)("plugin:mongoose|find", {
200
+ const docs = await (0, import_core2.invoke)("plugin:mongoose|find", {
160
201
  collection: this.name,
161
202
  filter,
162
203
  options
@@ -164,7 +205,7 @@ var Model = class {
164
205
  return Promise.all(docs.map((doc) => this.validate(doc)));
165
206
  }
166
207
  async findOne(filter = {}, options = {}) {
167
- const doc = await (0, import_core.invoke)("plugin:mongoose|find_one", {
208
+ const doc = await (0, import_core2.invoke)("plugin:mongoose|find_one", {
168
209
  collection: this.name,
169
210
  filter,
170
211
  options
@@ -176,13 +217,13 @@ var Model = class {
176
217
  }
177
218
  async create(doc) {
178
219
  const validatedDoc = await this.validate(doc);
179
- return await (0, import_core.invoke)("plugin:mongoose|create", {
220
+ return await (0, import_core2.invoke)("plugin:mongoose|create", {
180
221
  collection: this.name,
181
222
  document: validatedDoc
182
223
  });
183
224
  }
184
225
  async updateOne(filter, update, options = {}) {
185
- return await (0, import_core.invoke)("plugin:mongoose|update_one", {
226
+ return await (0, import_core2.invoke)("plugin:mongoose|update_one", {
186
227
  collection: this.name,
187
228
  filter,
188
229
  update,
@@ -191,46 +232,6 @@ var Model = class {
191
232
  }
192
233
  };
193
234
 
194
- // files/index.ts
195
- var import_core2 = require("@tauri-apps/api/core");
196
- var Files = class {
197
- constructor(name) {
198
- this.name = name;
199
- }
200
- async savePath(path, options = {}) {
201
- return await (0, import_core2.invoke)("plugin:mongoose|save_file", {
202
- collection: this.name,
203
- path,
204
- ...options
205
- });
206
- }
207
- async save(data, options = {}) {
208
- const bytes = await this.toBytes(data);
209
- return await (0, import_core2.invoke)("plugin:mongoose|save_file", {
210
- collection: this.name,
211
- data: Array.from(bytes),
212
- ...options
213
- });
214
- }
215
- async toBytes(data) {
216
- if (data instanceof Blob) {
217
- const buffer = await data.arrayBuffer();
218
- return new Uint8Array(buffer);
219
- }
220
- if (Array.isArray(data)) {
221
- return Uint8Array.from(data);
222
- }
223
- if (data instanceof ArrayBuffer) {
224
- return new Uint8Array(data);
225
- }
226
- if (ArrayBuffer.isView(data)) {
227
- const view = data;
228
- return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
229
- }
230
- throw new Error("Unsupported data type for Files.save");
231
- }
232
- };
233
-
234
235
  // index.ts
235
236
  async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
236
237
  let url;
@@ -267,6 +268,7 @@ async function getUser(username, db) {
267
268
  async function createUser(options) {
268
269
  return await (0, import_core3.invoke)("plugin:mongoose|create_db_user", { ...options });
269
270
  }
271
+ var index_default = Files;
270
272
  // Annotate the CommonJS export names for ESM import in node:
271
273
  0 && (module.exports = {
272
274
  Files,
package/dist/index.mjs CHANGED
@@ -1,8 +1,48 @@
1
1
  // index.ts
2
2
  import { invoke as invoke3 } from "@tauri-apps/api/core";
3
3
 
4
- // model/index.ts
4
+ // files/index.ts
5
5
  import { invoke } from "@tauri-apps/api/core";
6
+ var Files = class {
7
+ constructor(name) {
8
+ this.name = name;
9
+ }
10
+ async savePath(path, options = {}) {
11
+ return await invoke("plugin:mongoose|save_file", {
12
+ collection: this.name,
13
+ path,
14
+ ...options
15
+ });
16
+ }
17
+ async save(data, options = {}) {
18
+ const bytes = await this.toBytes(data);
19
+ return await invoke("plugin:mongoose|save_file", {
20
+ collection: this.name,
21
+ data: Array.from(bytes),
22
+ ...options
23
+ });
24
+ }
25
+ async toBytes(data) {
26
+ if (data instanceof Blob) {
27
+ const buffer = await data.arrayBuffer();
28
+ return new Uint8Array(buffer);
29
+ }
30
+ if (Array.isArray(data)) {
31
+ return Uint8Array.from(data);
32
+ }
33
+ if (data instanceof ArrayBuffer) {
34
+ return new Uint8Array(data);
35
+ }
36
+ if (ArrayBuffer.isView(data)) {
37
+ const view = data;
38
+ return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
39
+ }
40
+ throw new Error("Unsupported data type for Files.save");
41
+ }
42
+ };
43
+
44
+ // model/index.ts
45
+ import { invoke as invoke2 } from "@tauri-apps/api/core";
6
46
 
7
47
  // types/time.type.ts
8
48
  var Time = class _Time {
@@ -50,7 +90,7 @@ var Model = class {
50
90
  this.schema = schema;
51
91
  }
52
92
  async getById(id) {
53
- const doc = await invoke("plugin:mongoose|get_by_id", {
93
+ const doc = await invoke2("plugin:mongoose|get_by_id", {
54
94
  collection: this.name,
55
95
  id
56
96
  });
@@ -115,7 +155,7 @@ var Model = class {
115
155
  doc[key] = schemaItem.default();
116
156
  }
117
157
  if (schemaItem.unique && value !== void 0 && value !== null) {
118
- const existing = await invoke("plugin:mongoose|get_by_id", {
158
+ const existing = await invoke2("plugin:mongoose|get_by_id", {
119
159
  collection: this.name,
120
160
  id: value
121
161
  });
@@ -127,7 +167,7 @@ var Model = class {
127
167
  return doc;
128
168
  }
129
169
  async find(filter = {}, options = {}) {
130
- const docs = await invoke("plugin:mongoose|find", {
170
+ const docs = await invoke2("plugin:mongoose|find", {
131
171
  collection: this.name,
132
172
  filter,
133
173
  options
@@ -135,7 +175,7 @@ var Model = class {
135
175
  return Promise.all(docs.map((doc) => this.validate(doc)));
136
176
  }
137
177
  async findOne(filter = {}, options = {}) {
138
- const doc = await invoke("plugin:mongoose|find_one", {
178
+ const doc = await invoke2("plugin:mongoose|find_one", {
139
179
  collection: this.name,
140
180
  filter,
141
181
  options
@@ -147,13 +187,13 @@ var Model = class {
147
187
  }
148
188
  async create(doc) {
149
189
  const validatedDoc = await this.validate(doc);
150
- return await invoke("plugin:mongoose|create", {
190
+ return await invoke2("plugin:mongoose|create", {
151
191
  collection: this.name,
152
192
  document: validatedDoc
153
193
  });
154
194
  }
155
195
  async updateOne(filter, update, options = {}) {
156
- return await invoke("plugin:mongoose|update_one", {
196
+ return await invoke2("plugin:mongoose|update_one", {
157
197
  collection: this.name,
158
198
  filter,
159
199
  update,
@@ -162,46 +202,6 @@ var Model = class {
162
202
  }
163
203
  };
164
204
 
165
- // files/index.ts
166
- import { invoke as invoke2 } from "@tauri-apps/api/core";
167
- var Files = class {
168
- constructor(name) {
169
- this.name = name;
170
- }
171
- async savePath(path, options = {}) {
172
- return await invoke2("plugin:mongoose|save_file", {
173
- collection: this.name,
174
- path,
175
- ...options
176
- });
177
- }
178
- async save(data, options = {}) {
179
- const bytes = await this.toBytes(data);
180
- return await invoke2("plugin:mongoose|save_file", {
181
- collection: this.name,
182
- data: Array.from(bytes),
183
- ...options
184
- });
185
- }
186
- async toBytes(data) {
187
- if (data instanceof Blob) {
188
- const buffer = await data.arrayBuffer();
189
- return new Uint8Array(buffer);
190
- }
191
- if (Array.isArray(data)) {
192
- return Uint8Array.from(data);
193
- }
194
- if (data instanceof ArrayBuffer) {
195
- return new Uint8Array(data);
196
- }
197
- if (ArrayBuffer.isView(data)) {
198
- const view = data;
199
- return new Uint8Array(view.buffer, view.byteOffset, view.byteLength);
200
- }
201
- throw new Error("Unsupported data type for Files.save");
202
- }
203
- };
204
-
205
205
  // index.ts
206
206
  async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
207
207
  let url;
@@ -238,11 +238,13 @@ async function getUser(username, db) {
238
238
  async function createUser(options) {
239
239
  return await invoke3("plugin:mongoose|create_db_user", { ...options });
240
240
  }
241
+ var index_default = Files;
241
242
  export {
242
243
  Files,
243
244
  Model,
244
245
  connect,
245
246
  createUser,
247
+ index_default as default,
246
248
  getUser,
247
249
  getUsers
248
250
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tauri-plugin-mongoose",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "Tauri plugin for MongoDB/Mongoose-like database operations",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",