@dabble/patches 0.8.1 → 0.8.2
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/algorithms/ot/shared/rebaseChanges.js +6 -5
- package/dist/client/LWWDoc.js +11 -24
- package/dist/client/Patches.js +2 -2
- package/dist/client/PatchesDoc.d.ts +1 -1
- package/dist/client/PatchesDoc.js +2 -3
- package/dist/client/index.d.ts +1 -1
- package/dist/{index-C7ZhU2kS.d.ts → index-BO6EQFpw.d.ts} +2 -14
- package/dist/index.d.ts +13 -13
- package/dist/index.js +2 -10
- package/dist/json-patch/index.d.ts +11 -11
- package/dist/json-patch/index.js +0 -1
- package/dist/json-patch/ops/index.d.ts +1 -1
- package/dist/json-patch/ops/index.js +15 -14
- package/dist/micro/client.js +24 -6
- package/dist/micro/doc.js +15 -16
- package/dist/micro/index.d.ts +2 -2
- package/dist/micro/index.js +14 -7
- package/dist/micro/ops.d.ts +6 -4
- package/dist/micro/ops.js +35 -25
- package/dist/micro/server.d.ts +7 -4
- package/dist/micro/server.js +99 -31
- package/dist/micro/types.d.ts +33 -13
- package/dist/micro/types.js +8 -10
- package/dist/net/PatchesClient.d.ts +2 -2
- package/dist/net/PatchesSync.d.ts +6 -0
- package/dist/net/PatchesSync.js +20 -8
- package/dist/net/http/FetchTransport.d.ts +1 -3
- package/dist/net/http/FetchTransport.js +5 -11
- package/dist/net/index.d.ts +2 -2
- package/dist/net/protocol/JSONRPCClient.js +7 -0
- package/dist/net/protocol/JSONRPCServer.d.ts +4 -6
- package/dist/net/protocol/JSONRPCServer.js +3 -5
- package/dist/net/protocol/types.d.ts +1 -10
- package/dist/net/rest/PatchesREST.d.ts +2 -2
- package/dist/server/LWWMemoryStoreBackend.d.ts +0 -1
- package/dist/server/LWWMemoryStoreBackend.js +0 -3
- package/dist/server/LWWServer.js +2 -1
- package/dist/server/OTBranchManager.d.ts +2 -7
- package/dist/server/OTBranchManager.js +0 -2
- package/dist/server/OTServer.js +2 -1
- package/dist/server/PatchesHistoryManager.d.ts +1 -10
- package/dist/server/PatchesHistoryManager.js +2 -18
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/types.d.ts +0 -5
- package/dist/utils/concurrency.d.ts +6 -1
- package/dist/utils/concurrency.js +4 -0
- package/package.json +1 -1
|
@@ -143,9 +143,7 @@ class OTBranchManager {
|
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
import { assertBranchMetadata as assertBranchMetadata2 } from "./branchUtils.js";
|
|
146
|
-
const PatchesBranchManager = OTBranchManager;
|
|
147
146
|
export {
|
|
148
147
|
OTBranchManager,
|
|
149
|
-
PatchesBranchManager,
|
|
150
148
|
assertBranchMetadata2 as assertBranchMetadata
|
|
151
149
|
};
|
package/dist/server/OTServer.js
CHANGED
|
@@ -64,6 +64,7 @@ class OTServer {
|
|
|
64
64
|
* @returns An object with the committed changes and an optional reload flag.
|
|
65
65
|
*/
|
|
66
66
|
async commitChanges(docId, changes, options) {
|
|
67
|
+
const clientId = getClientId();
|
|
67
68
|
const { catchupChanges, newChanges, docReloadRequired } = await commitChanges(
|
|
68
69
|
this.store,
|
|
69
70
|
docId,
|
|
@@ -73,7 +74,7 @@ class OTServer {
|
|
|
73
74
|
);
|
|
74
75
|
if (newChanges.length > 0) {
|
|
75
76
|
try {
|
|
76
|
-
await this.onChangesCommitted.emit(docId, newChanges, options,
|
|
77
|
+
await this.onChangesCommitted.emit(docId, newChanges, options, clientId);
|
|
77
78
|
} catch (error) {
|
|
78
79
|
console.error(`Failed to notify clients about committed changes for doc ${docId}:`, error);
|
|
79
80
|
}
|
|
@@ -50,7 +50,7 @@ declare class PatchesHistoryManager {
|
|
|
50
50
|
* @returns A ReadableStream of the JSON state, or a stream of 'null' if not found.
|
|
51
51
|
* @throws Error if state loading fails.
|
|
52
52
|
*/
|
|
53
|
-
|
|
53
|
+
getVersionState(docId: string, versionId: string): Promise<ReadableStream<string>>;
|
|
54
54
|
/**
|
|
55
55
|
* Returns the document state immediately before a version's changes begin.
|
|
56
56
|
*
|
|
@@ -76,15 +76,6 @@ declare class PatchesHistoryManager {
|
|
|
76
76
|
* @returns An array of Change objects.
|
|
77
77
|
* @throws Error if the version ID is not found or change loading fails.
|
|
78
78
|
*/
|
|
79
|
-
getChangesForVersion(docId: string, versionId: string): Promise<Change[]>;
|
|
80
|
-
/**
|
|
81
|
-
* Alias for getStateAtVersion for RPC API compatibility.
|
|
82
|
-
* Returns a ReadableStream for efficient JSON-RPC streaming.
|
|
83
|
-
*/
|
|
84
|
-
getVersionState(docId: string, versionId: string): Promise<ReadableStream<string>>;
|
|
85
|
-
/**
|
|
86
|
-
* Alias for getChangesForVersion for RPC API compatibility.
|
|
87
|
-
*/
|
|
88
79
|
getVersionChanges(docId: string, versionId: string): Promise<Change[]>;
|
|
89
80
|
}
|
|
90
81
|
|
|
@@ -56,7 +56,7 @@ class PatchesHistoryManager {
|
|
|
56
56
|
* @returns A ReadableStream of the JSON state, or a stream of 'null' if not found.
|
|
57
57
|
* @throws Error if state loading fails.
|
|
58
58
|
*/
|
|
59
|
-
async
|
|
59
|
+
async getVersionState(docId, versionId) {
|
|
60
60
|
try {
|
|
61
61
|
const rawState = await this.store.loadVersionState(docId, versionId);
|
|
62
62
|
if (rawState === void 0) {
|
|
@@ -103,7 +103,7 @@ class PatchesHistoryManager {
|
|
|
103
103
|
* @returns An array of Change objects.
|
|
104
104
|
* @throws Error if the version ID is not found or change loading fails.
|
|
105
105
|
*/
|
|
106
|
-
async
|
|
106
|
+
async getVersionChanges(docId, versionId) {
|
|
107
107
|
try {
|
|
108
108
|
return await this.store.loadVersionChanges?.(docId, versionId) ?? [];
|
|
109
109
|
} catch (error) {
|
|
@@ -111,22 +111,6 @@ class PatchesHistoryManager {
|
|
|
111
111
|
throw new Error(`Could not load changes for version ${versionId}.`, { cause: error });
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
-
// ---------------------------------------------------------------------------
|
|
115
|
-
// Alias methods for RPC API compatibility
|
|
116
|
-
// ---------------------------------------------------------------------------
|
|
117
|
-
/**
|
|
118
|
-
* Alias for getStateAtVersion for RPC API compatibility.
|
|
119
|
-
* Returns a ReadableStream for efficient JSON-RPC streaming.
|
|
120
|
-
*/
|
|
121
|
-
async getVersionState(docId, versionId) {
|
|
122
|
-
return this.getStateAtVersion(docId, versionId);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Alias for getChangesForVersion for RPC API compatibility.
|
|
126
|
-
*/
|
|
127
|
-
async getVersionChanges(docId, versionId) {
|
|
128
|
-
return this.getChangesForVersion(docId, versionId);
|
|
129
|
-
}
|
|
130
114
|
}
|
|
131
115
|
export {
|
|
132
116
|
PatchesHistoryManager
|
package/dist/server/index.d.ts
CHANGED
|
@@ -2,12 +2,12 @@ export { LWWServer, LWWServerOptions } from './LWWServer.js';
|
|
|
2
2
|
export { OTServer, OTServerOptions } from './OTServer.js';
|
|
3
3
|
export { BranchManager } from './BranchManager.js';
|
|
4
4
|
export { LWWBranchManager } from './LWWBranchManager.js';
|
|
5
|
-
export { OTBranchManager
|
|
5
|
+
export { OTBranchManager } from './OTBranchManager.js';
|
|
6
6
|
export { LWWMemoryStoreBackend } from './LWWMemoryStoreBackend.js';
|
|
7
7
|
export { PatchesHistoryManager } from './PatchesHistoryManager.js';
|
|
8
8
|
export { buildVersionState, getBaseStateBeforeVersion } from '../algorithms/ot/server/buildVersionState.js';
|
|
9
9
|
export { concatStreams, jsonReadable, parseVersionState, readStreamAsString } from './jsonReadable.js';
|
|
10
|
-
export { blockable, blockableResponse, blocking, singleInvocation } from '../utils/concurrency.js';
|
|
10
|
+
export { blockable, blockableResponse, blocking, releaseConcurrency, singleInvocation } from '../utils/concurrency.js';
|
|
11
11
|
export { RevConflictError } from './RevConflictError.js';
|
|
12
12
|
export { BranchIdGenerator, BranchLoader, assertBranchMetadata, assertBranchOpenForMerge, assertNotABranch, branchManagerApi, createBranchRecord, generateBranchId, wrapMergeCommit } from './branchUtils.js';
|
|
13
13
|
export { CompressedStoreBackend } from './CompressedStoreBackend.js';
|
package/dist/server/index.js
CHANGED
|
@@ -2,12 +2,12 @@ import "../chunk-IZ2YBCUP.js";
|
|
|
2
2
|
import { LWWServer } from "./LWWServer.js";
|
|
3
3
|
import { OTServer } from "./OTServer.js";
|
|
4
4
|
import { LWWBranchManager } from "./LWWBranchManager.js";
|
|
5
|
-
import { OTBranchManager
|
|
5
|
+
import { OTBranchManager } from "./OTBranchManager.js";
|
|
6
6
|
import { LWWMemoryStoreBackend } from "./LWWMemoryStoreBackend.js";
|
|
7
7
|
import { PatchesHistoryManager } from "./PatchesHistoryManager.js";
|
|
8
8
|
import { buildVersionState, getBaseStateBeforeVersion } from "../algorithms/ot/server/buildVersionState.js";
|
|
9
9
|
import { concatStreams, jsonReadable, parseVersionState, readStreamAsString } from "./jsonReadable.js";
|
|
10
|
-
import { blockable, blockableResponse, blocking, singleInvocation } from "../utils/concurrency.js";
|
|
10
|
+
import { blockable, blockableResponse, blocking, releaseConcurrency, singleInvocation } from "../utils/concurrency.js";
|
|
11
11
|
import { RevConflictError } from "./RevConflictError.js";
|
|
12
12
|
import {
|
|
13
13
|
assertBranchMetadata,
|
|
@@ -28,7 +28,6 @@ export {
|
|
|
28
28
|
LWWServer,
|
|
29
29
|
OTBranchManager,
|
|
30
30
|
OTServer,
|
|
31
|
-
PatchesBranchManager,
|
|
32
31
|
PatchesHistoryManager,
|
|
33
32
|
RevConflictError,
|
|
34
33
|
assertBranchMetadata,
|
|
@@ -49,6 +48,7 @@ export {
|
|
|
49
48
|
jsonReadable,
|
|
50
49
|
parseVersionState,
|
|
51
50
|
readStreamAsString,
|
|
51
|
+
releaseConcurrency,
|
|
52
52
|
removeTombstoneIfExists,
|
|
53
53
|
singleInvocation,
|
|
54
54
|
wrapMergeCommit
|
package/dist/server/types.d.ts
CHANGED
|
@@ -157,11 +157,6 @@ interface BranchingStoreBackend {
|
|
|
157
157
|
createBranch(branch: Branch): Promise<void>;
|
|
158
158
|
/** Updates specific fields (status, name, metadata) of an existing branch record. */
|
|
159
159
|
updateBranch(branchId: string, updates: Partial<Pick<Branch, 'status' | 'name' | 'metadata'>>): Promise<void>;
|
|
160
|
-
/**
|
|
161
|
-
* @deprecated Use updateBranch with status instead.
|
|
162
|
-
* Marks a branch as closed. Implementations might handle this via updateBranch.
|
|
163
|
-
*/
|
|
164
|
-
closeBranch(branchId: string): Promise<void>;
|
|
165
160
|
}
|
|
166
161
|
|
|
167
162
|
export type { BranchingStoreBackend, LWWStoreBackend, ListFieldsOptions, OTStoreBackend, ServerStoreBackend, SnapshotResult, TombstoneStoreBackend, VersioningStoreBackend };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Release the concurrency entry for a document, freeing memory.
|
|
3
|
+
* Call when a document is untracked or deleted.
|
|
4
|
+
*/
|
|
5
|
+
declare function releaseConcurrency(docId: string): void;
|
|
1
6
|
/**
|
|
2
7
|
* Wrap a function which is blockable for a document.
|
|
3
8
|
* Also, a Typescript decorator for functions which are blockable.
|
|
@@ -25,4 +30,4 @@ declare function blockableResponse<T extends (docId: string, ...args: any[]) =>
|
|
|
25
30
|
declare function singleInvocation<T extends (...args: any[]) => Promise<any>>(target: T): T;
|
|
26
31
|
declare function singleInvocation<T extends (...args: any[]) => Promise<any>>(matchOnFirstArg: boolean): (target: T) => T;
|
|
27
32
|
|
|
28
|
-
export { blockable, blockableResponse, blocking, singleInvocation };
|
|
33
|
+
export { blockable, blockableResponse, blocking, releaseConcurrency, singleInvocation };
|
|
@@ -9,6 +9,9 @@ function concurrency(docId) {
|
|
|
9
9
|
}
|
|
10
10
|
return concurrency2;
|
|
11
11
|
}
|
|
12
|
+
function releaseConcurrency(docId) {
|
|
13
|
+
docIds.delete(docId);
|
|
14
|
+
}
|
|
12
15
|
function blockable(target) {
|
|
13
16
|
return function(...args) {
|
|
14
17
|
return concurrency(args[0]).blockFunction(target, args, this);
|
|
@@ -46,5 +49,6 @@ export {
|
|
|
46
49
|
blockable,
|
|
47
50
|
blockableResponse,
|
|
48
51
|
blocking,
|
|
52
|
+
releaseConcurrency,
|
|
49
53
|
singleInvocation
|
|
50
54
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dabble/patches",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.2",
|
|
4
4
|
"description": "Immutable JSON Patch implementation based on RFC 6902 supporting operational transformation and last-writer-wins",
|
|
5
5
|
"author": "Jacob Wright <jacwright@gmail.com>",
|
|
6
6
|
"bugs": {
|