@syncular/tauri 0.30.6 → 0.30.7
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.ts +2 -1
- package/dist/index.js +8 -6
- package/package.json +3 -3
- package/src/index.ts +37 -7
package/dist/index.d.ts
CHANGED
|
@@ -184,7 +184,8 @@ export declare class TauriSyncClient implements PromiseMethods<ClientSnapshotMet
|
|
|
184
184
|
/** The error a `{error}` reply surfaces (mirrors the web-client `ClientSyncError`). */
|
|
185
185
|
export declare class TauriSyncError extends Error {
|
|
186
186
|
readonly code: string;
|
|
187
|
-
|
|
187
|
+
readonly details: Readonly<Record<string, unknown>> | undefined;
|
|
188
|
+
constructor(code: string, message: string, details?: Readonly<Record<string, unknown>>);
|
|
188
189
|
}
|
|
189
190
|
/**
|
|
190
191
|
* Construct the bridge and issue the native `create` (opening/attaching the
|
package/dist/index.js
CHANGED
|
@@ -176,7 +176,7 @@ export class TauriSyncClient {
|
|
|
176
176
|
}
|
|
177
177
|
const reply = await this.#tauri.invoke(`${PLUGIN}syncular_command`, { command: { method, params } });
|
|
178
178
|
if (reply.error !== undefined) {
|
|
179
|
-
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
179
|
+
throw new TauriSyncError(reply.error.code, reply.error.message, reply.error.details ?? undefined);
|
|
180
180
|
}
|
|
181
181
|
return reply.result;
|
|
182
182
|
}
|
|
@@ -358,7 +358,7 @@ export class TauriSyncClient {
|
|
|
358
358
|
this.#requireActive();
|
|
359
359
|
const reply = await this.#tauri.invoke(`${PLUGIN}syncular_query`, { sql, params: (params ?? []).map(encodeParam) });
|
|
360
360
|
if (reply.error !== undefined) {
|
|
361
|
-
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
361
|
+
throw new TauriSyncError(reply.error.code, reply.error.message, reply.error.details ?? undefined);
|
|
362
362
|
}
|
|
363
363
|
const rows = reply.result.rows ?? [];
|
|
364
364
|
return rows.map((r) => decodeRow(r));
|
|
@@ -372,7 +372,7 @@ export class TauriSyncClient {
|
|
|
372
372
|
...(spec.owner !== undefined ? { owner: spec.owner } : {}),
|
|
373
373
|
});
|
|
374
374
|
if (reply.error !== undefined) {
|
|
375
|
-
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
375
|
+
throw new TauriSyncError(reply.error.code, reply.error.message, reply.error.details ?? undefined);
|
|
376
376
|
}
|
|
377
377
|
const result = reply.result;
|
|
378
378
|
return {
|
|
@@ -442,7 +442,7 @@ export class TauriSyncClient {
|
|
|
442
442
|
this.#requireActive();
|
|
443
443
|
const reply = await this.#tauri.invoke(`${PLUGIN}syncular_set_headers`, { headers });
|
|
444
444
|
if (reply.error !== undefined) {
|
|
445
|
-
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
445
|
+
throw new TauriSyncError(reply.error.code, reply.error.message, reply.error.details ?? undefined);
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
448
|
// -- Native CRDT (SPEC.md §5.10.5; needs the plugin `crdt-yjs` feature) ------
|
|
@@ -599,10 +599,12 @@ function decodeDiagnosticsSnapshot(value, kind) {
|
|
|
599
599
|
/** The error a `{error}` reply surfaces (mirrors the web-client `ClientSyncError`). */
|
|
600
600
|
export class TauriSyncError extends Error {
|
|
601
601
|
code;
|
|
602
|
-
|
|
602
|
+
details;
|
|
603
|
+
constructor(code, message, details) {
|
|
603
604
|
super(message);
|
|
604
605
|
this.name = 'TauriSyncError';
|
|
605
606
|
this.code = code;
|
|
607
|
+
this.details = details;
|
|
606
608
|
}
|
|
607
609
|
}
|
|
608
610
|
function toStringSet(value) {
|
|
@@ -737,7 +739,7 @@ export async function createTauriSyncClient(config) {
|
|
|
737
739
|
});
|
|
738
740
|
if (reply.error !== undefined) {
|
|
739
741
|
unlisten();
|
|
740
|
-
throw new TauriSyncError(reply.error.code, reply.error.message);
|
|
742
|
+
throw new TauriSyncError(reply.error.code, reply.error.message, reply.error.details ?? undefined);
|
|
741
743
|
}
|
|
742
744
|
return client;
|
|
743
745
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/tauri",
|
|
3
|
-
"version": "0.30.
|
|
3
|
+
"version": "0.30.7",
|
|
4
4
|
"description": "Tauri integration for the Syncular client",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
"test": "bun test"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@syncular/client": "0.30.
|
|
51
|
+
"@syncular/client": "0.30.7"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@tauri-apps/api": ">=2.0.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@syncular/react": "0.30.
|
|
57
|
+
"@syncular/react": "0.30.7"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
|
@@ -81,7 +81,11 @@ import {
|
|
|
81
81
|
/** A driver-protocol reply: `{result}` on success or `{error}` on failure. */
|
|
82
82
|
interface CommandReply {
|
|
83
83
|
readonly result?: unknown;
|
|
84
|
-
readonly error?: {
|
|
84
|
+
readonly error?: {
|
|
85
|
+
readonly code: string;
|
|
86
|
+
readonly message: string;
|
|
87
|
+
readonly details?: Readonly<Record<string, unknown>> | null;
|
|
88
|
+
};
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
/** One event pushed on `syncular://event` (the derived client-observable set). */
|
|
@@ -356,7 +360,11 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
|
|
|
356
360
|
{ command: { method, params } },
|
|
357
361
|
);
|
|
358
362
|
if (reply.error !== undefined) {
|
|
359
|
-
throw new TauriSyncError(
|
|
363
|
+
throw new TauriSyncError(
|
|
364
|
+
reply.error.code,
|
|
365
|
+
reply.error.message,
|
|
366
|
+
reply.error.details ?? undefined,
|
|
367
|
+
);
|
|
360
368
|
}
|
|
361
369
|
return reply.result;
|
|
362
370
|
}
|
|
@@ -566,7 +574,11 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
|
|
|
566
574
|
{ sql, params: (params ?? []).map(encodeParam) },
|
|
567
575
|
);
|
|
568
576
|
if (reply.error !== undefined) {
|
|
569
|
-
throw new TauriSyncError(
|
|
577
|
+
throw new TauriSyncError(
|
|
578
|
+
reply.error.code,
|
|
579
|
+
reply.error.message,
|
|
580
|
+
reply.error.details ?? undefined,
|
|
581
|
+
);
|
|
570
582
|
}
|
|
571
583
|
const rows = (reply.result as { rows?: unknown[] }).rows ?? [];
|
|
572
584
|
return rows.map((r) => decodeRow(r as Record<string, unknown>));
|
|
@@ -586,7 +598,11 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
|
|
|
586
598
|
},
|
|
587
599
|
);
|
|
588
600
|
if (reply.error !== undefined) {
|
|
589
|
-
throw new TauriSyncError(
|
|
601
|
+
throw new TauriSyncError(
|
|
602
|
+
reply.error.code,
|
|
603
|
+
reply.error.message,
|
|
604
|
+
reply.error.details ?? undefined,
|
|
605
|
+
);
|
|
590
606
|
}
|
|
591
607
|
const result = reply.result as {
|
|
592
608
|
revision: string;
|
|
@@ -702,7 +718,11 @@ export class TauriSyncClient implements PromiseMethods<ClientSnapshotMethods> {
|
|
|
702
718
|
{ headers },
|
|
703
719
|
);
|
|
704
720
|
if (reply.error !== undefined) {
|
|
705
|
-
throw new TauriSyncError(
|
|
721
|
+
throw new TauriSyncError(
|
|
722
|
+
reply.error.code,
|
|
723
|
+
reply.error.message,
|
|
724
|
+
reply.error.details ?? undefined,
|
|
725
|
+
);
|
|
706
726
|
}
|
|
707
727
|
}
|
|
708
728
|
|
|
@@ -930,10 +950,16 @@ function decodeDiagnosticsSnapshot(
|
|
|
930
950
|
/** The error a `{error}` reply surfaces (mirrors the web-client `ClientSyncError`). */
|
|
931
951
|
export class TauriSyncError extends Error {
|
|
932
952
|
readonly code: string;
|
|
933
|
-
|
|
953
|
+
readonly details: Readonly<Record<string, unknown>> | undefined;
|
|
954
|
+
constructor(
|
|
955
|
+
code: string,
|
|
956
|
+
message: string,
|
|
957
|
+
details?: Readonly<Record<string, unknown>>,
|
|
958
|
+
) {
|
|
934
959
|
super(message);
|
|
935
960
|
this.name = 'TauriSyncError';
|
|
936
961
|
this.code = code;
|
|
962
|
+
this.details = details;
|
|
937
963
|
}
|
|
938
964
|
}
|
|
939
965
|
|
|
@@ -1084,7 +1110,11 @@ export async function createTauriSyncClient(
|
|
|
1084
1110
|
});
|
|
1085
1111
|
if (reply.error !== undefined) {
|
|
1086
1112
|
unlisten();
|
|
1087
|
-
throw new TauriSyncError(
|
|
1113
|
+
throw new TauriSyncError(
|
|
1114
|
+
reply.error.code,
|
|
1115
|
+
reply.error.message,
|
|
1116
|
+
reply.error.details ?? undefined,
|
|
1117
|
+
);
|
|
1088
1118
|
}
|
|
1089
1119
|
|
|
1090
1120
|
return client;
|