document-model 6.0.0-dev.105 → 6.0.0-dev.106

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 (289) hide show
  1. package/dist/index.d.ts +81 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +216 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/{src/core/node.d.ts → node.d.mts} +25 -23
  6. package/dist/node.d.mts.map +1 -0
  7. package/dist/node.mjs +151 -0
  8. package/dist/node.mjs.map +1 -0
  9. package/package.json +11 -15
  10. package/dist/src/core/actions.d.ts +0 -87
  11. package/dist/src/core/actions.d.ts.map +0 -1
  12. package/dist/src/core/actions.js +0 -187
  13. package/dist/src/core/actions.js.map +0 -1
  14. package/dist/src/core/controller.d.ts +0 -30
  15. package/dist/src/core/controller.d.ts.map +0 -1
  16. package/dist/src/core/controller.js +0 -60
  17. package/dist/src/core/controller.js.map +0 -1
  18. package/dist/src/core/crypto.d.ts +0 -8
  19. package/dist/src/core/crypto.d.ts.map +0 -1
  20. package/dist/src/core/crypto.js +0 -68
  21. package/dist/src/core/crypto.js.map +0 -1
  22. package/dist/src/core/documents.d.ts +0 -147
  23. package/dist/src/core/documents.d.ts.map +0 -1
  24. package/dist/src/core/documents.js +0 -845
  25. package/dist/src/core/documents.js.map +0 -1
  26. package/dist/src/core/errors.d.ts +0 -21
  27. package/dist/src/core/errors.d.ts.map +0 -1
  28. package/dist/src/core/errors.js +0 -46
  29. package/dist/src/core/errors.js.map +0 -1
  30. package/dist/src/core/files.d.ts +0 -27
  31. package/dist/src/core/files.d.ts.map +0 -1
  32. package/dist/src/core/files.js +0 -90
  33. package/dist/src/core/files.js.map +0 -1
  34. package/dist/src/core/header.d.ts +0 -63
  35. package/dist/src/core/header.d.ts.map +0 -1
  36. package/dist/src/core/header.js +0 -173
  37. package/dist/src/core/header.js.map +0 -1
  38. package/dist/src/core/index.d.ts +0 -16
  39. package/dist/src/core/index.d.ts.map +0 -1
  40. package/dist/src/core/index.js +0 -16
  41. package/dist/src/core/index.js.map +0 -1
  42. package/dist/src/core/logger-types.d.ts +0 -12
  43. package/dist/src/core/logger-types.d.ts.map +0 -1
  44. package/dist/src/core/logger-types.js +0 -2
  45. package/dist/src/core/logger-types.js.map +0 -1
  46. package/dist/src/core/logger.d.ts +0 -27
  47. package/dist/src/core/logger.d.ts.map +0 -1
  48. package/dist/src/core/logger.js +0 -127
  49. package/dist/src/core/logger.js.map +0 -1
  50. package/dist/src/core/node.d.ts.map +0 -1
  51. package/dist/src/core/node.js +0 -155
  52. package/dist/src/core/node.js.map +0 -1
  53. package/dist/src/core/operations.d.ts +0 -50
  54. package/dist/src/core/operations.d.ts.map +0 -1
  55. package/dist/src/core/operations.js +0 -126
  56. package/dist/src/core/operations.js.map +0 -1
  57. package/dist/src/core/ph-types.d.ts +0 -2
  58. package/dist/src/core/ph-types.d.ts.map +0 -1
  59. package/dist/src/core/ph-types.js +0 -2
  60. package/dist/src/core/ph-types.js.map +0 -1
  61. package/dist/src/core/reducer.d.ts +0 -63
  62. package/dist/src/core/reducer.d.ts.map +0 -1
  63. package/dist/src/core/reducer.js +0 -446
  64. package/dist/src/core/reducer.js.map +0 -1
  65. package/dist/src/core/schemas.d.ts +0 -75
  66. package/dist/src/core/schemas.d.ts.map +0 -1
  67. package/dist/src/core/schemas.js +0 -116
  68. package/dist/src/core/schemas.js.map +0 -1
  69. package/dist/src/core/state.d.ts +0 -26
  70. package/dist/src/core/state.d.ts.map +0 -1
  71. package/dist/src/core/state.js +0 -56
  72. package/dist/src/core/state.js.map +0 -1
  73. package/dist/src/core/types.d.ts +0 -2
  74. package/dist/src/core/types.d.ts.map +0 -1
  75. package/dist/src/core/types.js +0 -2
  76. package/dist/src/core/types.js.map +0 -1
  77. package/dist/src/core/utils.d.ts +0 -6
  78. package/dist/src/core/utils.d.ts.map +0 -1
  79. package/dist/src/core/utils.js +0 -15
  80. package/dist/src/core/utils.js.map +0 -1
  81. package/dist/src/core/validation.d.ts +0 -4
  82. package/dist/src/core/validation.d.ts.map +0 -1
  83. package/dist/src/core/validation.js +0 -27
  84. package/dist/src/core/validation.js.map +0 -1
  85. package/dist/src/document-model/actions.d.ts +0 -164
  86. package/dist/src/document-model/actions.d.ts.map +0 -1
  87. package/dist/src/document-model/actions.js +0 -111
  88. package/dist/src/document-model/actions.js.map +0 -1
  89. package/dist/src/document-model/constants.d.ts +0 -6
  90. package/dist/src/document-model/constants.d.ts.map +0 -1
  91. package/dist/src/document-model/constants.js +0 -584
  92. package/dist/src/document-model/constants.js.map +0 -1
  93. package/dist/src/document-model/controller.d.ts +0 -5
  94. package/dist/src/document-model/controller.d.ts.map +0 -1
  95. package/dist/src/document-model/controller.js +0 -5
  96. package/dist/src/document-model/controller.js.map +0 -1
  97. package/dist/src/document-model/document-schema.d.ts +0 -69
  98. package/dist/src/document-model/document-schema.d.ts.map +0 -1
  99. package/dist/src/document-model/document-schema.js +0 -43
  100. package/dist/src/document-model/document-schema.js.map +0 -1
  101. package/dist/src/document-model/document-type.d.ts +0 -2
  102. package/dist/src/document-model/document-type.d.ts.map +0 -1
  103. package/dist/src/document-model/document-type.js +0 -2
  104. package/dist/src/document-model/document-type.js.map +0 -1
  105. package/dist/src/document-model/files.d.ts +0 -5
  106. package/dist/src/document-model/files.d.ts.map +0 -1
  107. package/dist/src/document-model/files.js +0 -9
  108. package/dist/src/document-model/files.js.map +0 -1
  109. package/dist/src/document-model/index.d.ts +0 -12
  110. package/dist/src/document-model/index.d.ts.map +0 -1
  111. package/dist/src/document-model/index.js +0 -12
  112. package/dist/src/document-model/index.js.map +0 -1
  113. package/dist/src/document-model/module.d.ts +0 -3
  114. package/dist/src/document-model/module.d.ts.map +0 -1
  115. package/dist/src/document-model/module.js +0 -24
  116. package/dist/src/document-model/module.js.map +0 -1
  117. package/dist/src/document-model/reducers.d.ts +0 -11
  118. package/dist/src/document-model/reducers.d.ts.map +0 -1
  119. package/dist/src/document-model/reducers.js +0 -618
  120. package/dist/src/document-model/reducers.js.map +0 -1
  121. package/dist/src/document-model/schemas.d.ts +0 -189
  122. package/dist/src/document-model/schemas.d.ts.map +0 -1
  123. package/dist/src/document-model/schemas.js +0 -388
  124. package/dist/src/document-model/schemas.js.map +0 -1
  125. package/dist/src/document-model/state.d.ts +0 -15
  126. package/dist/src/document-model/state.d.ts.map +0 -1
  127. package/dist/src/document-model/state.js +0 -75
  128. package/dist/src/document-model/state.js.map +0 -1
  129. package/dist/src/document-model/types.d.ts +0 -584
  130. package/dist/src/document-model/types.d.ts.map +0 -1
  131. package/dist/src/document-model/types.js +0 -2
  132. package/dist/src/document-model/types.js.map +0 -1
  133. package/dist/src/document-model/validation.d.ts +0 -32
  134. package/dist/src/document-model/validation.d.ts.map +0 -1
  135. package/dist/src/document-model/validation.js +0 -166
  136. package/dist/src/document-model/validation.js.map +0 -1
  137. package/dist/src/index.d.ts +0 -6
  138. package/dist/src/index.d.ts.map +0 -1
  139. package/dist/src/index.js +0 -3
  140. package/dist/src/index.js.map +0 -1
  141. package/dist/test/document/crypto.test.d.ts +0 -2
  142. package/dist/test/document/crypto.test.d.ts.map +0 -1
  143. package/dist/test/document/crypto.test.js +0 -192
  144. package/dist/test/document/crypto.test.js.map +0 -1
  145. package/dist/test/document/event-vs-command.test.d.ts +0 -2
  146. package/dist/test/document/event-vs-command.test.d.ts.map +0 -1
  147. package/dist/test/document/event-vs-command.test.js +0 -202
  148. package/dist/test/document/event-vs-command.test.js.map +0 -1
  149. package/dist/test/document/local.test.d.ts +0 -2
  150. package/dist/test/document/local.test.d.ts.map +0 -1
  151. package/dist/test/document/local.test.js +0 -226
  152. package/dist/test/document/local.test.js.map +0 -1
  153. package/dist/test/document/operation-id.test.d.ts +0 -2
  154. package/dist/test/document/operation-id.test.d.ts.map +0 -1
  155. package/dist/test/document/operation-id.test.js +0 -118
  156. package/dist/test/document/operation-id.test.js.map +0 -1
  157. package/dist/test/document/prune.test.d.ts +0 -2
  158. package/dist/test/document/prune.test.d.ts.map +0 -1
  159. package/dist/test/document/prune.test.js +0 -159
  160. package/dist/test/document/prune.test.js.map +0 -1
  161. package/dist/test/document/reducer.test.d.ts +0 -2
  162. package/dist/test/document/reducer.test.d.ts.map +0 -1
  163. package/dist/test/document/reducer.test.js +0 -284
  164. package/dist/test/document/reducer.test.js.map +0 -1
  165. package/dist/test/document/skip-operations.test.d.ts +0 -2
  166. package/dist/test/document/skip-operations.test.d.ts.map +0 -1
  167. package/dist/test/document/skip-operations.test.js +0 -495
  168. package/dist/test/document/skip-operations.test.js.map +0 -1
  169. package/dist/test/document/undo-redo-v2.test.d.ts +0 -2
  170. package/dist/test/document/undo-redo-v2.test.d.ts.map +0 -1
  171. package/dist/test/document/undo-redo-v2.test.js +0 -207
  172. package/dist/test/document/undo-redo-v2.test.js.map +0 -1
  173. package/dist/test/document/undo-redo.test.d.ts +0 -2
  174. package/dist/test/document/undo-redo.test.d.ts.map +0 -1
  175. package/dist/test/document/undo-redo.test.js +0 -413
  176. package/dist/test/document/undo-redo.test.js.map +0 -1
  177. package/dist/test/document/utils.test.d.ts +0 -2
  178. package/dist/test/document/utils.test.d.ts.map +0 -1
  179. package/dist/test/document/utils.test.js +0 -172
  180. package/dist/test/document/utils.test.js.map +0 -1
  181. package/dist/test/document-helpers/addUndo.test.d.ts +0 -2
  182. package/dist/test/document-helpers/addUndo.test.d.ts.map +0 -1
  183. package/dist/test/document-helpers/addUndo.test.js +0 -120
  184. package/dist/test/document-helpers/addUndo.test.js.map +0 -1
  185. package/dist/test/document-helpers/attachBranch.test.d.ts +0 -2
  186. package/dist/test/document-helpers/attachBranch.test.d.ts.map +0 -1
  187. package/dist/test/document-helpers/attachBranch.test.js +0 -364
  188. package/dist/test/document-helpers/attachBranch.test.js.map +0 -1
  189. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
  190. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
  191. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +0 -252
  192. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js.map +0 -1
  193. package/dist/test/document-helpers/conflictResolution.test.d.ts +0 -2
  194. package/dist/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
  195. package/dist/test/document-helpers/conflictResolution.test.js +0 -109
  196. package/dist/test/document-helpers/conflictResolution.test.js.map +0 -1
  197. package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
  198. package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
  199. package/dist/test/document-helpers/filterDuplicatedOperations.test.js +0 -126
  200. package/dist/test/document-helpers/filterDuplicatedOperations.test.js.map +0 -1
  201. package/dist/test/document-helpers/garbageCollect.test.d.ts +0 -2
  202. package/dist/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
  203. package/dist/test/document-helpers/garbageCollect.test.js +0 -136
  204. package/dist/test/document-helpers/garbageCollect.test.js.map +0 -1
  205. package/dist/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
  206. package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
  207. package/dist/test/document-helpers/groupOperationsByScope.test.js +0 -102
  208. package/dist/test/document-helpers/groupOperationsByScope.test.js.map +0 -1
  209. package/dist/test/document-helpers/headerRevision.test.d.ts +0 -2
  210. package/dist/test/document-helpers/headerRevision.test.d.ts.map +0 -1
  211. package/dist/test/document-helpers/headerRevision.test.js +0 -203
  212. package/dist/test/document-helpers/headerRevision.test.js.map +0 -1
  213. package/dist/test/document-helpers/merge.test.d.ts +0 -2
  214. package/dist/test/document-helpers/merge.test.d.ts.map +0 -1
  215. package/dist/test/document-helpers/merge.test.js +0 -906
  216. package/dist/test/document-helpers/merge.test.js.map +0 -1
  217. package/dist/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
  218. package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
  219. package/dist/test/document-helpers/nextSkipNumber.test.js +0 -135
  220. package/dist/test/document-helpers/nextSkipNumber.test.js.map +0 -1
  221. package/dist/test/document-helpers/prepareOperations.test.d.ts +0 -2
  222. package/dist/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
  223. package/dist/test/document-helpers/prepareOperations.test.js +0 -304
  224. package/dist/test/document-helpers/prepareOperations.test.js.map +0 -1
  225. package/dist/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
  226. package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
  227. package/dist/test/document-helpers/removeExistingOperations.test.js +0 -177
  228. package/dist/test/document-helpers/removeExistingOperations.test.js.map +0 -1
  229. package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
  230. package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
  231. package/dist/test/document-helpers/reshuffleByTimestamp.test.js +0 -148
  232. package/dist/test/document-helpers/reshuffleByTimestamp.test.js.map +0 -1
  233. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
  234. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
  235. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +0 -200
  236. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js.map +0 -1
  237. package/dist/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
  238. package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
  239. package/dist/test/document-helpers/skipHeaderOperations.test.js +0 -72
  240. package/dist/test/document-helpers/skipHeaderOperations.test.js.map +0 -1
  241. package/dist/test/document-helpers/sortOperations.test.d.ts +0 -2
  242. package/dist/test/document-helpers/sortOperations.test.d.ts.map +0 -1
  243. package/dist/test/document-helpers/sortOperations.test.js +0 -101
  244. package/dist/test/document-helpers/sortOperations.test.js.map +0 -1
  245. package/dist/test/document-helpers/split.test.d.ts +0 -2
  246. package/dist/test/document-helpers/split.test.d.ts.map +0 -1
  247. package/dist/test/document-helpers/split.test.js +0 -121
  248. package/dist/test/document-helpers/split.test.js.map +0 -1
  249. package/dist/test/document-helpers/utils.d.ts +0 -15
  250. package/dist/test/document-helpers/utils.d.ts.map +0 -1
  251. package/dist/test/document-helpers/utils.js +0 -61
  252. package/dist/test/document-helpers/utils.js.map +0 -1
  253. package/dist/test/document-model/replay.test.d.ts +0 -2
  254. package/dist/test/document-model/replay.test.d.ts.map +0 -1
  255. package/dist/test/document-model/replay.test.js +0 -139
  256. package/dist/test/document-model/replay.test.js.map +0 -1
  257. package/dist/test/document-model/skip-operations.test.d.ts +0 -2
  258. package/dist/test/document-model/skip-operations.test.d.ts.map +0 -1
  259. package/dist/test/document-model/skip-operations.test.js +0 -214
  260. package/dist/test/document-model/skip-operations.test.js.map +0 -1
  261. package/dist/test/document-model/validation.test.d.ts +0 -2
  262. package/dist/test/document-model/validation.test.d.ts.map +0 -1
  263. package/dist/test/document-model/validation.test.js +0 -451
  264. package/dist/test/document-model/validation.test.js.map +0 -1
  265. package/dist/test/document-model/versioning.test.d.ts +0 -2
  266. package/dist/test/document-model/versioning.test.d.ts.map +0 -1
  267. package/dist/test/document-model/versioning.test.js +0 -93
  268. package/dist/test/document-model/versioning.test.js.map +0 -1
  269. package/dist/test/document-model/zip.test.d.ts +0 -2
  270. package/dist/test/document-model/zip.test.d.ts.map +0 -1
  271. package/dist/test/document-model/zip.test.js +0 -79
  272. package/dist/test/document-model/zip.test.js.map +0 -1
  273. package/dist/test/helpers.d.ts +0 -79
  274. package/dist/test/helpers.d.ts.map +0 -1
  275. package/dist/test/helpers.js +0 -121
  276. package/dist/test/helpers.js.map +0 -1
  277. package/dist/test/index.d.ts +0 -4
  278. package/dist/test/index.d.ts.map +0 -1
  279. package/dist/test/index.js +0 -3
  280. package/dist/test/index.js.map +0 -1
  281. package/dist/test/types.d.ts +0 -6
  282. package/dist/test/types.d.ts.map +0 -1
  283. package/dist/test/types.js +0 -2
  284. package/dist/test/types.js.map +0 -1
  285. package/dist/tsconfig.tsbuildinfo +0 -1
  286. package/dist/vitest.config.d.ts +0 -3
  287. package/dist/vitest.config.d.ts.map +0 -1
  288. package/dist/vitest.config.js +0 -7
  289. package/dist/vitest.config.js.map +0 -1
@@ -1,446 +0,0 @@
1
- import { castDraft, create, unsafe } from "mutative";
2
- import { actionFromAction, loadState, operationFromAction, operationFromOperation, } from "./actions.js";
3
- import { diffOperations, garbageCollect, garbageCollectDocumentOperations, garbageCollectV2, hashDocumentStateForScope, isDocumentAction, isUndo, isUndoRedo, parseResultingState, replayDocument, skipHeaderOperations, sortOperations, updateHeaderRevision, } from "./documents.js";
4
- import { loadStateOperation, redoOperation, setNameOperation, undoOperation, undoOperationV2, } from "./operations.js";
5
- import { DocumentActionSchema } from "./schemas.js";
6
- // This rebuilds the document according to the provided actions.
7
- export function replayOperations(initialState, clearedOperations, stateReducer, header, dispatch, documentReducer = baseReducer, skipHeaderOperations = {}, options) {
8
- // wraps the provided custom reducer with the
9
- // base document reducer
10
- const wrappedReducer = createReducer(stateReducer, documentReducer);
11
- return replayDocument(initialState, clearedOperations, wrappedReducer, header, dispatch, skipHeaderOperations, options);
12
- }
13
- /**
14
- * Updates the operations history of the document based on the provided action.
15
- *
16
- * @param state The current state of the document.
17
- * @param action The action being applied to the document.
18
- * @param index The index of the operation to update.
19
- * @param skip The number of operations to skip before applying the action.
20
- * @param reuseLastOperationIndex Whether to reuse the last operation index (used when a an UNDO operation is performed after an existing one).
21
- * @param context The operation context for deterministic ID generation.
22
- * @returns The updated document state.
23
- */
24
- function updateOperationsForAction(document, action, reuseLastOperationIndex, skip, context) {
25
- // UNDO, REDO and PRUNE are meta operations
26
- // that alter the operations history themselves
27
- if (["UNDO", "REDO", "PRUNE"].includes(action.type)) {
28
- return document;
29
- }
30
- const scope = action.scope;
31
- const existing = document.operations[scope];
32
- // Relies on ops being sorted ascending by index — see reactor CLAUDE.md invariants.
33
- const lastOperationIndex = existing?.at(-1)?.index ?? -1;
34
- const index = reuseLastOperationIndex
35
- ? lastOperationIndex
36
- : lastOperationIndex + 1;
37
- const newOperation = operationFromAction(action, index, skip, context);
38
- const operations = [...(existing ?? []), newOperation];
39
- return {
40
- ...document,
41
- operations: { ...document.operations, [scope]: operations },
42
- };
43
- }
44
- function updateOperationsForOperation(document, operation, reuseLastOperationIndex, skip, context, skipIndexValidation) {
45
- const scope = operation.action.scope;
46
- const existing = document.operations[scope];
47
- // Relies on ops being sorted ascending by index — see reactor CLAUDE.md invariants.
48
- const lastOperationIndex = existing?.at(-1)?.index ?? -1;
49
- const nextIndex = reuseLastOperationIndex
50
- ? lastOperationIndex
51
- : lastOperationIndex + 1;
52
- if (!skipIndexValidation && operation.index - skip > nextIndex) {
53
- throw new Error(`Missing operations: expected ${nextIndex} with skip 0 or equivalent, got index ${operation.index} with skip ${skip}`);
54
- }
55
- const newOperation = operationFromOperation(operation, operation.index, skip, context);
56
- const operations = [...(existing ?? []), newOperation];
57
- return {
58
- ...document,
59
- operations: { ...document.operations, [scope]: operations },
60
- };
61
- }
62
- /**
63
- * Updates the document state based on the provided action.
64
- *
65
- * @param state The current state of the document.
66
- * @param action The action being applied to the document.
67
- * @param skip The number of operations to skip before applying the action.
68
- * @param reuseLastOperationIndex Whether to reuse the last operation index (used when a an UNDO operation is performed after an existing one).
69
- * @param context The operation context for deterministic ID generation.
70
- * @returns The updated document state.
71
- */
72
- export function updateDocument(document, action, reuseLastOperationIndex, skip, context, operation, skipIndexValidation) {
73
- let newDocument;
74
- if (operation) {
75
- // operation
76
- newDocument = updateOperationsForOperation(document, operation, reuseLastOperationIndex, skip, context, skipIndexValidation);
77
- }
78
- else {
79
- // action
80
- newDocument = updateOperationsForAction(document, action, reuseLastOperationIndex, skip, context);
81
- }
82
- newDocument = updateHeaderRevision(newDocument, action.scope, action.timestampUtcMs);
83
- return newDocument;
84
- }
85
- /**
86
- * The base document reducer function that wraps a custom reducer function.
87
- *
88
- * @param state The current state of the document.
89
- * @param action The action being applied to the document.
90
- * @param wrappedReducer The custom reducer function being wrapped by the base reducer.
91
- * @returns The updated document state.
92
- */
93
- function _baseReducer(document, action, wrappedReducer) {
94
- // throws if action is not valid base action
95
- const parsedAction = DocumentActionSchema().parse(action);
96
- switch (parsedAction.type) {
97
- // TODO: This needs to be changed to a HEADER scope action if it's changing the header.
98
- case "SET_NAME":
99
- return setNameOperation(document, parsedAction.input);
100
- case "PRUNE":
101
- return pruneOperation(document, parsedAction.input, wrappedReducer);
102
- case "LOAD_STATE":
103
- return loadStateOperation(document, parsedAction.input);
104
- default:
105
- return document;
106
- }
107
- }
108
- /**
109
- * Processes an UNDO or REDO action.
110
- *
111
- * @param document The current state of the document.
112
- * @param action The action being applied to the document.
113
- * @param skip The number of operations to skip before applying the action.
114
- * @returns The updated document, calculated skip value and transformed action (if applied).
115
- */
116
- export function processUndoRedo(document, action, skip, protocolVersion = 1) {
117
- switch (action.type) {
118
- case "UNDO":
119
- if (protocolVersion >= 2) {
120
- return undoOperationV2(document, action, skip);
121
- }
122
- return undoOperation(document, action, skip);
123
- case "REDO":
124
- return redoOperation(document, action, skip);
125
- default:
126
- return { document, action, skip, reuseLastOperationIndex: false };
127
- }
128
- }
129
- function processSkipOperation(document, action, customReducer, skipValue, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
130
- const scope = action.scope;
131
- const scopeOperations = document.operations[scope];
132
- if (!scopeOperations) {
133
- return document;
134
- }
135
- const latestOperation = scopeOperations.at(-1);
136
- if (!latestOperation)
137
- return document;
138
- const documentOperations = garbageCollectDocumentOperations({
139
- ...document.operations,
140
- [scope]: skipHeaderOperations(scopeOperations, latestOperation),
141
- });
142
- let scopeState = undefined;
143
- const documentScopeOps = documentOperations[scope];
144
- const lastRemainingOperation = documentScopeOps?.at(-1);
145
- // if the last operation has the resulting state and
146
- // reuseOperationResultingState is true then reuses it
147
- // instead of replaying the operations from the beginning
148
- if (reuseOperationResultingState && lastRemainingOperation?.resultingState) {
149
- scopeState = resultingStateParser(lastRemainingOperation.resultingState);
150
- }
151
- else {
152
- const { state } = replayOperations(document.initialState, documentOperations, customReducer, document.header, undefined, undefined, undefined, {
153
- reuseOperationResultingState,
154
- operationResultingStateParser: resultingStateParser,
155
- skipIndexValidation: true,
156
- });
157
- scopeState = state[scope];
158
- }
159
- return {
160
- ...document,
161
- state: {
162
- ...document.state,
163
- [scope]: scopeState,
164
- },
165
- operations: garbageCollectDocumentOperations({
166
- ...document.operations,
167
- }),
168
- };
169
- }
170
- function processUndoOperation(document, scope, customReducer, reuseOperationResultingState = false, resultingStateParser = parseResultingState) {
171
- const scopeOperations = document.operations[scope];
172
- if (!scopeOperations) {
173
- return document;
174
- }
175
- const operations = [...scopeOperations];
176
- const sortedOperations = sortOperations(operations);
177
- sortedOperations.pop();
178
- const documentOperations = garbageCollectDocumentOperations({
179
- ...document.operations,
180
- });
181
- const documentScopeOps = documentOperations[scope];
182
- if (!documentScopeOps) {
183
- return document;
184
- }
185
- const clearedOperations = [...documentScopeOps];
186
- const diff = diffOperations(garbageCollect(sortedOperations), clearedOperations);
187
- const doc = replayOperations(document.initialState, documentOperations, customReducer, document.header, undefined, undefined, undefined, {
188
- reuseOperationResultingState,
189
- operationResultingStateParser: resultingStateParser,
190
- });
191
- const clipboard = sortOperations([...document.clipboard, ...diff].filter((op) => op.action.type !== "NOOP")).reverse();
192
- return { ...doc, clipboard };
193
- }
194
- /**
195
- * Base document reducer that wraps a custom document reducer and handles
196
- * document-level actions such as undo, redo, prune, and set name.
197
- *
198
- * @template TGlobalState - The type of the state of the custom reducer.
199
- * @template TAction - The type of the actions of the custom reducer.
200
- * @param state - The current state of the document.
201
- * @param action - The action object to apply to the state.
202
- * @param customReducer - The custom reducer that implements the application logic
203
- * specific to the document's state.
204
- * @returns The new state of the document.
205
- */
206
- export function baseReducer(document, action, customReducer, dispatch, options = {}) {
207
- const { skip, ignoreSkipOperations = false, reuseOperationResultingState = false, operationResultingStateParser, pruneOnSkip = true, branch = "main", } = options;
208
- let _action = actionFromAction(action);
209
- let skipValue = skip ?? options.replayOptions?.operation.skip ?? 0;
210
- let newDocument = {
211
- ...document,
212
- };
213
- let reuseLastOperationIndex = false;
214
- const shouldProcessSkipOperation = !ignoreSkipOperations && skipValue > 0;
215
- if (isUndoRedo(_action)) {
216
- const { skip: calculatedSkip, action: transformedAction, document: processedDocument, reuseLastOperationIndex: reuseIndex, } = processUndoRedo(document, _action, skipValue, options.protocolVersion ?? 1);
217
- _action = transformedAction;
218
- skipValue = calculatedSkip;
219
- newDocument = processedDocument;
220
- reuseLastOperationIndex = reuseIndex;
221
- }
222
- else {
223
- newDocument = {
224
- ...newDocument,
225
- clipboard: [],
226
- };
227
- }
228
- // if the action is one the base document actions (SET_NAME, UNDO, REDO, PRUNE)
229
- // then runs the base reducer first
230
- if (isDocumentAction(_action)) {
231
- newDocument = _baseReducer(newDocument, _action, customReducer);
232
- }
233
- // updates the document revision number, last modified date
234
- // and operation history
235
- const operationContext = {
236
- documentId: document.header.id,
237
- scope: _action.scope,
238
- branch,
239
- };
240
- newDocument = updateDocument(newDocument, _action, reuseLastOperationIndex, skipValue, operationContext, options.replayOptions?.operation, options.skipIndexValidation);
241
- // Only process undo for actual UNDO actions in protocol v1
242
- // For v2, NOOPs always have skip=1 and indices increment
243
- // NOOP operations with skip > 0 will have their clipboard populated server-side
244
- const protocolVersion = options.protocolVersion ?? 1;
245
- if (isUndo(action) && protocolVersion < 2) {
246
- const result = processUndoOperation(newDocument, action.scope, customReducer);
247
- return result;
248
- }
249
- // V2 UNDO: Rebuild state using garbageCollectV2 which handles consecutive NOOPs as chains
250
- // Also trigger for NOOP operations loaded from sync (they have skip > 0)
251
- const isNoopWithSkip = _action.type === "NOOP" && skipValue > 0;
252
- if ((isUndo(action) || isNoopWithSkip) && protocolVersion >= 2) {
253
- const scope = _action.scope;
254
- const scopeOperations = newDocument.operations[scope] || [];
255
- const sortedOps = sortOperations([...scopeOperations]);
256
- // Get operations that should be applied (excludes undone operations)
257
- const effectiveOps = garbageCollectV2(sortedOps);
258
- // Build operations for replay - only include non-NOOP operations
259
- const opsToReplay = effectiveOps.filter((op) => op.action.type !== "NOOP");
260
- // Create document operations with only the effective ops for this scope
261
- const replayOps = {
262
- ...newDocument.operations,
263
- [scope]: opsToReplay,
264
- };
265
- // Replay to rebuild state using replayOperations which wraps the reducer
266
- // Pass skipIndexValidation since garbageCollectV2 creates gapped indices
267
- const rebuiltDoc = replayOperations(newDocument.initialState, replayOps, customReducer, newDocument.header, dispatch, baseReducer, {}, { skipIndexValidation: true });
268
- // Return document with rebuilt state but original operations (including all NOOPs)
269
- return {
270
- ...rebuiltDoc,
271
- operations: newDocument.operations,
272
- clipboard: [],
273
- };
274
- }
275
- if (shouldProcessSkipOperation) {
276
- const processed = processSkipOperation(newDocument, _action, customReducer, skipValue, reuseOperationResultingState, operationResultingStateParser);
277
- // Preserve operations when pruneOnSkip is false
278
- if (!pruneOnSkip) {
279
- newDocument = {
280
- ...processed,
281
- operations: newDocument.operations,
282
- };
283
- }
284
- else {
285
- newDocument = processed;
286
- }
287
- }
288
- // wraps the custom reducer with Mutative to avoid
289
- // mutation bugs and allow writing reducers with
290
- // mutating code
291
- newDocument = create(newDocument, (draft) => {
292
- // the reducer runs on a immutable version of
293
- // provided state
294
- try {
295
- const newState = customReducer(draft.state, _action, dispatch);
296
- // const clipboardValue = isUndoRedo(action) ? [...clipboard] : [];
297
- // if the reducer creates a new state object instead
298
- // of mutating the draft then returns the new state
299
- if (newState) {
300
- // Object.assign(draft.state, newState);
301
- unsafe(() => {
302
- // casts new state as draft to comply with typescript
303
- draft.state = castDraft(newState);
304
- // clipboard: [...clipboardValue],
305
- });
306
- }
307
- else {
308
- // unsafe(() => {
309
- // draft.clipboard = castDraft([...clipboardValue]);
310
- // });
311
- }
312
- }
313
- catch (error) {
314
- // if the reducer throws an error then we should keep the previous state (before replayOperations)
315
- // and remove skip number from action/operation
316
- const actionScopeOps = newDocument.operations[_action.scope];
317
- if (!actionScopeOps) {
318
- throw new Error(`No operations found for scope: ${_action.scope}`);
319
- }
320
- const lastOperationIndex = actionScopeOps.length - 1;
321
- const draftScopeOps = draft.operations[_action.scope];
322
- if (!draftScopeOps) {
323
- throw new Error(`No operations found in draft for scope: ${_action.scope}`);
324
- }
325
- draftScopeOps[lastOperationIndex].error = error.message;
326
- draftScopeOps[lastOperationIndex].skip = 0;
327
- if (shouldProcessSkipOperation) {
328
- draft.state = castDraft({
329
- ...document.state,
330
- });
331
- const documentScopeOps = document.operations[_action.scope];
332
- if (!documentScopeOps) {
333
- throw new Error(`No operations found for scope: ${_action.scope}`);
334
- }
335
- draft.operations = castDraft({
336
- ...document.operations,
337
- [_action.scope]: [
338
- ...documentScopeOps,
339
- {
340
- ...draftScopeOps[lastOperationIndex],
341
- },
342
- ],
343
- });
344
- }
345
- }
346
- });
347
- // updates the document history
348
- // meta operations are not added to the operations history
349
- if (["UNDO", "REDO", "PRUNE"].includes(_action.type)) {
350
- return newDocument;
351
- }
352
- // if reuseHash is true, checks if the action has
353
- // an hash and uses it instead of generating it
354
- const scope = _action.scope || "global";
355
- let hash = hashDocumentStateForScope(newDocument, scope);
356
- if (options.replayOptions?.operation.hash &&
357
- options.replayOptions.operation.hash !== "") {
358
- hash = options.replayOptions.operation.hash;
359
- }
360
- // updates the last operation with the hash of the resulting state
361
- const scopeOperations = newDocument.operations[scope];
362
- const lastOperation = scopeOperations?.at(-1);
363
- if (lastOperation) {
364
- lastOperation.hash = hash;
365
- if (reuseOperationResultingState) {
366
- lastOperation.resultingState = JSON.stringify(newDocument.state[scope]);
367
- }
368
- }
369
- return newDocument;
370
- }
371
- /**
372
- * Helper function to create a document model reducer.
373
- *
374
- * @remarks
375
- * This function creates a new reducer that wraps the provided `reducer` with
376
- * `documentReducer`, adding support for document actions:
377
- * - `SET_NAME`
378
- * - `UNDO`
379
- * - `REDO`
380
- * - `PRUNE`
381
- *
382
- * It also updates the document-related attributes on every operation.
383
- *
384
- * @param reducer - The custom reducer to wrap.
385
- * @param documentReducer - The document reducer to use.
386
- *
387
- * @returns The new reducer.
388
- */
389
- export function createReducer(stateReducer, documentReducer = baseReducer) {
390
- const reducer = (document, action, dispatch, options) => {
391
- return documentReducer(document, action, stateReducer, dispatch, options);
392
- };
393
- return reducer;
394
- }
395
- export function pruneOperation(document, input, wrappedReducer) {
396
- const operations = document.operations.global;
397
- if (!operations) {
398
- throw new Error("No global operations found");
399
- }
400
- let { start, end } = input;
401
- start = start || 0;
402
- end = end || operations.length;
403
- const actionsToPrune = operations.slice(start, end);
404
- const actionsToKeepStart = operations.slice(0, start);
405
- const actionsToKeepEnd = operations.slice(end);
406
- // runs all operations from the initial state to
407
- // the end of prune to get name and data
408
- const newDocument = replayOperations(document.initialState, {
409
- ...document.operations,
410
- global: actionsToKeepStart.concat(actionsToPrune),
411
- }, wrappedReducer, document.header);
412
- const newState = newDocument.state;
413
- const name = newDocument.header.name;
414
- // the new operation has the index of the first pruned operation
415
- const loadStateIndex = actionsToKeepStart.length;
416
- // if and operation is pruned then reuses the timestamp of the last operation
417
- // if not then assigns the timestamp of the following unpruned operation
418
- const loadStateTimestamp = actionsToKeepStart.length
419
- ? actionsToKeepStart[actionsToKeepStart.length - 1].timestampUtcMs
420
- : actionsToKeepEnd.length
421
- ? actionsToKeepEnd[0].timestampUtcMs
422
- : new Date().toISOString();
423
- const action = loadState({ name, ...newState }, actionsToPrune.length);
424
- // replaces pruned operations with LOAD_STATE
425
- return replayOperations(document.initialState, {
426
- ...document.operations,
427
- global: [
428
- ...actionsToKeepStart,
429
- {
430
- skip: 0,
431
- ...action,
432
- action,
433
- timestampUtcMs: loadStateTimestamp,
434
- index: loadStateIndex,
435
- hash: hashDocumentStateForScope({ state: newState }, "global"),
436
- },
437
- ...actionsToKeepEnd
438
- // updates the index for all the following operations
439
- .map((action, index) => ({
440
- ...action,
441
- index: loadStateIndex + index + 1,
442
- })),
443
- ],
444
- }, wrappedReducer, document.header);
445
- }
446
- //# sourceMappingURL=reducer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reducer.js","sourceRoot":"","sources":["../../../src/core/reducer.ts"],"names":[],"mappings":"AA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,gEAAgE;IAChE,MAAM,cAAc,GAAG,kBAAkB,CAAC,MAAM,CAAC;IAEjD,6EAA6E;IAC7E,wEAAwE;IACxE,MAAM,kBAAkB,GAAG,kBAAkB,CAAC,MAAM;QAClD,CAAC,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,cAAc;QAClE,CAAC,CAAC,gBAAgB,CAAC,MAAM;YACvB,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,cAAc;YACpC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAE/B,MAAM,MAAM,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IAEvE,6CAA6C;IAC7C,OAAO,gBAAgB,CACrB,QAAQ,CAAC,YAAY,EACrB;QACE,GAAG,QAAQ,CAAC,UAAU;QACtB,MAAM,EAAE;YACN,GAAG,kBAAkB;YACrB;gBACE,IAAI,EAAE,CAAC;gBACP,GAAG,MAAM;gBACT,MAAM;gBACN,cAAc,EAAE,kBAAkB;gBAClC,KAAK,EAAE,cAAc;gBACrB,IAAI,EAAE,yBAAyB,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,QAAQ,CAAC;aAC/D;YACD,GAAG,gBAAgB;gBACjB,qDAAqD;iBACpD,GAAG,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBACvB,GAAG,MAAM;gBACT,KAAK,EAAE,cAAc,GAAG,KAAK,GAAG,CAAC;aAClC,CAAC,CAAC;SACN;KACF,EACD,cAAc,EACd,QAAQ,CAAC,MAAM,CAChB,CAAC;AACJ,CAAC"}
@@ -1,75 +0,0 @@
1
- import { z } from "zod";
2
- import type { DocumentFile, LoadStateActionInput, LoadStateActionStateInput, PruneActionInput, SchemaLoadStateAction, SchemaPruneAction, SchemaRedoAction, SchemaSetNameAction, SchemaUndoAction } from "./types.js";
3
- type Properties<T> = Required<{
4
- [K in keyof T]: z.ZodType<T[K], T[K]>;
5
- }>;
6
- type definedNonNullAny = {};
7
- export declare const isDefinedNonNullAny: (v: any) => v is definedNonNullAny;
8
- export declare const definedNonNullAnySchema: z.ZodAny & z.ZodType<definedNonNullAny, any, z.core.$ZodTypeInternals<definedNonNullAny, any>>;
9
- export declare const Load_StateSchema: z.ZodEnum<{
10
- LOAD_STATE: "LOAD_STATE";
11
- }>;
12
- export declare const PruneSchema: z.ZodEnum<{
13
- PRUNE: "PRUNE";
14
- }>;
15
- export declare const RedoSchema: z.ZodEnum<{
16
- REDO: "REDO";
17
- }>;
18
- export declare const Set_NameSchema: z.ZodEnum<{
19
- SET_NAME: "SET_NAME";
20
- }>;
21
- export declare const UndoSchema: z.ZodEnum<{
22
- UNDO: "UNDO";
23
- }>;
24
- export declare function OperationScopeSchema(): z.ZodString;
25
- export declare function DocumentActionSchema(): z.ZodUnion<readonly [z.ZodObject<Required<{
26
- id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
27
- timestampUtcMs: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
28
- input: z.ZodType<LoadStateActionInput, LoadStateActionInput, z.core.$ZodTypeInternals<LoadStateActionInput, LoadStateActionInput>>;
29
- type: z.ZodType<"LOAD_STATE", "LOAD_STATE", z.core.$ZodTypeInternals<"LOAD_STATE", "LOAD_STATE">>;
30
- scope: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
31
- }>, z.core.$strip>, z.ZodObject<Required<{
32
- id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
33
- timestampUtcMs: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
34
- input: z.ZodType<PruneActionInput, PruneActionInput, z.core.$ZodTypeInternals<PruneActionInput, PruneActionInput>>;
35
- type: z.ZodType<"PRUNE", "PRUNE", z.core.$ZodTypeInternals<"PRUNE", "PRUNE">>;
36
- scope: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
37
- }>, z.core.$strip>, z.ZodObject<Required<{
38
- id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
39
- timestampUtcMs: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
40
- input: z.ZodType<import("./types.js").RedoActionInput, import("./types.js").RedoActionInput, z.core.$ZodTypeInternals<import("./types.js").RedoActionInput, import("./types.js").RedoActionInput>>;
41
- type: z.ZodType<"REDO", "REDO", z.core.$ZodTypeInternals<"REDO", "REDO">>;
42
- scope: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
43
- }>, z.core.$strip>, z.ZodObject<Required<{
44
- id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
45
- timestampUtcMs: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
46
- input: z.ZodType<import("./types.js").SetNameActionInput, import("./types.js").SetNameActionInput, z.core.$ZodTypeInternals<import("./types.js").SetNameActionInput, import("./types.js").SetNameActionInput>>;
47
- type: z.ZodType<"SET_NAME", "SET_NAME", z.core.$ZodTypeInternals<"SET_NAME", "SET_NAME">>;
48
- scope: z.ZodType<"global", "global", z.core.$ZodTypeInternals<"global", "global">>;
49
- }>, z.core.$strip>, z.ZodObject<Required<{
50
- id: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
51
- timestampUtcMs: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
52
- input: z.ZodType<import("./types.js").UndoActionInput, import("./types.js").UndoActionInput, z.core.$ZodTypeInternals<import("./types.js").UndoActionInput, import("./types.js").UndoActionInput>>;
53
- type: z.ZodType<"UNDO", "UNDO", z.core.$ZodTypeInternals<"UNDO", "UNDO">>;
54
- scope: z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>;
55
- }>, z.core.$strip>]>;
56
- export declare function DocumentFileSchema(): z.ZodObject<Properties<DocumentFile>>;
57
- export declare function LoadStateActionSchema(): z.ZodObject<Properties<SchemaLoadStateAction>>;
58
- export declare function LoadStateActionInputSchema(): z.ZodObject<Properties<LoadStateActionInput>>;
59
- export declare function LoadStateActionStateInputSchema(): z.ZodObject<Properties<LoadStateActionStateInput>>;
60
- export declare function PruneActionSchema(): z.ZodObject<Properties<SchemaPruneAction>>;
61
- export declare function PruneActionInputSchema(): z.ZodObject<Properties<PruneActionInput>>;
62
- export declare function RedoActionInputSchema(): z.ZodObject<{
63
- count: z.ZodNumber;
64
- }, z.core.$strip>;
65
- export declare function RedoActionSchema(): z.ZodObject<Properties<SchemaRedoAction>>;
66
- export declare function SetNameActionInputSchema(): z.ZodObject<{
67
- name: z.ZodString;
68
- }, z.core.$strip>;
69
- export declare function SetNameActionSchema(): z.ZodObject<Properties<SchemaSetNameAction>>;
70
- export declare function UndoActionInputSchema(): z.ZodObject<{
71
- count: z.ZodNumber;
72
- }, z.core.$strip>;
73
- export declare function UndoActionSchema(): z.ZodObject<Properties<SchemaUndoAction>>;
74
- export {};
75
- //# sourceMappingURL=schemas.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/core/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,KAAK,UAAU,CAAC,CAAC,IAAI,QAAQ,CAAC;KAC3B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH,KAAK,iBAAiB,GAAG,EAAE,CAAC;AAE5B,eAAO,MAAM,mBAAmB,GAAI,GAAG,GAAG,KAAG,CAAC,IAAI,iBACnB,CAAC;AAEhC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AAU,CAAC,gBAAgB,CAAC,CAAC,CAQ5E"}
@@ -1,116 +0,0 @@
1
- import { z } from "zod";
2
- export const isDefinedNonNullAny = (v) => v !== undefined && v !== null;
3
- export const definedNonNullAnySchema = z
4
- .any()
5
- .refine((v) => isDefinedNonNullAny(v));
6
- export const Load_StateSchema = z.enum(["LOAD_STATE"]);
7
- export const PruneSchema = z.enum(["PRUNE"]);
8
- export const RedoSchema = z.enum(["REDO"]);
9
- export const Set_NameSchema = z.enum(["SET_NAME"]);
10
- export const UndoSchema = z.enum(["UNDO"]);
11
- export function OperationScopeSchema() {
12
- return z.string();
13
- }
14
- export function DocumentActionSchema() {
15
- return z.union([
16
- LoadStateActionSchema(),
17
- PruneActionSchema(),
18
- RedoActionSchema(),
19
- SetNameActionSchema(),
20
- UndoActionSchema(),
21
- ]);
22
- }
23
- export function DocumentFileSchema() {
24
- return z.object({
25
- __typename: z.literal("DocumentFile").optional(),
26
- data: z.string(),
27
- extension: z.string().nullable(),
28
- fileName: z.string().nullable(),
29
- mimeType: z.string(),
30
- });
31
- }
32
- export function LoadStateActionSchema() {
33
- return z.object({
34
- id: z.string(),
35
- timestampUtcMs: z.string(),
36
- input: z.lazy(() => LoadStateActionInputSchema()),
37
- type: Load_StateSchema,
38
- scope: OperationScopeSchema(),
39
- });
40
- }
41
- export function LoadStateActionInputSchema() {
42
- return z.object({
43
- operations: z.number(),
44
- state: z.lazy(() => LoadStateActionStateInputSchema()),
45
- });
46
- }
47
- export function LoadStateActionStateInputSchema() {
48
- return z.object({
49
- data: z.unknown().nullish(),
50
- name: z.string(),
51
- });
52
- }
53
- export function PruneActionSchema() {
54
- return z.object({
55
- id: z.string(),
56
- timestampUtcMs: z.string(),
57
- input: z.lazy(() => PruneActionInputSchema()),
58
- type: PruneSchema,
59
- scope: OperationScopeSchema(),
60
- });
61
- }
62
- export function PruneActionInputSchema() {
63
- return z.object({
64
- end: z.number().nullish(),
65
- start: z.number().nullish(),
66
- });
67
- }
68
- export function RedoActionInputSchema() {
69
- return z.object({ count: z.number() });
70
- }
71
- export function RedoActionSchema() {
72
- return z.object({
73
- id: z.string(),
74
- timestampUtcMs: z.string().datetime(),
75
- input: RedoActionInputSchema(),
76
- type: RedoSchema,
77
- scope: OperationScopeSchema(),
78
- });
79
- }
80
- export function SetNameActionInputSchema() {
81
- return z.object({ name: z.string() });
82
- }
83
- export function SetNameActionSchema() {
84
- return z.object({
85
- id: z.string(),
86
- timestampUtcMs: z.string().datetime(),
87
- input: SetNameActionInputSchema(),
88
- type: Set_NameSchema,
89
- scope: z.literal("global"),
90
- });
91
- }
92
- // export function SetNameOperationSchema(): z.ZodObject<
93
- // Properties<SetNameOperation>
94
- // > {
95
- // return z.object({
96
- // __typename: z.literal("SetNameOperation").optional(),
97
- // hash: z.string(),
98
- // index: z.number(),
99
- // input: z.string(),
100
- // timestampUtcMs: z.string().datetime(),
101
- // type: z.string(),
102
- // });
103
- // }
104
- export function UndoActionInputSchema() {
105
- return z.object({ count: z.number() });
106
- }
107
- export function UndoActionSchema() {
108
- return z.object({
109
- id: z.string(),
110
- timestampUtcMs: z.string().datetime(),
111
- input: UndoActionInputSchema(),
112
- type: UndoSchema,
113
- scope: OperationScopeSchema(),
114
- });
115
- }
116
- //# sourceMappingURL=schemas.js.map