@sovereignbase/sequencer 1.0.0 → 1.0.1

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
@@ -57,6 +57,23 @@ type Change<T> = ReadonlyArray<Splice<T>>;
57
57
  /** Visible changes and optional Gossip returned by `apply()` or `merge()`. */
58
58
  type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
59
59
  //#endregion
60
+ //#region src/typescript/errors/class.d.ts
61
+ /** Semantic error codes reported by the Sequencer public API. */
62
+ type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
63
+ /** Error reported by Sequencer with a stable code and package-prefixed message. */
64
+ export declare class SequencerError extends Error {
65
+ /** Machine-readable code identifying the failure condition. */
66
+ readonly code: SequencerErrorCode;
67
+ /**
68
+ * Creates a Sequencer error.
69
+ *
70
+ * @param code Stable code identifying the failure condition.
71
+ * @param message Human-readable detail; defaults to `code`.
72
+ * @param options Standard error options; `cause` retains an underlying error.
73
+ */
74
+ constructor(code: SequencerErrorCode, message?: string, options?: ErrorOptions);
75
+ }
76
+ //#endregion
60
77
  //#region src/typescript/class.d.ts
61
78
  /** Visible Projection of a replicated Sequence. */
62
79
  export declare class Projection<T> {
@@ -68,6 +85,7 @@ export declare class Projection<T> {
68
85
  *
69
86
  * @param actorID Actor identifier used in acknowledgements.
70
87
  * @param trustedSequence Optional trusted Sequence in Structural Order, stored by the application.
88
+ * @throws {@link SequencerError} if native initialization fails.
71
89
  */
72
90
  constructor(actorID: number, trustedSequence?: unknown);
73
91
  /**
@@ -76,6 +94,7 @@ export declare class Projection<T> {
76
94
  * @param gossip Batch of Insertion and Acknowledgement tuples.
77
95
  * @returns Visible changes and optional acknowledgement Gossip, or
78
96
  * `undefined` for invalid input. Earlier entries may already have been applied.
97
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
79
98
  */
80
99
  apply(gossip: unknown): Result<T> | undefined;
81
100
  /**
@@ -84,12 +103,14 @@ export declare class Projection<T> {
84
103
  * @param values Nonempty array of values to insert.
85
104
  * @param at Insertion position in `0..length()`, inclusive.
86
105
  * @returns Gossip describing the insertion.
106
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
87
107
  */
88
108
  insert(values: Array<T>, at: number): Gossip<T>;
89
109
  /**
90
110
  * Returns the length, A.K.A. amount of entries of this projection.
91
111
  *
92
112
  * @returns Current Projection length.
113
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
93
114
  */
94
115
  length(): number;
95
116
  /**
@@ -98,6 +119,7 @@ export declare class Projection<T> {
98
119
  * @param sequence Sequence to merge.
99
120
  * @returns Visible changes and optional acknowledgement Gossip, or
100
121
  * `undefined` if the Sequence has an invalid runtime shape.
122
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
101
123
  */
102
124
  merge(sequence: unknown): Result<T> | undefined;
103
125
  /**
@@ -106,6 +128,7 @@ export declare class Projection<T> {
106
128
  * @param startAt First position to remove; defaults to 0.
107
129
  * @param endWith Last position to remove; defaults to `length() - 1`.
108
130
  * @returns Reducing Insertions and their acknowledgement as Gossip.
131
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
109
132
  */
110
133
  remove(startAt?: number, endWith?: number): Gossip<T>;
111
134
  /**
@@ -115,6 +138,7 @@ export declare class Projection<T> {
115
138
  * @param startAt First position to replace; defaults to 0.
116
139
  * @param endWith Last position to replace; defaults to `length() - 1`.
117
140
  * @returns Removal and insertion Gossip, in that order.
141
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
118
142
  */
119
143
  replace(withValues: Array<T>, startAt?: number, endWith?: number): Gossip<T>;
120
144
  /**
@@ -125,12 +149,14 @@ export declare class Projection<T> {
125
149
  * for propagating that decision to the relevant replicas.
126
150
  *
127
151
  * @param actorID Actor whose Acknowledgements are no longer required for compaction.
152
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
128
153
  */
129
154
  retire(actorID: number): void;
130
155
  /**
131
156
  * Sequences state into a compact serializable format.
132
157
  *
133
158
  * @returns A Sequence with acknowledged removals compacted in the exported state.
159
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
134
160
  */
135
161
  sequence(): Sequence<T>;
136
162
  /**
@@ -138,6 +164,7 @@ export declare class Projection<T> {
138
164
  *
139
165
  * @param at Valid visible position in `0..length() - 1`.
140
166
  * @returns The corresponding Footage value.
167
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
141
168
  */
142
169
  value(at: number): T | undefined;
143
170
  /**
@@ -146,11 +173,12 @@ export declare class Projection<T> {
146
173
  * @param startAt First included position; defaults to 0.
147
174
  * @param endWith Last included position; defaults to `length() - 1`.
148
175
  * @returns A new array of values, or an empty array for an empty range.
176
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
149
177
  */
150
178
  values(startAt?: number, endWith?: number): Array<T>;
151
179
  /** Destroys the Projection. Repeated calls have no effect. */
152
180
  destroy(): void;
153
181
  }
154
182
  //#endregion
155
- export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, Splice, U32List };
183
+ export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, U32List };
156
184
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/typescript/types/type.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,O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;;;;;;;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"}
package/dist/index.d.ts CHANGED
@@ -57,6 +57,23 @@ type Change<T> = ReadonlyArray<Splice<T>>;
57
57
  /** Visible changes and optional Gossip returned by `apply()` or `merge()`. */
58
58
  type Result<T> = Readonly<[change: Change<T>, gossip?: Gossip<T>]>;
59
59
  //#endregion
60
+ //#region src/typescript/errors/class.d.ts
61
+ /** Semantic error codes reported by the Sequencer public API. */
62
+ type SequencerErrorCode = 'PROJECTION_DESTROYED' | 'NATIVE_OPERATION_FAILED';
63
+ /** Error reported by Sequencer with a stable code and package-prefixed message. */
64
+ export declare class SequencerError extends Error {
65
+ /** Machine-readable code identifying the failure condition. */
66
+ readonly code: SequencerErrorCode;
67
+ /**
68
+ * Creates a Sequencer error.
69
+ *
70
+ * @param code Stable code identifying the failure condition.
71
+ * @param message Human-readable detail; defaults to `code`.
72
+ * @param options Standard error options; `cause` retains an underlying error.
73
+ */
74
+ constructor(code: SequencerErrorCode, message?: string, options?: ErrorOptions);
75
+ }
76
+ //#endregion
60
77
  //#region src/typescript/class.d.ts
61
78
  /** Visible Projection of a replicated Sequence. */
62
79
  export declare class Projection<T> {
@@ -68,6 +85,7 @@ export declare class Projection<T> {
68
85
  *
69
86
  * @param actorID Actor identifier used in acknowledgements.
70
87
  * @param trustedSequence Optional trusted Sequence in Structural Order, stored by the application.
88
+ * @throws {@link SequencerError} if native initialization fails.
71
89
  */
72
90
  constructor(actorID: number, trustedSequence?: unknown);
73
91
  /**
@@ -76,6 +94,7 @@ export declare class Projection<T> {
76
94
  * @param gossip Batch of Insertion and Acknowledgement tuples.
77
95
  * @returns Visible changes and optional acknowledgement Gossip, or
78
96
  * `undefined` for invalid input. Earlier entries may already have been applied.
97
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
79
98
  */
80
99
  apply(gossip: unknown): Result<T> | undefined;
81
100
  /**
@@ -84,12 +103,14 @@ export declare class Projection<T> {
84
103
  * @param values Nonempty array of values to insert.
85
104
  * @param at Insertion position in `0..length()`, inclusive.
86
105
  * @returns Gossip describing the insertion.
106
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
87
107
  */
88
108
  insert(values: Array<T>, at: number): Gossip<T>;
89
109
  /**
90
110
  * Returns the length, A.K.A. amount of entries of this projection.
91
111
  *
92
112
  * @returns Current Projection length.
113
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
93
114
  */
94
115
  length(): number;
95
116
  /**
@@ -98,6 +119,7 @@ export declare class Projection<T> {
98
119
  * @param sequence Sequence to merge.
99
120
  * @returns Visible changes and optional acknowledgement Gossip, or
100
121
  * `undefined` if the Sequence has an invalid runtime shape.
122
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
101
123
  */
102
124
  merge(sequence: unknown): Result<T> | undefined;
103
125
  /**
@@ -106,6 +128,7 @@ export declare class Projection<T> {
106
128
  * @param startAt First position to remove; defaults to 0.
107
129
  * @param endWith Last position to remove; defaults to `length() - 1`.
108
130
  * @returns Reducing Insertions and their acknowledgement as Gossip.
131
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
109
132
  */
110
133
  remove(startAt?: number, endWith?: number): Gossip<T>;
111
134
  /**
@@ -115,6 +138,7 @@ export declare class Projection<T> {
115
138
  * @param startAt First position to replace; defaults to 0.
116
139
  * @param endWith Last position to replace; defaults to `length() - 1`.
117
140
  * @returns Removal and insertion Gossip, in that order.
141
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
118
142
  */
119
143
  replace(withValues: Array<T>, startAt?: number, endWith?: number): Gossip<T>;
120
144
  /**
@@ -125,12 +149,14 @@ export declare class Projection<T> {
125
149
  * for propagating that decision to the relevant replicas.
126
150
  *
127
151
  * @param actorID Actor whose Acknowledgements are no longer required for compaction.
152
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
128
153
  */
129
154
  retire(actorID: number): void;
130
155
  /**
131
156
  * Sequences state into a compact serializable format.
132
157
  *
133
158
  * @returns A Sequence with acknowledged removals compacted in the exported state.
159
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
134
160
  */
135
161
  sequence(): Sequence<T>;
136
162
  /**
@@ -138,6 +164,7 @@ export declare class Projection<T> {
138
164
  *
139
165
  * @param at Valid visible position in `0..length() - 1`.
140
166
  * @returns The corresponding Footage value.
167
+ * @throws {@link SequencerError} with code `PROJECTION_DESTROYED` after destruction.
141
168
  */
142
169
  value(at: number): T | undefined;
143
170
  /**
@@ -146,11 +173,12 @@ export declare class Projection<T> {
146
173
  * @param startAt First included position; defaults to 0.
147
174
  * @param endWith Last included position; defaults to `length() - 1`.
148
175
  * @returns A new array of values, or an empty array for an empty range.
176
+ * @throws {@link SequencerError} if destroyed or the native runtime reports an operation failure.
149
177
  */
150
178
  values(startAt?: number, endWith?: number): Array<T>;
151
179
  /** Destroys the Projection. Repeated calls have no effect. */
152
180
  destroy(): void;
153
181
  }
154
182
  //#endregion
155
- export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, Splice, U32List };
183
+ export type { Acknowledgement, Change, Gossip, Insertion, InsertionWords, Result, Sequence, SequencerErrorCode, Splice, U32List };
156
184
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/typescript/types/type.ts","../src/typescript/class.ts"],"mappings":";;;KACY,UAAU,cAAc;;;;;;;;;KAUxB,iBAAiB;;;;;;KAOjB,UAAU,KAAK;;AAGvB,OAAO;;AAEP,UAAU,cAAc;;;;;;KAShB,kBAAkB;;K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