@dabble/patches 0.2.14 → 0.2.15

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.
@@ -1,40 +1,44 @@
1
- import type { Change, ListVersionsOptions, PatchesStoreBackend, VersionMetadata } from '../types.js';
1
+ import type { Change, ListVersionsOptions, VersionMetadata } from '../types.js';
2
+ import type { PatchesStoreBackend } from './types.js';
2
3
  /**
3
4
  * Helps retrieve historical information (versions, changes) for a document
4
5
  * using the new versioning model based on IDs and metadata.
5
6
  */
6
7
  export declare class PatchesHistoryManager {
7
- private readonly docId;
8
8
  private readonly store;
9
- constructor(docId: string, store: PatchesStoreBackend);
9
+ constructor(store: PatchesStoreBackend);
10
10
  /**
11
11
  * Lists version metadata for the document, supporting various filters.
12
+ * @param docId - The ID of the document.
12
13
  * @param options Filtering and sorting options (e.g., limit, reverse, origin, groupId, date range).
13
14
  * @returns A list of version metadata objects.
14
15
  */
15
- listVersions(options?: ListVersionsOptions): Promise<VersionMetadata[]>;
16
+ listVersions(docId: string, options?: ListVersionsOptions): Promise<VersionMetadata[]>;
16
17
  /**
17
18
  * Loads the full document state snapshot for a specific version by its ID.
19
+ * @param docId - The ID of the document.
18
20
  * @param versionId - The unique ID of the version.
19
21
  * @returns The document state at that version.
20
22
  * @throws Error if the version ID is not found or state loading fails.
21
23
  */
22
- getStateAtVersion(versionId: string): Promise<any>;
24
+ getStateAtVersion(docId: string, versionId: string): Promise<any>;
23
25
  /**
24
26
  * Loads the list of original client changes that were included in a specific version.
25
27
  * Useful for replaying/scrubbing through the operations within an offline or online session.
28
+ * @param docId - The ID of the document.
26
29
  * @param versionId - The unique ID of the version.
27
30
  * @returns An array of Change objects.
28
31
  * @throws Error if the version ID is not found or change loading fails.
29
32
  */
30
- getChangesForVersion(versionId: string): Promise<Change[]>;
33
+ getChangesForVersion(docId: string, versionId: string): Promise<Change[]>;
31
34
  /**
32
35
  * Lists committed server changes for the document, typically used for server-side processing
33
36
  * or deep history analysis based on raw revisions.
37
+ * @param docId - The ID of the document.
34
38
  * @param options - Options like start/end revision, limit.
35
39
  * @returns The list of committed Change objects.
36
40
  */
37
- listServerChanges(options?: {
41
+ listServerChanges(docId: string, options?: {
38
42
  limit?: number;
39
43
  startAfterRev?: number;
40
44
  endBeforeRev?: number;
@@ -3,57 +3,60 @@
3
3
  * using the new versioning model based on IDs and metadata.
4
4
  */
5
5
  export class PatchesHistoryManager {
6
- constructor(docId, store) {
7
- this.docId = docId;
6
+ constructor(store) {
8
7
  this.store = store;
9
8
  }
10
9
  /**
11
10
  * Lists version metadata for the document, supporting various filters.
11
+ * @param docId - The ID of the document.
12
12
  * @param options Filtering and sorting options (e.g., limit, reverse, origin, groupId, date range).
13
13
  * @returns A list of version metadata objects.
14
14
  */
15
- async listVersions(options = {}) {
16
- return await this.store.listVersions(this.docId, options);
15
+ async listVersions(docId, options = {}) {
16
+ return await this.store.listVersions(docId, options);
17
17
  }
18
18
  /**
19
19
  * Loads the full document state snapshot for a specific version by its ID.
20
+ * @param docId - The ID of the document.
20
21
  * @param versionId - The unique ID of the version.
21
22
  * @returns The document state at that version.
22
23
  * @throws Error if the version ID is not found or state loading fails.
23
24
  */
24
- async getStateAtVersion(versionId) {
25
+ async getStateAtVersion(docId, versionId) {
25
26
  try {
26
- return await this.store.loadVersionState(this.docId, versionId);
27
+ return await this.store.loadVersionState(docId, versionId);
27
28
  }
28
29
  catch (error) {
29
- console.error(`Failed to load state for version ${versionId} of doc ${this.docId}.`, error);
30
+ console.error(`Failed to load state for version ${versionId} of doc ${docId}.`, error);
30
31
  throw new Error(`Could not load state for version ${versionId}.`);
31
32
  }
32
33
  }
33
34
  /**
34
35
  * Loads the list of original client changes that were included in a specific version.
35
36
  * Useful for replaying/scrubbing through the operations within an offline or online session.
37
+ * @param docId - The ID of the document.
36
38
  * @param versionId - The unique ID of the version.
37
39
  * @returns An array of Change objects.
38
40
  * @throws Error if the version ID is not found or change loading fails.
39
41
  */
40
- async getChangesForVersion(versionId) {
42
+ async getChangesForVersion(docId, versionId) {
41
43
  try {
42
- return await this.store.loadVersionChanges(this.docId, versionId);
44
+ return await this.store.loadVersionChanges(docId, versionId);
43
45
  }
44
46
  catch (error) {
45
- console.error(`Failed to load changes for version ${versionId} of doc ${this.docId}.`, error);
47
+ console.error(`Failed to load changes for version ${versionId} of doc ${docId}.`, error);
46
48
  throw new Error(`Could not load changes for version ${versionId}.`);
47
49
  }
48
50
  }
49
51
  /**
50
52
  * Lists committed server changes for the document, typically used for server-side processing
51
53
  * or deep history analysis based on raw revisions.
54
+ * @param docId - The ID of the document.
52
55
  * @param options - Options like start/end revision, limit.
53
56
  * @returns The list of committed Change objects.
54
57
  */
55
- async listServerChanges(options = {}) {
58
+ async listServerChanges(docId, options = {}) {
56
59
  // Added return type
57
- return await this.store.listChanges(this.docId, options);
60
+ return await this.store.listChanges(docId, options);
58
61
  }
59
62
  }
@@ -1,4 +1,5 @@
1
- import type { Change, ListVersionsOptions, PatchesSnapshot, PatchesState, PatchesStoreBackend, VersionMetadata } from '../types.js';
1
+ import type { Change, ListVersionsOptions, PatchesSnapshot, PatchesState, VersionMetadata } from '../types.js';
2
+ import type { PatchesStoreBackend } from './types.js';
2
3
  /**
3
4
  * Configuration options for the PatchesServer.
4
5
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dabble/patches",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
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": {