document-model 6.0.0-dev.11 → 6.0.0-dev.110

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 (270) 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/node.d.mts +62 -0
  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 +15 -24
  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/crypto.d.ts +0 -8
  15. package/dist/src/core/crypto.d.ts.map +0 -1
  16. package/dist/src/core/crypto.js +0 -68
  17. package/dist/src/core/crypto.js.map +0 -1
  18. package/dist/src/core/documents.d.ts +0 -146
  19. package/dist/src/core/documents.d.ts.map +0 -1
  20. package/dist/src/core/documents.js +0 -814
  21. package/dist/src/core/documents.js.map +0 -1
  22. package/dist/src/core/errors.d.ts +0 -21
  23. package/dist/src/core/errors.d.ts.map +0 -1
  24. package/dist/src/core/errors.js +0 -46
  25. package/dist/src/core/errors.js.map +0 -1
  26. package/dist/src/core/files.d.ts +0 -14
  27. package/dist/src/core/files.d.ts.map +0 -1
  28. package/dist/src/core/files.js +0 -65
  29. package/dist/src/core/files.js.map +0 -1
  30. package/dist/src/core/header.d.ts +0 -63
  31. package/dist/src/core/header.d.ts.map +0 -1
  32. package/dist/src/core/header.js +0 -178
  33. package/dist/src/core/header.js.map +0 -1
  34. package/dist/src/core/index.d.ts +0 -13
  35. package/dist/src/core/index.d.ts.map +0 -1
  36. package/dist/src/core/index.js +0 -13
  37. package/dist/src/core/index.js.map +0 -1
  38. package/dist/src/core/node.d.ts +0 -53
  39. package/dist/src/core/node.d.ts.map +0 -1
  40. package/dist/src/core/node.js +0 -139
  41. package/dist/src/core/node.js.map +0 -1
  42. package/dist/src/core/operations.d.ts +0 -48
  43. package/dist/src/core/operations.d.ts.map +0 -1
  44. package/dist/src/core/operations.js +0 -122
  45. package/dist/src/core/operations.js.map +0 -1
  46. package/dist/src/core/ph-types.d.ts +0 -315
  47. package/dist/src/core/ph-types.d.ts.map +0 -1
  48. package/dist/src/core/ph-types.js +0 -15
  49. package/dist/src/core/ph-types.js.map +0 -1
  50. package/dist/src/core/reducer.d.ts +0 -63
  51. package/dist/src/core/reducer.d.ts.map +0 -1
  52. package/dist/src/core/reducer.js +0 -455
  53. package/dist/src/core/reducer.js.map +0 -1
  54. package/dist/src/core/schemas.d.ts +0 -69
  55. package/dist/src/core/schemas.d.ts.map +0 -1
  56. package/dist/src/core/schemas.js +0 -110
  57. package/dist/src/core/schemas.js.map +0 -1
  58. package/dist/src/core/state.d.ts +0 -26
  59. package/dist/src/core/state.d.ts.map +0 -1
  60. package/dist/src/core/state.js +0 -56
  61. package/dist/src/core/state.js.map +0 -1
  62. package/dist/src/core/types.d.ts +0 -536
  63. package/dist/src/core/types.d.ts.map +0 -1
  64. package/dist/src/core/types.js +0 -2
  65. package/dist/src/core/types.js.map +0 -1
  66. package/dist/src/core/utils.d.ts +0 -6
  67. package/dist/src/core/utils.d.ts.map +0 -1
  68. package/dist/src/core/utils.js +0 -15
  69. package/dist/src/core/utils.js.map +0 -1
  70. package/dist/src/core/validation.d.ts +0 -4
  71. package/dist/src/core/validation.d.ts.map +0 -1
  72. package/dist/src/core/validation.js +0 -27
  73. package/dist/src/core/validation.js.map +0 -1
  74. package/dist/src/document-model/actions.d.ts +0 -158
  75. package/dist/src/document-model/actions.d.ts.map +0 -1
  76. package/dist/src/document-model/actions.js +0 -111
  77. package/dist/src/document-model/actions.js.map +0 -1
  78. package/dist/src/document-model/constants.d.ts +0 -6
  79. package/dist/src/document-model/constants.d.ts.map +0 -1
  80. package/dist/src/document-model/constants.js +0 -573
  81. package/dist/src/document-model/constants.js.map +0 -1
  82. package/dist/src/document-model/document-schema.d.ts +0 -69
  83. package/dist/src/document-model/document-schema.d.ts.map +0 -1
  84. package/dist/src/document-model/document-schema.js +0 -43
  85. package/dist/src/document-model/document-schema.js.map +0 -1
  86. package/dist/src/document-model/document-type.d.ts +0 -2
  87. package/dist/src/document-model/document-type.d.ts.map +0 -1
  88. package/dist/src/document-model/document-type.js +0 -2
  89. package/dist/src/document-model/document-type.js.map +0 -1
  90. package/dist/src/document-model/files.d.ts +0 -5
  91. package/dist/src/document-model/files.d.ts.map +0 -1
  92. package/dist/src/document-model/files.js +0 -9
  93. package/dist/src/document-model/files.js.map +0 -1
  94. package/dist/src/document-model/index.d.ts +0 -11
  95. package/dist/src/document-model/index.d.ts.map +0 -1
  96. package/dist/src/document-model/index.js +0 -11
  97. package/dist/src/document-model/index.js.map +0 -1
  98. package/dist/src/document-model/module.d.ts +0 -3
  99. package/dist/src/document-model/module.d.ts.map +0 -1
  100. package/dist/src/document-model/module.js +0 -24
  101. package/dist/src/document-model/module.js.map +0 -1
  102. package/dist/src/document-model/reducers.d.ts +0 -11
  103. package/dist/src/document-model/reducers.d.ts.map +0 -1
  104. package/dist/src/document-model/reducers.js +0 -618
  105. package/dist/src/document-model/reducers.js.map +0 -1
  106. package/dist/src/document-model/schemas.d.ts +0 -189
  107. package/dist/src/document-model/schemas.d.ts.map +0 -1
  108. package/dist/src/document-model/schemas.js +0 -388
  109. package/dist/src/document-model/schemas.js.map +0 -1
  110. package/dist/src/document-model/state.d.ts +0 -15
  111. package/dist/src/document-model/state.d.ts.map +0 -1
  112. package/dist/src/document-model/state.js +0 -75
  113. package/dist/src/document-model/state.js.map +0 -1
  114. package/dist/src/document-model/types.d.ts +0 -679
  115. package/dist/src/document-model/types.d.ts.map +0 -1
  116. package/dist/src/document-model/types.js +0 -2
  117. package/dist/src/document-model/types.js.map +0 -1
  118. package/dist/src/document-model/validation.d.ts +0 -32
  119. package/dist/src/document-model/validation.d.ts.map +0 -1
  120. package/dist/src/document-model/validation.js +0 -166
  121. package/dist/src/document-model/validation.js.map +0 -1
  122. package/dist/src/index.d.ts +0 -6
  123. package/dist/src/index.d.ts.map +0 -1
  124. package/dist/src/index.js +0 -3
  125. package/dist/src/index.js.map +0 -1
  126. package/dist/test/document/crypto.test.d.ts +0 -2
  127. package/dist/test/document/crypto.test.d.ts.map +0 -1
  128. package/dist/test/document/crypto.test.js +0 -195
  129. package/dist/test/document/crypto.test.js.map +0 -1
  130. package/dist/test/document/event-vs-command.test.d.ts +0 -2
  131. package/dist/test/document/event-vs-command.test.d.ts.map +0 -1
  132. package/dist/test/document/event-vs-command.test.js +0 -202
  133. package/dist/test/document/event-vs-command.test.js.map +0 -1
  134. package/dist/test/document/local.test.d.ts +0 -2
  135. package/dist/test/document/local.test.d.ts.map +0 -1
  136. package/dist/test/document/local.test.js +0 -229
  137. package/dist/test/document/local.test.js.map +0 -1
  138. package/dist/test/document/operation-id.test.d.ts +0 -2
  139. package/dist/test/document/operation-id.test.d.ts.map +0 -1
  140. package/dist/test/document/operation-id.test.js +0 -118
  141. package/dist/test/document/operation-id.test.js.map +0 -1
  142. package/dist/test/document/prune.test.d.ts +0 -2
  143. package/dist/test/document/prune.test.d.ts.map +0 -1
  144. package/dist/test/document/prune.test.js +0 -159
  145. package/dist/test/document/prune.test.js.map +0 -1
  146. package/dist/test/document/reducer.test.d.ts +0 -2
  147. package/dist/test/document/reducer.test.d.ts.map +0 -1
  148. package/dist/test/document/reducer.test.js +0 -284
  149. package/dist/test/document/reducer.test.js.map +0 -1
  150. package/dist/test/document/skip-operations.test.d.ts +0 -2
  151. package/dist/test/document/skip-operations.test.d.ts.map +0 -1
  152. package/dist/test/document/skip-operations.test.js +0 -412
  153. package/dist/test/document/skip-operations.test.js.map +0 -1
  154. package/dist/test/document/undo-redo-v2.test.d.ts +0 -2
  155. package/dist/test/document/undo-redo-v2.test.d.ts.map +0 -1
  156. package/dist/test/document/undo-redo-v2.test.js +0 -207
  157. package/dist/test/document/undo-redo-v2.test.js.map +0 -1
  158. package/dist/test/document/undo-redo.test.d.ts +0 -2
  159. package/dist/test/document/undo-redo.test.d.ts.map +0 -1
  160. package/dist/test/document/undo-redo.test.js +0 -413
  161. package/dist/test/document/undo-redo.test.js.map +0 -1
  162. package/dist/test/document/utils.test.d.ts +0 -2
  163. package/dist/test/document/utils.test.d.ts.map +0 -1
  164. package/dist/test/document/utils.test.js +0 -172
  165. package/dist/test/document/utils.test.js.map +0 -1
  166. package/dist/test/document-helpers/addUndo.test.d.ts +0 -2
  167. package/dist/test/document-helpers/addUndo.test.d.ts.map +0 -1
  168. package/dist/test/document-helpers/addUndo.test.js +0 -120
  169. package/dist/test/document-helpers/addUndo.test.js.map +0 -1
  170. package/dist/test/document-helpers/attachBranch.test.d.ts +0 -2
  171. package/dist/test/document-helpers/attachBranch.test.d.ts.map +0 -1
  172. package/dist/test/document-helpers/attachBranch.test.js +0 -364
  173. package/dist/test/document-helpers/attachBranch.test.js.map +0 -1
  174. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts +0 -2
  175. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.d.ts.map +0 -1
  176. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js +0 -252
  177. package/dist/test/document-helpers/checkCleanedOperationsIntegrity.test.js.map +0 -1
  178. package/dist/test/document-helpers/conflictResolution.test.d.ts +0 -2
  179. package/dist/test/document-helpers/conflictResolution.test.d.ts.map +0 -1
  180. package/dist/test/document-helpers/conflictResolution.test.js +0 -109
  181. package/dist/test/document-helpers/conflictResolution.test.js.map +0 -1
  182. package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts +0 -2
  183. package/dist/test/document-helpers/filterDuplicatedOperations.test.d.ts.map +0 -1
  184. package/dist/test/document-helpers/filterDuplicatedOperations.test.js +0 -126
  185. package/dist/test/document-helpers/filterDuplicatedOperations.test.js.map +0 -1
  186. package/dist/test/document-helpers/garbageCollect.test.d.ts +0 -2
  187. package/dist/test/document-helpers/garbageCollect.test.d.ts.map +0 -1
  188. package/dist/test/document-helpers/garbageCollect.test.js +0 -136
  189. package/dist/test/document-helpers/garbageCollect.test.js.map +0 -1
  190. package/dist/test/document-helpers/groupOperationsByScope.test.d.ts +0 -2
  191. package/dist/test/document-helpers/groupOperationsByScope.test.d.ts.map +0 -1
  192. package/dist/test/document-helpers/groupOperationsByScope.test.js +0 -102
  193. package/dist/test/document-helpers/groupOperationsByScope.test.js.map +0 -1
  194. package/dist/test/document-helpers/merge.test.d.ts +0 -2
  195. package/dist/test/document-helpers/merge.test.d.ts.map +0 -1
  196. package/dist/test/document-helpers/merge.test.js +0 -906
  197. package/dist/test/document-helpers/merge.test.js.map +0 -1
  198. package/dist/test/document-helpers/nextSkipNumber.test.d.ts +0 -2
  199. package/dist/test/document-helpers/nextSkipNumber.test.d.ts.map +0 -1
  200. package/dist/test/document-helpers/nextSkipNumber.test.js +0 -135
  201. package/dist/test/document-helpers/nextSkipNumber.test.js.map +0 -1
  202. package/dist/test/document-helpers/prepareOperations.test.d.ts +0 -2
  203. package/dist/test/document-helpers/prepareOperations.test.d.ts.map +0 -1
  204. package/dist/test/document-helpers/prepareOperations.test.js +0 -304
  205. package/dist/test/document-helpers/prepareOperations.test.js.map +0 -1
  206. package/dist/test/document-helpers/removeExistingOperations.test.d.ts +0 -2
  207. package/dist/test/document-helpers/removeExistingOperations.test.d.ts.map +0 -1
  208. package/dist/test/document-helpers/removeExistingOperations.test.js +0 -177
  209. package/dist/test/document-helpers/removeExistingOperations.test.js.map +0 -1
  210. package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts +0 -2
  211. package/dist/test/document-helpers/reshuffleByTimestamp.test.d.ts.map +0 -1
  212. package/dist/test/document-helpers/reshuffleByTimestamp.test.js +0 -148
  213. package/dist/test/document-helpers/reshuffleByTimestamp.test.js.map +0 -1
  214. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts +0 -2
  215. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.d.ts.map +0 -1
  216. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js +0 -200
  217. package/dist/test/document-helpers/reshuffleByTimestampAndIndex.test.js.map +0 -1
  218. package/dist/test/document-helpers/skipHeaderOperations.test.d.ts +0 -2
  219. package/dist/test/document-helpers/skipHeaderOperations.test.d.ts.map +0 -1
  220. package/dist/test/document-helpers/skipHeaderOperations.test.js +0 -72
  221. package/dist/test/document-helpers/skipHeaderOperations.test.js.map +0 -1
  222. package/dist/test/document-helpers/sortOperations.test.d.ts +0 -2
  223. package/dist/test/document-helpers/sortOperations.test.d.ts.map +0 -1
  224. package/dist/test/document-helpers/sortOperations.test.js +0 -101
  225. package/dist/test/document-helpers/sortOperations.test.js.map +0 -1
  226. package/dist/test/document-helpers/split.test.d.ts +0 -2
  227. package/dist/test/document-helpers/split.test.d.ts.map +0 -1
  228. package/dist/test/document-helpers/split.test.js +0 -121
  229. package/dist/test/document-helpers/split.test.js.map +0 -1
  230. package/dist/test/document-helpers/utils.d.ts +0 -15
  231. package/dist/test/document-helpers/utils.d.ts.map +0 -1
  232. package/dist/test/document-helpers/utils.js +0 -61
  233. package/dist/test/document-helpers/utils.js.map +0 -1
  234. package/dist/test/document-model/replay.test.d.ts +0 -2
  235. package/dist/test/document-model/replay.test.d.ts.map +0 -1
  236. package/dist/test/document-model/replay.test.js +0 -139
  237. package/dist/test/document-model/replay.test.js.map +0 -1
  238. package/dist/test/document-model/skip-operations.test.d.ts +0 -2
  239. package/dist/test/document-model/skip-operations.test.d.ts.map +0 -1
  240. package/dist/test/document-model/skip-operations.test.js +0 -214
  241. package/dist/test/document-model/skip-operations.test.js.map +0 -1
  242. package/dist/test/document-model/validation.test.d.ts +0 -2
  243. package/dist/test/document-model/validation.test.d.ts.map +0 -1
  244. package/dist/test/document-model/validation.test.js +0 -451
  245. package/dist/test/document-model/validation.test.js.map +0 -1
  246. package/dist/test/document-model/versioning.test.d.ts +0 -2
  247. package/dist/test/document-model/versioning.test.d.ts.map +0 -1
  248. package/dist/test/document-model/versioning.test.js +0 -93
  249. package/dist/test/document-model/versioning.test.js.map +0 -1
  250. package/dist/test/document-model/zip.test.d.ts +0 -2
  251. package/dist/test/document-model/zip.test.d.ts.map +0 -1
  252. package/dist/test/document-model/zip.test.js +0 -79
  253. package/dist/test/document-model/zip.test.js.map +0 -1
  254. package/dist/test/helpers.d.ts +0 -77
  255. package/dist/test/helpers.d.ts.map +0 -1
  256. package/dist/test/helpers.js +0 -118
  257. package/dist/test/helpers.js.map +0 -1
  258. package/dist/test/index.d.ts +0 -4
  259. package/dist/test/index.d.ts.map +0 -1
  260. package/dist/test/index.js +0 -3
  261. package/dist/test/index.js.map +0 -1
  262. package/dist/test/types.d.ts +0 -6
  263. package/dist/test/types.d.ts.map +0 -1
  264. package/dist/test/types.js +0 -2
  265. package/dist/test/types.js.map +0 -1
  266. package/dist/tsconfig.tsbuildinfo +0 -1
  267. package/dist/vitest.config.d.ts +0 -3
  268. package/dist/vitest.config.d.ts.map +0 -1
  269. package/dist/vitest.config.js +0 -7
  270. package/dist/vitest.config.js.map +0 -1
@@ -1,87 +0,0 @@
1
- import type { Action, ActionContext, ActionSigner, AppActionSigner, Operation, PHBaseState, PHDocument, Signature, UserActionSigner } from "./ph-types.js";
2
- import type { ActionSignatureContext, ActionSigningHandler, ActionVerificationHandler, LoadStateAction, NOOPAction, RedoAction, Reducer, SchemaPruneAction, UndoAction } from "./types.js";
3
- /**
4
- * Context required to derive a deterministic operation ID.
5
- */
6
- export type OperationContext = {
7
- documentId: string;
8
- scope: string;
9
- branch: string;
10
- };
11
- /**
12
- * Cancels the last `count` operations.
13
- *
14
- * @param count - Number of operations to cancel
15
- * @category Actions
16
- */
17
- export declare const undo: (skip?: number, scope?: string) => UndoAction;
18
- /**
19
- * Cancels the last `count` {@link undo | UNDO} operations.
20
- *
21
- * @param count - Number of UNDO operations to cancel
22
- * @category Actions
23
- */
24
- export declare const redo: (count?: number, scope?: string) => RedoAction;
25
- /**
26
- * Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
27
- *
28
- * @remarks
29
- * Useful to keep operations history smaller. Operations to prune are selected by index,
30
- * similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
31
- *
32
- * @param start - Index of the first operation to prune
33
- * @param end - Index of the last operation to prune
34
- * @category Actions
35
- */
36
- export declare const prune: (start?: number, end?: number, scope?: string) => SchemaPruneAction;
37
- /**
38
- * Replaces the state of the document.
39
- *
40
- * @remarks
41
- * This action shouldn't be used directly. It is dispatched by the {@link prune} action.
42
- *
43
- * @param state - State to be set in the document.
44
- * @param operations - Number of operations that were removed from the previous state.
45
- * @category Actions
46
- */
47
- export declare const loadState: <TState extends PHBaseState = PHBaseState>(state: TState & {
48
- name: string;
49
- }, operations: number) => LoadStateAction;
50
- export declare const noop: (scope?: string) => NOOPAction;
51
- /**
52
- * Helper function to be used by action creators.
53
- *
54
- * @remarks
55
- * Creates an action with the given type and input properties. The input
56
- * properties default to an empty object.
57
- *
58
- * @typeParam A - Type of the action to be returned.
59
- *
60
- * @param type - The type of the action.
61
- * @param input - The input properties of the action.
62
- * @param attachments - The attachments included in the action.
63
- * @param validator - The validator to use for the input properties.
64
- * @param scope - The scope of the action, can either be 'global' or 'local'.
65
- * @param skip - The number of operations to skip before this new action is applied.
66
- *
67
- * @throws Error if the type is empty or not a string.
68
- *
69
- * @returns The new action.
70
- */
71
- export declare function createAction<TAction extends Action>(type: TAction["type"], input?: TAction["input"], attachments?: TAction["attachments"], validator?: () => {
72
- parse(v: unknown): TAction["input"];
73
- }, scope?: Action["scope"]): TAction;
74
- /**
75
- * This function should be used instead of { ...action } to ensure
76
- * that extra properties are not included in the action.
77
- */
78
- export declare const actionFromAction: (action: Action) => Action;
79
- export declare const operationFromAction: (action: Action, index: number, skip: number, context: OperationContext) => Operation;
80
- export declare const operationFromOperation: (operation: Operation, index: number, skip: number, context: OperationContext) => Operation;
81
- export declare const operationWithContext: (operation: Operation, context: ActionContext) => Operation;
82
- export declare const actionContext: () => ActionContext;
83
- export declare const actionSigner: (user: UserActionSigner, app: AppActionSigner, signatures?: Signature[]) => ActionSigner;
84
- export declare function buildOperationSignature(context: ActionSignatureContext, signMethod: ActionSigningHandler): Promise<Signature>;
85
- export declare function buildSignedAction<TState extends PHBaseState = PHBaseState>(action: Action, reducer: Reducer<TState>, document: PHDocument<TState>, signer: ActionSigner, signHandler: ActionSigningHandler): Promise<Operation>;
86
- export declare function verifyOperationSignature(signature: Signature, signer: Omit<ActionSigner, "signatures">, verifyHandler: ActionVerificationHandler): Promise<boolean>;
87
- //# sourceMappingURL=actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../src/core/actions.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,MAAM,EACN,aAAa,EACb,YAAY,EACZ,eAAe,EACf,SAAS,EACT,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EACjB,MAAM,eAAe,CAAC;AAOvB,OAAO,KAAK,EACV,sBAAsB,EACtB,oBAAoB,EACpB,yBAAyB,EACzB,eAAe,EACf,UAAU,EACV,UAAU,EACV,OAAO,EACP,iBAAiB,EACjB,UAAU,EACX,MAAM,YAAY,CAAC;AAGpB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,aAAQ,EAAE,cAAgB,eAO5C,CAAC;AAEJ;;;;;GAKG;AACH,eAAO,MAAM,IAAI,GAAI,cAAS,EAAE,cAAgB,eAO7C,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,eAAO,MAAM,KAAK,GAAI,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE,cAAgB,sBAOjE,CAAC;AAEJ;;;;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B,OAAO,CAAC,SAAS,CAAC,CAKpB;AAED,wBAAsB,iBAAiB,CACrC,MAAM,SAAS,WAAW,GAAG,WAAW,EAExC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,EACxB,QAAQ,EAAE,UAAU,CAAC,MAAM,CAAC,EAC5B,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,oBAAoB,sBAkClC;AAED,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,EACxC,aAAa,EAAE,yBAAyB,oBAOzC"}
@@ -1,187 +0,0 @@
1
- import { ZodError } from "zod";
2
- import { ab2hex, buildOperationSignatureMessage, buildOperationSignatureParams, hex2ab, } from "./crypto.js";
3
- import { InvalidActionInputError, InvalidActionInputZodError, } from "./errors.js";
4
- import { LoadStateActionInputSchema, PruneActionInputSchema, RedoActionInputSchema, UndoActionInputSchema, } from "./schemas.js";
5
- import { deriveOperationId, generateId } from "./utils.js";
6
- /**
7
- * Cancels the last `count` operations.
8
- *
9
- * @param count - Number of operations to cancel
10
- * @category Actions
11
- */
12
- export const undo = (skip = 1, scope = "global") => createAction("UNDO", skip, undefined, UndoActionInputSchema, scope);
13
- /**
14
- * Cancels the last `count` {@link undo | UNDO} operations.
15
- *
16
- * @param count - Number of UNDO operations to cancel
17
- * @category Actions
18
- */
19
- export const redo = (count = 1, scope = "global") => createAction("REDO", count, undefined, RedoActionInputSchema, scope);
20
- /**
21
- * Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
22
- *
23
- * @remarks
24
- * Useful to keep operations history smaller. Operations to prune are selected by index,
25
- * similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
26
- *
27
- * @param start - Index of the first operation to prune
28
- * @param end - Index of the last operation to prune
29
- * @category Actions
30
- */
31
- export const prune = (start, end, scope = "global") => createAction("PRUNE", { start, end }, undefined, PruneActionInputSchema, scope);
32
- /**
33
- * Replaces the state of the document.
34
- *
35
- * @remarks
36
- * This action shouldn't be used directly. It is dispatched by the {@link prune} action.
37
- *
38
- * @param state - State to be set in the document.
39
- * @param operations - Number of operations that were removed from the previous state.
40
- * @category Actions
41
- */
42
- export const loadState = (state, operations) => createAction("LOAD_STATE", { state, operations }, undefined, LoadStateActionInputSchema);
43
- export const noop = (scope = "global") => createAction("NOOP", {}, undefined, undefined, scope);
44
- // TODO improve base actions type
45
- /**
46
- * Helper function to be used by action creators.
47
- *
48
- * @remarks
49
- * Creates an action with the given type and input properties. The input
50
- * properties default to an empty object.
51
- *
52
- * @typeParam A - Type of the action to be returned.
53
- *
54
- * @param type - The type of the action.
55
- * @param input - The input properties of the action.
56
- * @param attachments - The attachments included in the action.
57
- * @param validator - The validator to use for the input properties.
58
- * @param scope - The scope of the action, can either be 'global' or 'local'.
59
- * @param skip - The number of operations to skip before this new action is applied.
60
- *
61
- * @throws Error if the type is empty or not a string.
62
- *
63
- * @returns The new action.
64
- */
65
- export function createAction(type, input, attachments, validator, scope = "global") {
66
- if (!type)
67
- throw new Error("Empty action type");
68
- if (typeof type !== "string")
69
- throw new Error(`Invalid action type: ${JSON.stringify(type)}`);
70
- const action = {
71
- id: generateId(),
72
- timestampUtcMs: new Date().toISOString(),
73
- type,
74
- input,
75
- scope,
76
- };
77
- if (attachments)
78
- action.attachments = attachments;
79
- try {
80
- validator?.().parse(action.input);
81
- }
82
- catch (error) {
83
- if (error instanceof ZodError) {
84
- throw new InvalidActionInputZodError(error.issues);
85
- }
86
- throw new InvalidActionInputError(error);
87
- }
88
- return action;
89
- }
90
- /**
91
- * This function should be used instead of { ...action } to ensure
92
- * that extra properties are not included in the action.
93
- */
94
- export const actionFromAction = (action) => {
95
- return {
96
- id: action.id,
97
- timestampUtcMs: action.timestampUtcMs,
98
- type: action.type,
99
- input: action.input,
100
- scope: action.scope,
101
- context: action.context,
102
- attachments: action.attachments,
103
- };
104
- };
105
- export const operationFromAction = (action, index, skip, context) => {
106
- return {
107
- ...action,
108
- action,
109
- id: deriveOperationId(context.documentId, context.scope, context.branch, action.id),
110
- timestampUtcMs: new Date().toISOString(),
111
- hash: "",
112
- error: undefined,
113
- index,
114
- skip,
115
- };
116
- };
117
- export const operationFromOperation = (operation, index, skip, context) => {
118
- const id = deriveOperationId(context.documentId, context.scope, context.branch, operation.action.id);
119
- return {
120
- ...operation,
121
- hash: "",
122
- error: undefined,
123
- index,
124
- skip,
125
- id,
126
- };
127
- };
128
- export const operationWithContext = (operation, context) => {
129
- if (!operation.action) {
130
- throw new Error("Operation has no action");
131
- }
132
- return {
133
- ...operation,
134
- action: {
135
- ...operation.action,
136
- context,
137
- },
138
- };
139
- };
140
- export const actionContext = () => ({});
141
- export const actionSigner = (user, app, signatures = []) => ({
142
- user,
143
- app,
144
- signatures,
145
- });
146
- export async function buildOperationSignature(context, signMethod) {
147
- const params = buildOperationSignatureParams(context);
148
- const message = buildOperationSignatureMessage(params);
149
- const signature = await signMethod(message);
150
- return [...params, `0x${ab2hex(signature)}`];
151
- }
152
- export async function buildSignedAction(action, reducer, document, signer, signHandler) {
153
- const result = reducer(document, action, undefined, {
154
- //reuseHash: true,
155
- reuseOperationResultingState: true,
156
- });
157
- const scopeOperations = result.operations[action.scope];
158
- if (!scopeOperations) {
159
- throw new Error(`No operations found for scope: ${action.scope}`);
160
- }
161
- const operation = scopeOperations.at(-1);
162
- if (!operation) {
163
- throw new Error("Action was not applied");
164
- }
165
- const previousStateHash = scopeOperations.at(-2)?.hash ?? "";
166
- const signature = await buildOperationSignature({
167
- documentId: document.header.id,
168
- signer,
169
- action,
170
- previousStateHash,
171
- }, signHandler);
172
- const actionContext = {
173
- signer: actionSigner(signer.user, signer.app, [
174
- ...signer.signatures,
175
- signature,
176
- ]),
177
- };
178
- return operationWithContext(operation, actionContext);
179
- }
180
- export async function verifyOperationSignature(signature, signer, verifyHandler) {
181
- const publicKey = signer.app.key;
182
- const params = signature.slice(0, 4);
183
- const signatureBytes = hex2ab(signature[4]);
184
- const expectedMessage = buildOperationSignatureMessage(params);
185
- return verifyHandler(publicKey, signatureBytes, expectedMessage);
186
- }
187
- //# sourceMappingURL=actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/core/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,EACL,MAAM,EACN,8BAA8B,EAC9B,6BAA6B,EAC7B,MAAM,GACP,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,uBAAuB,EACvB,0BAA0B,GAC3B,MAAM,aAAa,CAAC;AAYrB,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,cAAc,CAAC;AAYtB,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAW3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,EAAE,CACjD,YAAY,CACV,MAAM,EACN,IAAI,EACJ,SAAS,EACT,qBAAqB,EACrB,KAAK,CACN,CAAC;AAEJ;;;;;GAKG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,QAAQ,EAAE,EAAE,CAClD,YAAY,CACV,MAAM,EACN,KAAK,EACL,SAAS,EACT,qBAAqB,EACrB,KAAK,CACN,CAAC;AAEJ;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,GAAY,EAAE,KAAK,GAAG,QAAQ,EAAE,EAAE,CACtE,YAAY,CACV,OAAO,EACP,EAAE,KAAK,EAAE,GAAG,EAAE,EACd,SAAS,EACT,sBAAsB,EACtB,KAAK,CACN,CAAC;AAEJ;;;;;;;;;GASG;AACH,MAAM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,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,SAAS,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,iBAAiB,GAAG,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,uBAAuB,CAC7C;QACE,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC9B,MAAM;QACN,MAAM;QACN,iBAAiB;KAClB,EACD,WAAW,CACZ,CAAC;IAEF,MAAM,aAAa,GAAkB;QACnC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE;YAC5C,GAAG,MAAM,CAAC,UAAU;YACpB,SAAS;SACV,CAAC;KACH,CAAC;IAEF,OAAO,oBAAoB,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,SAAoB,EACpB,MAAwC,EACxC,aAAwC;IAExC,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;IACjC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAqC,CAAC;IACzE,MAAM,cAAc,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,eAAe,GAAG,8BAA8B,CAAC,MAAM,CAAC,CAAC;IAC/D,OAAO,aAAa,CAAC,SAAS,EAAE,cAAc,EAAE,eAAe,CAAC,CAAC;AACnE,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { ActionSignatureContext } from "./types.js";
2
- export declare const hashBrowser: (data: string | Uint8Array | ArrayBufferView | DataView, algorithm?: string, encoding?: string, _params?: Record<string, unknown>) => string;
3
- export declare function getUnixTimestamp(date: Date | string): string;
4
- export declare function buildOperationSignatureParams({ documentId, signer, action, previousStateHash, }: ActionSignatureContext): [string, string, string, string];
5
- export declare function buildOperationSignatureMessage(params: [string, string, string, string]): Uint8Array;
6
- export declare function ab2hex(ab: ArrayBuffer | ArrayBufferView): string;
7
- export declare function hex2ab(hex: string): Uint8Array<ArrayBuffer>;
8
- //# sourceMappingURL=crypto.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/core/crypto.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD,eAAO,MAAM,WAAW,GACtB,MAAM,MAAM,GAAG,UAAU,GAAG,eAAe,GAAG,QAAQ,EACtD,kBAAkB,EAClB,iBAAmB,EACnB,UAAU,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,WAqBlC,CAAC;AAgCF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAE5D;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,UAAU,EACV,MAAM,EACN,MAAM,EACN,iBAAiB,GAClB,EAAE,sBAAsB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAU3D;AAID,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GACvC,UAAU,CAIZ;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,WAAW,GAAG,eAAe,GAAG,MAAM,CAKhE;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,2BAMjC"}
@@ -1,68 +0,0 @@
1
- import stringifyJson from "safe-stable-stringify";
2
- import { createHash as createSha1Hash } from "sha1-uint8array";
3
- export const hashBrowser = (data, algorithm = "sha1", encoding = "base64", _params) => {
4
- if (!["sha1"].includes(algorithm)) {
5
- throw new Error(`Hashing algorithm not supported: "${algorithm}". Available: sha1`);
6
- }
7
- if (!["base64", "hex"].includes(encoding)) {
8
- throw new Error(`Hash encoding not supported: "${encoding}". Available: base64, hex`);
9
- }
10
- const hash = hashUIntArray(data, algorithm);
11
- if (encoding === "hex") {
12
- return uint8ArrayToHex(hash);
13
- }
14
- return uint8ArrayToBase64(hash);
15
- };
16
- function uint8ArrayToBase64(uint8Array) {
17
- // Convert the Uint8Array to a binary string
18
- let binaryString = "";
19
- for (let i = 0; i < uint8Array.length; i++) {
20
- binaryString += String.fromCharCode(uint8Array[i]);
21
- }
22
- // Encode the binary string to base64
23
- const base64String = btoa(binaryString);
24
- return base64String;
25
- }
26
- function uint8ArrayToHex(uint8Array) {
27
- return Array.from(uint8Array)
28
- .map((byte) => byte.toString(16).padStart(2, "0"))
29
- .join("");
30
- }
31
- function hashUIntArray(data, algorithm = "sha1") {
32
- if (!["sha1"].includes(algorithm)) {
33
- throw new Error("Hashing algorithm not supported: Available: sha1");
34
- }
35
- return createSha1Hash("sha1")
36
- .update(data)
37
- .digest();
38
- }
39
- export function getUnixTimestamp(date) {
40
- return (new Date(date).getTime() / 1000).toFixed(0);
41
- }
42
- export function buildOperationSignatureParams({ documentId, signer, action, previousStateHash, }) {
43
- const { /*id, timestamp,*/ scope, type } = action;
44
- return [
45
- /*getUnixTimestamp(timestamp)*/ getUnixTimestamp(new Date()),
46
- signer.app.key,
47
- hashBrowser([documentId, scope, /*id,*/ type, stringifyJson(action.input)].join("")),
48
- previousStateHash,
49
- ];
50
- }
51
- const textEncode = new TextEncoder();
52
- export function buildOperationSignatureMessage(params) {
53
- const message = params.join("");
54
- const prefix = "\x19Signed Operation:\n" + message.length.toString();
55
- return textEncode.encode(prefix + message);
56
- }
57
- export function ab2hex(ab) {
58
- const view = ArrayBuffer.isView(ab) ? ab : new Uint8Array(ab);
59
- return Array.prototype.map
60
- .call(view, (x) => ("00" + x.toString(16)).slice(-2))
61
- .join("");
62
- }
63
- export function hex2ab(hex) {
64
- return new Uint8Array(hex.match(/[\da-f]{2}/gi)?.map(function (h) {
65
- return parseInt(h, 16);
66
- }) ?? []);
67
- }
68
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/core/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAG/D,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAsD,EACtD,SAAS,GAAG,MAAM,EAClB,QAAQ,GAAG,QAAQ,EACnB,OAAiC,EACjC,EAAE;IACF,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,qCAAqC,SAAS,oBAAoB,CACnE,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC1C,MAAM,IAAI,KAAK,CACb,iCAAiC,QAAQ,2BAA2B,CACrE,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAE5C,IAAI,QAAQ,KAAK,KAAK,EAAE,CAAC;QACvB,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF,SAAS,kBAAkB,CAAC,UAAsB;IAChD,4CAA4C;IAC5C,IAAI,YAAY,GAAG,EAAE,CAAC;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,YAAY,IAAI,MAAM,C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AE,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CACxE;QACD,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,GAAG,IAAI,WAAW,EAAE,CAAC;AAErC,MAAM,UAAU,8BAA8B,CAC5C,MAAwC;IAExC,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChC,MAAM,MAAM,GAAG,yBAAyB,GAAG,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;IACrE,OAAO,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,EAAiC;IACtD,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC9D,OAAO,KAAK,CAAC,SAAS,CAAC,GAAG;SACvB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;SAC5D,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,GAAW;IAChC,OAAO,IAAI,UAAU,CACnB,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC;QACxC,OAAO,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACzB,CAAC,CAAC,IAAI,EAAE,CACT,CAAC;AACJ,CAAC"}
@@ -1,146 +0,0 @@
1
- import type { Action, DocumentOperations, Operation, PHBaseState, PHDocument, PHDocumentHeader } from "./ph-types.js";
2
- import type { CreateState, DocumentAction, DocumentOperationsIgnoreMap, MappedOperation, OperationIndex, Reducer, ReplayDocumentOptions, SignalDispatch, SkipHeaderOperationIndex, SkipHeaderOperations, UndoAction, UndoRedoAction } from "./types.js";
3
- export declare function isNoopOperation<TOp extends {
4
- type: string;
5
- skip: number;
6
- hash: string;
7
- }>(op: Partial<TOp>): boolean;
8
- export declare function isUndoRedo(action: Action): action is UndoRedoAction;
9
- export declare function isUndo(action: Action): action is UndoAction;
10
- export declare function isDocumentAction(action: Action): action is DocumentAction;
11
- /**
12
- * Important note: it is the responsibility of the caller to set the document type
13
- * on the header.
14
- */
15
- export declare function baseCreateDocument<TState extends PHBaseState = PHBaseState>(createState: CreateState<TState>, initialState?: Partial<TState>): PHDocument<TState>;
16
- export declare function hashDocumentStateForScope(document: {
17
- state: {
18
- [key: string]: unknown;
19
- };
20
- }, scope?: string): string;
21
- export declare function readOnly<T>(value: T): Readonly<T>;
22
- /**
23
- * Maps skipped operations in an array of operations.
24
- * Skipped operations are operations that are ignored during processing.
25
- * @param operations - The array of operations to map.
26
- * @param skippedHeadOperations - The number of operations to skip at the head of the array of operations.
27
- * @returns An array of mapped operations with ignore flag indicating if the operation is skipped.
28
- * @throws Error if the operation index is invalid and there are missing operations.
29
- */
30
- export declare function mapSkippedOperations(operations: Operation[], skippedHeadOperations?: number): MappedOperation[];
31
- /**
32
- * V2 version of mapSkippedOperations for protocol version 2+.
33
- * In V2, all NOOPs have skip=1 and consecutive NOOPs form chains.
34
- * N consecutive NOOPs at any point skip N preceding content operations.
35
- *
36
- * Algorithm: Process from end to start
37
- * - When hitting a NOOP: increment chain length, mark as ignored
38
- * - When hitting a non-NOOP:
39
- * - If chain > 0: decrement chain, mark as ignored (this op was undone)
40
- * - If chain == 0: mark as not ignored (apply this op)
41
- */
42
- export declare function mapSkippedOperationsV2(operations: Operation[]): MappedOperation[];
43
- /**
44
- * V2 garbage collect that returns only operations that should be applied for state.
45
- * Uses the V2 model where consecutive NOOPs form chains.
46
- * Unlike V1 garbageCollect, this preserves ALL operations but marks which to apply.
47
- */
48
- export declare function garbageCollectV2<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
49
- export declare function sortMappedOperations(operations: DocumentOperationsIgnoreMap): MappedOperation[];
50
- export declare function replayDocument<TState extends PHBaseState = PHBaseState>(initialState: TState, operations: DocumentOperations, reducer: Reducer<TState>, header: PHDocumentHeader, dispatch?: SignalDispatch, skipHeaderOperations?: SkipHeaderOperations, options?: ReplayDocumentOptions): PHDocument<TState>;
51
- export declare function parseResultingState<TState>(state: string | null | undefined): TState;
52
- export declare enum IntegrityIssueType {
53
- UNEXPECTED_INDEX = "UNEXPECTED_INDEX"
54
- }
55
- export declare enum IntegrityIssueSubType {
56
- DUPLICATED_INDEX = "DUPLICATED_INDEX",
57
- MISSING_INDEX = "MISSING_INDEX"
58
- }
59
- type IntegrityIssue = {
60
- operation: OperationIndex;
61
- issue: IntegrityIssueType;
62
- category: IntegrityIssueSubType;
63
- message: string;
64
- };
65
- type Reshuffle = (startIndex: OperationIndex, opsA: Operation[], opsB: Operation[]) => Operation[];
66
- export declare function checkCleanedOperationsIntegrity(sortedOperations: OperationIndex[]): IntegrityIssue[];
67
- export declare function garbageCollect<TOpIndex extends OperationIndex>(sortedOperations: TOpIndex[]): TOpIndex[];
68
- export declare function addUndo(sortedOperations: Operation[]): Operation[];
69
- export declare function sortOperations<TOpIndex extends OperationIndex>(operations: TOpIndex[]): TOpIndex[];
70
- export declare function reshuffleByTimestamp<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
71
- export declare function reshuffleByTimestampAndIndex<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
72
- export declare function operationsAreEqual<TOp extends {
73
- index: number;
74
- skip: number;
75
- type?: string;
76
- scope?: string;
77
- input?: unknown;
78
- }>(op1: TOp, op2: TOp): boolean;
79
- export declare function attachBranch(trunk: Operation[], newBranch: Operation[]): [Operation[], Operation[]];
80
- export declare function precedes(op1: OperationIndex, op2: OperationIndex): boolean;
81
- export declare function split(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[]): [Operation[], Operation[], Operation[]];
82
- export declare function merge(sortedTargetOperations: Operation[], sortedMergeOperations: Operation[], reshuffle: Reshuffle): Operation[];
83
- export declare function nextSkipNumber(sortedOperations: OperationIndex[]): number;
84
- export declare function checkOperationsIntegrity(operations: Operation[]): IntegrityIssue[];
85
- export declare function groupOperationsByScope(operations: Operation[]): Partial<Record<string, Operation[]>>;
86
- type PrepareOperationsResult = {
87
- validOperations: Operation[];
88
- invalidOperations: Operation[];
89
- duplicatedOperations: Operation[];
90
- integrityIssues: IntegrityIssue[];
91
- };
92
- export declare function prepareOperations(operationsHistory: Operation[], newOperations: Operation[]): PrepareOperationsResult;
93
- export declare function removeExistingOperations(newOperations: Operation[], operationsHistory: Operation[]): Operation[];
94
- /**
95
- * Skips header operations and returns the remaining operations.
96
- *
97
- * @param operations - The array of operations.
98
- * @param skipHeaderOperation - The skip header operation index.
99
- * @returns The remaining operations after skipping header operations.
100
- */
101
- export declare function skipHeaderOperations(operations: Operation[], skipHeaderOperation: SkipHeaderOperationIndex): Operation[];
102
- export declare function garbageCollectDocumentOperations(documentOperations: DocumentOperations): DocumentOperations;
103
- /**
104
- * Filters out duplicated operations from the target operations array based on their IDs.
105
- * If an operation has an ID, it is considered duplicated if there is another operation in the source operations array with the same ID.
106
- * If an operation does not have an ID, it is considered unique and will not be filtered out.
107
- * @param targetOperations - The array of target operations to filter.
108
- * @param sourceOperations - The array of source operations to compare against.
109
- * @returns An array of operations with duplicates filtered out.
110
- */
111
- export declare function filterDuplicatedOperations<T extends {
112
- id?: string | number;
113
- }>(targetOperations: T[], sourceOperations: T[]): T[];
114
- export declare function filterDocumentOperationsResultingState(documentOperations?: DocumentOperations): {
115
- [x: string]: Operation[] | {
116
- id: string;
117
- index: number;
118
- skip: number;
119
- timestampUtcMs: string;
120
- hash: string;
121
- error?: string;
122
- action: Action;
123
- }[];
124
- };
125
- /**
126
- * Calculates the difference between two arrays of operations.
127
- * Returns an array of operations that are present in `clearedOperationsA` but not in `clearedOperationsB`.
128
- *
129
- * @template TOp - The type of the operations.
130
- * @param {TOp[]} clearedOperationsA - The first array of operations.
131
- * @param {TOp[]} clearedOperationsB - The second array of operations.
132
- * @returns {TOp[]} - The difference between the two arrays of operations.
133
- */
134
- export declare function diffOperations<TOp extends OperationIndex>(clearedOperationsA: TOp[], clearedOperationsB: TOp[]): TOp[];
135
- export declare function getDocumentLastModified(document: PHDocument): string;
136
- /**
137
- * Updates the document header with the latest revision number and
138
- * date of last modification.
139
- *
140
- * @param state The current state of the document.
141
- * @param operation The action being applied to the document.
142
- * @returns The updated document state.
143
- */
144
- export declare function updateHeaderRevision(document: PHDocument, scope: string): PHDocument;
145
- export {};
146
- //# sourceMappingURL=documents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../../src/core/documents.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,MAAM,EACN,kBAAkB,EAClB,SAAS,EACT,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,2BAA2B,EAC3B,eAAe,EACf,cAAc,EAEd,OAAO,EACP,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,UAAU,EACV,cAAc,EACf,MAAM,YAAY,CAAC;AAGpB,wBAAgB,eAAe,CAC7B,GAAG,SAAS;IACV,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,EACD,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,GAAG,OAAO,CAO3B;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,cAAc,CAEnE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,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