@tauri-apps/plugin-sql 2.0.0-alpha.1 → 2.0.0-alpha.3

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/README.md CHANGED
@@ -4,7 +4,7 @@ Interface with SQL databases through [sqlx](https://github.com/launchbadge/sqlx)
4
4
 
5
5
  ## Install
6
6
 
7
- _This plugin requires a Rust version of at least **1.65**_
7
+ _This plugin requires a Rust version of at least **1.70**_
8
8
 
9
9
  There are three general methods of installation that we can recommend.
10
10
 
@@ -1,8 +1,3 @@
1
- declare global {
2
- interface Window {
3
- __TAURI_INVOKE__: <T>(cmd: string, args?: unknown) => Promise<T>;
4
- }
5
- }
6
1
  export interface QueryResult {
7
2
  /** The number of rows affected by the query. */
8
3
  rowsAffected: number;
@@ -33,7 +28,7 @@ export default class Database {
33
28
  *
34
29
  * # Sqlite
35
30
  *
36
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
31
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
37
32
  *
38
33
  * @example
39
34
  * ```ts
@@ -50,7 +45,7 @@ export default class Database {
50
45
  *
51
46
  * # Sqlite
52
47
  *
53
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
48
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
54
49
  *
55
50
  * @example
56
51
  * ```ts
@@ -1,3 +1,44 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol */
16
+
17
+
18
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
19
+ var e = new Error(message);
20
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21
+ };
22
+
23
+ /**
24
+ * Sends a message to the backend.
25
+ * @example
26
+ * ```typescript
27
+ * import { invoke } from '@tauri-apps/api/primitives';
28
+ * await invoke('login', { user: 'tauri', password: 'poiwe3h4r5ip3yrhtew9ty' });
29
+ * ```
30
+ *
31
+ * @param cmd The command name.
32
+ * @param args The optional arguments to pass to the command.
33
+ * @param options The request options.
34
+ * @return A promise resolving or rejecting to the backend response.
35
+ *
36
+ * @since 1.0.0
37
+ */
38
+ async function invoke(cmd, args = {}, options) {
39
+ return window.__TAURI_INTERNALS__.invoke(cmd, args, options);
40
+ }
41
+
1
42
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2
43
  // SPDX-License-Identifier: Apache-2.0
3
44
  // SPDX-License-Identifier: MIT
@@ -19,7 +60,7 @@ class Database {
19
60
  *
20
61
  * # Sqlite
21
62
  *
22
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
63
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
23
64
  *
24
65
  * @example
25
66
  * ```ts
@@ -27,7 +68,7 @@ class Database {
27
68
  * ```
28
69
  */
29
70
  static async load(path) {
30
- const _path = await window.__TAURI_INVOKE__("plugin:sql|load", {
71
+ const _path = await invoke("plugin:sql|load", {
31
72
  db: path,
32
73
  });
33
74
  return new Database(_path);
@@ -41,7 +82,7 @@ class Database {
41
82
  *
42
83
  * # Sqlite
43
84
  *
44
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
85
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
45
86
  *
46
87
  * @example
47
88
  * ```ts
@@ -84,7 +125,7 @@ class Database {
84
125
  * ```
85
126
  */
86
127
  async execute(query, bindValues) {
87
- const [rowsAffected, lastInsertId] = await window.__TAURI_INVOKE__("plugin:sql|execute", {
128
+ const [rowsAffected, lastInsertId] = await invoke("plugin:sql|execute", {
88
129
  db: this.path,
89
130
  query,
90
131
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -113,7 +154,7 @@ class Database {
113
154
  * ```
114
155
  */
115
156
  async select(query, bindValues) {
116
- const result = await window.__TAURI_INVOKE__("plugin:sql|select", {
157
+ const result = await invoke("plugin:sql|select", {
117
158
  db: this.path,
118
159
  query,
119
160
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -132,7 +173,7 @@ class Database {
132
173
  * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
133
174
  */
134
175
  async close(db) {
135
- const success = await window.__TAURI_INVOKE__("plugin:sql|close", {
176
+ const success = await invoke("plugin:sql|close", {
136
177
  db,
137
178
  });
138
179
  return success;
package/dist-js/index.mjs CHANGED
@@ -1,3 +1,5 @@
1
+ import { invoke } from '@tauri-apps/api/primitives';
2
+
1
3
  // Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2
4
  // SPDX-License-Identifier: Apache-2.0
3
5
  // SPDX-License-Identifier: MIT
@@ -19,7 +21,7 @@ class Database {
19
21
  *
20
22
  * # Sqlite
21
23
  *
22
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
24
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
23
25
  *
24
26
  * @example
25
27
  * ```ts
@@ -27,7 +29,7 @@ class Database {
27
29
  * ```
28
30
  */
29
31
  static async load(path) {
30
- const _path = await window.__TAURI_INVOKE__("plugin:sql|load", {
32
+ const _path = await invoke("plugin:sql|load", {
31
33
  db: path,
32
34
  });
33
35
  return new Database(_path);
@@ -41,7 +43,7 @@ class Database {
41
43
  *
42
44
  * # Sqlite
43
45
  *
44
- * The path is relative to `tauri::api::path::BaseDirectory::App` and must start with `sqlite:`.
46
+ * The path is relative to `tauri::path::BaseDirectory::App` and must start with `sqlite:`.
45
47
  *
46
48
  * @example
47
49
  * ```ts
@@ -84,7 +86,7 @@ class Database {
84
86
  * ```
85
87
  */
86
88
  async execute(query, bindValues) {
87
- const [rowsAffected, lastInsertId] = await window.__TAURI_INVOKE__("plugin:sql|execute", {
89
+ const [rowsAffected, lastInsertId] = await invoke("plugin:sql|execute", {
88
90
  db: this.path,
89
91
  query,
90
92
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -113,7 +115,7 @@ class Database {
113
115
  * ```
114
116
  */
115
117
  async select(query, bindValues) {
116
- const result = await window.__TAURI_INVOKE__("plugin:sql|select", {
118
+ const result = await invoke("plugin:sql|select", {
117
119
  db: this.path,
118
120
  query,
119
121
  values: bindValues !== null && bindValues !== void 0 ? bindValues : [],
@@ -132,7 +134,7 @@ class Database {
132
134
  * @param db - Optionally state the name of a database if you are managing more than one. Otherwise, all database pools will be in scope.
133
135
  */
134
136
  async close(db) {
135
- const success = await window.__TAURI_INVOKE__("plugin:sql|close", {
137
+ const success = await invoke("plugin:sql|close", {
136
138
  db,
137
139
  });
138
140
  return success;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tauri-apps/plugin-sql",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "Interface with SQL databases",
5
5
  "license": "MIT or APACHE-2.0",
6
6
  "authors": [
@@ -25,7 +25,7 @@
25
25
  "tslib": "2.6.0"
26
26
  },
27
27
  "dependencies": {
28
- "@tauri-apps/api": "2.0.0-alpha.6"
28
+ "@tauri-apps/api": "2.0.0-alpha.11"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "rollup -c"