@noldova/checkpoints.protocol 0.0.0-stage → 0.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.
Files changed (204) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +34 -4
  3. package/src/api/index.d.ts +4062 -0
  4. package/src/api/index.js +98 -0
  5. package/src/api/index.js.map +1 -0
  6. package/src/exceptions/capture-checkpoint-mismatch.exception.js +17 -0
  7. package/src/exceptions/capture-checkpoint-mismatch.exception.js.map +1 -0
  8. package/src/exceptions/capture-space-mismatch.exception.js +17 -0
  9. package/src/exceptions/capture-space-mismatch.exception.js.map +1 -0
  10. package/src/exceptions/change-sides-mismatch.exception.js +17 -0
  11. package/src/exceptions/change-sides-mismatch.exception.js.map +1 -0
  12. package/src/exceptions/compare-changes-mismatch.exception.js +17 -0
  13. package/src/exceptions/compare-changes-mismatch.exception.js.map +1 -0
  14. package/src/exceptions/content-too-long.exception.js +19 -0
  15. package/src/exceptions/content-too-long.exception.js.map +1 -0
  16. package/src/exceptions/field-not-a-boolean.exception.js +19 -0
  17. package/src/exceptions/field-not-a-boolean.exception.js.map +1 -0
  18. package/src/exceptions/field-not-a-list.exception.js +19 -0
  19. package/src/exceptions/field-not-a-list.exception.js.map +1 -0
  20. package/src/exceptions/field-not-a-number-or-null.exception.js +19 -0
  21. package/src/exceptions/field-not-a-number-or-null.exception.js.map +1 -0
  22. package/src/exceptions/field-not-a-number.exception.js +19 -0
  23. package/src/exceptions/field-not-a-number.exception.js.map +1 -0
  24. package/src/exceptions/field-not-a-string-list.exception.js +19 -0
  25. package/src/exceptions/field-not-a-string-list.exception.js.map +1 -0
  26. package/src/exceptions/field-not-a-string-or-null.exception.js +19 -0
  27. package/src/exceptions/field-not-a-string-or-null.exception.js.map +1 -0
  28. package/src/exceptions/field-not-a-string.exception.js +19 -0
  29. package/src/exceptions/field-not-a-string.exception.js.map +1 -0
  30. package/src/exceptions/invalid-base64.exception.js +15 -0
  31. package/src/exceptions/invalid-base64.exception.js.map +1 -0
  32. package/src/exceptions/invalid-checkpoint-id.exception.js +17 -0
  33. package/src/exceptions/invalid-checkpoint-id.exception.js.map +1 -0
  34. package/src/exceptions/invalid-date.exception.js +15 -0
  35. package/src/exceptions/invalid-date.exception.js.map +1 -0
  36. package/src/exceptions/invalid-folder-path.exception.js +17 -0
  37. package/src/exceptions/invalid-folder-path.exception.js.map +1 -0
  38. package/src/exceptions/invalid-identity.exception.js +17 -0
  39. package/src/exceptions/invalid-identity.exception.js.map +1 -0
  40. package/src/exceptions/invalid-plan-state.exception.js +17 -0
  41. package/src/exceptions/invalid-plan-state.exception.js.map +1 -0
  42. package/src/exceptions/invalid-read-limit.exception.js +17 -0
  43. package/src/exceptions/invalid-read-limit.exception.js.map +1 -0
  44. package/src/exceptions/invalid-relative-path.exception.js +18 -0
  45. package/src/exceptions/invalid-relative-path.exception.js.map +1 -0
  46. package/src/exceptions/invalid-size.exception.js +17 -0
  47. package/src/exceptions/invalid-size.exception.js.map +1 -0
  48. package/src/exceptions/invalid-time.exception.js +17 -0
  49. package/src/exceptions/invalid-time.exception.js.map +1 -0
  50. package/src/exceptions/label-too-long.exception.js +17 -0
  51. package/src/exceptions/label-too-long.exception.js.map +1 -0
  52. package/src/exceptions/missing-field.exception.js +19 -0
  53. package/src/exceptions/missing-field.exception.js.map +1 -0
  54. package/src/exceptions/not-an-object.exception.js +17 -0
  55. package/src/exceptions/not-an-object.exception.js.map +1 -0
  56. package/src/exceptions/preview-plan-mismatch.exception.js +17 -0
  57. package/src/exceptions/preview-plan-mismatch.exception.js.map +1 -0
  58. package/src/exceptions/protocol.exception.js +14 -0
  59. package/src/exceptions/protocol.exception.js.map +1 -0
  60. package/src/exceptions/read-cut-mismatch.exception.js +17 -0
  61. package/src/exceptions/read-cut-mismatch.exception.js.map +1 -0
  62. package/src/exceptions/read-outcome-mismatch.exception.js +17 -0
  63. package/src/exceptions/read-outcome-mismatch.exception.js.map +1 -0
  64. package/src/exceptions/restore-checkpoints-mismatch.exception.js +17 -0
  65. package/src/exceptions/restore-checkpoints-mismatch.exception.js.map +1 -0
  66. package/src/exceptions/side-size-mismatch.exception.js +17 -0
  67. package/src/exceptions/side-size-mismatch.exception.js.map +1 -0
  68. package/src/exceptions/step-sides-mismatch.exception.js +17 -0
  69. package/src/exceptions/step-sides-mismatch.exception.js.map +1 -0
  70. package/src/exceptions/unknown-capture-mode.exception.js +17 -0
  71. package/src/exceptions/unknown-capture-mode.exception.js.map +1 -0
  72. package/src/exceptions/unknown-capture-outcome.exception.js +17 -0
  73. package/src/exceptions/unknown-capture-outcome.exception.js.map +1 -0
  74. package/src/exceptions/unknown-change-status.exception.js +17 -0
  75. package/src/exceptions/unknown-change-status.exception.js.map +1 -0
  76. package/src/exceptions/unknown-compare-outcome.exception.js +17 -0
  77. package/src/exceptions/unknown-compare-outcome.exception.js.map +1 -0
  78. package/src/exceptions/unknown-delete-folder-outcome.exception.js +17 -0
  79. package/src/exceptions/unknown-delete-folder-outcome.exception.js.map +1 -0
  80. package/src/exceptions/unknown-field.exception.js +19 -0
  81. package/src/exceptions/unknown-field.exception.js.map +1 -0
  82. package/src/exceptions/unknown-keep-reason.exception.js +17 -0
  83. package/src/exceptions/unknown-keep-reason.exception.js.map +1 -0
  84. package/src/exceptions/unknown-path-kind.exception.js +17 -0
  85. package/src/exceptions/unknown-path-kind.exception.js.map +1 -0
  86. package/src/exceptions/unknown-preview-outcome.exception.js +17 -0
  87. package/src/exceptions/unknown-preview-outcome.exception.js.map +1 -0
  88. package/src/exceptions/unknown-read-outcome.exception.js +17 -0
  89. package/src/exceptions/unknown-read-outcome.exception.js.map +1 -0
  90. package/src/exceptions/unknown-restore-action.exception.js +17 -0
  91. package/src/exceptions/unknown-restore-action.exception.js.map +1 -0
  92. package/src/exceptions/unknown-restore-outcome.exception.js +17 -0
  93. package/src/exceptions/unknown-restore-outcome.exception.js.map +1 -0
  94. package/src/exceptions/unknown-unread-reason.exception.js +17 -0
  95. package/src/exceptions/unknown-unread-reason.exception.js.map +1 -0
  96. package/src/exceptions/unread-code-mismatch.exception.js +17 -0
  97. package/src/exceptions/unread-code-mismatch.exception.js.map +1 -0
  98. package/src/exceptions/unread-reason-mismatch.exception.js +17 -0
  99. package/src/exceptions/unread-reason-mismatch.exception.js.map +1 -0
  100. package/src/models/capture-mode.js +27 -0
  101. package/src/models/capture-mode.js.map +1 -0
  102. package/src/models/capture-outcome.js +31 -0
  103. package/src/models/capture-outcome.js.map +1 -0
  104. package/src/models/capture-paused-event.js +35 -0
  105. package/src/models/capture-paused-event.js.map +1 -0
  106. package/src/models/capture-request.js +32 -0
  107. package/src/models/capture-request.js.map +1 -0
  108. package/src/models/capture-result.js +50 -0
  109. package/src/models/capture-result.js.map +1 -0
  110. package/src/models/capture-resumed-event.js +28 -0
  111. package/src/models/capture-resumed-event.js.map +1 -0
  112. package/src/models/change-side.js +36 -0
  113. package/src/models/change-side.js.map +1 -0
  114. package/src/models/change-status.js +32 -0
  115. package/src/models/change-status.js.map +1 -0
  116. package/src/models/change.js +57 -0
  117. package/src/models/change.js.map +1 -0
  118. package/src/models/checkpoint-list.js +26 -0
  119. package/src/models/checkpoint-list.js.map +1 -0
  120. package/src/models/checkpoint.js +55 -0
  121. package/src/models/checkpoint.js.map +1 -0
  122. package/src/models/compare-outcome.js +30 -0
  123. package/src/models/compare-outcome.js.map +1 -0
  124. package/src/models/compare-request.js +35 -0
  125. package/src/models/compare-request.js.map +1 -0
  126. package/src/models/compare-result.js +32 -0
  127. package/src/models/compare-result.js.map +1 -0
  128. package/src/models/delete-folder-outcome.js +27 -0
  129. package/src/models/delete-folder-outcome.js.map +1 -0
  130. package/src/models/delete-folder-request.js +27 -0
  131. package/src/models/delete-folder-request.js.map +1 -0
  132. package/src/models/delete-folder-result.js +26 -0
  133. package/src/models/delete-folder-result.js.map +1 -0
  134. package/src/models/diff-target.js +28 -0
  135. package/src/models/diff-target.js.map +1 -0
  136. package/src/models/folder-reference.js +32 -0
  137. package/src/models/folder-reference.js.map +1 -0
  138. package/src/models/folder-usage.js +36 -0
  139. package/src/models/folder-usage.js.map +1 -0
  140. package/src/models/keep-reason.js +30 -0
  141. package/src/models/keep-reason.js.map +1 -0
  142. package/src/models/kept-path.js +32 -0
  143. package/src/models/kept-path.js.map +1 -0
  144. package/src/models/list-request.js +27 -0
  145. package/src/models/list-request.js.map +1 -0
  146. package/src/models/path-kind.js +29 -0
  147. package/src/models/path-kind.js.map +1 -0
  148. package/src/models/preview-outcome.js +33 -0
  149. package/src/models/preview-outcome.js.map +1 -0
  150. package/src/models/preview-request.js +34 -0
  151. package/src/models/preview-request.js.map +1 -0
  152. package/src/models/preview-result.js +33 -0
  153. package/src/models/preview-result.js.map +1 -0
  154. package/src/models/read-outcome.js +35 -0
  155. package/src/models/read-outcome.js.map +1 -0
  156. package/src/models/read-request.js +54 -0
  157. package/src/models/read-request.js.map +1 -0
  158. package/src/models/read-result.js +52 -0
  159. package/src/models/read-result.js.map +1 -0
  160. package/src/models/restore-action.js +28 -0
  161. package/src/models/restore-action.js.map +1 -0
  162. package/src/models/restore-held-up-event.js +35 -0
  163. package/src/models/restore-held-up-event.js.map +1 -0
  164. package/src/models/restore-outcome.js +36 -0
  165. package/src/models/restore-outcome.js.map +1 -0
  166. package/src/models/restore-plan.js +59 -0
  167. package/src/models/restore-plan.js.map +1 -0
  168. package/src/models/restore-request.js +30 -0
  169. package/src/models/restore-request.js.map +1 -0
  170. package/src/models/restore-result.js +40 -0
  171. package/src/models/restore-result.js.map +1 -0
  172. package/src/models/restore-step.js +47 -0
  173. package/src/models/restore-step.js.map +1 -0
  174. package/src/models/restored-event.js +35 -0
  175. package/src/models/restored-event.js.map +1 -0
  176. package/src/models/storage-list.js +26 -0
  177. package/src/models/storage-list.js.map +1 -0
  178. package/src/models/storage-request.js +20 -0
  179. package/src/models/storage-request.js.map +1 -0
  180. package/src/models/unread-path.js +37 -0
  181. package/src/models/unread-path.js.map +1 -0
  182. package/src/models/unread-reason.js +29 -0
  183. package/src/models/unread-reason.js.map +1 -0
  184. package/src/resources.js +247 -0
  185. package/src/resources.js.map +1 -0
  186. package/src/services/base64.js +48 -0
  187. package/src/services/base64.js.map +1 -0
  188. package/src/services/byte-size.js +15 -0
  189. package/src/services/byte-size.js.map +1 -0
  190. package/src/services/checkpoint-id.js +16 -0
  191. package/src/services/checkpoint-id.js.map +1 -0
  192. package/src/services/folder-identity.js +16 -0
  193. package/src/services/folder-identity.js.map +1 -0
  194. package/src/services/json-object.reader.js +89 -0
  195. package/src/services/json-object.reader.js.map +1 -0
  196. package/src/services/relative-path.js +14 -0
  197. package/src/services/relative-path.js.map +1 -0
  198. package/src/services/scope-paths.js +24 -0
  199. package/src/services/scope-paths.js.map +1 -0
  200. package/src/types/json-object.js +9 -0
  201. package/src/types/json-object.js.map +1 -0
  202. package/src/types/json-value.js +9 -0
  203. package/src/types/json-value.js.map +1 -0
  204. package/README.md +0 -3
@@ -0,0 +1,4062 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) Noldova.
4
+ *
5
+ * This source code is licensed under the license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import { Exception, type ExceptionOptions } from "@noldova/context.exceptions";
10
+
11
+ /**
12
+ * A JSON object whose values are JSON values.
13
+ */
14
+ export type JsonObject = { readonly [key: string]: JsonValue };
15
+
16
+ /**
17
+ * A value that JSON can represent.
18
+ */
19
+ export type JsonValue = string | number | boolean | null | JsonObject | readonly JsonValue[];
20
+
21
+ /**
22
+ * The base of the checkpoints protocol's exceptions, thrown when a model is built from values it refuses, or read from JSON that isn't
23
+ * its wire form. Its subclasses: {@link CaptureCheckpointMismatchException}, {@link CaptureSpaceMismatchException},
24
+ * {@link ChangeSidesMismatchException}, {@link CompareChangesMismatchException}, {@link ContentTooLongException},
25
+ * {@link FieldNotABooleanException}, {@link FieldNotAListException}, {@link FieldNotANumberException},
26
+ * {@link FieldNotANumberOrNullException}, {@link FieldNotAStringException}, {@link FieldNotAStringListException},
27
+ * {@link FieldNotAStringOrNullException}, {@link InvalidBase64Exception}, {@link InvalidCheckpointIdException},
28
+ * {@link InvalidDateException}, {@link InvalidFolderPathException}, {@link InvalidIdentityException}, {@link InvalidPlanStateException},
29
+ * {@link InvalidReadLimitException}, {@link InvalidRelativePathException}, {@link InvalidSizeException}, {@link InvalidTimeException},
30
+ * {@link LabelTooLongException}, {@link MissingFieldException}, {@link NotAnObjectException}, {@link PreviewPlanMismatchException},
31
+ * {@link ReadCutMismatchException}, {@link ReadOutcomeMismatchException}, {@link RestoreCheckpointsMismatchException},
32
+ * {@link SideSizeMismatchException}, {@link StepSidesMismatchException}, {@link UnknownCaptureModeException},
33
+ * {@link UnknownCaptureOutcomeException}, {@link UnknownChangeStatusException}, {@link UnknownCompareOutcomeException},
34
+ * {@link UnknownDeleteFolderOutcomeException}, {@link UnknownFieldException}, {@link UnknownKeepReasonException},
35
+ * {@link UnknownPathKindException}, {@link UnknownPreviewOutcomeException}, {@link UnknownReadOutcomeException},
36
+ * {@link UnknownRestoreActionException}, {@link UnknownRestoreOutcomeException}, {@link UnknownUnreadReasonException},
37
+ * {@link UnreadCodeMismatchException}, {@link UnreadReasonMismatchException}.
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import { FolderReference, ProtocolException } from "@noldova/checkpoints.protocol";
42
+ *
43
+ * try {
44
+ * new FolderReference("project 1", "/work/project");
45
+ * }
46
+ * catch (error) {
47
+ * console.log(error instanceof ProtocolException);
48
+ * }
49
+ * ```
50
+ */
51
+ export declare abstract class ProtocolException extends Exception {
52
+ /**
53
+ * Initializes the message and the cause for a subclass.
54
+ *
55
+ * @param message The exception's message.
56
+ * @param options The failure that caused it, if any.
57
+ */
58
+ protected constructor(message: string, options?: ExceptionOptions);
59
+ }
60
+
61
+ /**
62
+ * Thrown when a capture result holds a checkpoint other than exactly when its outcome is Captured.
63
+ */
64
+ export declare class CaptureCheckpointMismatchException extends ProtocolException {
65
+ /**
66
+ * The outcome the result was given.
67
+ */
68
+ public readonly outcome: CaptureOutcome;
69
+
70
+ /**
71
+ * Formats the exception's message from its facts.
72
+ *
73
+ * @param outcome The outcome the result was given.
74
+ * @example
75
+ * ```ts
76
+ * import { CaptureCheckpointMismatchException, CaptureOutcome } from "@noldova/checkpoints.protocol";
77
+ *
78
+ * const exception = new CaptureCheckpointMismatchException(CaptureOutcome.FolderMissing);
79
+ * console.log(exception.message, exception.outcome);
80
+ * ```
81
+ */
82
+ public constructor(outcome: CaptureOutcome);
83
+ }
84
+
85
+ /**
86
+ * Thrown when a capture result holds the space free and the space needed other than exactly when its outcome is LowDiskSpace.
87
+ */
88
+ export declare class CaptureSpaceMismatchException extends ProtocolException {
89
+ /**
90
+ * The outcome the result was given.
91
+ */
92
+ public readonly outcome: CaptureOutcome;
93
+
94
+ /**
95
+ * Formats the exception's message from its facts.
96
+ *
97
+ * @param outcome The outcome the result was given.
98
+ * @example
99
+ * ```ts
100
+ * import { CaptureOutcome, CaptureSpaceMismatchException } from "@noldova/checkpoints.protocol";
101
+ *
102
+ * const exception = new CaptureSpaceMismatchException(CaptureOutcome.Captured);
103
+ * console.log(exception.message, exception.outcome);
104
+ * ```
105
+ */
106
+ public constructor(outcome: CaptureOutcome);
107
+ }
108
+
109
+ /**
110
+ * Thrown when a change's sides don't fit its status.
111
+ */
112
+ export declare class ChangeSidesMismatchException extends ProtocolException {
113
+ /**
114
+ * The status the change was given.
115
+ */
116
+ public readonly status: ChangeStatus;
117
+
118
+ /**
119
+ * Formats the exception's message from its facts.
120
+ *
121
+ * @param status The status the change was given.
122
+ * @example
123
+ * ```ts
124
+ * import { ChangeSidesMismatchException, ChangeStatus } from "@noldova/checkpoints.protocol";
125
+ *
126
+ * const exception = new ChangeSidesMismatchException(ChangeStatus.Added);
127
+ * console.log(exception.message, exception.status);
128
+ * ```
129
+ */
130
+ public constructor(status: ChangeStatus);
131
+ }
132
+
133
+ /**
134
+ * Thrown when a compare result holds changes though its outcome isn't Compared.
135
+ */
136
+ export declare class CompareChangesMismatchException extends ProtocolException {
137
+ /**
138
+ * The outcome the result was given.
139
+ */
140
+ public readonly outcome: CompareOutcome;
141
+
142
+ /**
143
+ * Formats the exception's message from its facts.
144
+ *
145
+ * @param outcome The outcome the result was given.
146
+ * @example
147
+ * ```ts
148
+ * import { CompareChangesMismatchException, CompareOutcome } from "@noldova/checkpoints.protocol";
149
+ *
150
+ * const exception = new CompareChangesMismatchException(CompareOutcome.FolderMissing);
151
+ * console.log(exception.message, exception.outcome);
152
+ * ```
153
+ */
154
+ public constructor(outcome: CompareOutcome);
155
+ }
156
+
157
+ /**
158
+ * Thrown when a read result's content is longer than its size.
159
+ */
160
+ export declare class ContentTooLongException extends ProtocolException {
161
+ /**
162
+ * The content's length, in bytes.
163
+ */
164
+ public readonly length: number;
165
+
166
+ /**
167
+ * The size the result was given, in bytes.
168
+ */
169
+ public readonly size: number;
170
+
171
+ /**
172
+ * Formats the exception's message from its facts.
173
+ *
174
+ * @param length The content's length, in bytes.
175
+ * @param size The size the result was given, in bytes.
176
+ * @example
177
+ * ```ts
178
+ * import { ContentTooLongException } from "@noldova/checkpoints.protocol";
179
+ *
180
+ * const exception = new ContentTooLongException(3, 2);
181
+ * console.log(exception.message, exception.length, exception.size);
182
+ * ```
183
+ */
184
+ public constructor(length: number, size: number);
185
+ }
186
+
187
+ /**
188
+ * Thrown when a model's field is neither `true` nor `false`.
189
+ */
190
+ export declare class FieldNotABooleanException extends ProtocolException {
191
+ /**
192
+ * The field's name.
193
+ */
194
+ public readonly field: string;
195
+
196
+ /**
197
+ * The model's name.
198
+ */
199
+ public readonly model: string;
200
+
201
+ /**
202
+ * Formats the exception's message from its facts.
203
+ *
204
+ * @param model The model's name.
205
+ * @param field The field's name.
206
+ * @example
207
+ * ```ts
208
+ * import { FieldNotABooleanException } from "@noldova/checkpoints.protocol";
209
+ *
210
+ * const exception = new FieldNotABooleanException("Model", "number");
211
+ * console.log(exception.message, exception.model, exception.field);
212
+ * ```
213
+ */
214
+ public constructor(model: string, field: string);
215
+ }
216
+
217
+ /**
218
+ * Thrown when a model's field isn't a list.
219
+ */
220
+ export declare class FieldNotAListException extends ProtocolException {
221
+ /**
222
+ * The field's name.
223
+ */
224
+ public readonly field: string;
225
+
226
+ /**
227
+ * The model's name.
228
+ */
229
+ public readonly model: string;
230
+
231
+ /**
232
+ * Formats the exception's message from its facts.
233
+ *
234
+ * @param model The model's name.
235
+ * @param field The field's name.
236
+ * @example
237
+ * ```ts
238
+ * import { FieldNotAListException } from "@noldova/checkpoints.protocol";
239
+ *
240
+ * const exception = new FieldNotAListException("Model", "number");
241
+ * console.log(exception.message, exception.model, exception.field);
242
+ * ```
243
+ */
244
+ public constructor(model: string, field: string);
245
+ }
246
+
247
+ /**
248
+ * Thrown when a model's field isn't a number.
249
+ */
250
+ export declare class FieldNotANumberException extends ProtocolException {
251
+ /**
252
+ * The field's name.
253
+ */
254
+ public readonly field: string;
255
+
256
+ /**
257
+ * The model's name.
258
+ */
259
+ public readonly model: string;
260
+
261
+ /**
262
+ * Formats the exception's message from its facts.
263
+ *
264
+ * @param model The model's name.
265
+ * @param field The field's name.
266
+ * @example
267
+ * ```ts
268
+ * import { FieldNotANumberException } from "@noldova/checkpoints.protocol";
269
+ *
270
+ * const exception = new FieldNotANumberException("Model", "text");
271
+ * console.log(exception.message, exception.model, exception.field);
272
+ * ```
273
+ */
274
+ public constructor(model: string, field: string);
275
+ }
276
+
277
+ /**
278
+ * Thrown when a model's field is neither a number nor `null`.
279
+ */
280
+ export declare class FieldNotANumberOrNullException extends ProtocolException {
281
+ /**
282
+ * The field's name.
283
+ */
284
+ public readonly field: string;
285
+
286
+ /**
287
+ * The model's name.
288
+ */
289
+ public readonly model: string;
290
+
291
+ /**
292
+ * Formats the exception's message from its facts.
293
+ *
294
+ * @param model The model's name.
295
+ * @param field The field's name.
296
+ * @example
297
+ * ```ts
298
+ * import { FieldNotANumberOrNullException } from "@noldova/checkpoints.protocol";
299
+ *
300
+ * const exception = new FieldNotANumberOrNullException("Model", "text");
301
+ * console.log(exception.message, exception.model, exception.field);
302
+ * ```
303
+ */
304
+ public constructor(model: string, field: string);
305
+ }
306
+
307
+ /**
308
+ * Thrown when a model's field isn't text.
309
+ */
310
+ export declare class FieldNotAStringException extends ProtocolException {
311
+ /**
312
+ * The field's name.
313
+ */
314
+ public readonly field: string;
315
+
316
+ /**
317
+ * The model's name.
318
+ */
319
+ public readonly model: string;
320
+
321
+ /**
322
+ * Formats the exception's message from its facts.
323
+ *
324
+ * @param model The model's name.
325
+ * @param field The field's name.
326
+ * @example
327
+ * ```ts
328
+ * import { FieldNotAStringException } from "@noldova/checkpoints.protocol";
329
+ *
330
+ * const exception = new FieldNotAStringException("Model", "number");
331
+ * console.log(exception.message, exception.model, exception.field);
332
+ * ```
333
+ */
334
+ public constructor(model: string, field: string);
335
+ }
336
+
337
+ /**
338
+ * Thrown when a model's field isn't a list of text.
339
+ */
340
+ export declare class FieldNotAStringListException extends ProtocolException {
341
+ /**
342
+ * The field's name.
343
+ */
344
+ public readonly field: string;
345
+
346
+ /**
347
+ * The model's name.
348
+ */
349
+ public readonly model: string;
350
+
351
+ /**
352
+ * Formats the exception's message from its facts.
353
+ *
354
+ * @param model The model's name.
355
+ * @param field The field's name.
356
+ * @example
357
+ * ```ts
358
+ * import { FieldNotAStringListException } from "@noldova/checkpoints.protocol";
359
+ *
360
+ * const exception = new FieldNotAStringListException("Model", "mixed");
361
+ * console.log(exception.message, exception.model, exception.field);
362
+ * ```
363
+ */
364
+ public constructor(model: string, field: string);
365
+ }
366
+
367
+ /**
368
+ * Thrown when a model's field is neither text nor `null`.
369
+ */
370
+ export declare class FieldNotAStringOrNullException extends ProtocolException {
371
+ /**
372
+ * The field's name.
373
+ */
374
+ public readonly field: string;
375
+
376
+ /**
377
+ * The model's name.
378
+ */
379
+ public readonly model: string;
380
+
381
+ /**
382
+ * Formats the exception's message from its facts.
383
+ *
384
+ * @param model The model's name.
385
+ * @param field The field's name.
386
+ * @example
387
+ * ```ts
388
+ * import { FieldNotAStringOrNullException } from "@noldova/checkpoints.protocol";
389
+ *
390
+ * const exception = new FieldNotAStringOrNullException("Model", "number");
391
+ * console.log(exception.message, exception.model, exception.field);
392
+ * ```
393
+ */
394
+ public constructor(model: string, field: string);
395
+ }
396
+
397
+ /**
398
+ * Thrown when a read result's wire content isn't padded base64 text.
399
+ */
400
+ export declare class InvalidBase64Exception extends ProtocolException {
401
+ /**
402
+ * Formats the exception's message.
403
+ * @example
404
+ * ```ts
405
+ * import { InvalidBase64Exception } from "@noldova/checkpoints.protocol";
406
+ *
407
+ * const exception = new InvalidBase64Exception();
408
+ * console.log(exception.message);
409
+ * ```
410
+ */
411
+ public constructor();
412
+ }
413
+
414
+ /**
415
+ * Thrown when a checkpoint's id isn't a lowercase UUID of version 7.
416
+ */
417
+ export declare class InvalidCheckpointIdException extends ProtocolException {
418
+ /**
419
+ * The id refused.
420
+ */
421
+ public readonly id: string;
422
+
423
+ /**
424
+ * Formats the exception's message from its facts.
425
+ *
426
+ * @param id The id refused.
427
+ * @example
428
+ * ```ts
429
+ * import { InvalidCheckpointIdException } from "@noldova/checkpoints.protocol";
430
+ *
431
+ * const exception = new InvalidCheckpointIdException("a");
432
+ * console.log(exception.message, exception.id);
433
+ * ```
434
+ */
435
+ public constructor(id: string);
436
+ }
437
+
438
+ /**
439
+ * Thrown when a checkpoint's time is a date that isn't valid, which it couldn't write.
440
+ */
441
+ export declare class InvalidDateException extends ProtocolException {
442
+ /**
443
+ * Formats the exception's message.
444
+ * @example
445
+ * ```ts
446
+ * import { InvalidDateException } from "@noldova/checkpoints.protocol";
447
+ *
448
+ * const exception = new InvalidDateException();
449
+ * console.log(exception.message);
450
+ * ```
451
+ */
452
+ public constructor();
453
+ }
454
+
455
+ /**
456
+ * Thrown when a folder's path isn't absolute.
457
+ */
458
+ export declare class InvalidFolderPathException extends ProtocolException {
459
+ /**
460
+ * The path refused.
461
+ */
462
+ public readonly path: string;
463
+
464
+ /**
465
+ * Formats the exception's message from its facts.
466
+ *
467
+ * @param path The path refused.
468
+ * @example
469
+ * ```ts
470
+ * import { InvalidFolderPathException } from "@noldova/checkpoints.protocol";
471
+ *
472
+ * const exception = new InvalidFolderPathException("project");
473
+ * console.log(exception.message, exception.path);
474
+ * ```
475
+ */
476
+ public constructor(path: string);
477
+ }
478
+
479
+ /**
480
+ * Thrown when a folder's identity isn't 1 to 64 letters, digits or hyphens.
481
+ */
482
+ export declare class InvalidIdentityException extends ProtocolException {
483
+ /**
484
+ * The identity refused.
485
+ */
486
+ public readonly identity: string;
487
+
488
+ /**
489
+ * Formats the exception's message from its facts.
490
+ *
491
+ * @param identity The identity refused.
492
+ * @example
493
+ * ```ts
494
+ * import { InvalidIdentityException } from "@noldova/checkpoints.protocol";
495
+ *
496
+ * const exception = new InvalidIdentityException("project 1");
497
+ * console.log(exception.message, exception.identity);
498
+ * ```
499
+ */
500
+ public constructor(identity: string);
501
+ }
502
+
503
+ /**
504
+ * Thrown when a plan's state isn't a lowercase SHA-256 in hexadecimal.
505
+ */
506
+ export declare class InvalidPlanStateException extends ProtocolException {
507
+ /**
508
+ * The state refused.
509
+ */
510
+ public readonly state: string;
511
+
512
+ /**
513
+ * Formats the exception's message from its facts.
514
+ *
515
+ * @param state The state refused.
516
+ * @example
517
+ * ```ts
518
+ * import { InvalidPlanStateException } from "@noldova/checkpoints.protocol";
519
+ *
520
+ * const exception = new InvalidPlanStateException("x");
521
+ * console.log(exception.message, exception.state);
522
+ * ```
523
+ */
524
+ public constructor(state: string);
525
+ }
526
+
527
+ /**
528
+ * Thrown when a read's limit isn't a whole number of bytes from 1 to 16 MiB.
529
+ */
530
+ export declare class InvalidReadLimitException extends ProtocolException {
531
+ /**
532
+ * The limit refused.
533
+ */
534
+ public readonly limit: number;
535
+
536
+ /**
537
+ * Formats the exception's message from its facts.
538
+ *
539
+ * @param limit The limit refused.
540
+ * @example
541
+ * ```ts
542
+ * import { InvalidReadLimitException } from "@noldova/checkpoints.protocol";
543
+ *
544
+ * const exception = new InvalidReadLimitException(0);
545
+ * console.log(exception.message, exception.limit);
546
+ * ```
547
+ */
548
+ public constructor(limit: number);
549
+ }
550
+
551
+ /**
552
+ * Thrown when a path inside a folder has an empty name, `.` or `..`, or, in a restore's scope, a `\`.
553
+ */
554
+ export declare class InvalidRelativePathException extends ProtocolException {
555
+ /**
556
+ * The path refused.
557
+ */
558
+ public readonly path: string;
559
+
560
+ /**
561
+ * Formats the exception's message from its facts: one for a path that breaks only the `\` rule, which names that rule, and one
562
+ * for a path that breaks the rules of its names.
563
+ *
564
+ * @param path The path refused.
565
+ * @example
566
+ * ```ts
567
+ * import { InvalidRelativePathException } from "@noldova/checkpoints.protocol";
568
+ *
569
+ * const exception = new InvalidRelativePathException("a//b");
570
+ * console.log(exception.message, exception.path);
571
+ * ```
572
+ */
573
+ public constructor(path: string);
574
+ }
575
+
576
+ /**
577
+ * Thrown when a size isn't a whole number of bytes, 0 or more.
578
+ */
579
+ export declare class InvalidSizeException extends ProtocolException {
580
+ /**
581
+ * The size refused.
582
+ */
583
+ public readonly size: number;
584
+
585
+ /**
586
+ * Formats the exception's message from its facts.
587
+ *
588
+ * @param size The size refused.
589
+ * @example
590
+ * ```ts
591
+ * import { InvalidSizeException } from "@noldova/checkpoints.protocol";
592
+ *
593
+ * const exception = new InvalidSizeException(-1);
594
+ * console.log(exception.message, exception.size);
595
+ * ```
596
+ */
597
+ public constructor(size: number);
598
+ }
599
+
600
+ /**
601
+ * Thrown when a checkpoint's wire time isn't a time in UTC with milliseconds.
602
+ */
603
+ export declare class InvalidTimeException extends ProtocolException {
604
+ /**
605
+ * The time's text refused.
606
+ */
607
+ public readonly time: string;
608
+
609
+ /**
610
+ * Formats the exception's message from its facts.
611
+ *
612
+ * @param time The time's text refused.
613
+ * @example
614
+ * ```ts
615
+ * import { InvalidTimeException } from "@noldova/checkpoints.protocol";
616
+ *
617
+ * const exception = new InvalidTimeException("2026-10-18T12:00:00Z");
618
+ * console.log(exception.message, exception.time);
619
+ * ```
620
+ */
621
+ public constructor(time: string);
622
+ }
623
+
624
+ /**
625
+ * Thrown when a label is longer than 1,024 characters.
626
+ */
627
+ export declare class LabelTooLongException extends ProtocolException {
628
+ /**
629
+ * The label's length, in characters.
630
+ */
631
+ public readonly length: number;
632
+
633
+ /**
634
+ * Formats the exception's message from its facts.
635
+ *
636
+ * @param length The label's length, in characters.
637
+ * @example
638
+ * ```ts
639
+ * import { LabelTooLongException } from "@noldova/checkpoints.protocol";
640
+ *
641
+ * const exception = new LabelTooLongException(1_025);
642
+ * console.log(exception.message, exception.length);
643
+ * ```
644
+ */
645
+ public constructor(length: number);
646
+ }
647
+
648
+ /**
649
+ * Thrown when a model's wire form lacks a field it needs.
650
+ */
651
+ export declare class MissingFieldException extends ProtocolException {
652
+ /**
653
+ * The field's name.
654
+ */
655
+ public readonly field: string;
656
+
657
+ /**
658
+ * The model's name.
659
+ */
660
+ public readonly model: string;
661
+
662
+ /**
663
+ * Formats the exception's message from its facts.
664
+ *
665
+ * @param model The model's name.
666
+ * @param field The field's name.
667
+ * @example
668
+ * ```ts
669
+ * import { MissingFieldException } from "@noldova/checkpoints.protocol";
670
+ *
671
+ * const exception = new MissingFieldException("Model", "missing");
672
+ * console.log(exception.message, exception.model, exception.field);
673
+ * ```
674
+ */
675
+ public constructor(model: string, field: string);
676
+ }
677
+
678
+ /**
679
+ * Thrown when a model's wire form isn't a JSON object.
680
+ */
681
+ export declare class NotAnObjectException extends ProtocolException {
682
+ /**
683
+ * The model's name.
684
+ */
685
+ public readonly model: string;
686
+
687
+ /**
688
+ * Formats the exception's message from its facts.
689
+ *
690
+ * @param model The model's name.
691
+ * @example
692
+ * ```ts
693
+ * import { NotAnObjectException } from "@noldova/checkpoints.protocol";
694
+ *
695
+ * const exception = new NotAnObjectException("Model");
696
+ * console.log(exception.message, exception.model);
697
+ * ```
698
+ */
699
+ public constructor(model: string);
700
+ }
701
+
702
+ /**
703
+ * Thrown when a preview result holds a plan other than exactly when its outcome is Planned.
704
+ */
705
+ export declare class PreviewPlanMismatchException extends ProtocolException {
706
+ /**
707
+ * The outcome the result was given.
708
+ */
709
+ public readonly outcome: PreviewOutcome;
710
+
711
+ /**
712
+ * Formats the exception's message from its facts.
713
+ *
714
+ * @param outcome The outcome the result was given.
715
+ * @example
716
+ * ```ts
717
+ * import { PreviewOutcome, PreviewPlanMismatchException } from "@noldova/checkpoints.protocol";
718
+ *
719
+ * const exception = new PreviewPlanMismatchException(PreviewOutcome.HeldUp);
720
+ * console.log(exception.message, exception.outcome);
721
+ * ```
722
+ */
723
+ public constructor(outcome: PreviewOutcome);
724
+ }
725
+
726
+ /**
727
+ * Thrown when a read result's wire form says it is cut other than exactly when its content is shorter than its size.
728
+ */
729
+ export declare class ReadCutMismatchException extends ProtocolException {
730
+ /**
731
+ * Whether the wire form says the content is cut.
732
+ */
733
+ public readonly isCut: boolean;
734
+
735
+ /**
736
+ * Formats the exception's message from its facts.
737
+ *
738
+ * @param isCut Whether the wire form says the content is cut.
739
+ * @example
740
+ * ```ts
741
+ * import { ReadCutMismatchException } from "@noldova/checkpoints.protocol";
742
+ *
743
+ * const exception = new ReadCutMismatchException(true);
744
+ * console.log(exception.message, exception.isCut);
745
+ * ```
746
+ */
747
+ public constructor(isCut: boolean);
748
+ }
749
+
750
+ /**
751
+ * Thrown when a read result holds content or a size though its outcome isn't Read.
752
+ */
753
+ export declare class ReadOutcomeMismatchException extends ProtocolException {
754
+ /**
755
+ * The outcome the result was given.
756
+ */
757
+ public readonly outcome: ReadOutcome;
758
+
759
+ /**
760
+ * Formats the exception's message from its facts.
761
+ *
762
+ * @param outcome The outcome the result was given.
763
+ * @example
764
+ * ```ts
765
+ * import { ReadOutcome, ReadOutcomeMismatchException } from "@noldova/checkpoints.protocol";
766
+ *
767
+ * const exception = new ReadOutcomeMismatchException(ReadOutcome.PathMissing);
768
+ * console.log(exception.message, exception.outcome);
769
+ * ```
770
+ */
771
+ public constructor(outcome: ReadOutcome);
772
+ }
773
+
774
+ /**
775
+ * Thrown when a restore result holds the checkpoint before or a recovered one against its outcome.
776
+ */
777
+ export declare class RestoreCheckpointsMismatchException extends ProtocolException {
778
+ /**
779
+ * The outcome the result was given.
780
+ */
781
+ public readonly outcome: RestoreOutcome;
782
+
783
+ /**
784
+ * Formats the exception's message from its facts.
785
+ *
786
+ * @param outcome The outcome the result was given.
787
+ * @example
788
+ * ```ts
789
+ * import { RestoreCheckpointsMismatchException, RestoreOutcome } from "@noldova/checkpoints.protocol";
790
+ *
791
+ * const exception = new RestoreCheckpointsMismatchException(RestoreOutcome.MovedOn);
792
+ * console.log(exception.message, exception.outcome);
793
+ * ```
794
+ */
795
+ public constructor(outcome: RestoreOutcome);
796
+ }
797
+
798
+ /**
799
+ * Thrown when a side has a size other than exactly when it isn't a folder, or is a folder taken as text.
800
+ */
801
+ export declare class SideSizeMismatchException extends ProtocolException {
802
+ /**
803
+ * The kind the side was given.
804
+ */
805
+ public readonly kind: PathKind;
806
+
807
+ /**
808
+ * Formats the exception's message from its facts.
809
+ *
810
+ * @param kind The kind the side was given.
811
+ * @example
812
+ * ```ts
813
+ * import { PathKind, SideSizeMismatchException } from "@noldova/checkpoints.protocol";
814
+ *
815
+ * const exception = new SideSizeMismatchException(PathKind.Folder);
816
+ * console.log(exception.message, exception.kind);
817
+ * ```
818
+ */
819
+ public constructor(kind: PathKind);
820
+ }
821
+
822
+ /**
823
+ * Thrown when a restore step's sides don't fit its action.
824
+ */
825
+ export declare class StepSidesMismatchException extends ProtocolException {
826
+ /**
827
+ * The action the step was given.
828
+ */
829
+ public readonly action: RestoreAction;
830
+
831
+ /**
832
+ * Formats the exception's message from its facts.
833
+ *
834
+ * @param action The action the step was given.
835
+ * @example
836
+ * ```ts
837
+ * import { RestoreAction, StepSidesMismatchException } from "@noldova/checkpoints.protocol";
838
+ *
839
+ * const exception = new StepSidesMismatchException(RestoreAction.Write);
840
+ * console.log(exception.message, exception.action);
841
+ * ```
842
+ */
843
+ public constructor(action: RestoreAction);
844
+ }
845
+
846
+ /**
847
+ * Thrown when a wire value names no capture mode.
848
+ */
849
+ export declare class UnknownCaptureModeException extends ProtocolException {
850
+ /**
851
+ * The wire value, as text.
852
+ */
853
+ public readonly value: string;
854
+
855
+ /**
856
+ * Formats the exception's message from its facts.
857
+ *
858
+ * @param value The wire value, as text.
859
+ * @example
860
+ * ```ts
861
+ * import { UnknownCaptureModeException } from "@noldova/checkpoints.protocol";
862
+ *
863
+ * const exception = new UnknownCaptureModeException("everyFile");
864
+ * console.log(exception.message, exception.value);
865
+ * ```
866
+ */
867
+ public constructor(value: string);
868
+ }
869
+
870
+ /**
871
+ * Thrown when a wire value names no capture outcome.
872
+ */
873
+ export declare class UnknownCaptureOutcomeException extends ProtocolException {
874
+ /**
875
+ * The wire value, as text.
876
+ */
877
+ public readonly value: string;
878
+
879
+ /**
880
+ * Formats the exception's message from its facts.
881
+ *
882
+ * @param value The wire value, as text.
883
+ * @example
884
+ * ```ts
885
+ * import { UnknownCaptureOutcomeException } from "@noldova/checkpoints.protocol";
886
+ *
887
+ * const exception = new UnknownCaptureOutcomeException("Paused");
888
+ * console.log(exception.message, exception.value);
889
+ * ```
890
+ */
891
+ public constructor(value: string);
892
+ }
893
+
894
+ /**
895
+ * Thrown when a wire value names no change status.
896
+ */
897
+ export declare class UnknownChangeStatusException extends ProtocolException {
898
+ /**
899
+ * The wire value, as text.
900
+ */
901
+ public readonly value: string;
902
+
903
+ /**
904
+ * Formats the exception's message from its facts.
905
+ *
906
+ * @param value The wire value, as text.
907
+ * @example
908
+ * ```ts
909
+ * import { UnknownChangeStatusException } from "@noldova/checkpoints.protocol";
910
+ *
911
+ * const exception = new UnknownChangeStatusException("Renamed");
912
+ * console.log(exception.message, exception.value);
913
+ * ```
914
+ */
915
+ public constructor(value: string);
916
+ }
917
+
918
+ /**
919
+ * Thrown when a wire value names no compare outcome.
920
+ */
921
+ export declare class UnknownCompareOutcomeException extends ProtocolException {
922
+ /**
923
+ * The wire value, as text.
924
+ */
925
+ public readonly value: string;
926
+
927
+ /**
928
+ * Formats the exception's message from its facts.
929
+ *
930
+ * @param value The wire value, as text.
931
+ * @example
932
+ * ```ts
933
+ * import { UnknownCompareOutcomeException } from "@noldova/checkpoints.protocol";
934
+ *
935
+ * const exception = new UnknownCompareOutcomeException("Paused");
936
+ * console.log(exception.message, exception.value);
937
+ * ```
938
+ */
939
+ public constructor(value: string);
940
+ }
941
+
942
+ /**
943
+ * Thrown when a wire value names no delete outcome.
944
+ */
945
+ export declare class UnknownDeleteFolderOutcomeException extends ProtocolException {
946
+ /**
947
+ * The wire value, as text.
948
+ */
949
+ public readonly value: string;
950
+
951
+ /**
952
+ * Formats the exception's message from its facts.
953
+ *
954
+ * @param value The wire value, as text.
955
+ * @example
956
+ * ```ts
957
+ * import { UnknownDeleteFolderOutcomeException } from "@noldova/checkpoints.protocol";
958
+ *
959
+ * const exception = new UnknownDeleteFolderOutcomeException("Missing");
960
+ * console.log(exception.message, exception.value);
961
+ * ```
962
+ */
963
+ public constructor(value: string);
964
+ }
965
+
966
+ /**
967
+ * Thrown when a model's wire form has a field the model doesn't.
968
+ */
969
+ export declare class UnknownFieldException extends ProtocolException {
970
+ /**
971
+ * The field's name.
972
+ */
973
+ public readonly field: string;
974
+
975
+ /**
976
+ * The model's name.
977
+ */
978
+ public readonly model: string;
979
+
980
+ /**
981
+ * Formats the exception's message from its facts.
982
+ *
983
+ * @param model The model's name.
984
+ * @param field The field's name.
985
+ * @example
986
+ * ```ts
987
+ * import { UnknownFieldException } from "@noldova/checkpoints.protocol";
988
+ *
989
+ * const exception = new UnknownFieldException("Model", "other");
990
+ * console.log(exception.message, exception.model, exception.field);
991
+ * ```
992
+ */
993
+ public constructor(model: string, field: string);
994
+ }
995
+
996
+ /**
997
+ * Thrown when a wire value names no reason a restore keeps a path.
998
+ */
999
+ export declare class UnknownKeepReasonException extends ProtocolException {
1000
+ /**
1001
+ * The wire value, as text.
1002
+ */
1003
+ public readonly value: string;
1004
+
1005
+ /**
1006
+ * Formats the exception's message from its facts.
1007
+ *
1008
+ * @param value The wire value, as text.
1009
+ * @example
1010
+ * ```ts
1011
+ * import { UnknownKeepReasonException } from "@noldova/checkpoints.protocol";
1012
+ *
1013
+ * const exception = new UnknownKeepReasonException("Locked");
1014
+ * console.log(exception.message, exception.value);
1015
+ * ```
1016
+ */
1017
+ public constructor(value: string);
1018
+ }
1019
+
1020
+ /**
1021
+ * Thrown when a wire value names no kind of path.
1022
+ */
1023
+ export declare class UnknownPathKindException extends ProtocolException {
1024
+ /**
1025
+ * The wire value, as text.
1026
+ */
1027
+ public readonly value: string;
1028
+
1029
+ /**
1030
+ * Formats the exception's message from its facts.
1031
+ *
1032
+ * @param value The wire value, as text.
1033
+ * @example
1034
+ * ```ts
1035
+ * import { UnknownPathKindException } from "@noldova/checkpoints.protocol";
1036
+ *
1037
+ * const exception = new UnknownPathKindException("Socket");
1038
+ * console.log(exception.message, exception.value);
1039
+ * ```
1040
+ */
1041
+ public constructor(value: string);
1042
+ }
1043
+
1044
+ /**
1045
+ * Thrown when a wire value names no preview outcome.
1046
+ */
1047
+ export declare class UnknownPreviewOutcomeException extends ProtocolException {
1048
+ /**
1049
+ * The wire value, as text.
1050
+ */
1051
+ public readonly value: string;
1052
+
1053
+ /**
1054
+ * Formats the exception's message from its facts.
1055
+ *
1056
+ * @param value The wire value, as text.
1057
+ * @example
1058
+ * ```ts
1059
+ * import { UnknownPreviewOutcomeException } from "@noldova/checkpoints.protocol";
1060
+ *
1061
+ * const exception = new UnknownPreviewOutcomeException("Compared");
1062
+ * console.log(exception.message, exception.value);
1063
+ * ```
1064
+ */
1065
+ public constructor(value: string);
1066
+ }
1067
+
1068
+ /**
1069
+ * Thrown when a wire value names no read outcome.
1070
+ */
1071
+ export declare class UnknownReadOutcomeException extends ProtocolException {
1072
+ /**
1073
+ * The wire value, as text.
1074
+ */
1075
+ public readonly value: string;
1076
+
1077
+ /**
1078
+ * Formats the exception's message from its facts.
1079
+ *
1080
+ * @param value The wire value, as text.
1081
+ * @example
1082
+ * ```ts
1083
+ * import { UnknownReadOutcomeException } from "@noldova/checkpoints.protocol";
1084
+ *
1085
+ * const exception = new UnknownReadOutcomeException("Cut");
1086
+ * console.log(exception.message, exception.value);
1087
+ * ```
1088
+ */
1089
+ public constructor(value: string);
1090
+ }
1091
+
1092
+ /**
1093
+ * Thrown when a wire value names no restore action.
1094
+ */
1095
+ export declare class UnknownRestoreActionException extends ProtocolException {
1096
+ /**
1097
+ * The wire value, as text.
1098
+ */
1099
+ public readonly value: string;
1100
+
1101
+ /**
1102
+ * Formats the exception's message from its facts.
1103
+ *
1104
+ * @param value The wire value, as text.
1105
+ * @example
1106
+ * ```ts
1107
+ * import { UnknownRestoreActionException } from "@noldova/checkpoints.protocol";
1108
+ *
1109
+ * const exception = new UnknownRestoreActionException("Move");
1110
+ * console.log(exception.message, exception.value);
1111
+ * ```
1112
+ */
1113
+ public constructor(value: string);
1114
+ }
1115
+
1116
+ /**
1117
+ * Thrown when a wire value names no restore outcome.
1118
+ */
1119
+ export declare class UnknownRestoreOutcomeException extends ProtocolException {
1120
+ /**
1121
+ * The wire value, as text.
1122
+ */
1123
+ public readonly value: string;
1124
+
1125
+ /**
1126
+ * Formats the exception's message from its facts.
1127
+ *
1128
+ * @param value The wire value, as text.
1129
+ * @example
1130
+ * ```ts
1131
+ * import { UnknownRestoreOutcomeException } from "@noldova/checkpoints.protocol";
1132
+ *
1133
+ * const exception = new UnknownRestoreOutcomeException("Planned");
1134
+ * console.log(exception.message, exception.value);
1135
+ * ```
1136
+ */
1137
+ public constructor(value: string);
1138
+ }
1139
+
1140
+ /**
1141
+ * Thrown when a wire value names no reason for a path that couldn't be read.
1142
+ */
1143
+ export declare class UnknownUnreadReasonException extends ProtocolException {
1144
+ /**
1145
+ * The wire value, as text.
1146
+ */
1147
+ public readonly value: string;
1148
+
1149
+ /**
1150
+ * Formats the exception's message from its facts.
1151
+ *
1152
+ * @param value The wire value, as text.
1153
+ * @example
1154
+ * ```ts
1155
+ * import { UnknownUnreadReasonException } from "@noldova/checkpoints.protocol";
1156
+ *
1157
+ * const exception = new UnknownUnreadReasonException("Locked");
1158
+ * console.log(exception.message, exception.value);
1159
+ * ```
1160
+ */
1161
+ public constructor(value: string);
1162
+ }
1163
+
1164
+ /**
1165
+ * Thrown when a path that couldn't be read has an error code other than exactly when its reason is Unreadable.
1166
+ */
1167
+ export declare class UnreadCodeMismatchException extends ProtocolException {
1168
+ /**
1169
+ * The reason the path was given.
1170
+ */
1171
+ public readonly reason: UnreadReason;
1172
+
1173
+ /**
1174
+ * Formats the exception's message from its facts.
1175
+ *
1176
+ * @param reason The reason the path was given.
1177
+ * @example
1178
+ * ```ts
1179
+ * import { UnreadCodeMismatchException, UnreadReason } from "@noldova/checkpoints.protocol";
1180
+ *
1181
+ * const exception = new UnreadCodeMismatchException(UnreadReason.Denied);
1182
+ * console.log(exception.message, exception.reason);
1183
+ * ```
1184
+ */
1185
+ public constructor(reason: UnreadReason);
1186
+ }
1187
+
1188
+ /**
1189
+ * Thrown when a change has a reason it couldn't be read other than exactly when its status is Unknown.
1190
+ */
1191
+ export declare class UnreadReasonMismatchException extends ProtocolException {
1192
+ /**
1193
+ * The status the change was given.
1194
+ */
1195
+ public readonly status: ChangeStatus;
1196
+
1197
+ /**
1198
+ * Formats the exception's message from its facts.
1199
+ *
1200
+ * @param status The status the change was given.
1201
+ * @example
1202
+ * ```ts
1203
+ * import { ChangeStatus, UnreadReasonMismatchException } from "@noldova/checkpoints.protocol";
1204
+ *
1205
+ * const exception = new UnreadReasonMismatchException(ChangeStatus.Modified);
1206
+ * console.log(exception.message, exception.status);
1207
+ * ```
1208
+ */
1209
+ public constructor(status: ChangeStatus);
1210
+ }
1211
+
1212
+ /**
1213
+ * Which files a checkpoint keeps.
1214
+ */
1215
+ export declare class CaptureMode {
1216
+ /**
1217
+ * Every file, link and folder but each `.git`.
1218
+ */
1219
+ public static readonly EveryFile: CaptureMode;
1220
+
1221
+ /**
1222
+ * Every file, link and folder that the folder's `.gitignore` files don't ignore, matched as Git matches them, and never a `.git`.
1223
+ */
1224
+ public static readonly IgnoreFiles: CaptureMode;
1225
+
1226
+ /**
1227
+ * The mode's wire value.
1228
+ */
1229
+ public readonly value: string;
1230
+
1231
+ private constructor();
1232
+
1233
+ /**
1234
+ * Reads a mode from its wire value.
1235
+ *
1236
+ * @param value The wire value.
1237
+ * @returns The mode.
1238
+ * @throws {ProtocolException} Thrown synchronously when the value names no mode.
1239
+ * @example
1240
+ * ```ts
1241
+ * import { CaptureMode } from "@noldova/checkpoints.protocol";
1242
+ *
1243
+ * console.log(CaptureMode.fromJson("EveryFile") === CaptureMode.EveryFile);
1244
+ * ```
1245
+ */
1246
+ public static fromJson(value: unknown): CaptureMode;
1247
+
1248
+ /**
1249
+ * @returns The mode's wire value.
1250
+ * @example
1251
+ * ```ts
1252
+ * import { CaptureMode } from "@noldova/checkpoints.protocol";
1253
+ *
1254
+ * console.log(CaptureMode.IgnoreFiles.toJson());
1255
+ * ```
1256
+ */
1257
+ public toJson(): string;
1258
+ }
1259
+
1260
+ /**
1261
+ * Whether a capture took a checkpoint, and why not when it didn't.
1262
+ */
1263
+ export declare class CaptureOutcome {
1264
+ /**
1265
+ * The capture took a checkpoint.
1266
+ */
1267
+ public static readonly Captured: CaptureOutcome;
1268
+
1269
+ /**
1270
+ * The folder's path is missing, so no checkpoint was taken; a missing folder is never captured as empty.
1271
+ */
1272
+ public static readonly FolderMissing: CaptureOutcome;
1273
+
1274
+ /**
1275
+ * A restore of the folder is running, or was interrupted and couldn't be rolled back, so no checkpoint was taken.
1276
+ */
1277
+ public static readonly HeldUp: CaptureOutcome;
1278
+
1279
+ /**
1280
+ * The store's volume lacks the space the checkpoint needs, 2 GiB beyond what it adds, before or while its content is written, so no
1281
+ * checkpoint was taken; the result says the space free and the space needed.
1282
+ */
1283
+ public static readonly LowDiskSpace: CaptureOutcome;
1284
+
1285
+ /**
1286
+ * Whether the capture took a checkpoint.
1287
+ */
1288
+ public readonly isCaptured: boolean;
1289
+
1290
+ /**
1291
+ * The outcome's wire value.
1292
+ */
1293
+ public readonly value: string;
1294
+
1295
+ private constructor();
1296
+
1297
+ /**
1298
+ * Reads an outcome from its wire value.
1299
+ *
1300
+ * @param value The wire value.
1301
+ * @returns The outcome.
1302
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
1303
+ * @example
1304
+ * ```ts
1305
+ * import { CaptureOutcome } from "@noldova/checkpoints.protocol";
1306
+ *
1307
+ * console.log(CaptureOutcome.fromJson("Captured") === CaptureOutcome.Captured);
1308
+ * ```
1309
+ */
1310
+ public static fromJson(value: unknown): CaptureOutcome;
1311
+
1312
+ /**
1313
+ * @returns The outcome's wire value.
1314
+ * @example
1315
+ * ```ts
1316
+ * import { CaptureOutcome } from "@noldova/checkpoints.protocol";
1317
+ *
1318
+ * console.log(CaptureOutcome.LowDiskSpace.toJson());
1319
+ * ```
1320
+ */
1321
+ public toJson(): string;
1322
+ }
1323
+
1324
+ /**
1325
+ * Why a checkpoint keeps no content for a path.
1326
+ */
1327
+ export declare class UnreadReason {
1328
+ /**
1329
+ * The file kept changing while it was read, three times in all.
1330
+ */
1331
+ public static readonly Changing: UnreadReason;
1332
+
1333
+ /**
1334
+ * The system wouldn't let the module read the path.
1335
+ */
1336
+ public static readonly Denied: UnreadReason;
1337
+
1338
+ /**
1339
+ * The name isn't valid Unicode, so the API can't name it; the path is shown with replacement characters.
1340
+ */
1341
+ public static readonly InvalidName: UnreadReason;
1342
+
1343
+ /**
1344
+ * The system gave an error reading the path that is about this one path only, such as a name too long for it, a network share that timed out,
1345
+ * or a cloud file that isn't on the computer; {@link UnreadPath.code} holds the error's code.
1346
+ */
1347
+ public static readonly Unreadable: UnreadReason;
1348
+
1349
+ /**
1350
+ * The reason's wire value.
1351
+ */
1352
+ public readonly value: string;
1353
+
1354
+ private constructor();
1355
+
1356
+ /**
1357
+ * Reads a reason from its wire value.
1358
+ *
1359
+ * @param value The wire value.
1360
+ * @returns The reason.
1361
+ * @throws {ProtocolException} Thrown synchronously when the value names no reason.
1362
+ * @example
1363
+ * ```ts
1364
+ * import { UnreadReason } from "@noldova/checkpoints.protocol";
1365
+ *
1366
+ * console.log(UnreadReason.fromJson("Denied") === UnreadReason.Denied);
1367
+ * ```
1368
+ */
1369
+ public static fromJson(value: unknown): UnreadReason;
1370
+
1371
+ /**
1372
+ * @returns The reason's wire value.
1373
+ * @example
1374
+ * ```ts
1375
+ * import { UnreadReason } from "@noldova/checkpoints.protocol";
1376
+ *
1377
+ * console.log(UnreadReason.Unreadable.toJson());
1378
+ * ```
1379
+ */
1380
+ public toJson(): string;
1381
+ }
1382
+
1383
+ /**
1384
+ * A path a checkpoint keeps no content for, and why; a restore of the checkpoint leaves the path as it is.
1385
+ */
1386
+ export declare class UnreadPath {
1387
+ /**
1388
+ * The path, relative to the folder, with `/` between names.
1389
+ */
1390
+ public readonly path: string;
1391
+
1392
+ /**
1393
+ * Why the checkpoint keeps no content for it.
1394
+ */
1395
+ public readonly reason: UnreadReason;
1396
+
1397
+ /**
1398
+ * The system's error code, such as `ENAMETOOLONG`, when the reason is {@link UnreadReason.Unreadable}; otherwise `null`. The wire form
1399
+ * always holds the code, as `null` when there is none, and a wire form without it is refused.
1400
+ */
1401
+ public readonly code: string | null;
1402
+
1403
+ /**
1404
+ * @param path The path, relative to the folder, with `/` between names.
1405
+ * @param reason Why the checkpoint keeps no content for it.
1406
+ * @param code The system's error code when the reason is {@link UnreadReason.Unreadable}; otherwise `null`.
1407
+ * @throws {ProtocolException} Thrown synchronously when the path has an empty name, `.` or `..`, or it has a code other than exactly when
1408
+ * its reason is {@link UnreadReason.Unreadable}.
1409
+ * @example
1410
+ * ```ts
1411
+ * import { UnreadPath, UnreadReason } from "@noldova/checkpoints.protocol";
1412
+ *
1413
+ * const path = new UnreadPath("docs/report.pdf", UnreadReason.Unreadable, "ETIMEDOUT");
1414
+ * console.log(path.code);
1415
+ * ```
1416
+ */
1417
+ public constructor(path: string, reason: UnreadReason, code: string | null);
1418
+
1419
+ /**
1420
+ * Reads a path from its wire form.
1421
+ *
1422
+ * @param value The wire form.
1423
+ * @returns The path.
1424
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a path.
1425
+ * @example
1426
+ * ```ts
1427
+ * import { UnreadPath } from "@noldova/checkpoints.protocol";
1428
+ *
1429
+ * const path = UnreadPath.fromJson({ path: "src/main.ts", reason: "Denied", code: null });
1430
+ * console.log(path.reason.value);
1431
+ * ```
1432
+ */
1433
+ public static fromJson(value: unknown): UnreadPath;
1434
+
1435
+ /**
1436
+ * @returns The wire form.
1437
+ * @example
1438
+ * ```ts
1439
+ * import { UnreadPath, UnreadReason } from "@noldova/checkpoints.protocol";
1440
+ *
1441
+ * const path = new UnreadPath("docs/report.pdf", UnreadReason.Unreadable, "ETIMEDOUT");
1442
+ * console.log(JSON.stringify(path.toJson()));
1443
+ * ```
1444
+ */
1445
+ public toJson(): JsonObject;
1446
+ }
1447
+
1448
+ /**
1449
+ * A checkpoint: a folder's files as they were when it was taken.
1450
+ */
1451
+ export declare class Checkpoint {
1452
+ /**
1453
+ * The checkpoint's id, a UUID of version 7, so that ids sort by the time they were taken.
1454
+ */
1455
+ public readonly id: string;
1456
+
1457
+ /**
1458
+ * The label the app attached, of up to 1,024 characters, or `null`.
1459
+ */
1460
+ public readonly label: string | null;
1461
+
1462
+ /**
1463
+ * Which files the checkpoint keeps.
1464
+ */
1465
+ public readonly mode: CaptureMode;
1466
+
1467
+ /**
1468
+ * When the capture started.
1469
+ */
1470
+ public readonly time: Date;
1471
+
1472
+ /**
1473
+ * The paths the checkpoint keeps no content for, with why.
1474
+ */
1475
+ public readonly unreadPaths: readonly UnreadPath[];
1476
+
1477
+ /**
1478
+ * @param id The checkpoint's id, a UUID of version 7.
1479
+ * @param time When the capture started.
1480
+ * @param mode Which files the checkpoint keeps.
1481
+ * @param label The label the app attached, or `null`.
1482
+ * @param unreadPaths The paths the checkpoint keeps no content for.
1483
+ * @throws {ProtocolException} Thrown synchronously when the id isn't a UUID of version 7, the time isn't a valid date, or the label is
1484
+ * longer than 1,024 characters.
1485
+ * @example
1486
+ * ```ts
1487
+ * import { CaptureMode, Checkpoint } from "@noldova/checkpoints.protocol";
1488
+ *
1489
+ * const checkpoint = new Checkpoint("01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f", new Date(), CaptureMode.EveryFile, "Turn 3", []);
1490
+ * console.log(checkpoint.toJson());
1491
+ * ```
1492
+ */
1493
+ public constructor(id: string, time: Date, mode: CaptureMode, label: string | null, unreadPaths: readonly UnreadPath[]);
1494
+
1495
+ /**
1496
+ * Reads a checkpoint from its wire form, whose time is an ISO 8601 text in UTC.
1497
+ *
1498
+ * @param value The wire form.
1499
+ * @returns The checkpoint.
1500
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a checkpoint.
1501
+ * @example
1502
+ * ```ts
1503
+ * import { Checkpoint } from "@noldova/checkpoints.protocol";
1504
+ *
1505
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
1506
+ * const checkpoint = Checkpoint.fromJson({ id: id, time: "2026-10-18T12:00:00.000Z", mode: "EveryFile", label: "Turn 3", unreadPaths: [] });
1507
+ * console.log(checkpoint.time.toISOString());
1508
+ * ```
1509
+ */
1510
+ public static fromJson(value: unknown): Checkpoint;
1511
+
1512
+ /**
1513
+ * @returns The wire form.
1514
+ * @example
1515
+ * ```ts
1516
+ * import { CaptureMode, Checkpoint } from "@noldova/checkpoints.protocol";
1517
+ *
1518
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
1519
+ * const checkpoint = new Checkpoint(id, new Date("2026-10-18T12:00:00.000Z"), CaptureMode.EveryFile, null, []);
1520
+ * console.log(JSON.stringify(checkpoint.toJson()));
1521
+ * ```
1522
+ */
1523
+ public toJson(): JsonObject;
1524
+ }
1525
+
1526
+ /**
1527
+ * A folder as the app names it: the identity its checkpoints are kept under, so a moved folder keeps them, and where it is now.
1528
+ */
1529
+ export declare class FolderReference {
1530
+ /**
1531
+ * The identity the app owns, 1 to 64 letters, digits and `-`, such as a project's id.
1532
+ */
1533
+ public readonly identity: string;
1534
+
1535
+ /**
1536
+ * The folder's absolute path on this device now.
1537
+ */
1538
+ public readonly path: string;
1539
+
1540
+ /**
1541
+ * @param identity The identity the app owns.
1542
+ * @param path The folder's absolute path on this device now.
1543
+ * @throws {ProtocolException} Thrown synchronously when the identity isn't 1 to 64 letters, digits and `-`, or the path isn't absolute.
1544
+ * @example
1545
+ * ```ts
1546
+ * import { FolderReference } from "@noldova/checkpoints.protocol";
1547
+ *
1548
+ * const folder = new FolderReference("project-1", "/work/project");
1549
+ * console.log(folder.identity);
1550
+ * ```
1551
+ */
1552
+ public constructor(identity: string, path: string);
1553
+
1554
+ /**
1555
+ * Reads a folder from its wire form.
1556
+ *
1557
+ * @param value The wire form.
1558
+ * @returns The folder.
1559
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a folder.
1560
+ * @example
1561
+ * ```ts
1562
+ * import { FolderReference } from "@noldova/checkpoints.protocol";
1563
+ *
1564
+ * const folder = FolderReference.fromJson({ identity: "project-1", path: "/work/project" });
1565
+ * console.log(folder.path);
1566
+ * ```
1567
+ */
1568
+ public static fromJson(value: unknown): FolderReference;
1569
+
1570
+ /**
1571
+ * @returns The wire form.
1572
+ * @example
1573
+ * ```ts
1574
+ * import { FolderReference } from "@noldova/checkpoints.protocol";
1575
+ *
1576
+ * const folder = new FolderReference("project-1", "/work/project");
1577
+ * console.log(JSON.stringify(folder.toJson()));
1578
+ * ```
1579
+ */
1580
+ public toJson(): JsonObject;
1581
+ }
1582
+
1583
+ /**
1584
+ * The request of `checkpoints.capture`: take a checkpoint of a folder.
1585
+ */
1586
+ export declare class CaptureRequest {
1587
+ /**
1588
+ * The method's name, `"checkpoints.capture"`.
1589
+ */
1590
+ public static readonly method: string;
1591
+
1592
+ /**
1593
+ * The folder to take a checkpoint of.
1594
+ */
1595
+ public readonly folder: FolderReference;
1596
+
1597
+ /**
1598
+ * The label to attach, or `null`.
1599
+ */
1600
+ public readonly label: string | null;
1601
+
1602
+ /**
1603
+ * @param folder The folder to take a checkpoint of.
1604
+ * @param label The label to attach, of up to 1,024 characters, or `null`.
1605
+ * @throws {ProtocolException} Thrown synchronously when the label is longer than 1,024 characters.
1606
+ * @example
1607
+ * ```ts
1608
+ * import { CaptureRequest, FolderReference } from "@noldova/checkpoints.protocol";
1609
+ *
1610
+ * const request = new CaptureRequest(new FolderReference("project-1", "/work/project"), "Turn 3");
1611
+ * console.log(CaptureRequest.method, request.toJson());
1612
+ * ```
1613
+ */
1614
+ public constructor(folder: FolderReference, label: string | null);
1615
+
1616
+ /**
1617
+ * Reads a request from its wire form.
1618
+ *
1619
+ * @param value The wire form.
1620
+ * @returns The request.
1621
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
1622
+ * @example
1623
+ * ```ts
1624
+ * import { CaptureRequest } from "@noldova/checkpoints.protocol";
1625
+ *
1626
+ * const folderJson = { identity: "project-1", path: "/work/project" };
1627
+ * const request = CaptureRequest.fromJson({ folder: folderJson, label: null });
1628
+ * console.log(request.label);
1629
+ * ```
1630
+ */
1631
+ public static fromJson(value: unknown): CaptureRequest;
1632
+
1633
+ /**
1634
+ * @returns The wire form.
1635
+ * @example
1636
+ * ```ts
1637
+ * import { CaptureRequest, FolderReference } from "@noldova/checkpoints.protocol";
1638
+ *
1639
+ * const folder = new FolderReference("project-1", "/work/project");
1640
+ * const request = new CaptureRequest(folder, "Turn 3");
1641
+ * console.log(JSON.stringify(request.toJson()));
1642
+ * ```
1643
+ */
1644
+ public toJson(): JsonObject;
1645
+ }
1646
+
1647
+ /**
1648
+ * What a capture did: the checkpoint it took, or why it took none, with the space free and the space needed when it took none for want
1649
+ * of space.
1650
+ */
1651
+ export declare class CaptureResult {
1652
+ /**
1653
+ * The checkpoint taken, or `null` when none was.
1654
+ */
1655
+ public readonly checkpoint: Checkpoint | null;
1656
+
1657
+ /**
1658
+ * Whether the capture took a checkpoint.
1659
+ */
1660
+ public readonly outcome: CaptureOutcome;
1661
+
1662
+ /**
1663
+ * The bytes free on the store's volume for the module, when the outcome is `LowDiskSpace`, or `null`.
1664
+ */
1665
+ public readonly spaceFree: number | null;
1666
+
1667
+ /**
1668
+ * The bytes the checkpoint needed free, when the outcome is `LowDiskSpace`, or `null`.
1669
+ */
1670
+ public readonly spaceNeeded: number | null;
1671
+
1672
+ /**
1673
+ * @param outcome Whether the capture took a checkpoint.
1674
+ * @param checkpoint The checkpoint taken, or `null` when none was.
1675
+ * @param spaceFree The bytes free, when the outcome is `LowDiskSpace`, or `null`.
1676
+ * @param spaceNeeded The bytes needed, when the outcome is `LowDiskSpace`, or `null`.
1677
+ * @throws {ProtocolException} Thrown synchronously when the outcome and the checkpoint or the space disagree, or a size isn't a whole
1678
+ * number of bytes.
1679
+ * @example
1680
+ * ```ts
1681
+ * import { CaptureOutcome, CaptureResult } from "@noldova/checkpoints.protocol";
1682
+ *
1683
+ * const result = new CaptureResult(CaptureOutcome.LowDiskSpace, null, 1_073_741_824, 3_221_225_472);
1684
+ * console.log(result.spaceNeeded);
1685
+ * ```
1686
+ */
1687
+ public constructor(outcome: CaptureOutcome, checkpoint: Checkpoint | null, spaceFree: number | null, spaceNeeded: number | null);
1688
+
1689
+ /**
1690
+ * Reads a result from its wire form.
1691
+ *
1692
+ * @param value The wire form.
1693
+ * @returns The result.
1694
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result.
1695
+ * @example
1696
+ * ```ts
1697
+ * import { CaptureResult } from "@noldova/checkpoints.protocol";
1698
+ *
1699
+ * const result = CaptureResult.fromJson({ outcome: "FolderMissing", checkpoint: null, spaceFree: null, spaceNeeded: null });
1700
+ * console.log(result.outcome.isCaptured);
1701
+ * ```
1702
+ */
1703
+ public static fromJson(value: unknown): CaptureResult;
1704
+
1705
+ /**
1706
+ * @returns The wire form.
1707
+ * @example
1708
+ * ```ts
1709
+ * import { CaptureOutcome, CaptureResult } from "@noldova/checkpoints.protocol";
1710
+ *
1711
+ * const result = new CaptureResult(CaptureOutcome.LowDiskSpace, null, 1_073_741_824, 3_221_225_472);
1712
+ * console.log(JSON.stringify(result.toJson()));
1713
+ * ```
1714
+ */
1715
+ public toJson(): JsonObject;
1716
+ }
1717
+
1718
+ /**
1719
+ * The request of `checkpoints.list`: a folder's checkpoints.
1720
+ */
1721
+ export declare class ListRequest {
1722
+ /**
1723
+ * The method's name, `"checkpoints.list"`.
1724
+ */
1725
+ public static readonly method: string;
1726
+
1727
+ /**
1728
+ * The folder whose checkpoints to list.
1729
+ */
1730
+ public readonly folder: FolderReference;
1731
+
1732
+ /**
1733
+ * @param folder The folder whose checkpoints to list.
1734
+ * @example
1735
+ * ```ts
1736
+ * import { FolderReference, ListRequest } from "@noldova/checkpoints.protocol";
1737
+ *
1738
+ * const folder = new FolderReference("project-1", "/work/project");
1739
+ * const request = new ListRequest(folder);
1740
+ * console.log(ListRequest.method);
1741
+ * ```
1742
+ */
1743
+ public constructor(folder: FolderReference);
1744
+
1745
+ /**
1746
+ * Reads a request from its wire form.
1747
+ *
1748
+ * @param value The wire form.
1749
+ * @returns The request.
1750
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
1751
+ * @example
1752
+ * ```ts
1753
+ * import { ListRequest } from "@noldova/checkpoints.protocol";
1754
+ *
1755
+ * const folderJson = { identity: "project-1", path: "/work/project" };
1756
+ * const request = ListRequest.fromJson({ folder: folderJson });
1757
+ * console.log(request.folder.path);
1758
+ * ```
1759
+ */
1760
+ public static fromJson(value: unknown): ListRequest;
1761
+
1762
+ /**
1763
+ * @returns The wire form.
1764
+ * @example
1765
+ * ```ts
1766
+ * import { FolderReference, ListRequest } from "@noldova/checkpoints.protocol";
1767
+ *
1768
+ * const folder = new FolderReference("project-1", "/work/project");
1769
+ * const request = new ListRequest(folder);
1770
+ * console.log(JSON.stringify(request.toJson()));
1771
+ * ```
1772
+ */
1773
+ public toJson(): JsonObject;
1774
+ }
1775
+
1776
+ /**
1777
+ * A folder's checkpoints, newest first.
1778
+ */
1779
+ export declare class CheckpointList {
1780
+ /**
1781
+ * The checkpoints, newest first.
1782
+ */
1783
+ public readonly checkpoints: readonly Checkpoint[];
1784
+
1785
+ /**
1786
+ * @param checkpoints The checkpoints, newest first.
1787
+ * @example
1788
+ * ```ts
1789
+ * import { CheckpointList } from "@noldova/checkpoints.protocol";
1790
+ *
1791
+ * const list = new CheckpointList([]);
1792
+ * console.log(list.checkpoints.length);
1793
+ * ```
1794
+ */
1795
+ public constructor(checkpoints: readonly Checkpoint[]);
1796
+
1797
+ /**
1798
+ * Reads a list from its wire form.
1799
+ *
1800
+ * @param value The wire form.
1801
+ * @returns The list.
1802
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a list.
1803
+ * @example
1804
+ * ```ts
1805
+ * import { CheckpointList } from "@noldova/checkpoints.protocol";
1806
+ *
1807
+ * const list = CheckpointList.fromJson({ checkpoints: [] });
1808
+ * console.log(list.checkpoints.length);
1809
+ * ```
1810
+ */
1811
+ public static fromJson(value: unknown): CheckpointList;
1812
+
1813
+ /**
1814
+ * @returns The wire form.
1815
+ * @example
1816
+ * ```ts
1817
+ * import { CheckpointList } from "@noldova/checkpoints.protocol";
1818
+ *
1819
+ * const list = new CheckpointList([]);
1820
+ * console.log(JSON.stringify(list.toJson()));
1821
+ * ```
1822
+ */
1823
+ public toJson(): JsonObject;
1824
+ }
1825
+
1826
+ /**
1827
+ * What a path is on one side of a change.
1828
+ */
1829
+ export declare class PathKind {
1830
+ /**
1831
+ * A file.
1832
+ */
1833
+ public static readonly File: PathKind;
1834
+
1835
+ /**
1836
+ * A file its owner may run; Windows keeps no such mode, so there every file is a {@link PathKind.File}.
1837
+ */
1838
+ public static readonly Executable: PathKind;
1839
+
1840
+ /**
1841
+ * A link, which is never followed.
1842
+ */
1843
+ public static readonly Link: PathKind;
1844
+
1845
+ /**
1846
+ * A folder.
1847
+ */
1848
+ public static readonly Folder: PathKind;
1849
+
1850
+ /**
1851
+ * The kind's wire value.
1852
+ */
1853
+ public readonly value: string;
1854
+
1855
+ private constructor();
1856
+
1857
+ /**
1858
+ * Reads a kind from its wire value.
1859
+ *
1860
+ * @param value The wire value.
1861
+ * @returns The kind.
1862
+ * @throws {ProtocolException} Thrown synchronously when the value names no kind.
1863
+ * @example
1864
+ * ```ts
1865
+ * import { PathKind } from "@noldova/checkpoints.protocol";
1866
+ *
1867
+ * console.log(PathKind.fromJson("File") === PathKind.File);
1868
+ * ```
1869
+ */
1870
+ public static fromJson(value: unknown): PathKind;
1871
+
1872
+ /**
1873
+ * @returns The kind's wire value.
1874
+ * @example
1875
+ * ```ts
1876
+ * import { PathKind } from "@noldova/checkpoints.protocol";
1877
+ *
1878
+ * console.log(PathKind.Folder.toJson());
1879
+ * ```
1880
+ */
1881
+ public toJson(): string;
1882
+ }
1883
+
1884
+ /**
1885
+ * How a path changed from one side of a comparison to the other.
1886
+ */
1887
+ export declare class ChangeStatus {
1888
+ /**
1889
+ * The path is only on the side after.
1890
+ */
1891
+ public static readonly Added: ChangeStatus;
1892
+
1893
+ /**
1894
+ * The path is only on the side before.
1895
+ */
1896
+ public static readonly Deleted: ChangeStatus;
1897
+
1898
+ /**
1899
+ * The path's content changed, or it became executable or stopped being so.
1900
+ */
1901
+ public static readonly Modified: ChangeStatus;
1902
+
1903
+ /**
1904
+ * The path changed between a file, a link and a folder.
1905
+ */
1906
+ public static readonly KindChanged: ChangeStatus;
1907
+
1908
+ /**
1909
+ * A side couldn't read the path, so whether it changed is unknown; such a path is never reported as deleted.
1910
+ */
1911
+ public static readonly Unknown: ChangeStatus;
1912
+
1913
+ /**
1914
+ * The status's wire value.
1915
+ */
1916
+ public readonly value: string;
1917
+
1918
+ private constructor();
1919
+
1920
+ /**
1921
+ * Reads a status from its wire value.
1922
+ *
1923
+ * @param value The wire value.
1924
+ * @returns The status.
1925
+ * @throws {ProtocolException} Thrown synchronously when the value names no status.
1926
+ * @example
1927
+ * ```ts
1928
+ * import { ChangeStatus } from "@noldova/checkpoints.protocol";
1929
+ *
1930
+ * console.log(ChangeStatus.fromJson("Added") === ChangeStatus.Added);
1931
+ * ```
1932
+ */
1933
+ public static fromJson(value: unknown): ChangeStatus;
1934
+
1935
+ /**
1936
+ * @returns The status's wire value.
1937
+ * @example
1938
+ * ```ts
1939
+ * import { ChangeStatus } from "@noldova/checkpoints.protocol";
1940
+ *
1941
+ * console.log(ChangeStatus.KindChanged.toJson());
1942
+ * ```
1943
+ */
1944
+ public toJson(): string;
1945
+ }
1946
+
1947
+ /**
1948
+ * A path as one side of a change has it.
1949
+ */
1950
+ export declare class ChangeSide {
1951
+ /**
1952
+ * Whether Git would take the content as text: no NUL in its first 8,000 bytes, and at most 32 MiB. A folder is never text.
1953
+ */
1954
+ public readonly isText: boolean;
1955
+
1956
+ /**
1957
+ * What the path is.
1958
+ */
1959
+ public readonly kind: PathKind;
1960
+
1961
+ /**
1962
+ * The content's size in bytes, a link's being its target's, or `null` for a folder.
1963
+ */
1964
+ public readonly size: number | null;
1965
+
1966
+ /**
1967
+ * @param kind What the path is.
1968
+ * @param size The content's size in bytes, or `null` for a folder.
1969
+ * @param isText Whether Git would take the content as text.
1970
+ * @throws {ProtocolException} Thrown synchronously when a folder has a size or is text, another kind has none, or the size isn't a whole
1971
+ * number of 0 or more.
1972
+ * @example
1973
+ * ```ts
1974
+ * import { ChangeSide, PathKind } from "@noldova/checkpoints.protocol";
1975
+ *
1976
+ * const side = new ChangeSide(PathKind.File, 1_024, true);
1977
+ * console.log(side.size);
1978
+ * ```
1979
+ */
1980
+ public constructor(kind: PathKind, size: number | null, isText: boolean);
1981
+
1982
+ /**
1983
+ * Reads a side from its wire form.
1984
+ *
1985
+ * @param value The wire form.
1986
+ * @returns The side.
1987
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a side.
1988
+ * @example
1989
+ * ```ts
1990
+ * import { ChangeSide } from "@noldova/checkpoints.protocol";
1991
+ *
1992
+ * const side = ChangeSide.fromJson({ kind: "Folder", size: null, isText: false });
1993
+ * console.log(side.kind.value);
1994
+ * ```
1995
+ */
1996
+ public static fromJson(value: unknown): ChangeSide;
1997
+
1998
+ /**
1999
+ * @returns The wire form.
2000
+ * @example
2001
+ * ```ts
2002
+ * import { ChangeSide, PathKind } from "@noldova/checkpoints.protocol";
2003
+ *
2004
+ * const side = new ChangeSide(PathKind.File, 1_024, true);
2005
+ * console.log(JSON.stringify(side.toJson()));
2006
+ * ```
2007
+ */
2008
+ public toJson(): JsonObject;
2009
+ }
2010
+
2011
+ /**
2012
+ * One path that differs between the two sides of a comparison.
2013
+ */
2014
+ export declare class Change {
2015
+ /**
2016
+ * The path on the side after, or `null` when it's only before, or unknown there.
2017
+ */
2018
+ public readonly after: ChangeSide | null;
2019
+
2020
+ /**
2021
+ * The path on the side before, or `null` when it's only after, or unknown there.
2022
+ */
2023
+ public readonly before: ChangeSide | null;
2024
+
2025
+ /**
2026
+ * The path, relative to the folder, with `/` between names.
2027
+ */
2028
+ public readonly path: string;
2029
+
2030
+ /**
2031
+ * How the path changed.
2032
+ */
2033
+ public readonly status: ChangeStatus;
2034
+
2035
+ /**
2036
+ * Why a side couldn't read the path, for a change whose status is {@link ChangeStatus.Unknown}; otherwise `null`.
2037
+ */
2038
+ public readonly unreadReason: UnreadReason | null;
2039
+
2040
+ /**
2041
+ * @param path The path, relative to the folder, with `/` between names.
2042
+ * @param status How the path changed.
2043
+ * @param before The path on the side before, or `null`.
2044
+ * @param after The path on the side after, or `null`.
2045
+ * @param unreadReason Why a side couldn't read the path, or `null`.
2046
+ * @throws {ProtocolException} Thrown synchronously when the path has an empty name, `.` or `..`, the sides don't fit the status, or the
2047
+ * reason is given exactly when the status isn't {@link ChangeStatus.Unknown}.
2048
+ * @example
2049
+ * ```ts
2050
+ * import { Change, ChangeSide, ChangeStatus, PathKind } from "@noldova/checkpoints.protocol";
2051
+ *
2052
+ * const change = new Change("src/main.ts", ChangeStatus.Added, null, new ChangeSide(PathKind.File, 12, true), null);
2053
+ * console.log(change.status.value);
2054
+ * ```
2055
+ */
2056
+ public constructor(path: string, status: ChangeStatus, before: ChangeSide | null, after: ChangeSide | null, unreadReason: UnreadReason | null);
2057
+
2058
+ /**
2059
+ * Reads a change from its wire form.
2060
+ *
2061
+ * @param value The wire form.
2062
+ * @returns The change.
2063
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a change.
2064
+ * @example
2065
+ * ```ts
2066
+ * import { Change } from "@noldova/checkpoints.protocol";
2067
+ *
2068
+ * const change = Change.fromJson({ path: "notes.txt", status: "Deleted", before: { kind: "File", size: 3, isText: true }, after: null, unreadReason: null });
2069
+ * console.log(change.before?.size);
2070
+ * ```
2071
+ */
2072
+ public static fromJson(value: unknown): Change;
2073
+
2074
+ /**
2075
+ * @returns The wire form.
2076
+ * @example
2077
+ * ```ts
2078
+ * import { Change, ChangeSide, ChangeStatus, PathKind } from "@noldova/checkpoints.protocol";
2079
+ *
2080
+ * const change = new Change("src/main.ts", ChangeStatus.Added, null, new ChangeSide(PathKind.File, 12, true), null);
2081
+ * console.log(JSON.stringify(change.toJson()));
2082
+ * ```
2083
+ */
2084
+ public toJson(): JsonObject;
2085
+ }
2086
+
2087
+ /**
2088
+ * Whether a comparison compared, and why not when it didn't.
2089
+ */
2090
+ export declare class CompareOutcome {
2091
+ /**
2092
+ * The comparison compared the two sides.
2093
+ */
2094
+ public static readonly Compared: CompareOutcome;
2095
+
2096
+ /**
2097
+ * The comparison was with the folder now, and the folder's path is missing; a missing folder is never compared as empty.
2098
+ */
2099
+ public static readonly FolderMissing: CompareOutcome;
2100
+
2101
+ /**
2102
+ * The folder has no checkpoint with an id the request gave.
2103
+ */
2104
+ public static readonly CheckpointMissing: CompareOutcome;
2105
+
2106
+ /**
2107
+ * Whether the comparison compared.
2108
+ */
2109
+ public readonly isCompared: boolean;
2110
+
2111
+ /**
2112
+ * The outcome's wire value.
2113
+ */
2114
+ public readonly value: string;
2115
+
2116
+ private constructor();
2117
+
2118
+ /**
2119
+ * Reads an outcome from its wire value.
2120
+ *
2121
+ * @param value The wire value.
2122
+ * @returns The outcome.
2123
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
2124
+ * @example
2125
+ * ```ts
2126
+ * import { CompareOutcome } from "@noldova/checkpoints.protocol";
2127
+ *
2128
+ * console.log(CompareOutcome.fromJson("Compared") === CompareOutcome.Compared);
2129
+ * ```
2130
+ */
2131
+ public static fromJson(value: unknown): CompareOutcome;
2132
+
2133
+ /**
2134
+ * @returns The outcome's wire value.
2135
+ * @example
2136
+ * ```ts
2137
+ * import { CompareOutcome } from "@noldova/checkpoints.protocol";
2138
+ *
2139
+ * console.log(CompareOutcome.CheckpointMissing.toJson());
2140
+ * ```
2141
+ */
2142
+ public toJson(): string;
2143
+ }
2144
+
2145
+ /**
2146
+ * The request of `checkpoints.compare`: the changes from one of a folder's checkpoints to another, or to the folder now.
2147
+ */
2148
+ export declare class CompareRequest {
2149
+ /**
2150
+ * The method's name, `"checkpoints.compare"`.
2151
+ */
2152
+ public static readonly method: string;
2153
+
2154
+ /**
2155
+ * The folder whose checkpoints to compare.
2156
+ */
2157
+ public readonly folder: FolderReference;
2158
+
2159
+ /**
2160
+ * The id of the checkpoint the changes start from.
2161
+ */
2162
+ public readonly from: string;
2163
+
2164
+ /**
2165
+ * The id of the checkpoint the changes lead to, or `null` for the folder now.
2166
+ */
2167
+ public readonly to: string | null;
2168
+
2169
+ /**
2170
+ * @param folder The folder whose checkpoints to compare.
2171
+ * @param from The id of the checkpoint the changes start from.
2172
+ * @param to The id of the checkpoint the changes lead to, or `null` for the folder now.
2173
+ * @throws {ProtocolException} Thrown synchronously when an id isn't a UUID of version 7.
2174
+ * @example
2175
+ * ```ts
2176
+ * import { CompareRequest, FolderReference } from "@noldova/checkpoints.protocol";
2177
+ *
2178
+ * const request = new CompareRequest(new FolderReference("project-1", "/work/project"), "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f", null);
2179
+ * console.log(CompareRequest.method, request.toJson());
2180
+ * ```
2181
+ */
2182
+ public constructor(folder: FolderReference, from: string, to: string | null);
2183
+
2184
+ /**
2185
+ * Reads a request from its wire form.
2186
+ *
2187
+ * @param value The wire form.
2188
+ * @returns The request.
2189
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
2190
+ * @example
2191
+ * ```ts
2192
+ * import { CompareRequest } from "@noldova/checkpoints.protocol";
2193
+ *
2194
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2195
+ * const other = "01928f6e-7a3c-7c4d-8e5f-0a1b2c3d4e5f";
2196
+ * const folderJson = { identity: "project-1", path: "/work/project" };
2197
+ * const request = CompareRequest.fromJson({ folder: folderJson, from: id, to: other });
2198
+ * console.log(request.to);
2199
+ * ```
2200
+ */
2201
+ public static fromJson(value: unknown): CompareRequest;
2202
+
2203
+ /**
2204
+ * @returns The wire form.
2205
+ * @example
2206
+ * ```ts
2207
+ * import { CompareRequest, FolderReference } from "@noldova/checkpoints.protocol";
2208
+ *
2209
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2210
+ * const folder = new FolderReference("project-1", "/work/project");
2211
+ * const request = new CompareRequest(folder, id, null);
2212
+ * console.log(JSON.stringify(request.toJson()));
2213
+ * ```
2214
+ */
2215
+ public toJson(): JsonObject;
2216
+ }
2217
+
2218
+ /**
2219
+ * What a comparison found: the changes, or why it compared nothing.
2220
+ */
2221
+ export declare class CompareResult {
2222
+ /**
2223
+ * The changes, in their paths' byte order; none when the outcome isn't {@link CompareOutcome.Compared}.
2224
+ */
2225
+ public readonly changes: readonly Change[];
2226
+
2227
+ /**
2228
+ * Whether the comparison compared.
2229
+ */
2230
+ public readonly outcome: CompareOutcome;
2231
+
2232
+ /**
2233
+ * @param outcome Whether the comparison compared.
2234
+ * @param changes The changes.
2235
+ * @throws {ProtocolException} Thrown synchronously when an outcome other than {@link CompareOutcome.Compared} has changes.
2236
+ * @example
2237
+ * ```ts
2238
+ * import { CompareOutcome, CompareResult } from "@noldova/checkpoints.protocol";
2239
+ *
2240
+ * const result = new CompareResult(CompareOutcome.CheckpointMissing, []);
2241
+ * console.log(result.outcome.isCompared);
2242
+ * ```
2243
+ */
2244
+ public constructor(outcome: CompareOutcome, changes: readonly Change[]);
2245
+
2246
+ /**
2247
+ * Reads a result from its wire form.
2248
+ *
2249
+ * @param value The wire form.
2250
+ * @returns The result.
2251
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result.
2252
+ * @example
2253
+ * ```ts
2254
+ * import { CompareResult } from "@noldova/checkpoints.protocol";
2255
+ *
2256
+ * const result = CompareResult.fromJson({ outcome: "Compared", changes: [] });
2257
+ * console.log(result.changes.length);
2258
+ * ```
2259
+ */
2260
+ public static fromJson(value: unknown): CompareResult;
2261
+
2262
+ /**
2263
+ * @returns The wire form.
2264
+ * @example
2265
+ * ```ts
2266
+ * import { CompareOutcome, CompareResult } from "@noldova/checkpoints.protocol";
2267
+ *
2268
+ * const result = new CompareResult(CompareOutcome.CheckpointMissing, []);
2269
+ * console.log(JSON.stringify(result.toJson()));
2270
+ * ```
2271
+ */
2272
+ public toJson(): JsonObject;
2273
+ }
2274
+
2275
+ /**
2276
+ * What a read's line diff compares the file with.
2277
+ */
2278
+ export declare class DiffTarget {
2279
+ /**
2280
+ * The id of the checkpoint whose file the diff leads to, or `null` for the file in the folder now.
2281
+ */
2282
+ public readonly checkpoint: string | null;
2283
+
2284
+ /**
2285
+ * @param checkpoint The id of the checkpoint whose file the diff leads to, or `null` for the folder now.
2286
+ * @throws {ProtocolException} Thrown synchronously when the id isn't a UUID of version 7.
2287
+ * @example
2288
+ * ```ts
2289
+ * import { DiffTarget } from "@noldova/checkpoints.protocol";
2290
+ *
2291
+ * const target = new DiffTarget(null);
2292
+ * console.log(target.checkpoint);
2293
+ * ```
2294
+ */
2295
+ public constructor(checkpoint: string | null);
2296
+
2297
+ /**
2298
+ * Reads a target from its wire form.
2299
+ *
2300
+ * @param value The wire form.
2301
+ * @returns The target.
2302
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a target.
2303
+ * @example
2304
+ * ```ts
2305
+ * import { DiffTarget } from "@noldova/checkpoints.protocol";
2306
+ *
2307
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2308
+ * const target = DiffTarget.fromJson({ checkpoint: id });
2309
+ * console.log(target.checkpoint);
2310
+ * ```
2311
+ */
2312
+ public static fromJson(value: unknown): DiffTarget;
2313
+
2314
+ /**
2315
+ * @returns The wire form.
2316
+ * @example
2317
+ * ```ts
2318
+ * import { DiffTarget } from "@noldova/checkpoints.protocol";
2319
+ *
2320
+ * const target = new DiffTarget(null);
2321
+ * console.log(JSON.stringify(target.toJson()));
2322
+ * ```
2323
+ */
2324
+ public toJson(): JsonObject;
2325
+ }
2326
+
2327
+ /**
2328
+ * Whether a read gave content, and why not when it didn't.
2329
+ */
2330
+ export declare class ReadOutcome {
2331
+ /**
2332
+ * The read gave the content, or the line diff.
2333
+ */
2334
+ public static readonly Read: ReadOutcome;
2335
+
2336
+ /**
2337
+ * The diff was with the folder now, and the folder's path is missing.
2338
+ */
2339
+ public static readonly FolderMissing: ReadOutcome;
2340
+
2341
+ /**
2342
+ * The folder has no checkpoint with an id the request gave.
2343
+ */
2344
+ public static readonly CheckpointMissing: ReadOutcome;
2345
+
2346
+ /**
2347
+ * No side holds the path as a file or a link.
2348
+ */
2349
+ public static readonly PathMissing: ReadOutcome;
2350
+
2351
+ /**
2352
+ * A side couldn't read the path.
2353
+ */
2354
+ public static readonly Unknown: ReadOutcome;
2355
+
2356
+ /**
2357
+ * A side of the diff isn't text, so it has no line diff.
2358
+ */
2359
+ public static readonly Binary: ReadOutcome;
2360
+
2361
+ /**
2362
+ * Whether the read gave content.
2363
+ */
2364
+ public readonly isRead: boolean;
2365
+
2366
+ /**
2367
+ * The outcome's wire value.
2368
+ */
2369
+ public readonly value: string;
2370
+
2371
+ private constructor();
2372
+
2373
+ /**
2374
+ * Reads an outcome from its wire value.
2375
+ *
2376
+ * @param value The wire value.
2377
+ * @returns The outcome.
2378
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
2379
+ * @example
2380
+ * ```ts
2381
+ * import { ReadOutcome } from "@noldova/checkpoints.protocol";
2382
+ *
2383
+ * console.log(ReadOutcome.fromJson("Read") === ReadOutcome.Read);
2384
+ * ```
2385
+ */
2386
+ public static fromJson(value: unknown): ReadOutcome;
2387
+
2388
+ /**
2389
+ * @returns The outcome's wire value.
2390
+ * @example
2391
+ * ```ts
2392
+ * import { ReadOutcome } from "@noldova/checkpoints.protocol";
2393
+ *
2394
+ * console.log(ReadOutcome.Binary.toJson());
2395
+ * ```
2396
+ */
2397
+ public toJson(): string;
2398
+ }
2399
+
2400
+ /**
2401
+ * The request of `checkpoints.read`: one file's content at a checkpoint, or its line diff from that checkpoint to a target.
2402
+ */
2403
+ export declare class ReadRequest {
2404
+ /**
2405
+ * The method's name, `"checkpoints.read"`.
2406
+ */
2407
+ public static readonly method: string;
2408
+
2409
+ /**
2410
+ * What the line diff leads to, or `null` for the file's content.
2411
+ */
2412
+ public readonly against: DiffTarget | null;
2413
+
2414
+ /**
2415
+ * The id of the checkpoint to read the file at, where the line diff starts.
2416
+ */
2417
+ public readonly checkpoint: string;
2418
+
2419
+ /**
2420
+ * The folder whose checkpoint to read.
2421
+ */
2422
+ public readonly folder: FolderReference;
2423
+
2424
+ /**
2425
+ * The most bytes to give, from 1 to 16 MiB; a line diff is cut at its last whole line within it.
2426
+ */
2427
+ public readonly limit: number;
2428
+
2429
+ /**
2430
+ * The file's path, relative to the folder, with `/` between names.
2431
+ */
2432
+ public readonly path: string;
2433
+
2434
+ /**
2435
+ * @param folder The folder whose checkpoint to read.
2436
+ * @param checkpoint The id of the checkpoint to read the file at.
2437
+ * @param path The file's path, relative to the folder, with `/` between names.
2438
+ * @param against What the line diff leads to, or `null` for the file's content.
2439
+ * @param limit The most bytes to give, from 1 to 16 MiB.
2440
+ * @throws {ProtocolException} Thrown synchronously when the id isn't a UUID of version 7, the path has an empty name, `.` or `..`, or the
2441
+ * limit isn't a whole number from 1 to 16 MiB.
2442
+ * @example
2443
+ * ```ts
2444
+ * import { DiffTarget, FolderReference, ReadRequest } from "@noldova/checkpoints.protocol";
2445
+ *
2446
+ * const folder = new FolderReference("project-1", "/work/project");
2447
+ * const request = new ReadRequest(folder, "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f", "src/main.ts", new DiffTarget(null), 65536);
2448
+ * console.log(ReadRequest.method, request.toJson());
2449
+ * ```
2450
+ */
2451
+ public constructor(folder: FolderReference, checkpoint: string, path: string, against: DiffTarget | null, limit: number);
2452
+
2453
+ /**
2454
+ * Reads a request from its wire form.
2455
+ *
2456
+ * @param value The wire form.
2457
+ * @returns The request.
2458
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
2459
+ * @example
2460
+ * ```ts
2461
+ * import { ReadRequest } from "@noldova/checkpoints.protocol";
2462
+ *
2463
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2464
+ * const folderJson = { identity: "project-1", path: "/work/project" };
2465
+ * const request = ReadRequest.fromJson({ folder: folderJson, checkpoint: id, path: "src/main.ts", against: null, limit: 1 });
2466
+ * console.log(request.against);
2467
+ * ```
2468
+ */
2469
+ public static fromJson(value: unknown): ReadRequest;
2470
+
2471
+ /**
2472
+ * @returns The wire form.
2473
+ * @example
2474
+ * ```ts
2475
+ * import { DiffTarget, FolderReference, ReadRequest } from "@noldova/checkpoints.protocol";
2476
+ *
2477
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2478
+ * const folder = new FolderReference("project-1", "/work/project");
2479
+ * const request = new ReadRequest(folder, id, "src/main.ts", new DiffTarget(null), 65_536);
2480
+ * console.log(JSON.stringify(request.toJson()));
2481
+ * ```
2482
+ */
2483
+ public toJson(): JsonObject;
2484
+ }
2485
+
2486
+ /**
2487
+ * What a read gave: the bytes up to the request's limit, and the size of the whole, or why it gave none. The wire form holds the
2488
+ * bytes as base64 text.
2489
+ */
2490
+ export declare class ReadResult {
2491
+ /**
2492
+ * The file's bytes, or the line diff's, as Git writes it from its first `@@` line; empty when the outcome isn't {@link ReadOutcome.Read}.
2493
+ */
2494
+ public readonly content: Uint8Array;
2495
+
2496
+ /**
2497
+ * Whether the read gave content.
2498
+ */
2499
+ public readonly outcome: ReadOutcome;
2500
+
2501
+ /**
2502
+ * The size in bytes of the whole file or line diff, of which the content may be only the start.
2503
+ */
2504
+ public readonly size: number;
2505
+
2506
+ /**
2507
+ * @param outcome Whether the read gave content.
2508
+ * @param content The bytes up to the request's limit.
2509
+ * @param size The size in bytes of the whole.
2510
+ * @throws {ProtocolException} Thrown synchronously when an outcome other than {@link ReadOutcome.Read} has content or a size, the size
2511
+ * isn't a whole number of 0 or more, or the content is longer than the size.
2512
+ * @example
2513
+ * ```ts
2514
+ * import { ReadOutcome, ReadResult } from "@noldova/checkpoints.protocol";
2515
+ *
2516
+ * const result = new ReadResult(ReadOutcome.Read, new Uint8Array([104, 105]), 5);
2517
+ * console.log(result.isCut);
2518
+ * ```
2519
+ */
2520
+ public constructor(outcome: ReadOutcome, content: Uint8Array, size: number);
2521
+
2522
+ /**
2523
+ * Whether the content is only the start of the whole, cut at the request's limit.
2524
+ * @example
2525
+ * ```ts
2526
+ * import { ReadOutcome, ReadResult } from "@noldova/checkpoints.protocol";
2527
+ *
2528
+ * console.log(new ReadResult(ReadOutcome.Read, new Uint8Array([104, 105]), 2).isCut);
2529
+ * ```
2530
+ */
2531
+ public get isCut(): boolean;
2532
+
2533
+ /**
2534
+ * Reads a result from its wire form.
2535
+ *
2536
+ * @param value The wire form.
2537
+ * @returns The result.
2538
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result, such as content that isn't base64 text.
2539
+ * @example
2540
+ * ```ts
2541
+ * import { ReadResult } from "@noldova/checkpoints.protocol";
2542
+ *
2543
+ * const result = ReadResult.fromJson({ outcome: "Read", content: "aGk=", isCut: false, size: 2 });
2544
+ * console.log(result.content.length);
2545
+ * ```
2546
+ */
2547
+ public static fromJson(value: unknown): ReadResult;
2548
+
2549
+ /**
2550
+ * @returns The wire form.
2551
+ * @example
2552
+ * ```ts
2553
+ * import { ReadOutcome, ReadResult } from "@noldova/checkpoints.protocol";
2554
+ *
2555
+ * const result = new ReadResult(ReadOutcome.Read, new Uint8Array([104, 105]), 5);
2556
+ * console.log(JSON.stringify(result.toJson()));
2557
+ * ```
2558
+ */
2559
+ public toJson(): JsonObject;
2560
+ }
2561
+
2562
+ /**
2563
+ * What a restore does to one path.
2564
+ */
2565
+ export declare class RestoreAction {
2566
+ /**
2567
+ * The checkpoint holds the path and the folder now doesn't, so the restore writes it.
2568
+ */
2569
+ public static readonly Write: RestoreAction;
2570
+
2571
+ /**
2572
+ * Both hold the path, with other content or another kind, so the restore replaces it.
2573
+ */
2574
+ public static readonly Replace: RestoreAction;
2575
+
2576
+ /**
2577
+ * The folder now holds the path and the checkpoint doesn't, so the restore deletes it.
2578
+ */
2579
+ public static readonly Delete: RestoreAction;
2580
+
2581
+ /**
2582
+ * The action's wire value.
2583
+ */
2584
+ public readonly value: string;
2585
+
2586
+ private constructor();
2587
+
2588
+ /**
2589
+ * Reads an action from its wire value.
2590
+ *
2591
+ * @param value The wire value.
2592
+ * @returns The action.
2593
+ * @throws {ProtocolException} Thrown synchronously when the value names no action.
2594
+ * @example
2595
+ * ```ts
2596
+ * import { RestoreAction } from "@noldova/checkpoints.protocol";
2597
+ *
2598
+ * console.log(RestoreAction.fromJson("Write") === RestoreAction.Write);
2599
+ * ```
2600
+ */
2601
+ public static fromJson(value: unknown): RestoreAction;
2602
+
2603
+ /**
2604
+ * @returns The action's wire value.
2605
+ * @example
2606
+ * ```ts
2607
+ * import { RestoreAction } from "@noldova/checkpoints.protocol";
2608
+ *
2609
+ * console.log(RestoreAction.Delete.toJson());
2610
+ * ```
2611
+ */
2612
+ public toJson(): string;
2613
+ }
2614
+
2615
+ /**
2616
+ * Why a restore leaves a path as it is.
2617
+ */
2618
+ export declare class KeepReason {
2619
+ /**
2620
+ * The path is a `.git`, or a name Git treats as one, which a restore never reads, writes, replaces or deletes.
2621
+ */
2622
+ public static readonly Repository: KeepReason;
2623
+
2624
+ /**
2625
+ * The path is a folder that holds a `.git` at any depth, which a restore never moves, replaces, renames or removes; the files
2626
+ * inside it are restored each on its own.
2627
+ */
2628
+ public static readonly RepositoryFolder: KeepReason;
2629
+
2630
+ /**
2631
+ * The checkpoint followed the ignore files, and its rules or the folder's current ones ignore the path.
2632
+ */
2633
+ public static readonly Ignored: KeepReason;
2634
+
2635
+ /**
2636
+ * The checkpoint couldn't read the path, so it keeps no content for it.
2637
+ */
2638
+ public static readonly Unread: KeepReason;
2639
+
2640
+ /**
2641
+ * The path is a link, and this system won't let the module create one.
2642
+ */
2643
+ public static readonly LinkUnsupported: KeepReason;
2644
+
2645
+ /**
2646
+ * The reason's wire value.
2647
+ */
2648
+ public readonly value: string;
2649
+
2650
+ private constructor();
2651
+
2652
+ /**
2653
+ * Reads a reason from its wire value.
2654
+ *
2655
+ * @param value The wire value.
2656
+ * @returns The reason.
2657
+ * @throws {ProtocolException} Thrown synchronously when the value names no reason.
2658
+ * @example
2659
+ * ```ts
2660
+ * import { KeepReason } from "@noldova/checkpoints.protocol";
2661
+ *
2662
+ * console.log(KeepReason.fromJson("Repository") === KeepReason.Repository);
2663
+ * ```
2664
+ */
2665
+ public static fromJson(value: unknown): KeepReason;
2666
+
2667
+ /**
2668
+ * @returns The reason's wire value.
2669
+ * @example
2670
+ * ```ts
2671
+ * import { KeepReason } from "@noldova/checkpoints.protocol";
2672
+ *
2673
+ * console.log(KeepReason.LinkUnsupported.toJson());
2674
+ * ```
2675
+ */
2676
+ public toJson(): string;
2677
+ }
2678
+
2679
+ /**
2680
+ * One path a restore changes: what it does, and the path's side now and in the checkpoint.
2681
+ */
2682
+ export declare class RestoreStep {
2683
+ /**
2684
+ * What the restore does to the path.
2685
+ */
2686
+ public readonly action: RestoreAction;
2687
+
2688
+ /**
2689
+ * The path in the checkpoint, or `null` for a {@link RestoreAction.Delete}.
2690
+ */
2691
+ public readonly after: ChangeSide | null;
2692
+
2693
+ /**
2694
+ * The path in the folder now, or `null` for a {@link RestoreAction.Write}.
2695
+ */
2696
+ public readonly before: ChangeSide | null;
2697
+
2698
+ /**
2699
+ * The path, relative to the folder, with `/` between its names.
2700
+ */
2701
+ public readonly path: string;
2702
+
2703
+ /**
2704
+ * @param path The path, relative to the folder.
2705
+ * @param action What the restore does to the path.
2706
+ * @param before The path in the folder now, or `null` for a write.
2707
+ * @param after The path in the checkpoint, or `null` for a delete.
2708
+ * @throws {ProtocolException} Thrown synchronously when the path isn't relative to the folder, or a side is missing or present against the action.
2709
+ * @example
2710
+ * ```ts
2711
+ * import { ChangeSide, PathKind, RestoreAction, RestoreStep } from "@noldova/checkpoints.protocol";
2712
+ *
2713
+ * const step = new RestoreStep("src/main.ts", RestoreAction.Write, null, new ChangeSide(PathKind.File, 12, true));
2714
+ * console.log(step.action.value);
2715
+ * ```
2716
+ */
2717
+ public constructor(path: string, action: RestoreAction, before: ChangeSide | null, after: ChangeSide | null);
2718
+
2719
+ /**
2720
+ * Reads a step from its wire form.
2721
+ *
2722
+ * @param value The wire form.
2723
+ * @returns The step.
2724
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a step.
2725
+ * @example
2726
+ * ```ts
2727
+ * import { RestoreStep } from "@noldova/checkpoints.protocol";
2728
+ *
2729
+ * const step = RestoreStep.fromJson({ path: "old.txt", action: "Delete", before: { kind: "File", size: 3, isText: true }, after: null });
2730
+ * console.log(step.after);
2731
+ * ```
2732
+ */
2733
+ public static fromJson(value: unknown): RestoreStep;
2734
+
2735
+ /**
2736
+ * @returns The wire form.
2737
+ * @example
2738
+ * ```ts
2739
+ * import { ChangeSide, PathKind, RestoreAction, RestoreStep } from "@noldova/checkpoints.protocol";
2740
+ *
2741
+ * const step = new RestoreStep("src/main.ts", RestoreAction.Write, null, new ChangeSide(PathKind.File, 12, true));
2742
+ * console.log(JSON.stringify(step.toJson()));
2743
+ * ```
2744
+ */
2745
+ public toJson(): JsonObject;
2746
+ }
2747
+
2748
+ /**
2749
+ * One path a restore leaves as it is, and why.
2750
+ */
2751
+ export declare class KeptPath {
2752
+ /**
2753
+ * The path, relative to the folder, with `/` between its names.
2754
+ */
2755
+ public readonly path: string;
2756
+
2757
+ /**
2758
+ * Why the restore leaves it.
2759
+ */
2760
+ public readonly reason: KeepReason;
2761
+
2762
+ /**
2763
+ * @param path The path, relative to the folder.
2764
+ * @param reason Why the restore leaves it.
2765
+ * @throws {ProtocolException} Thrown synchronously when the path isn't relative to the folder.
2766
+ * @example
2767
+ * ```ts
2768
+ * import { KeepReason, KeptPath } from "@noldova/checkpoints.protocol";
2769
+ *
2770
+ * const kept = new KeptPath(".git", KeepReason.Repository);
2771
+ * console.log(kept.reason.value);
2772
+ * ```
2773
+ */
2774
+ public constructor(path: string, reason: KeepReason);
2775
+
2776
+ /**
2777
+ * Reads a kept path from its wire form.
2778
+ *
2779
+ * @param value The wire form.
2780
+ * @returns The kept path.
2781
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a kept path.
2782
+ * @example
2783
+ * ```ts
2784
+ * import { KeptPath } from "@noldova/checkpoints.protocol";
2785
+ *
2786
+ * const kept = KeptPath.fromJson({ path: "vendor/lib/.git", reason: "RepositoryFolder" });
2787
+ * console.log(kept.path);
2788
+ * ```
2789
+ */
2790
+ public static fromJson(value: unknown): KeptPath;
2791
+
2792
+ /**
2793
+ * @returns The wire form.
2794
+ * @example
2795
+ * ```ts
2796
+ * import { KeepReason, KeptPath } from "@noldova/checkpoints.protocol";
2797
+ *
2798
+ * const kept = new KeptPath(".git", KeepReason.Repository);
2799
+ * console.log(JSON.stringify(kept.toJson()));
2800
+ * ```
2801
+ */
2802
+ public toJson(): JsonObject;
2803
+ }
2804
+
2805
+ /**
2806
+ * A restore's plan: what it writes, replaces and deletes, what stays as it is and why, the space it needs, and the state of the
2807
+ * folder it was planned on. A restore carries out a plan only while the folder is still in that state.
2808
+ */
2809
+ export declare class RestorePlan {
2810
+ /**
2811
+ * The bytes the restore writes into the folder.
2812
+ */
2813
+ public readonly bytesToWrite: number;
2814
+
2815
+ /**
2816
+ * The id of the checkpoint the plan restores.
2817
+ */
2818
+ public readonly checkpoint: string;
2819
+
2820
+ /**
2821
+ * The paths the restore is limited to, as its preview asked, or `null` for the whole folder; the restore plans again with them. The
2822
+ * wire form always holds the paths, as `null` for the whole folder, and a wire form without them is refused.
2823
+ */
2824
+ public readonly paths: readonly string[] | null;
2825
+
2826
+ /**
2827
+ * The free space in bytes the restore needs, on the folder's volume and the store's together.
2828
+ */
2829
+ public readonly spaceNeeded: number;
2830
+
2831
+ /**
2832
+ * The SHA-256 of the folder's state when planned, in lowercase hexadecimal: each planned path's state and each folder's file id on
2833
+ * its way from the root.
2834
+ */
2835
+ public readonly state: string;
2836
+
2837
+ /**
2838
+ * The paths that stay as they are, in their paths' byte order.
2839
+ */
2840
+ public readonly stays: readonly KeptPath[];
2841
+
2842
+ /**
2843
+ * The paths the restore changes, in their paths' byte order.
2844
+ */
2845
+ public readonly steps: readonly RestoreStep[];
2846
+
2847
+ /**
2848
+ * @param checkpoint The id of the checkpoint the plan restores, a lowercase UUID version 7.
2849
+ * @param steps The paths the restore changes.
2850
+ * @param stays The paths that stay as they are.
2851
+ * @param bytesToWrite The bytes the restore writes.
2852
+ * @param spaceNeeded The free space in bytes the restore needs.
2853
+ * @param state The SHA-256 of the folder's state when planned.
2854
+ * @param paths The paths the restore is limited to, or `null` for the whole folder.
2855
+ * @throws {ProtocolException} Thrown synchronously when the id isn't a lowercase UUID version 7, a size isn't a whole number of 0 or
2856
+ * more, the state isn't a lowercase SHA-256 in hexadecimal, or a path has an empty name, "." or "..", or holds "\" on any system.
2857
+ * @example
2858
+ * ```ts
2859
+ * import { KeepReason, KeptPath, RestorePlan } from "@noldova/checkpoints.protocol";
2860
+ *
2861
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2862
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
2863
+ * const plan = new RestorePlan(id, [], [new KeptPath(".git", KeepReason.Repository)], 0, 0, state, null);
2864
+ * console.log(plan.paths);
2865
+ * ```
2866
+ */
2867
+ public constructor(
2868
+ checkpoint: string, steps: readonly RestoreStep[], stays: readonly KeptPath[], bytesToWrite: number, spaceNeeded: number, state: string,
2869
+ paths: readonly string[] | null);
2870
+
2871
+ /**
2872
+ * Reads a plan from its wire form.
2873
+ *
2874
+ * @param value The wire form.
2875
+ * @returns The plan.
2876
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a plan.
2877
+ * @example
2878
+ * ```ts
2879
+ * import { RestorePlan } from "@noldova/checkpoints.protocol";
2880
+ *
2881
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2882
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
2883
+ * const plan = RestorePlan.fromJson({ checkpoint: id, steps: [], stays: [], bytesToWrite: 0, spaceNeeded: 0, state, paths: ["src"] });
2884
+ * console.log(plan.paths);
2885
+ * ```
2886
+ */
2887
+ public static fromJson(value: unknown): RestorePlan;
2888
+
2889
+ /**
2890
+ * @returns The wire form.
2891
+ * @example
2892
+ * ```ts
2893
+ * import { KeepReason, KeptPath, RestorePlan } from "@noldova/checkpoints.protocol";
2894
+ *
2895
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
2896
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
2897
+ * const plan = new RestorePlan(id, [], [new KeptPath(".git", KeepReason.Repository)], 0, 0, state, null);
2898
+ * console.log(JSON.stringify(plan.toJson()));
2899
+ * ```
2900
+ */
2901
+ public toJson(): JsonObject;
2902
+ }
2903
+
2904
+ /**
2905
+ * Whether a preview gave a plan, and why not when it didn't.
2906
+ */
2907
+ export declare class PreviewOutcome {
2908
+ /**
2909
+ * The preview gave a plan.
2910
+ */
2911
+ public static readonly Planned: PreviewOutcome;
2912
+
2913
+ /**
2914
+ * The folder's store holds no checkpoint with that id.
2915
+ */
2916
+ public static readonly CheckpointMissing: PreviewOutcome;
2917
+
2918
+ /**
2919
+ * The folder's path is missing.
2920
+ */
2921
+ public static readonly FolderMissing: PreviewOutcome;
2922
+
2923
+ /**
2924
+ * A restore of the folder is running, or was interrupted and couldn't be rolled back.
2925
+ */
2926
+ public static readonly HeldUp: PreviewOutcome;
2927
+
2928
+ /**
2929
+ * Whether the preview gave a plan.
2930
+ */
2931
+ public readonly isPlanned: boolean;
2932
+
2933
+ /**
2934
+ * The outcome's wire value.
2935
+ */
2936
+ public readonly value: string;
2937
+
2938
+ private constructor();
2939
+
2940
+ /**
2941
+ * Reads an outcome from its wire value.
2942
+ *
2943
+ * @param value The wire value.
2944
+ * @returns The outcome.
2945
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
2946
+ * @example
2947
+ * ```ts
2948
+ * import { PreviewOutcome } from "@noldova/checkpoints.protocol";
2949
+ *
2950
+ * console.log(PreviewOutcome.fromJson("Planned") === PreviewOutcome.Planned);
2951
+ * ```
2952
+ */
2953
+ public static fromJson(value: unknown): PreviewOutcome;
2954
+
2955
+ /**
2956
+ * @returns The outcome's wire value.
2957
+ * @example
2958
+ * ```ts
2959
+ * import { PreviewOutcome } from "@noldova/checkpoints.protocol";
2960
+ *
2961
+ * console.log(PreviewOutcome.HeldUp.toJson());
2962
+ * ```
2963
+ */
2964
+ public toJson(): string;
2965
+ }
2966
+
2967
+ /**
2968
+ * The parameters of `checkpoints.previewRestore`: the folder, the checkpoint to plan a restore of, and the paths the restore is limited
2969
+ * to, if any.
2970
+ */
2971
+ export declare class PreviewRequest {
2972
+ /**
2973
+ * The method's name, `"checkpoints.previewRestore"`.
2974
+ */
2975
+ public static readonly method: string;
2976
+
2977
+ /**
2978
+ * The id of the checkpoint to restore.
2979
+ */
2980
+ public readonly checkpoint: string;
2981
+
2982
+ /**
2983
+ * The folder to restore.
2984
+ */
2985
+ public readonly folder: FolderReference;
2986
+
2987
+ /**
2988
+ * The paths the restore is limited to, relative to the folder with "/" between names, or `null` for the whole folder. Each must equal
2989
+ * the module's own path for it exactly, as a comparison gives it, letter case and Unicode normalisation included; one holding "\"
2990
+ * is refused on every system. The wire form always holds the paths, as `null` for the whole folder, and a wire form without them is
2991
+ * refused. The plan changes only paths at or under one of them, and a folder above one that the checkpoint holds as a folder and the
2992
+ * folder now holds as something else; everything else stays as it is now and is left out of the plan's state.
2993
+ */
2994
+ public readonly paths: readonly string[] | null;
2995
+
2996
+ /**
2997
+ * @param folder The folder to restore.
2998
+ * @param checkpoint The id of the checkpoint to restore, a lowercase UUID version 7.
2999
+ * @param paths The paths the restore is limited to, or `null` for the whole folder.
3000
+ * @throws {ProtocolException} Thrown synchronously when the id isn't a lowercase UUID version 7, or a path has an empty name, "." or
3001
+ * "..", or holds "\" on any system.
3002
+ * @example
3003
+ * ```ts
3004
+ * import { FolderReference, PreviewRequest } from "@noldova/checkpoints.protocol";
3005
+ *
3006
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3007
+ * const folder = new FolderReference("project-1", "/work/project");
3008
+ * const request = new PreviewRequest(folder, id, ["src/main.ts"]);
3009
+ * console.log(request.paths);
3010
+ * ```
3011
+ */
3012
+ public constructor(folder: FolderReference, checkpoint: string, paths: readonly string[] | null);
3013
+
3014
+ /**
3015
+ * Reads a request from its wire form.
3016
+ *
3017
+ * @param value The wire form.
3018
+ * @returns The request.
3019
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
3020
+ * @example
3021
+ * ```ts
3022
+ * import { PreviewRequest } from "@noldova/checkpoints.protocol";
3023
+ *
3024
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3025
+ * const folderJson = { identity: "project-1", path: "/work/project" };
3026
+ * const request = PreviewRequest.fromJson({ folder: folderJson, checkpoint: id, paths: null });
3027
+ * console.log(request.paths);
3028
+ * ```
3029
+ */
3030
+ public static fromJson(value: unknown): PreviewRequest;
3031
+
3032
+ /**
3033
+ * @returns The wire form.
3034
+ * @example
3035
+ * ```ts
3036
+ * import { FolderReference, PreviewRequest } from "@noldova/checkpoints.protocol";
3037
+ *
3038
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3039
+ * const folder = new FolderReference("project-1", "/work/project");
3040
+ * const request = new PreviewRequest(folder, id, ["src/main.ts"]);
3041
+ * console.log(JSON.stringify(request.toJson()));
3042
+ * ```
3043
+ */
3044
+ public toJson(): JsonObject;
3045
+ }
3046
+
3047
+ /**
3048
+ * What a preview gave: the plan, or why it gave none.
3049
+ */
3050
+ export declare class PreviewResult {
3051
+ /**
3052
+ * Whether the preview gave a plan.
3053
+ */
3054
+ public readonly outcome: PreviewOutcome;
3055
+
3056
+ /**
3057
+ * The plan, or `null` when the outcome isn't {@link PreviewOutcome.Planned}.
3058
+ */
3059
+ public readonly plan: RestorePlan | null;
3060
+
3061
+ /**
3062
+ * @param outcome Whether the preview gave a plan.
3063
+ * @param plan The plan, or `null`.
3064
+ * @throws {ProtocolException} Thrown synchronously when the result holds a plan other than exactly when its outcome is {@link
3065
+ * PreviewOutcome.Planned}.
3066
+ * @example
3067
+ * ```ts
3068
+ * import { PreviewOutcome, PreviewResult } from "@noldova/checkpoints.protocol";
3069
+ *
3070
+ * const result = new PreviewResult(PreviewOutcome.HeldUp, null);
3071
+ * console.log(result.outcome.isPlanned);
3072
+ * ```
3073
+ */
3074
+ public constructor(outcome: PreviewOutcome, plan: RestorePlan | null);
3075
+
3076
+ /**
3077
+ * Reads a result from its wire form.
3078
+ *
3079
+ * @param value The wire form.
3080
+ * @returns The result.
3081
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result.
3082
+ * @example
3083
+ * ```ts
3084
+ * import { PreviewResult } from "@noldova/checkpoints.protocol";
3085
+ *
3086
+ * const result = PreviewResult.fromJson({ outcome: "FolderMissing", plan: null });
3087
+ * console.log(result.plan);
3088
+ * ```
3089
+ */
3090
+ public static fromJson(value: unknown): PreviewResult;
3091
+
3092
+ /**
3093
+ * @returns The wire form.
3094
+ * @example
3095
+ * ```ts
3096
+ * import { PreviewOutcome, PreviewResult } from "@noldova/checkpoints.protocol";
3097
+ *
3098
+ * const result = new PreviewResult(PreviewOutcome.HeldUp, null);
3099
+ * console.log(JSON.stringify(result.toJson()));
3100
+ * ```
3101
+ */
3102
+ public toJson(): JsonObject;
3103
+ }
3104
+
3105
+ /**
3106
+ * Whether a restore finished, and why not when it didn't.
3107
+ */
3108
+ export declare class RestoreOutcome {
3109
+ /**
3110
+ * The folder holds the checkpoint's files, apart from the paths the plan keeps.
3111
+ */
3112
+ public static readonly Restored: RestoreOutcome;
3113
+
3114
+ /**
3115
+ * The folder has changed since the plan, so nothing was changed; a fresh preview gives a plan for the folder now.
3116
+ */
3117
+ public static readonly MovedOn: RestoreOutcome;
3118
+
3119
+ /**
3120
+ * The folder's store holds no checkpoint with the plan's id.
3121
+ */
3122
+ public static readonly CheckpointMissing: RestoreOutcome;
3123
+
3124
+ /**
3125
+ * The folder's path is missing.
3126
+ */
3127
+ public static readonly FolderMissing: RestoreOutcome;
3128
+
3129
+ /**
3130
+ * The folder's volume or the store's lacks the space the restore needs, so nothing was changed.
3131
+ */
3132
+ public static readonly LowDiskSpace: RestoreOutcome;
3133
+
3134
+ /**
3135
+ * Another restore of the folder is running, or was interrupted and couldn't be rolled back.
3136
+ */
3137
+ public static readonly HeldUp: RestoreOutcome;
3138
+
3139
+ /**
3140
+ * The restore started, then put every path back as it was before it: another program wrote a path it was changing, or a step
3141
+ * failed.
3142
+ */
3143
+ public static readonly RolledBack: RestoreOutcome;
3144
+
3145
+ /**
3146
+ * Whether the restore finished.
3147
+ */
3148
+ public readonly isRestored: boolean;
3149
+
3150
+ /**
3151
+ * The outcome's wire value.
3152
+ */
3153
+ public readonly value: string;
3154
+
3155
+ private constructor();
3156
+
3157
+ /**
3158
+ * Reads an outcome from its wire value.
3159
+ *
3160
+ * @param value The wire value.
3161
+ * @returns The outcome.
3162
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
3163
+ * @example
3164
+ * ```ts
3165
+ * import { RestoreOutcome } from "@noldova/checkpoints.protocol";
3166
+ *
3167
+ * console.log(RestoreOutcome.fromJson("Restored") === RestoreOutcome.Restored);
3168
+ * ```
3169
+ */
3170
+ public static fromJson(value: unknown): RestoreOutcome;
3171
+
3172
+ /**
3173
+ * @returns The outcome's wire value.
3174
+ * @example
3175
+ * ```ts
3176
+ * import { RestoreOutcome } from "@noldova/checkpoints.protocol";
3177
+ *
3178
+ * console.log(RestoreOutcome.RolledBack.toJson());
3179
+ * ```
3180
+ */
3181
+ public toJson(): string;
3182
+ }
3183
+
3184
+ /**
3185
+ * The parameters of `checkpoints.restore`: the folder and the plan the person accepted.
3186
+ */
3187
+ export declare class RestoreRequest {
3188
+ /**
3189
+ * The method's name, `"checkpoints.restore"`.
3190
+ */
3191
+ public static readonly method: string;
3192
+
3193
+ /**
3194
+ * The folder to restore.
3195
+ */
3196
+ public readonly folder: FolderReference;
3197
+
3198
+ /**
3199
+ * The plan the person accepted, as its preview gave it.
3200
+ */
3201
+ public readonly plan: RestorePlan;
3202
+
3203
+ /**
3204
+ * @param folder The folder to restore.
3205
+ * @param plan The plan the person accepted.
3206
+ * @example
3207
+ * ```ts
3208
+ * import { FolderReference, RestorePlan, RestoreRequest } from "@noldova/checkpoints.protocol";
3209
+ *
3210
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3211
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
3212
+ * const folder = new FolderReference("project-1", "/work/project");
3213
+ * const request = new RestoreRequest(folder, new RestorePlan(id, [], [], 0, 0, state, null));
3214
+ * console.log(RestoreRequest.method);
3215
+ * ```
3216
+ */
3217
+ public constructor(folder: FolderReference, plan: RestorePlan);
3218
+
3219
+ /**
3220
+ * Reads a request from its wire form.
3221
+ *
3222
+ * @param value The wire form.
3223
+ * @returns The request.
3224
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
3225
+ * @example
3226
+ * ```ts
3227
+ * import { RestoreRequest } from "@noldova/checkpoints.protocol";
3228
+ *
3229
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3230
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
3231
+ * const folderJson = { identity: "project-1", path: "/work/project" };
3232
+ * const request = RestoreRequest.fromJson({ folder: folderJson, plan: { checkpoint: id, steps: [], stays: [], bytesToWrite: 0, spaceNeeded: 0, state, paths: null } });
3233
+ * console.log(request.plan.checkpoint);
3234
+ * ```
3235
+ */
3236
+ public static fromJson(value: unknown): RestoreRequest;
3237
+
3238
+ /**
3239
+ * @returns The wire form.
3240
+ * @example
3241
+ * ```ts
3242
+ * import { FolderReference, RestorePlan, RestoreRequest } from "@noldova/checkpoints.protocol";
3243
+ *
3244
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3245
+ * const state = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855";
3246
+ * const folder = new FolderReference("project-1", "/work/project");
3247
+ * const request = new RestoreRequest(folder, new RestorePlan(id, [], [], 0, 0, state, null));
3248
+ * console.log(JSON.stringify(request.toJson()));
3249
+ * ```
3250
+ */
3251
+ public toJson(): JsonObject;
3252
+ }
3253
+
3254
+ /**
3255
+ * What a restore did: its outcome, the checkpoint taken before it, which is the person's undo, and any checkpoint that keeps what
3256
+ * another program wrote while it ran.
3257
+ */
3258
+ export declare class RestoreResult {
3259
+ /**
3260
+ * The checkpoint taken before the restore, or `null` when the outcome is neither {@link RestoreOutcome.Restored} nor
3261
+ * {@link RestoreOutcome.RolledBack}.
3262
+ */
3263
+ public readonly before: Checkpoint | null;
3264
+
3265
+ /**
3266
+ * Whether the restore finished.
3267
+ */
3268
+ public readonly outcome: RestoreOutcome;
3269
+
3270
+ /**
3271
+ * The checkpoint, labelled as recovered after the restore, that keeps the paths another program changed while they were moved
3272
+ * aside, or `null` when there were none or the outcome isn't {@link RestoreOutcome.Restored}.
3273
+ */
3274
+ public readonly recovered: Checkpoint | null;
3275
+
3276
+ /**
3277
+ * @param outcome Whether the restore finished.
3278
+ * @param before The checkpoint taken before the restore, or `null`.
3279
+ * @param recovered The checkpoint that keeps what another program wrote, or `null`.
3280
+ * @throws {ProtocolException} Thrown synchronously when the result holds a checkpoint before other than exactly when its outcome is
3281
+ * {@link RestoreOutcome.Restored} or {@link RestoreOutcome.RolledBack}, or a recovered one when it isn't Restored.
3282
+ * @example
3283
+ * ```ts
3284
+ * import { RestoreOutcome, RestoreResult } from "@noldova/checkpoints.protocol";
3285
+ *
3286
+ * const result = new RestoreResult(RestoreOutcome.MovedOn, null, null);
3287
+ * console.log(result.outcome.isRestored);
3288
+ * ```
3289
+ */
3290
+ public constructor(outcome: RestoreOutcome, before: Checkpoint | null, recovered: Checkpoint | null);
3291
+
3292
+ /**
3293
+ * Reads a result from its wire form.
3294
+ *
3295
+ * @param value The wire form.
3296
+ * @returns The result.
3297
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result.
3298
+ * @example
3299
+ * ```ts
3300
+ * import { RestoreResult } from "@noldova/checkpoints.protocol";
3301
+ *
3302
+ * const result = RestoreResult.fromJson({ outcome: "HeldUp", before: null, recovered: null });
3303
+ * console.log(result.before);
3304
+ * ```
3305
+ */
3306
+ public static fromJson(value: unknown): RestoreResult;
3307
+
3308
+ /**
3309
+ * @returns The wire form.
3310
+ * @example
3311
+ * ```ts
3312
+ * import { RestoreOutcome, RestoreResult } from "@noldova/checkpoints.protocol";
3313
+ *
3314
+ * const result = new RestoreResult(RestoreOutcome.MovedOn, null, null);
3315
+ * console.log(JSON.stringify(result.toJson()));
3316
+ * ```
3317
+ */
3318
+ public toJson(): JsonObject;
3319
+ }
3320
+
3321
+ /**
3322
+ * A request for every folder's space used, the `checkpoints.storage` method; it names no folder.
3323
+ */
3324
+ export declare class StorageRequest {
3325
+ /**
3326
+ * The method's name, `"checkpoints.storage"`.
3327
+ */
3328
+ public static readonly method: string;
3329
+
3330
+ /**
3331
+ * Creates the request, which names no folder.
3332
+ * @example
3333
+ * ```ts
3334
+ * import { StorageRequest } from "@noldova/checkpoints.protocol";
3335
+ *
3336
+ * const request = new StorageRequest();
3337
+ * console.log(StorageRequest.method);
3338
+ * ```
3339
+ */
3340
+ public constructor();
3341
+
3342
+ /**
3343
+ * Reads a request from its wire form, an empty object.
3344
+ *
3345
+ * @param value The wire form.
3346
+ * @returns The request.
3347
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
3348
+ * @example
3349
+ * ```ts
3350
+ * import { StorageRequest } from "@noldova/checkpoints.protocol";
3351
+ *
3352
+ * const request = StorageRequest.fromJson({});
3353
+ * console.log(request.toJson());
3354
+ * ```
3355
+ */
3356
+ public static fromJson(value: unknown): StorageRequest;
3357
+
3358
+ /**
3359
+ * @returns The wire form.
3360
+ * @example
3361
+ * ```ts
3362
+ * import { StorageRequest } from "@noldova/checkpoints.protocol";
3363
+ *
3364
+ * const request = new StorageRequest();
3365
+ * console.log(JSON.stringify(request.toJson()));
3366
+ * ```
3367
+ */
3368
+ public toJson(): JsonObject;
3369
+ }
3370
+
3371
+ /**
3372
+ * One folder's space used.
3373
+ */
3374
+ export declare class FolderUsage {
3375
+ /**
3376
+ * The sum of the sizes of the folder's store's files, in bytes, as they were while the store was read: a capture or the store's
3377
+ * housekeeping running then may change it at once.
3378
+ */
3379
+ public readonly bytes: number;
3380
+
3381
+ /**
3382
+ * The identity the folder's checkpoints are kept under.
3383
+ */
3384
+ public readonly identity: string;
3385
+
3386
+ /**
3387
+ * The folder's absolute path at its last capture, or `null` when the store can't say.
3388
+ */
3389
+ public readonly path: string | null;
3390
+
3391
+ /**
3392
+ * @param identity The identity, 1 to 64 letters, digits and `-`.
3393
+ * @param path The folder's absolute path at its last capture, or `null`.
3394
+ * @param bytes The space used, a whole number of bytes, 0 or more.
3395
+ * @throws {ProtocolException} Thrown synchronously when the identity, the path or the size isn't valid.
3396
+ * @example
3397
+ * ```ts
3398
+ * import { FolderUsage } from "@noldova/checkpoints.protocol";
3399
+ *
3400
+ * const usage = new FolderUsage("project-1", "/work/project", 4_096);
3401
+ * console.log(usage.bytes);
3402
+ * ```
3403
+ */
3404
+ public constructor(identity: string, path: string | null, bytes: number);
3405
+
3406
+ /**
3407
+ * Reads a folder's space used from its wire form.
3408
+ *
3409
+ * @param value The wire form.
3410
+ * @returns The folder's space used.
3411
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a folder's space used.
3412
+ * @example
3413
+ * ```ts
3414
+ * import { FolderUsage } from "@noldova/checkpoints.protocol";
3415
+ *
3416
+ * const usage = FolderUsage.fromJson({ identity: "project-1", path: null, bytes: 0 });
3417
+ * console.log(usage.path);
3418
+ * ```
3419
+ */
3420
+ public static fromJson(value: unknown): FolderUsage;
3421
+
3422
+ /**
3423
+ * @returns The wire form.
3424
+ * @example
3425
+ * ```ts
3426
+ * import { FolderUsage } from "@noldova/checkpoints.protocol";
3427
+ *
3428
+ * const usage = new FolderUsage("project-1", "/work/project", 4_096);
3429
+ * console.log(JSON.stringify(usage.toJson()));
3430
+ * ```
3431
+ */
3432
+ public toJson(): JsonObject;
3433
+ }
3434
+
3435
+ /**
3436
+ * Every folder's space used, the answer to `checkpoints.storage`.
3437
+ */
3438
+ export declare class StorageList {
3439
+ /**
3440
+ * The folders, the largest first, and folders of the same size by identity.
3441
+ */
3442
+ public readonly folders: readonly FolderUsage[];
3443
+
3444
+ /**
3445
+ * @param folders The folders, the largest first.
3446
+ * @example
3447
+ * ```ts
3448
+ * import { FolderUsage, StorageList } from "@noldova/checkpoints.protocol";
3449
+ *
3450
+ * const list = new StorageList([new FolderUsage("project-1", "/work/project", 4_096)]);
3451
+ * console.log(list.folders.length);
3452
+ * ```
3453
+ */
3454
+ public constructor(folders: readonly FolderUsage[]);
3455
+
3456
+ /**
3457
+ * Reads a list from its wire form.
3458
+ *
3459
+ * @param value The wire form.
3460
+ * @returns The list.
3461
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a list.
3462
+ * @example
3463
+ * ```ts
3464
+ * import { StorageList } from "@noldova/checkpoints.protocol";
3465
+ *
3466
+ * const list = StorageList.fromJson({ folders: [{ identity: "project-1", path: null, bytes: 0 }] });
3467
+ * console.log(list.folders[0]?.bytes);
3468
+ * ```
3469
+ */
3470
+ public static fromJson(value: unknown): StorageList;
3471
+
3472
+ /**
3473
+ * @returns The wire form.
3474
+ * @example
3475
+ * ```ts
3476
+ * import { FolderUsage, StorageList } from "@noldova/checkpoints.protocol";
3477
+ *
3478
+ * const list = new StorageList([new FolderUsage("project-1", "/work/project", 4_096)]);
3479
+ * console.log(JSON.stringify(list.toJson()));
3480
+ * ```
3481
+ */
3482
+ public toJson(): JsonObject;
3483
+ }
3484
+
3485
+ /**
3486
+ * How a folder's delete ended.
3487
+ */
3488
+ export declare class DeleteFolderOutcome {
3489
+ /**
3490
+ * The folder's checkpoints are deleted, or it had none; its next capture starts a new store.
3491
+ */
3492
+ public static readonly Deleted: DeleteFolderOutcome;
3493
+
3494
+ /**
3495
+ * A restore of the folder was interrupted and can't be finished or undone yet, so nothing was deleted: its journal is what puts the
3496
+ * folder's files right.
3497
+ */
3498
+ public static readonly HeldUp: DeleteFolderOutcome;
3499
+
3500
+ /**
3501
+ * The outcome's wire value.
3502
+ */
3503
+ public readonly value: string;
3504
+
3505
+ private constructor();
3506
+
3507
+ /**
3508
+ * Reads an outcome from its wire value.
3509
+ *
3510
+ * @param value The wire value.
3511
+ * @returns The outcome.
3512
+ * @throws {ProtocolException} Thrown synchronously when the value names no outcome.
3513
+ * @example
3514
+ * ```ts
3515
+ * import { DeleteFolderOutcome } from "@noldova/checkpoints.protocol";
3516
+ *
3517
+ * console.log(DeleteFolderOutcome.fromJson("Deleted") === DeleteFolderOutcome.Deleted);
3518
+ * ```
3519
+ */
3520
+ public static fromJson(value: unknown): DeleteFolderOutcome;
3521
+
3522
+ /**
3523
+ * @returns The outcome's wire value.
3524
+ * @example
3525
+ * ```ts
3526
+ * import { DeleteFolderOutcome } from "@noldova/checkpoints.protocol";
3527
+ *
3528
+ * console.log(DeleteFolderOutcome.HeldUp.toJson());
3529
+ * ```
3530
+ */
3531
+ public toJson(): string;
3532
+ }
3533
+
3534
+ /**
3535
+ * A request to delete all of a folder's checkpoints, the `checkpoints.deleteFolder` method.
3536
+ */
3537
+ export declare class DeleteFolderRequest {
3538
+ /**
3539
+ * The method's name, `"checkpoints.deleteFolder"`.
3540
+ */
3541
+ public static readonly method: string;
3542
+
3543
+ /**
3544
+ * The folder whose checkpoints to delete; its path is where an interrupted restore of it is finished or undone first.
3545
+ */
3546
+ public readonly folder: FolderReference;
3547
+
3548
+ /**
3549
+ * @param folder The folder whose checkpoints to delete.
3550
+ * @example
3551
+ * ```ts
3552
+ * import { DeleteFolderRequest, FolderReference } from "@noldova/checkpoints.protocol";
3553
+ *
3554
+ * const folder = new FolderReference("project-1", "/work/project");
3555
+ * const request = new DeleteFolderRequest(folder);
3556
+ * console.log(DeleteFolderRequest.method);
3557
+ * ```
3558
+ */
3559
+ public constructor(folder: FolderReference);
3560
+
3561
+ /**
3562
+ * Reads a request from its wire form.
3563
+ *
3564
+ * @param value The wire form.
3565
+ * @returns The request.
3566
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a request.
3567
+ * @example
3568
+ * ```ts
3569
+ * import { DeleteFolderRequest } from "@noldova/checkpoints.protocol";
3570
+ *
3571
+ * const folderJson = { identity: "project-1", path: "/work/project" };
3572
+ * const request = DeleteFolderRequest.fromJson({ folder: folderJson });
3573
+ * console.log(request.folder.identity);
3574
+ * ```
3575
+ */
3576
+ public static fromJson(value: unknown): DeleteFolderRequest;
3577
+
3578
+ /**
3579
+ * @returns The wire form.
3580
+ * @example
3581
+ * ```ts
3582
+ * import { DeleteFolderRequest, FolderReference } from "@noldova/checkpoints.protocol";
3583
+ *
3584
+ * const folder = new FolderReference("project-1", "/work/project");
3585
+ * const request = new DeleteFolderRequest(folder);
3586
+ * console.log(JSON.stringify(request.toJson()));
3587
+ * ```
3588
+ */
3589
+ public toJson(): JsonObject;
3590
+ }
3591
+
3592
+ /**
3593
+ * What a folder's delete did, the answer to `checkpoints.deleteFolder`.
3594
+ */
3595
+ export declare class DeleteFolderResult {
3596
+ /**
3597
+ * How the delete ended.
3598
+ */
3599
+ public readonly outcome: DeleteFolderOutcome;
3600
+
3601
+ /**
3602
+ * @param outcome How the delete ended.
3603
+ * @example
3604
+ * ```ts
3605
+ * import { DeleteFolderOutcome, DeleteFolderResult } from "@noldova/checkpoints.protocol";
3606
+ *
3607
+ * const result = new DeleteFolderResult(DeleteFolderOutcome.Deleted);
3608
+ * console.log(result.outcome.value);
3609
+ * ```
3610
+ */
3611
+ public constructor(outcome: DeleteFolderOutcome);
3612
+
3613
+ /**
3614
+ * Reads a result from its wire form.
3615
+ *
3616
+ * @param value The wire form.
3617
+ * @returns The result.
3618
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of a result.
3619
+ * @example
3620
+ * ```ts
3621
+ * import { DeleteFolderResult } from "@noldova/checkpoints.protocol";
3622
+ *
3623
+ * const result = DeleteFolderResult.fromJson({ outcome: "HeldUp" });
3624
+ * console.log(result.outcome.value);
3625
+ * ```
3626
+ */
3627
+ public static fromJson(value: unknown): DeleteFolderResult;
3628
+
3629
+ /**
3630
+ * @returns The wire form.
3631
+ * @example
3632
+ * ```ts
3633
+ * import { DeleteFolderOutcome, DeleteFolderResult } from "@noldova/checkpoints.protocol";
3634
+ *
3635
+ * const result = new DeleteFolderResult(DeleteFolderOutcome.Deleted);
3636
+ * console.log(JSON.stringify(result.toJson()));
3637
+ * ```
3638
+ */
3639
+ public toJson(): JsonObject;
3640
+ }
3641
+
3642
+ /**
3643
+ * The payload of `checkpoints.restored`, raised when a restore finishes, including one resumed from its journal.
3644
+ */
3645
+ export declare class RestoredEvent {
3646
+ /**
3647
+ * The event's name, `"checkpoints.restored"`.
3648
+ */
3649
+ public static readonly event: string;
3650
+
3651
+ /**
3652
+ * The id of the checkpoint taken before the restore.
3653
+ */
3654
+ public readonly before: string;
3655
+
3656
+ /**
3657
+ * The id of the checkpoint restored.
3658
+ */
3659
+ public readonly checkpoint: string;
3660
+
3661
+ /**
3662
+ * The folder's identity.
3663
+ */
3664
+ public readonly identity: string;
3665
+
3666
+ /**
3667
+ * @param identity The folder's identity, 1 to 64 letters, digits or hyphens.
3668
+ * @param checkpoint The id of the checkpoint restored.
3669
+ * @param before The id of the checkpoint taken before the restore.
3670
+ * @throws {ProtocolException} Thrown synchronously when the identity or an id isn't one.
3671
+ * @example
3672
+ * ```ts
3673
+ * import { RestoredEvent } from "@noldova/checkpoints.protocol";
3674
+ *
3675
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3676
+ * const other = "01928f6e-7a3c-7c4d-8e5f-0a1b2c3d4e5f";
3677
+ * const event = new RestoredEvent("project-1", id, other);
3678
+ * console.log(RestoredEvent.event);
3679
+ * ```
3680
+ */
3681
+ public constructor(identity: string, checkpoint: string, before: string);
3682
+
3683
+ /**
3684
+ * Reads an event from its wire form.
3685
+ *
3686
+ * @param value The wire form.
3687
+ * @returns The event.
3688
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of the event.
3689
+ * @example
3690
+ * ```ts
3691
+ * import { RestoredEvent } from "@noldova/checkpoints.protocol";
3692
+ *
3693
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3694
+ * const other = "01928f6e-7a3c-7c4d-8e5f-0a1b2c3d4e5f";
3695
+ * const event = RestoredEvent.fromJson({ identity: "project-1", checkpoint: id, before: other });
3696
+ * console.log(event.before);
3697
+ * ```
3698
+ */
3699
+ public static fromJson(value: unknown): RestoredEvent;
3700
+
3701
+ /**
3702
+ * @returns The wire form.
3703
+ * @example
3704
+ * ```ts
3705
+ * import { RestoredEvent } from "@noldova/checkpoints.protocol";
3706
+ *
3707
+ * const id = "01928f6e-7a3b-7c4d-8e5f-0a1b2c3d4e5f";
3708
+ * const other = "01928f6e-7a3c-7c4d-8e5f-0a1b2c3d4e5f";
3709
+ * const event = new RestoredEvent("project-1", id, other);
3710
+ * console.log(JSON.stringify(event.toJson()));
3711
+ * ```
3712
+ */
3713
+ public toJson(): JsonObject;
3714
+ }
3715
+
3716
+ /**
3717
+ * The payload of `checkpoints.capturePaused`, raised when a capture took no checkpoint for want of space on the store's volume;
3718
+ * the module also posts a `checkpoints.lowDiskSpace` notification, until a capture has the space.
3719
+ */
3720
+ export declare class CapturePausedEvent {
3721
+ /**
3722
+ * The event's name, `"checkpoints.capturePaused"`.
3723
+ */
3724
+ public static readonly event: string;
3725
+
3726
+ /**
3727
+ * The folder's identity.
3728
+ */
3729
+ public readonly identity: string;
3730
+
3731
+ /**
3732
+ * The bytes free on the store's volume for the module.
3733
+ */
3734
+ public readonly spaceFree: number;
3735
+
3736
+ /**
3737
+ * The bytes the checkpoint needed free.
3738
+ */
3739
+ public readonly spaceNeeded: number;
3740
+
3741
+ /**
3742
+ * @param identity The folder's identity, 1 to 64 letters, digits or hyphens.
3743
+ * @param spaceFree The bytes free.
3744
+ * @param spaceNeeded The bytes needed.
3745
+ * @throws {ProtocolException} Thrown synchronously when the identity isn't one, or a size isn't a whole number of bytes.
3746
+ * @example
3747
+ * ```ts
3748
+ * import { CapturePausedEvent } from "@noldova/checkpoints.protocol";
3749
+ *
3750
+ * const event = new CapturePausedEvent("project-1", 1_073_741_824, 3_221_225_472);
3751
+ * console.log(event.spaceNeeded);
3752
+ * ```
3753
+ */
3754
+ public constructor(identity: string, spaceFree: number, spaceNeeded: number);
3755
+
3756
+ /**
3757
+ * Reads an event from its wire form.
3758
+ *
3759
+ * @param value The wire form.
3760
+ * @returns The event.
3761
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of the event.
3762
+ * @example
3763
+ * ```ts
3764
+ * import { CapturePausedEvent } from "@noldova/checkpoints.protocol";
3765
+ *
3766
+ * const event = CapturePausedEvent.fromJson({ identity: "project-1", spaceFree: 0, spaceNeeded: 2_147_483_648 });
3767
+ * console.log(event.spaceFree);
3768
+ * ```
3769
+ */
3770
+ public static fromJson(value: unknown): CapturePausedEvent;
3771
+
3772
+ /**
3773
+ * @returns The wire form.
3774
+ * @example
3775
+ * ```ts
3776
+ * import { CapturePausedEvent } from "@noldova/checkpoints.protocol";
3777
+ *
3778
+ * const event = new CapturePausedEvent("project-1", 1_073_741_824, 3_221_225_472);
3779
+ * console.log(JSON.stringify(event.toJson()));
3780
+ * ```
3781
+ */
3782
+ public toJson(): JsonObject;
3783
+ }
3784
+
3785
+ /**
3786
+ * The payload of `checkpoints.captureResumed`, raised by the first capture that has the space after captures of the folder were
3787
+ * paused, which also dismisses the `checkpoints.lowDiskSpace` notification.
3788
+ */
3789
+ export declare class CaptureResumedEvent {
3790
+ /**
3791
+ * The event's name, `"checkpoints.captureResumed"`.
3792
+ */
3793
+ public static readonly event: string;
3794
+
3795
+ /**
3796
+ * The folder's identity.
3797
+ */
3798
+ public readonly identity: string;
3799
+
3800
+ /**
3801
+ * @param identity The folder's identity, 1 to 64 letters, digits or hyphens.
3802
+ * @throws {ProtocolException} Thrown synchronously when the identity isn't one.
3803
+ * @example
3804
+ * ```ts
3805
+ * import { CaptureResumedEvent } from "@noldova/checkpoints.protocol";
3806
+ *
3807
+ * const event = new CaptureResumedEvent("project-1");
3808
+ * console.log(event.identity);
3809
+ * ```
3810
+ */
3811
+ public constructor(identity: string);
3812
+
3813
+ /**
3814
+ * Reads an event from its wire form.
3815
+ *
3816
+ * @param value The wire form.
3817
+ * @returns The event.
3818
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of the event.
3819
+ * @example
3820
+ * ```ts
3821
+ * import { CaptureResumedEvent } from "@noldova/checkpoints.protocol";
3822
+ *
3823
+ * const event = CaptureResumedEvent.fromJson({ identity: "project-1" });
3824
+ * console.log(event.identity);
3825
+ * ```
3826
+ */
3827
+ public static fromJson(value: unknown): CaptureResumedEvent;
3828
+
3829
+ /**
3830
+ * @returns The wire form.
3831
+ * @example
3832
+ * ```ts
3833
+ * import { CaptureResumedEvent } from "@noldova/checkpoints.protocol";
3834
+ *
3835
+ * const event = new CaptureResumedEvent("project-1");
3836
+ * console.log(JSON.stringify(event.toJson()));
3837
+ * ```
3838
+ */
3839
+ public toJson(): JsonObject;
3840
+ }
3841
+
3842
+ /**
3843
+ * The payload of `checkpoints.restoreHeldUp`, raised when an interrupted restore couldn't be rolled back because the system wouldn't
3844
+ * let the module change some paths; the folder's captures and restores are held up until a later rollback finishes.
3845
+ */
3846
+ export declare class RestoreHeldUpEvent {
3847
+ /**
3848
+ * The event's name, `"checkpoints.restoreHeldUp"`.
3849
+ */
3850
+ public static readonly event: string;
3851
+
3852
+ /**
3853
+ * The folder's identity.
3854
+ */
3855
+ public readonly identity: string;
3856
+
3857
+ /**
3858
+ * The paths the module couldn't change, relative to the folder, with `/` between their names.
3859
+ */
3860
+ public readonly paths: readonly string[];
3861
+
3862
+ /**
3863
+ * @param identity The folder's identity, 1 to 64 letters, digits or hyphens.
3864
+ * @param paths The paths the module couldn't change.
3865
+ * @throws {ProtocolException} Thrown synchronously when the identity isn't one, or a path isn't relative to the folder.
3866
+ * @example
3867
+ * ```ts
3868
+ * import { RestoreHeldUpEvent } from "@noldova/checkpoints.protocol";
3869
+ *
3870
+ * const event = new RestoreHeldUpEvent("project-1", ["db/locked.sqlite"]);
3871
+ * console.log(event.paths);
3872
+ * ```
3873
+ */
3874
+ public constructor(identity: string, paths: readonly string[]);
3875
+
3876
+ /**
3877
+ * Reads an event from its wire form.
3878
+ *
3879
+ * @param value The wire form.
3880
+ * @returns The event.
3881
+ * @throws {ProtocolException} Thrown synchronously when the value isn't the wire form of the event.
3882
+ * @example
3883
+ * ```ts
3884
+ * import { RestoreHeldUpEvent } from "@noldova/checkpoints.protocol";
3885
+ *
3886
+ * const event = RestoreHeldUpEvent.fromJson({ identity: "project-1", paths: [] });
3887
+ * console.log(event.paths.length);
3888
+ * ```
3889
+ */
3890
+ public static fromJson(value: unknown): RestoreHeldUpEvent;
3891
+
3892
+ /**
3893
+ * @returns The wire form.
3894
+ * @example
3895
+ * ```ts
3896
+ * import { RestoreHeldUpEvent } from "@noldova/checkpoints.protocol";
3897
+ *
3898
+ * const event = new RestoreHeldUpEvent("project-1", ["db/locked.sqlite"]);
3899
+ * console.log(JSON.stringify(event.toJson()));
3900
+ * ```
3901
+ */
3902
+ public toJson(): JsonObject;
3903
+ }
3904
+
3905
+ /**
3906
+ * Reads the fields of a JSON object that a model's wire form must be, failing with a {@link ProtocolException} that names the model.
3907
+ */
3908
+ export declare class JsonObjectReader {
3909
+ /**
3910
+ * @param value The value to read, which must be a JSON object.
3911
+ * @param model The model's name, for the failures' messages.
3912
+ * @throws {ProtocolException} Thrown synchronously when the value isn't an object.
3913
+ * @example
3914
+ * ```ts
3915
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3916
+ *
3917
+ * const reader = new JsonObjectReader({ label: "Turn 3" }, "Model");
3918
+ * reader.refuseOtherFields(["label"]);
3919
+ * console.log(reader.readString("label"));
3920
+ * ```
3921
+ */
3922
+ public constructor(value: unknown, model: string);
3923
+
3924
+ /**
3925
+ * @param field The field's name.
3926
+ * @returns The field's value.
3927
+ * @throws {ProtocolException} Thrown synchronously when the object has no such field.
3928
+ * @example
3929
+ * ```ts
3930
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3931
+ *
3932
+ * const reader = new JsonObjectReader({ label: "Turn 3" }, "Model");
3933
+ * console.log(reader.read("label"));
3934
+ * ```
3935
+ */
3936
+ public read(field: string): unknown;
3937
+
3938
+ /**
3939
+ * @param field The field's name.
3940
+ * @returns The field's `true` or `false`.
3941
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or is neither `true` nor `false`.
3942
+ * @example
3943
+ * ```ts
3944
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3945
+ *
3946
+ * const reader = new JsonObjectReader({ isText: true }, "Model");
3947
+ * console.log(reader.readBoolean("isText"));
3948
+ * ```
3949
+ */
3950
+ public readBoolean(field: string): boolean;
3951
+
3952
+ /**
3953
+ * @param field The field's name.
3954
+ * @returns The field's list.
3955
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or isn't a list.
3956
+ * @example
3957
+ * ```ts
3958
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3959
+ *
3960
+ * const reader = new JsonObjectReader({ steps: [] }, "Model");
3961
+ * console.log(reader.readList("steps").length);
3962
+ * ```
3963
+ */
3964
+ public readList(field: string): readonly unknown[];
3965
+
3966
+ /**
3967
+ * @param field The field's name.
3968
+ * @returns The field's number.
3969
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or isn't a number.
3970
+ * @example
3971
+ * ```ts
3972
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3973
+ *
3974
+ * const reader = new JsonObjectReader({ size: 1_024 }, "Model");
3975
+ * console.log(reader.readNumber("size"));
3976
+ * ```
3977
+ */
3978
+ public readNumber(field: string): number;
3979
+
3980
+ /**
3981
+ * @param field The field's name.
3982
+ * @returns The field's number, or `null`.
3983
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or is neither a number nor `null`.
3984
+ * @example
3985
+ * ```ts
3986
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
3987
+ *
3988
+ * const reader = new JsonObjectReader({ size: null }, "Model");
3989
+ * console.log(reader.readNumberOrNull("size"));
3990
+ * ```
3991
+ */
3992
+ public readNumberOrNull(field: string): number | null;
3993
+
3994
+ /**
3995
+ * @param field The field's name.
3996
+ * @returns The field's text.
3997
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or isn't text.
3998
+ * @example
3999
+ * ```ts
4000
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
4001
+ *
4002
+ * const reader = new JsonObjectReader({ label: "Turn 3" }, "Model");
4003
+ * console.log(reader.readString("label"));
4004
+ * ```
4005
+ */
4006
+ public readString(field: string): string;
4007
+
4008
+ /**
4009
+ * @param field The field's name.
4010
+ * @returns The field's text, or `null`.
4011
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or is neither text nor `null`.
4012
+ * @example
4013
+ * ```ts
4014
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
4015
+ *
4016
+ * const reader = new JsonObjectReader({ label: null }, "Model");
4017
+ * console.log(reader.readStringOrNull("label"));
4018
+ * ```
4019
+ */
4020
+ public readStringOrNull(field: string): string | null;
4021
+
4022
+ /**
4023
+ * @param field The field's name.
4024
+ * @returns The field's list of text.
4025
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or isn't a list of text.
4026
+ * @example
4027
+ * ```ts
4028
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
4029
+ *
4030
+ * const reader = new JsonObjectReader({ paths: ["src", "docs"] }, "Model");
4031
+ * console.log(reader.readStringList("paths"));
4032
+ * ```
4033
+ */
4034
+ public readStringList(field: string): readonly string[];
4035
+
4036
+ /**
4037
+ * @param field The field's name.
4038
+ * @returns The field's list of text, or `null`.
4039
+ * @throws {ProtocolException} Thrown synchronously when the field is missing or is neither a list of text nor `null`.
4040
+ * @example
4041
+ * ```ts
4042
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
4043
+ *
4044
+ * const reader = new JsonObjectReader({ paths: null }, "Model");
4045
+ * console.log(reader.readStringListOrNull("paths"));
4046
+ * ```
4047
+ */
4048
+ public readStringListOrNull(field: string): readonly string[] | null;
4049
+
4050
+ /**
4051
+ * @param known The fields the model has.
4052
+ * @throws {ProtocolException} Thrown synchronously when the object has a field the model doesn't.
4053
+ * @example
4054
+ * ```ts
4055
+ * import { JsonObjectReader } from "@noldova/checkpoints.protocol";
4056
+ *
4057
+ * const reader = new JsonObjectReader({ label: "Turn 3" }, "Model");
4058
+ * reader.refuseOtherFields(["label"]);
4059
+ * ```
4060
+ */
4061
+ public refuseOtherFields(known: readonly string[]): void;
4062
+ }