tauri-plugin-mongoose 0.2.2 → 0.2.5
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 +26 -3
- package/dist/index.d.ts +26 -3
- package/dist/index.js +34 -5
- package/dist/index.mjs +31 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -56,7 +56,30 @@ interface ConnectOptions {
|
|
|
56
56
|
url: string;
|
|
57
57
|
dbName?: string;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
interface ConnectCallbacks {
|
|
60
|
+
onSuccess?: () => void;
|
|
61
|
+
onError?: (error: string) => void;
|
|
62
|
+
}
|
|
63
|
+
interface MongoDBRole {
|
|
64
|
+
role: string;
|
|
65
|
+
db: string;
|
|
66
|
+
}
|
|
67
|
+
interface MongoDBUser {
|
|
68
|
+
_id: string;
|
|
69
|
+
userId: {
|
|
70
|
+
$binary: {
|
|
71
|
+
base64: string;
|
|
72
|
+
subType: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
user: string;
|
|
76
|
+
db: string;
|
|
77
|
+
roles: MongoDBRole[];
|
|
78
|
+
mechanisms?: string[];
|
|
79
|
+
}
|
|
80
|
+
declare function connect(options: ConnectOptions, callbacks?: ConnectCallbacks): Promise<void>;
|
|
81
|
+
declare function connect(url: string, dbName?: string, callbacks?: ConnectCallbacks): Promise<void>;
|
|
82
|
+
declare function getUsers(): Promise<MongoDBUser[]>;
|
|
83
|
+
declare function getUser(username: string, db?: string): Promise<MongoDBUser | null>;
|
|
61
84
|
|
|
62
|
-
export { type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
|
85
|
+
export { type ConnectCallbacks, type ConnectOptions, type InferSchemaType, Model, type MongoDBRole, type MongoDBUser, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, getUser, getUsers };
|
package/dist/index.d.ts
CHANGED
|
@@ -56,7 +56,30 @@ interface ConnectOptions {
|
|
|
56
56
|
url: string;
|
|
57
57
|
dbName?: string;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
interface ConnectCallbacks {
|
|
60
|
+
onSuccess?: () => void;
|
|
61
|
+
onError?: (error: string) => void;
|
|
62
|
+
}
|
|
63
|
+
interface MongoDBRole {
|
|
64
|
+
role: string;
|
|
65
|
+
db: string;
|
|
66
|
+
}
|
|
67
|
+
interface MongoDBUser {
|
|
68
|
+
_id: string;
|
|
69
|
+
userId: {
|
|
70
|
+
$binary: {
|
|
71
|
+
base64: string;
|
|
72
|
+
subType: string;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
user: string;
|
|
76
|
+
db: string;
|
|
77
|
+
roles: MongoDBRole[];
|
|
78
|
+
mechanisms?: string[];
|
|
79
|
+
}
|
|
80
|
+
declare function connect(options: ConnectOptions, callbacks?: ConnectCallbacks): Promise<void>;
|
|
81
|
+
declare function connect(url: string, dbName?: string, callbacks?: ConnectCallbacks): Promise<void>;
|
|
82
|
+
declare function getUsers(): Promise<MongoDBUser[]>;
|
|
83
|
+
declare function getUser(username: string, db?: string): Promise<MongoDBUser | null>;
|
|
61
84
|
|
|
62
|
-
export { type ConnectOptions, type InferSchemaType, Model, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect };
|
|
85
|
+
export { type ConnectCallbacks, type ConnectOptions, type InferSchemaType, Model, type MongoDBRole, type MongoDBUser, type Schema, type SchemaItem, type SchemaTypes, type TypeMap, connect, getUser, getUsers };
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
Model: () => Model,
|
|
24
|
-
connect: () => connect
|
|
24
|
+
connect: () => connect,
|
|
25
|
+
getUser: () => getUser,
|
|
26
|
+
getUsers: () => getUsers
|
|
25
27
|
});
|
|
26
28
|
module.exports = __toCommonJS(index_exports);
|
|
27
29
|
var import_core2 = require("@tauri-apps/api/core");
|
|
@@ -142,15 +144,42 @@ var Model = class {
|
|
|
142
144
|
};
|
|
143
145
|
|
|
144
146
|
// index.ts
|
|
145
|
-
async function connect(urlOrOptions,
|
|
147
|
+
async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
|
|
148
|
+
let url;
|
|
149
|
+
let dbName;
|
|
150
|
+
let cbs;
|
|
146
151
|
if (typeof urlOrOptions === "string") {
|
|
147
|
-
|
|
152
|
+
url = urlOrOptions;
|
|
153
|
+
if (typeof dbNameOrCallbacks === "string") {
|
|
154
|
+
dbName = dbNameOrCallbacks;
|
|
155
|
+
cbs = callbacks;
|
|
156
|
+
} else {
|
|
157
|
+
cbs = dbNameOrCallbacks;
|
|
158
|
+
}
|
|
148
159
|
} else {
|
|
149
|
-
|
|
160
|
+
url = urlOrOptions.url;
|
|
161
|
+
dbName = urlOrOptions.dbName;
|
|
162
|
+
cbs = dbNameOrCallbacks;
|
|
163
|
+
}
|
|
164
|
+
try {
|
|
165
|
+
await (0, import_core2.invoke)("plugin:mongoose|connect", { url, dbName });
|
|
166
|
+
cbs?.onSuccess?.();
|
|
167
|
+
} catch (error) {
|
|
168
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
169
|
+
cbs?.onError?.(errorMessage);
|
|
170
|
+
throw error;
|
|
150
171
|
}
|
|
151
172
|
}
|
|
173
|
+
async function getUsers() {
|
|
174
|
+
return await (0, import_core2.invoke)("plugin:mongoose|get_users");
|
|
175
|
+
}
|
|
176
|
+
async function getUser(username, db) {
|
|
177
|
+
return await (0, import_core2.invoke)("plugin:mongoose|get_user", { username, db });
|
|
178
|
+
}
|
|
152
179
|
// Annotate the CommonJS export names for ESM import in node:
|
|
153
180
|
0 && (module.exports = {
|
|
154
181
|
Model,
|
|
155
|
-
connect
|
|
182
|
+
connect,
|
|
183
|
+
getUser,
|
|
184
|
+
getUsers
|
|
156
185
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -117,14 +117,41 @@ var Model = class {
|
|
|
117
117
|
};
|
|
118
118
|
|
|
119
119
|
// index.ts
|
|
120
|
-
async function connect(urlOrOptions,
|
|
120
|
+
async function connect(urlOrOptions, dbNameOrCallbacks, callbacks) {
|
|
121
|
+
let url;
|
|
122
|
+
let dbName;
|
|
123
|
+
let cbs;
|
|
121
124
|
if (typeof urlOrOptions === "string") {
|
|
122
|
-
|
|
125
|
+
url = urlOrOptions;
|
|
126
|
+
if (typeof dbNameOrCallbacks === "string") {
|
|
127
|
+
dbName = dbNameOrCallbacks;
|
|
128
|
+
cbs = callbacks;
|
|
129
|
+
} else {
|
|
130
|
+
cbs = dbNameOrCallbacks;
|
|
131
|
+
}
|
|
123
132
|
} else {
|
|
124
|
-
|
|
133
|
+
url = urlOrOptions.url;
|
|
134
|
+
dbName = urlOrOptions.dbName;
|
|
135
|
+
cbs = dbNameOrCallbacks;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
await invoke2("plugin:mongoose|connect", { url, dbName });
|
|
139
|
+
cbs?.onSuccess?.();
|
|
140
|
+
} catch (error) {
|
|
141
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
142
|
+
cbs?.onError?.(errorMessage);
|
|
143
|
+
throw error;
|
|
125
144
|
}
|
|
126
145
|
}
|
|
146
|
+
async function getUsers() {
|
|
147
|
+
return await invoke2("plugin:mongoose|get_users");
|
|
148
|
+
}
|
|
149
|
+
async function getUser(username, db) {
|
|
150
|
+
return await invoke2("plugin:mongoose|get_user", { username, db });
|
|
151
|
+
}
|
|
127
152
|
export {
|
|
128
153
|
Model,
|
|
129
|
-
connect
|
|
154
|
+
connect,
|
|
155
|
+
getUser,
|
|
156
|
+
getUsers
|
|
130
157
|
};
|