@sovereignbase/sequencer 1.0.1 → 1.1.0

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.cts CHANGED
@@ -24,26 +24,33 @@ footage?: ReadonlyArray<T | undefined>]>;
24
24
  /**
25
25
  * Describes one Actor's acknowledgement frontier.
26
26
  * `[actorID, sessionID, sessionEnd, ...]` contains removal Session/frontier pairs.
27
- * The application is responsible for acknowledging complete received Session prefixes.
27
+ * Actor-only tuples establish membership before removals, including offline Actors.
28
+ * Compaction requires equal complete Session frontiers from every active Actor.
29
+ * The application must deliver pending history before claiming that frontier.
28
30
  */
29
31
  type Acknowledgement = U32List;
30
- /** Ordered replication batch; delivery may be duplicated or causally reordered. */
32
+ /** Replication batch within retained history; delivery may be duplicated or causally reordered. */
31
33
  type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
32
34
  /**
33
35
  * Retained state required to hydrate the same visible Projection.
34
- * One structural array and one JavaScript-owned content array.
36
+ * One structural array and JavaScript-owned Footage.
35
37
  * Small snapshots use six-word insertion records after length-prefixed ACKs;
36
38
  * `words[0]` locates those records. Large snapshots begin with
37
39
  * `[0, frontiersEnd, insertionCount]` and omit predictable coordinate fields.
38
- * Both layouts retain complete coordinates and acknowledgements.
40
+ * Both layouts encode the retained coordinates and acknowledgements.
41
+ * Eligible masks, deleted Footage and compacted Session claims are omitted;
42
+ * Actor membership remains. Compaction may translate retained coordinates.
39
43
  * Positive insertion diffs consume successive spans of `footage`.
44
+ * String-encoded Footage preserves Insertion order, not visible text order.
45
+ * It uses one UTF-16 code unit per Frame. Missing slots use
46
+ * NUL (`\u0000`); hydration splits the string with `split('')`.
40
47
  * `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
41
48
  */
42
- type Sequence<T> = Readonly<[
49
+ type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
43
50
  /** Acknowledgements followed by canonical Insertions in Structural Order. */
44
51
  words: U32List,
45
52
  /** Consecutive positive Insertion spans, including missing Footage slots. */
46
- footage: ReadonlyArray<T | undefined>]>;
53
+ footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
47
54
  /** Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively. */
48
55
  type Splice<T> = Readonly<[
49
56
  /** First affected position in the Projection after preceding Splices. */
@@ -59,7 +66,7 @@ type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
59
66
  //#endregion
60
67
  //#region src/typescript/errors/class.d.ts
61
68
  /** Semantic error codes reported by the Sequencer public API. */
62
- type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
69
+ type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
63
70
  /** Error reported by Sequencer with a stable code and package-prefixed message. */
64
71
  export declare class SequencerError extends Error {
65
72
  /** Machine-readable code identifying the failure condition. */
@@ -84,7 +91,7 @@ export declare class Projection<T> {
84
91
  * Prepares to sequence a projection, optionally hydrating from a trusted sequence stored by the application.
85
92
  *
86
93
  * @param actorID Actor identifier used in acknowledgements.
87
- * @param trustedSequence Optional trusted Sequence in Structural Order, stored by the application.
94
+ * @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
88
95
  * @throws {@link SequencerError} if native initialization fails.
89
96
  */
90
97
  constructor(actorID: number, trustedSequence?: unknown);
@@ -155,10 +162,17 @@ export declare class Projection<T> {
155
162
  /**
156
163
  * Sequences state into a compact serializable format.
157
164
  *
165
+ * @remarks
166
+ * Register active Actors before removal. Equal complete Session frontiers
167
+ * permit masks and deleted Footage to be omitted from the retained checkpoint.
168
+ * Compaction may translate retained anchors without rewriting this instance.
169
+ *
170
+ * @param stringEncode Whether to concatenate Footage into a string; each text Frame must be one UTF-16 code unit. Defaults to `false`.
158
171
  * @returns A Sequence with acknowledged removals compacted in the exported state.
159
172
  * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
173
+ * @throws {@link SequencerError} with code `STRING_ENCODING_FAILED` if Footage concatenation fails.
160
174
  */
161
- sequence(): Sequence<T>;
175
+ sequence<StringEncoded extends boolean = false>(stringEncode?: StringEncoded): Sequence<T, StringEncoded>;
162
176
  /**
163
177
  * Returns the value at a Projection position.
164
178
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;KAShB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;KAYtD,SAAS,KAAK;;AAGtB,OAAO;;AAEP,SAAS,cAAc;;KAKf,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KCtEzD;;qBAIC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBCdD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAaF,MAAM,kBAAkB,OAAO;;;;;;;;;EAY/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAU7C;;;;;;;;;EAYA,MAAM,oBAAoB,OAAO;;;;;;;;;EAYjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAanD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EAoB1E,OAAO;;;;;;;EAUP,YAAY,SAAS;;;;;;;;EAWrB,MAAM,aAAa;;;;;;;;;EAYnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAKlD"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;KAiBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;KAKrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KC7EzD;;qBAIC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBCdD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAaF,MAAM,kBAAkB,OAAO;;;;;;;;;EAY/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAU7C;;;;;;;;;EAYA,MAAM,oBAAoB,OAAO;;;;;;;;;EAYjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAanD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EAoB1E,OAAO;;;;;;;;;;;;;;EAiBP,SAAS,uCACP,eAAe,gBACd,SAAS,GAAG;;;;;;;;EAWf,MAAM,aAAa;;;;;;;;;EAYnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAKlD"}
package/dist/index.d.ts CHANGED
@@ -24,26 +24,33 @@ footage?: ReadonlyArray<T | undefined>]>;
24
24
  /**
25
25
  * Describes one Actor's acknowledgement frontier.
26
26
  * `[actorID, sessionID, sessionEnd, ...]` contains removal Session/frontier pairs.
27
- * The application is responsible for acknowledging complete received Session prefixes.
27
+ * Actor-only tuples establish membership before removals, including offline Actors.
28
+ * Compaction requires equal complete Session frontiers from every active Actor.
29
+ * The application must deliver pending history before claiming that frontier.
28
30
  */
29
31
  type Acknowledgement = U32List;
30
- /** Ordered replication batch; delivery may be duplicated or causally reordered. */
32
+ /** Replication batch within retained history; delivery may be duplicated or causally reordered. */
31
33
  type Gossip<T> = ReadonlyArray<Acknowledgement | Insertion<T>>;
32
34
  /**
33
35
  * Retained state required to hydrate the same visible Projection.
34
- * One structural array and one JavaScript-owned content array.
36
+ * One structural array and JavaScript-owned Footage.
35
37
  * Small snapshots use six-word insertion records after length-prefixed ACKs;
36
38
  * `words[0]` locates those records. Large snapshots begin with
37
39
  * `[0, frontiersEnd, insertionCount]` and omit predictable coordinate fields.
38
- * Both layouts retain complete coordinates and acknowledgements.
40
+ * Both layouts encode the retained coordinates and acknowledgements.
41
+ * Eligible masks, deleted Footage and compacted Session claims are omitted;
42
+ * Actor membership remains. Compaction may translate retained coordinates.
39
43
  * Positive insertion diffs consume successive spans of `footage`.
44
+ * String-encoded Footage preserves Insertion order, not visible text order.
45
+ * It uses one UTF-16 code unit per Frame. Missing slots use
46
+ * NUL (`\u0000`); hydration splits the string with `split('')`.
40
47
  * `[[], []]` is an empty Sequence. Both numeric arrays and typed views are accepted.
41
48
  */
42
- type Sequence<T> = Readonly<[
49
+ type Sequence<T, StringEncoded extends boolean = false> = Readonly<[
43
50
  /** Acknowledgements followed by canonical Insertions in Structural Order. */
44
51
  words: U32List,
45
52
  /** Consecutive positive Insertion spans, including missing Footage slots. */
46
- footage: ReadonlyArray<T | undefined>]>;
53
+ footage: StringEncoded extends true ? string : ReadonlyArray<T | undefined>]>;
47
54
  /** Visible mutation: insertion uses `[at, at, values]`; removal ends exclusively. */
48
55
  type Splice<T> = Readonly<[
49
56
  /** First affected position in the Projection after preceding Splices. */
@@ -59,7 +66,7 @@ type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
59
66
  //#endregion
60
67
  //#region src/typescript/errors/class.d.ts
61
68
  /** Semantic error codes reported by the Sequencer public API. */
62
- type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
69
+ type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED' | 'STRING_ENCODING_FAILED';
63
70
  /** Error reported by Sequencer with a stable code and package-prefixed message. */
64
71
  export declare class SequencerError extends Error {
65
72
  /** Machine-readable code identifying the failure condition. */
@@ -84,7 +91,7 @@ export declare class Projection<T> {
84
91
  * Prepares to sequence a projection, optionally hydrating from a trusted sequence stored by the application.
85
92
  *
86
93
  * @param actorID Actor identifier used in acknowledgements.
87
- * @param trustedSequence Optional trusted Sequence in Structural Order, stored by the application.
94
+ * @param trustedSequence Optional trusted Sequence in Structural Order; string Footage is split into UTF-16 code units.
88
95
  * @throws {@link SequencerError} if native initialization fails.
89
96
  */
90
97
  constructor(actorID: number, trustedSequence?: unknown);
@@ -155,10 +162,17 @@ export declare class Projection<T> {
155
162
  /**
156
163
  * Sequences state into a compact serializable format.
157
164
  *
165
+ * @remarks
166
+ * Register active Actors before removal. Equal complete Session frontiers
167
+ * permit masks and deleted Footage to be omitted from the retained checkpoint.
168
+ * Compaction may translate retained anchors without rewriting this instance.
169
+ *
170
+ * @param stringEncode Whether to concatenate Footage into a string; each text Frame must be one UTF-16 code unit. Defaults to `false`.
158
171
  * @returns A Sequence with acknowledged removals compacted in the exported state.
159
172
  * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
173
+ * @throws {@link SequencerError} with code `STRING_ENCODING_FAILED` if Footage concatenation fails.
160
174
  */
161
- sequence(): Sequence<T>;
175
+ sequence<StringEncoded extends boolean = false>(stringEncode?: StringEncoded): Sequence<T, StringEncoded>;
162
176
  /**
163
177
  * Returns the value at a Projection position.
164
178
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;KAShB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;KAYtD,SAAS,KAAK;;AAGtB,OAAO;;AAEP,SAAS,cAAc;;KAKf,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KCtEzD;;qBAIC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBCdD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAaF,MAAM,kBAAkB,OAAO;;;;;;;;;EAY/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAU7C;;;;;;;;;EAYA,MAAM,oBAAoB,OAAO;;;;;;;;;EAYjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAanD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EAoB1E,OAAO;;;;;;;EAUP,YAAY,SAAS;;;;;;;;EAWrB,MAAM,aAAa;;;;;;;;;EAYnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAKlD"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/errors/class.ts","../src/typescript/class.ts"],"mappings":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;;;KAWhB,kBAAkB;;KAGlB,OAAO,KAAK,cAAc,kBAAkB,UAAU;;;;;;;;;;;;;;;;KAiBtD,SAAS,GAAG,yCAAyC;;AAG7D,OAAO;;AAEP,SAAS,sCAAsC,cAAc;;KAKrD,OAAO,KAAK;;AAGpB;;AAEA;;AAEA,SAAS,cAAc;;KAKf,OAAO,KAAK,cAAc,OAAO;;KAEjC,OAAO,KAAK,UAAU,QAAQ,OAAO,IAAI,SAAS,OAAO;;;;KC7EzD;;qBAIC,uBAAuB;;WAEzB,MAAM;;;;;;;;EAUb,YAAA,MAAM,oBACN,kBACA,UAAU;;;;;qBCdD,WAAW;WAYJ;;UAVV;;;;;;;;EAUU,YAAA,iBAChB;;;;;;;;;EAaF,MAAM,kBAAkB,OAAO;;;;;;;;;EAY/B,OAAO,QAAQ,MAAM,IAAI,aAAa,OAAO;;;;;;;EAU7C;;;;;;;;;EAYA,MAAM,oBAAoB,OAAO;;;;;;;;;EAYjC,OAAO,kBAAkB,mBAAmB,OAAO;;;;;;;;;;EAanD,QAAQ,YAAY,MAAM,IAAI,kBAAkB,mBAAmB,OAAO;;;;;;;;;;;EAoB1E,OAAO;;;;;;;;;;;;;;EAiBP,SAAS,uCACP,eAAe,gBACd,SAAS,GAAG;;;;;;;;EAWf,MAAM,aAAa;;;;;;;;;EAYnB,OAAO,kBAAkB,mBAAmB,MAAM;;EAKlD"}