cry-synced-db-client 0.1.100 → 0.1.102
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.js
CHANGED
|
@@ -4057,7 +4057,7 @@ var SyncedDb = class _SyncedDb {
|
|
|
4057
4057
|
return null;
|
|
4058
4058
|
}
|
|
4059
4059
|
await this.connectionManager.withRestTimeout(
|
|
4060
|
-
this.restInterface.
|
|
4060
|
+
this.restInterface.call("hardDeleteOne", { collection, query: { _id: id } }),
|
|
4061
4061
|
"hardDeleteOne"
|
|
4062
4062
|
);
|
|
4063
4063
|
await this.dexieDb.deleteOne(collection, id);
|
|
@@ -4093,7 +4093,7 @@ var SyncedDb = class _SyncedDb {
|
|
|
4093
4093
|
if (!item) break;
|
|
4094
4094
|
try {
|
|
4095
4095
|
await this.connectionManager.withRestTimeout(
|
|
4096
|
-
this.restInterface.
|
|
4096
|
+
this.restInterface.call("hardDeleteOne", { collection, query: { _id: item.id } }),
|
|
4097
4097
|
"hardDelete"
|
|
4098
4098
|
);
|
|
4099
4099
|
await this.dexieDb.deleteOne(collection, item.id);
|
|
@@ -6898,6 +6898,14 @@ var RestProxy = class {
|
|
|
6898
6898
|
this._totalRequestMs = 0;
|
|
6899
6899
|
this._requestCount = 0;
|
|
6900
6900
|
}
|
|
6901
|
+
/** Typed rdb2 operation call — exposes the full rdb2 API. */
|
|
6902
|
+
async call(operation, payload, options) {
|
|
6903
|
+
return this.restCall(
|
|
6904
|
+
operation,
|
|
6905
|
+
payload,
|
|
6906
|
+
options
|
|
6907
|
+
);
|
|
6908
|
+
}
|
|
6901
6909
|
async restCall(operation, payload = {}, options) {
|
|
6902
6910
|
var _a, _b, _c;
|
|
6903
6911
|
const timeout = (_a = options == null ? void 0 : options.timeoutMs) != null ? _a : this.defaultTimeoutMs;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AggregateOptions, Timestamp } from "mongodb";
|
|
2
2
|
import type { I_RestInterface, QuerySpec, QueryOpts, GetNewerSpec, BatchSpec, CollectionUpdateRequest, CollectionUpdateResult } from "../types/I_RestInterface";
|
|
3
3
|
import type { Id } from "../types/DbEntity";
|
|
4
|
+
import type { Rdb2CallMap, Rdb2Operation } from "../types/Rdb2CallMap";
|
|
4
5
|
/** Progress callback for tracking upload progress */
|
|
5
6
|
export type ProgressCallback = (sentBytes: number, totalBytes: number) => void;
|
|
6
7
|
export interface RestProxyConfig {
|
|
@@ -93,6 +94,11 @@ export declare class RestProxy implements I_RestInterface {
|
|
|
93
94
|
getRequestCount(): number;
|
|
94
95
|
/** Reset timing stats */
|
|
95
96
|
resetTimingStats(): void;
|
|
97
|
+
/** Typed rdb2 operation call — exposes the full rdb2 API. */
|
|
98
|
+
call<K extends Rdb2Operation, T = unknown>(operation: K, payload?: Rdb2CallMap[K], options?: {
|
|
99
|
+
timeoutMs?: number;
|
|
100
|
+
signal?: AbortSignal;
|
|
101
|
+
}): Promise<T>;
|
|
96
102
|
private restCall;
|
|
97
103
|
/** Combine multiple abort signals into one */
|
|
98
104
|
private combineSignals;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Timestamp, Document, SchemaMember, CollationOptions, ReadPreference, FindOneAndUpdateOptions, AggregateOptions } from "mongodb";
|
|
2
2
|
import type { Types } from "cry-db";
|
|
3
3
|
import type { Id } from "./DbEntity";
|
|
4
|
+
import type { Rdb2CallMap, Rdb2Operation } from "./Rdb2CallMap";
|
|
4
5
|
export type CollectionUpdateResult = Types.CollectionUpdateResult;
|
|
5
6
|
export type Obj = {
|
|
6
7
|
[key: string]: any;
|
|
@@ -79,4 +80,9 @@ export interface I_RestInterface {
|
|
|
79
80
|
upsertBatch<T>(collection: string, batch: BatchSpec<T>): Promise<T[]>;
|
|
80
81
|
/** Pošlje batch update/delete za več kolekcij naenkrat */
|
|
81
82
|
updateCollections<T>(collectionsBatches: CollectionUpdateRequest<T>[]): Promise<CollectionUpdateResult[]>;
|
|
83
|
+
/** Generic rdb2 operation call for operations beyond the minimal sync interface */
|
|
84
|
+
call<K extends Rdb2Operation, T = unknown>(operation: K, payload?: Rdb2CallMap[K], options?: {
|
|
85
|
+
timeoutMs?: number;
|
|
86
|
+
signal?: AbortSignal;
|
|
87
|
+
}): Promise<T>;
|
|
82
88
|
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { AggregateOptions } from "mongodb";
|
|
2
|
+
import type { Id } from "./DbEntity";
|
|
3
|
+
import type { QuerySpec, QueryOpts, Projection, BatchSpec, UpsertOptions, GetNewerSpec, CollectionUpdateRequest } from "./I_RestInterface";
|
|
4
|
+
/**
|
|
5
|
+
* Maps each rdb2 API operation to its payload shape.
|
|
6
|
+
* Derived from rdb2-api-spec.json — excludes disallowed
|
|
7
|
+
* server-only operations (close, createCollection, transactions, etc.).
|
|
8
|
+
*/
|
|
9
|
+
export interface Rdb2CallMap {
|
|
10
|
+
ping: {};
|
|
11
|
+
isConnected: {};
|
|
12
|
+
isOnReplicaSet: {};
|
|
13
|
+
getDatabases: {};
|
|
14
|
+
getDatabaseInfos: {};
|
|
15
|
+
getDb: {};
|
|
16
|
+
getCollections: {};
|
|
17
|
+
find: {
|
|
18
|
+
collection: string;
|
|
19
|
+
query?: QuerySpec<any>;
|
|
20
|
+
opts?: QueryOpts;
|
|
21
|
+
};
|
|
22
|
+
findOne: {
|
|
23
|
+
collection: string;
|
|
24
|
+
query: QuerySpec<any>;
|
|
25
|
+
projection?: Projection;
|
|
26
|
+
opts?: QueryOpts;
|
|
27
|
+
};
|
|
28
|
+
findAll: {
|
|
29
|
+
collection: string;
|
|
30
|
+
query?: QuerySpec<any>;
|
|
31
|
+
opts?: QueryOpts;
|
|
32
|
+
};
|
|
33
|
+
findById: {
|
|
34
|
+
collection: string;
|
|
35
|
+
id: Id;
|
|
36
|
+
projection?: Projection;
|
|
37
|
+
opts?: QueryOpts;
|
|
38
|
+
};
|
|
39
|
+
findByIds: {
|
|
40
|
+
collection: string;
|
|
41
|
+
ids: Id[];
|
|
42
|
+
projection?: Projection;
|
|
43
|
+
opts?: QueryOpts;
|
|
44
|
+
};
|
|
45
|
+
findByIdsInManyCollections: {
|
|
46
|
+
request: {
|
|
47
|
+
collection: string;
|
|
48
|
+
ids: Id[];
|
|
49
|
+
}[];
|
|
50
|
+
opts?: QueryOpts;
|
|
51
|
+
};
|
|
52
|
+
findNewer: {
|
|
53
|
+
collection: string;
|
|
54
|
+
timestamp: any;
|
|
55
|
+
query?: QuerySpec<any>;
|
|
56
|
+
opts?: QueryOpts;
|
|
57
|
+
};
|
|
58
|
+
findNewerMany: {
|
|
59
|
+
spec?: GetNewerSpec<any>[];
|
|
60
|
+
};
|
|
61
|
+
count: {
|
|
62
|
+
collection: string;
|
|
63
|
+
query?: QuerySpec<any>;
|
|
64
|
+
opts?: QueryOpts;
|
|
65
|
+
};
|
|
66
|
+
distinct: {
|
|
67
|
+
collection: string;
|
|
68
|
+
field: string;
|
|
69
|
+
};
|
|
70
|
+
aggregate: {
|
|
71
|
+
collection: string;
|
|
72
|
+
pipeline: object[];
|
|
73
|
+
opts?: AggregateOptions;
|
|
74
|
+
};
|
|
75
|
+
isUnique: {
|
|
76
|
+
collection: string;
|
|
77
|
+
field: string;
|
|
78
|
+
value: any;
|
|
79
|
+
id?: Id;
|
|
80
|
+
};
|
|
81
|
+
testHash: {
|
|
82
|
+
collection: string;
|
|
83
|
+
query: QuerySpec<any>;
|
|
84
|
+
field: string;
|
|
85
|
+
unhashedValue: string;
|
|
86
|
+
};
|
|
87
|
+
insert: {
|
|
88
|
+
collection: string;
|
|
89
|
+
insert: any;
|
|
90
|
+
};
|
|
91
|
+
insertMany: {
|
|
92
|
+
collection: string;
|
|
93
|
+
insert: any[];
|
|
94
|
+
};
|
|
95
|
+
save: {
|
|
96
|
+
collection: string;
|
|
97
|
+
update: any;
|
|
98
|
+
id?: Id;
|
|
99
|
+
options?: any;
|
|
100
|
+
};
|
|
101
|
+
update: {
|
|
102
|
+
collection: string;
|
|
103
|
+
query: QuerySpec<any>;
|
|
104
|
+
update: any;
|
|
105
|
+
};
|
|
106
|
+
updateOne: {
|
|
107
|
+
collection: string;
|
|
108
|
+
query: QuerySpec<any>;
|
|
109
|
+
update: any;
|
|
110
|
+
options?: any;
|
|
111
|
+
};
|
|
112
|
+
upsert: {
|
|
113
|
+
collection: string;
|
|
114
|
+
query: QuerySpec<any>;
|
|
115
|
+
update: any;
|
|
116
|
+
options?: UpsertOptions;
|
|
117
|
+
};
|
|
118
|
+
upsertBatch: {
|
|
119
|
+
collection: string;
|
|
120
|
+
batch: BatchSpec<any>;
|
|
121
|
+
};
|
|
122
|
+
updateCollections: {
|
|
123
|
+
collectionsBatches: CollectionUpdateRequest<any>[];
|
|
124
|
+
};
|
|
125
|
+
delete: {
|
|
126
|
+
collection: string;
|
|
127
|
+
query: QuerySpec<any>;
|
|
128
|
+
};
|
|
129
|
+
deleteOne: {
|
|
130
|
+
collection: string;
|
|
131
|
+
query: QuerySpec<any>;
|
|
132
|
+
};
|
|
133
|
+
hardDelete: {
|
|
134
|
+
collection: string;
|
|
135
|
+
query: QuerySpec<any>;
|
|
136
|
+
};
|
|
137
|
+
hardDeleteOne: {
|
|
138
|
+
collection: string;
|
|
139
|
+
query: QuerySpec<any>;
|
|
140
|
+
};
|
|
141
|
+
blockOne: {
|
|
142
|
+
collection: string;
|
|
143
|
+
query: QuerySpec<any>;
|
|
144
|
+
};
|
|
145
|
+
unblockOne: {
|
|
146
|
+
collection: string;
|
|
147
|
+
query: QuerySpec<any>;
|
|
148
|
+
};
|
|
149
|
+
latestTimestamp: {
|
|
150
|
+
collection: string;
|
|
151
|
+
};
|
|
152
|
+
latestTimestamps: {
|
|
153
|
+
collections: string[];
|
|
154
|
+
};
|
|
155
|
+
resetCollectionSync: {
|
|
156
|
+
collection: string;
|
|
157
|
+
};
|
|
158
|
+
dbLogGet: {
|
|
159
|
+
collection: string;
|
|
160
|
+
id: Id;
|
|
161
|
+
};
|
|
162
|
+
dbLogPurge: {
|
|
163
|
+
collection: string;
|
|
164
|
+
id?: Id;
|
|
165
|
+
};
|
|
166
|
+
inTransaction: {};
|
|
167
|
+
newId: {};
|
|
168
|
+
}
|
|
169
|
+
/** Union of all allowed rdb2 operation names. */
|
|
170
|
+
export type Rdb2Operation = keyof Rdb2CallMap;
|
|
@@ -7,3 +7,4 @@ export type { I_ServerUpdateNotifier as ServerUpdateNotifier, ServerUpdateCallba
|
|
|
7
7
|
export type { I_SyncedDb as SyncedDb, SyncedDbConfig, CollectionConfig, CollectionSyncConfig, SyncInfo, ServerWriteRequestInfo, ServerWriteResultInfo, FindNewerManyCallInfo, FindNewerManyResultInfo, DexieWriteRequestInfo, DexieWriteResultInfo, LocalstorageWriteResultInfo, WsNotificationInfo, InfrastructureErrorType, InfrastructureErrorInfo, ConflictSource, ConflictResolutionReport, CrossTabSyncInfo, } from "./I_SyncedDb";
|
|
8
8
|
export type { NetworkStatusChangeInfo } from "../db/types/managers";
|
|
9
9
|
export type { CollectionConfig as CollectionConfigFull, CollectionSyncConfig as CollectionSyncConfigFull } from "./CollectionConfig";
|
|
10
|
+
export type { Rdb2CallMap, Rdb2Operation } from "./Rdb2CallMap";
|