document-model 1.0.20 → 1.0.21

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 (157) hide show
  1. package/package.json +16 -15
  2. package/dist/browser/document/actions/creators.d.ts +0 -46
  3. package/dist/browser/document/actions/index.d.ts +0 -10
  4. package/dist/browser/document/actions/types.d.ts +0 -8
  5. package/dist/browser/document/index.d.ts +0 -6
  6. package/dist/browser/document/object.d.ts +0 -391
  7. package/dist/browser/document/reducer.d.ts +0 -16
  8. package/dist/browser/document/schema/index.d.ts +0 -2
  9. package/dist/browser/document/schema/types.d.ts +0 -174
  10. package/dist/browser/document/schema/zod.d.ts +0 -113
  11. package/dist/browser/document/signal.d.ts +0 -22
  12. package/dist/browser/document/types.d.ts +0 -190
  13. package/dist/browser/document/utils/base.d.ts +0 -61
  14. package/dist/browser/document/utils/file.d.ts +0 -47
  15. package/dist/browser/document/utils/index.d.ts +0 -2
  16. package/dist/browser/document/utils/node.d.ts +0 -9
  17. package/dist/browser/document-model/custom/reducers/header.d.ts +0 -2
  18. package/dist/browser/document-model/custom/reducers/module.d.ts +0 -2
  19. package/dist/browser/document-model/custom/reducers/operation-error.d.ts +0 -2
  20. package/dist/browser/document-model/custom/reducers/operation-example.d.ts +0 -2
  21. package/dist/browser/document-model/custom/reducers/operation.d.ts +0 -2
  22. package/dist/browser/document-model/custom/reducers/state.d.ts +0 -2
  23. package/dist/browser/document-model/custom/reducers/versioning.d.ts +0 -7
  24. package/dist/browser/document-model/custom/utils.d.ts +0 -1
  25. package/dist/browser/document-model/gen/actions.d.ts +0 -15
  26. package/dist/browser/document-model/gen/creators.d.ts +0 -7
  27. package/dist/browser/document-model/gen/document-model.d.ts +0 -2
  28. package/dist/browser/document-model/gen/header/actions.d.ts +0 -9
  29. package/dist/browser/document-model/gen/header/creators.d.ts +0 -8
  30. package/dist/browser/document-model/gen/header/object.d.ts +0 -11
  31. package/dist/browser/document-model/gen/header/operations.d.ts +0 -10
  32. package/dist/browser/document-model/gen/index.d.ts +0 -5
  33. package/dist/browser/document-model/gen/module/actions.d.ts +0 -8
  34. package/dist/browser/document-model/gen/module/creators.d.ts +0 -7
  35. package/dist/browser/document-model/gen/module/object.d.ts +0 -10
  36. package/dist/browser/document-model/gen/module/operations.d.ts +0 -9
  37. package/dist/browser/document-model/gen/object.d.ts +0 -28
  38. package/dist/browser/document-model/gen/operation/actions.d.ts +0 -13
  39. package/dist/browser/document-model/gen/operation/creators.d.ts +0 -12
  40. package/dist/browser/document-model/gen/operation/object.d.ts +0 -15
  41. package/dist/browser/document-model/gen/operation/operations.d.ts +0 -14
  42. package/dist/browser/document-model/gen/operation-error/actions.d.ts +0 -10
  43. package/dist/browser/document-model/gen/operation-error/creators.d.ts +0 -9
  44. package/dist/browser/document-model/gen/operation-error/object.d.ts +0 -12
  45. package/dist/browser/document-model/gen/operation-error/operations.d.ts +0 -11
  46. package/dist/browser/document-model/gen/operation-example/actions.d.ts +0 -7
  47. package/dist/browser/document-model/gen/operation-example/creators.d.ts +0 -6
  48. package/dist/browser/document-model/gen/operation-example/object.d.ts +0 -9
  49. package/dist/browser/document-model/gen/operation-example/operations.d.ts +0 -8
  50. package/dist/browser/document-model/gen/reducer.d.ts +0 -3
  51. package/dist/browser/document-model/gen/schema/index.d.ts +0 -2
  52. package/dist/browser/document-model/gen/schema/types.d.ts +0 -453
  53. package/dist/browser/document-model/gen/schema/zod.d.ts +0 -453
  54. package/dist/browser/document-model/gen/state/actions.d.ts +0 -9
  55. package/dist/browser/document-model/gen/state/creators.d.ts +0 -8
  56. package/dist/browser/document-model/gen/state/object.d.ts +0 -11
  57. package/dist/browser/document-model/gen/state/operations.d.ts +0 -10
  58. package/dist/browser/document-model/gen/types.d.ts +0 -8
  59. package/dist/browser/document-model/gen/utils.d.ts +0 -6
  60. package/dist/browser/document-model/gen/versioning/actions.d.ts +0 -8
  61. package/dist/browser/document-model/gen/versioning/creators.d.ts +0 -7
  62. package/dist/browser/document-model/gen/versioning/object.d.ts +0 -10
  63. package/dist/browser/document-model/gen/versioning/operations.d.ts +0 -9
  64. package/dist/browser/document-model/index.d.ts +0 -74
  65. package/dist/browser/document-model.cjs +0 -1
  66. package/dist/browser/document-model.d.ts +0 -1
  67. package/dist/browser/document-model.js +0 -16
  68. package/dist/browser/document.cjs +0 -1
  69. package/dist/browser/document.d.ts +0 -1
  70. package/dist/browser/document.js +0 -14
  71. package/dist/browser/index.cjs +0 -1
  72. package/dist/browser/index.d.ts +0 -25
  73. package/dist/browser/index.js +0 -17
  74. package/dist/browser/internal/index-22f88bf2.js +0 -1926
  75. package/dist/browser/internal/index-3607fd07.js +0 -34
  76. package/dist/browser/internal/index-79fde5f3.js +0 -1
  77. package/dist/browser/internal/index-dda5d688.js +0 -22
  78. package/dist/browser/internal/object-32802eed.js +0 -6
  79. package/dist/browser/internal/object-d03c84c9.js +0 -1779
  80. package/dist/node/document/actions/creators.d.ts +0 -46
  81. package/dist/node/document/actions/index.d.ts +0 -10
  82. package/dist/node/document/actions/types.d.ts +0 -8
  83. package/dist/node/document/index.d.ts +0 -6
  84. package/dist/node/document/object.d.ts +0 -391
  85. package/dist/node/document/reducer.d.ts +0 -16
  86. package/dist/node/document/schema/index.d.ts +0 -2
  87. package/dist/node/document/schema/types.d.ts +0 -174
  88. package/dist/node/document/schema/zod.d.ts +0 -113
  89. package/dist/node/document/signal.d.ts +0 -22
  90. package/dist/node/document/types.d.ts +0 -190
  91. package/dist/node/document/utils/base.d.ts +0 -61
  92. package/dist/node/document/utils/file.d.ts +0 -47
  93. package/dist/node/document/utils/index.d.ts +0 -2
  94. package/dist/node/document/utils/node.d.ts +0 -9
  95. package/dist/node/document-model/custom/reducers/header.d.ts +0 -2
  96. package/dist/node/document-model/custom/reducers/module.d.ts +0 -2
  97. package/dist/node/document-model/custom/reducers/operation-error.d.ts +0 -2
  98. package/dist/node/document-model/custom/reducers/operation-example.d.ts +0 -2
  99. package/dist/node/document-model/custom/reducers/operation.d.ts +0 -2
  100. package/dist/node/document-model/custom/reducers/state.d.ts +0 -2
  101. package/dist/node/document-model/custom/reducers/versioning.d.ts +0 -7
  102. package/dist/node/document-model/custom/utils.d.ts +0 -1
  103. package/dist/node/document-model/gen/actions.d.ts +0 -15
  104. package/dist/node/document-model/gen/creators.d.ts +0 -7
  105. package/dist/node/document-model/gen/document-model.d.ts +0 -2
  106. package/dist/node/document-model/gen/header/actions.d.ts +0 -9
  107. package/dist/node/document-model/gen/header/creators.d.ts +0 -8
  108. package/dist/node/document-model/gen/header/object.d.ts +0 -11
  109. package/dist/node/document-model/gen/header/operations.d.ts +0 -10
  110. package/dist/node/document-model/gen/index.d.ts +0 -5
  111. package/dist/node/document-model/gen/module/actions.d.ts +0 -8
  112. package/dist/node/document-model/gen/module/creators.d.ts +0 -7
  113. package/dist/node/document-model/gen/module/object.d.ts +0 -10
  114. package/dist/node/document-model/gen/module/operations.d.ts +0 -9
  115. package/dist/node/document-model/gen/object.d.ts +0 -28
  116. package/dist/node/document-model/gen/operation/actions.d.ts +0 -13
  117. package/dist/node/document-model/gen/operation/creators.d.ts +0 -12
  118. package/dist/node/document-model/gen/operation/object.d.ts +0 -15
  119. package/dist/node/document-model/gen/operation/operations.d.ts +0 -14
  120. package/dist/node/document-model/gen/operation-error/actions.d.ts +0 -10
  121. package/dist/node/document-model/gen/operation-error/creators.d.ts +0 -9
  122. package/dist/node/document-model/gen/operation-error/object.d.ts +0 -12
  123. package/dist/node/document-model/gen/operation-error/operations.d.ts +0 -11
  124. package/dist/node/document-model/gen/operation-example/actions.d.ts +0 -7
  125. package/dist/node/document-model/gen/operation-example/creators.d.ts +0 -6
  126. package/dist/node/document-model/gen/operation-example/object.d.ts +0 -9
  127. package/dist/node/document-model/gen/operation-example/operations.d.ts +0 -8
  128. package/dist/node/document-model/gen/reducer.d.ts +0 -3
  129. package/dist/node/document-model/gen/schema/index.d.ts +0 -2
  130. package/dist/node/document-model/gen/schema/types.d.ts +0 -453
  131. package/dist/node/document-model/gen/schema/zod.d.ts +0 -453
  132. package/dist/node/document-model/gen/state/actions.d.ts +0 -9
  133. package/dist/node/document-model/gen/state/creators.d.ts +0 -8
  134. package/dist/node/document-model/gen/state/object.d.ts +0 -11
  135. package/dist/node/document-model/gen/state/operations.d.ts +0 -10
  136. package/dist/node/document-model/gen/types.d.ts +0 -8
  137. package/dist/node/document-model/gen/utils.d.ts +0 -6
  138. package/dist/node/document-model/gen/versioning/actions.d.ts +0 -8
  139. package/dist/node/document-model/gen/versioning/creators.d.ts +0 -7
  140. package/dist/node/document-model/gen/versioning/object.d.ts +0 -10
  141. package/dist/node/document-model/gen/versioning/operations.d.ts +0 -9
  142. package/dist/node/document-model/index.d.ts +0 -74
  143. package/dist/node/document-model.cjs +0 -1
  144. package/dist/node/document-model.d.ts +0 -1
  145. package/dist/node/document-model.js +0 -20
  146. package/dist/node/document.cjs +0 -1
  147. package/dist/node/document.d.ts +0 -1
  148. package/dist/node/document.js +0 -18
  149. package/dist/node/index.cjs +0 -1
  150. package/dist/node/index.d.ts +0 -25
  151. package/dist/node/index.js +0 -21
  152. package/dist/node/internal/index-14279b3a.js +0 -1930
  153. package/dist/node/internal/index-4b25c8a5.js +0 -1
  154. package/dist/node/internal/index-bfc402ef.js +0 -22
  155. package/dist/node/internal/index-e02d7854.js +0 -34
  156. package/dist/node/internal/object-ac706c4a.js +0 -1
  157. package/dist/node/internal/object-b97efc1b.js +0 -781
@@ -1,46 +0,0 @@
1
- import { ExtendedState, OperationScope } from '../types';
2
- import { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction } from './types';
3
- /**
4
- * Changes the name of the document.
5
- *
6
- * @param name - The name to be set in the document.
7
- * @category Actions
8
- */
9
- export declare const setName: (name: string) => SetNameAction;
10
- /**
11
- * Cancels the last `count` operations.
12
- *
13
- * @param count - Number of operations to cancel
14
- * @category Actions
15
- */
16
- export declare const undo: (count?: number, scope?: OperationScope) => UndoAction;
17
- /**
18
- * Cancels the last `count` {@link undo | UNDO} operations.
19
- *
20
- * @param count - Number of UNDO operations to cancel
21
- * @category Actions
22
- */
23
- export declare const redo: (count?: number, scope?: OperationScope) => RedoAction;
24
- /**
25
- * Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
26
- *
27
- * @remarks
28
- * Useful to keep operations history smaller. Operations to prune are selected by index,
29
- * similar to the {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | slice} method in Arrays.
30
- *
31
- * @param start - Index of the first operation to prune
32
- * @param end - Index of the last operation to prune
33
- * @category Actions
34
- */
35
- export declare const prune: (start?: number | undefined, end?: number | undefined, scope?: OperationScope) => PruneAction;
36
- /**
37
- * Replaces the state of the document.
38
- *
39
- * @remarks
40
- * This action shouldn't be used directly. It is dispatched by the {@link prune} action.
41
- *
42
- * @param state - State to be set in the document.
43
- * @param operations - Number of operations that were removed from the previous state.
44
- * @category Actions
45
- */
46
- export declare const loadState: <S, T>(state: Pick<ExtendedState<S, T>, "name" | "state">, operations: number) => LoadStateAction;
@@ -1,10 +0,0 @@
1
- import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction } from '../types';
2
- export declare function setNameOperation<T>(document: T, name: string): T;
3
- export declare function undoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: UndoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
4
- export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>, action: RedoAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
5
- export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>, action: PruneAction, wrappedReducer: ImmutableStateReducer<T, A, L>): Document<T, A, L>;
6
- export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
7
- name: string;
8
- state?: State<T, L>;
9
- }): Document<T, A, L>;
10
- export * from './creators';
@@ -1,8 +0,0 @@
1
- import { BaseAction } from '../types';
2
- export declare const SET_NAME = "SET_NAME";
3
- export declare const UNDO = "UNDO";
4
- export declare const REDO = "REDO";
5
- export declare const PRUNE = "PRUNE";
6
- export declare const LOAD_STATE = "LOAD_STATE";
7
- export { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction, } from '../types';
8
- export type { BaseAction };
@@ -1,6 +0,0 @@
1
- export * as actions from './actions/creators';
2
- export * from './object';
3
- export * from './reducer';
4
- export * from './signal';
5
- export * from './types';
6
- export * as utils from './utils';
@@ -1,391 +0,0 @@
1
- import type { BaseAction } from './actions/types';
2
- import type { SignalDispatch } from './signal';
3
- import type { Action, AttachmentRef, Document, ExtendedState, OperationScope, Reducer } from './types';
4
- /**
5
- * This is an abstract class representing a document and provides methods
6
- * for creating and manipulating documents.
7
- * @typeparam T - The type of data stored in the document.
8
- * @typeparam A - The type of action the document can take.
9
- */
10
- export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
11
- protected _document: Document<T, A, L>;
12
- private _reducer;
13
- private _signalDispatch?;
14
- /**
15
- * Constructs a BaseDocument instance with an initial state.
16
- * @param reducer - The reducer function that updates the state.
17
- * @param document - The initial state of the document.
18
- */
19
- constructor(reducer: Reducer<T, A, L>, document: Document<T, A, L>, signalDispatch?: SignalDispatch);
20
- /**
21
- * Dispatches an action to update the state of the document.
22
- * @param action - The action to dispatch.
23
- * @returns The Document instance.
24
- */
25
- protected dispatch(action: A | BaseAction): this;
26
- /**
27
- * Saves the state of the document to a file.
28
- * @param path - The file path where the state should be saved.
29
- * @param extension - The file extension to use when saving the state.
30
- * @returns The file path where the state was saved.
31
- */
32
- protected saveToFile(path: string, extension: string, name?: string): Promise<string>;
33
- /**
34
- * Loads the state of the document from a file.
35
- * @param path - The file path where the state is stored.
36
- */
37
- loadFromFile(path: string): Promise<void>;
38
- /**
39
- * Loads the state of the document from a file and returns it.
40
- * @param path - The file path where the state is stored.
41
- * @param reducer - The reducer function that updates the state.
42
- * @returns The state of the document.
43
- */
44
- protected static stateFromFile<T, A extends Action, L>(path: string, reducer: Reducer<T, A, L>): Promise<Document<T, A, L>>;
45
- /**
46
- * Gets the current state of the document.
47
- */
48
- get state(): {
49
- readonly global: import("immer").Immutable<T>;
50
- readonly local: import("immer").Immutable<L>;
51
- };
52
- /**
53
- * Gets the list of operations performed on the document.
54
- */
55
- get operations(): {
56
- readonly global: readonly ({
57
- readonly input: {
58
- readonly operations: number;
59
- readonly state: {
60
- readonly data?: unknown;
61
- readonly name: string;
62
- };
63
- };
64
- readonly type: "LOAD_STATE";
65
- readonly scope: OperationScope;
66
- readonly index: number;
67
- readonly timestamp: string;
68
- readonly hash: string;
69
- } | {
70
- readonly input: {
71
- readonly end?: import("./types").InputMaybe<number>;
72
- readonly start?: import("./types").InputMaybe<number>;
73
- };
74
- readonly type: "PRUNE";
75
- readonly scope: OperationScope;
76
- readonly index: number;
77
- readonly timestamp: string;
78
- readonly hash: string;
79
- } | {
80
- readonly input: number;
81
- readonly type: "REDO";
82
- readonly scope: OperationScope;
83
- readonly index: number;
84
- readonly timestamp: string;
85
- readonly hash: string;
86
- } | {
87
- readonly input: string;
88
- readonly type: "SET_NAME";
89
- readonly scope: "global";
90
- readonly index: number;
91
- readonly timestamp: string;
92
- readonly hash: string;
93
- } | {
94
- readonly input: number;
95
- readonly type: "UNDO";
96
- readonly scope: OperationScope;
97
- readonly index: number;
98
- readonly timestamp: string;
99
- readonly hash: string;
100
- } | import("immer").Immutable<A & {
101
- index: number;
102
- timestamp: string;
103
- hash: string;
104
- }>)[];
105
- readonly local: readonly ({
106
- readonly input: {
107
- readonly operations: number;
108
- readonly state: {
109
- readonly data?: unknown;
110
- readonly name: string;
111
- };
112
- };
113
- readonly type: "LOAD_STATE";
114
- readonly scope: OperationScope;
115
- readonly index: number;
116
- readonly timestamp: string;
117
- readonly hash: string;
118
- } | {
119
- readonly input: {
120
- readonly end?: import("./types").InputMaybe<number>;
121
- readonly start?: import("./types").InputMaybe<number>;
122
- };
123
- readonly type: "PRUNE";
124
- readonly scope: OperationScope;
125
- readonly index: number;
126
- readonly timestamp: string;
127
- readonly hash: string;
128
- } | {
129
- readonly input: number;
130
- readonly type: "REDO";
131
- readonly scope: OperationScope;
132
- readonly index: number;
133
- readonly timestamp: string;
134
- readonly hash: string;
135
- } | {
136
- readonly input: string;
137
- readonly type: "SET_NAME";
138
- readonly scope: "global";
139
- readonly index: number;
140
- readonly timestamp: string;
141
- readonly hash: string;
142
- } | {
143
- readonly input: number;
144
- readonly type: "UNDO";
145
- readonly scope: OperationScope;
146
- readonly index: number;
147
- readonly timestamp: string;
148
- readonly hash: string;
149
- } | import("immer").Immutable<A & {
150
- index: number;
151
- timestamp: string;
152
- hash: string;
153
- }>)[];
154
- };
155
- /**
156
- * Gets the name of the document.
157
- */
158
- get name(): string;
159
- /**
160
- * Gets the type of document.
161
- */
162
- get documentType(): string;
163
- /**
164
- * Gets the timestamp of the date the document was created.
165
- */
166
- get created(): string;
167
- /**
168
- * Gets the timestamp of the date the document was last modified.
169
- */
170
- get lastModified(): string;
171
- /**
172
- * Gets the global revision number of the document.
173
- */
174
- get revision(): number;
175
- getRevision(scope: OperationScope): number;
176
- /**
177
- * Gets the initial state of the document.
178
- */
179
- get initialState(): {
180
- readonly name: string;
181
- readonly revision: {
182
- readonly global: number;
183
- readonly local: number;
184
- };
185
- readonly documentType: string;
186
- readonly created: string;
187
- readonly lastModified: string;
188
- readonly state: {
189
- readonly global: import("immer").Immutable<T>;
190
- readonly local: import("immer").Immutable<L>;
191
- };
192
- readonly attachments: {
193
- readonly [x: string]: {
194
- readonly data: string;
195
- readonly mimeType: string;
196
- readonly extension?: string | null | undefined;
197
- readonly fileName?: string | null | undefined;
198
- };
199
- };
200
- };
201
- /**
202
- * Returns the current document as an object
203
- */
204
- toDocument(): {
205
- readonly name: string;
206
- readonly revision: {
207
- readonly global: number;
208
- readonly local: number;
209
- };
210
- readonly documentType: string;
211
- readonly created: string;
212
- readonly lastModified: string;
213
- readonly state: {
214
- readonly global: import("immer").Immutable<T>;
215
- readonly local: import("immer").Immutable<L>;
216
- };
217
- readonly attachments: {
218
- readonly [x: string]: {
219
- readonly data: string;
220
- readonly mimeType: string;
221
- readonly extension?: string | null | undefined;
222
- readonly fileName?: string | null | undefined;
223
- };
224
- };
225
- readonly operations: {
226
- readonly global: readonly ({
227
- readonly input: {
228
- readonly operations: number;
229
- readonly state: {
230
- readonly data?: unknown;
231
- readonly name: string;
232
- };
233
- };
234
- readonly type: "LOAD_STATE";
235
- readonly scope: OperationScope;
236
- readonly index: number;
237
- readonly timestamp: string;
238
- readonly hash: string;
239
- } | {
240
- readonly input: {
241
- readonly end?: import("./types").InputMaybe<number>;
242
- readonly start?: import("./types").InputMaybe<number>;
243
- };
244
- readonly type: "PRUNE";
245
- readonly scope: OperationScope;
246
- readonly index: number;
247
- readonly timestamp: string;
248
- readonly hash: string;
249
- } | {
250
- readonly input: number;
251
- readonly type: "REDO";
252
- readonly scope: OperationScope;
253
- readonly index: number;
254
- readonly timestamp: string;
255
- readonly hash: string;
256
- } | {
257
- readonly input: string;
258
- readonly type: "SET_NAME";
259
- readonly scope: "global";
260
- readonly index: number;
261
- readonly timestamp: string;
262
- readonly hash: string;
263
- } | {
264
- readonly input: number;
265
- readonly type: "UNDO";
266
- readonly scope: OperationScope;
267
- readonly index: number;
268
- readonly timestamp: string;
269
- readonly hash: string;
270
- } | import("immer").Immutable<A & {
271
- index: number;
272
- timestamp: string;
273
- hash: string;
274
- }>)[];
275
- readonly local: readonly ({
276
- readonly input: {
277
- readonly operations: number;
278
- readonly state: {
279
- readonly data?: unknown;
280
- readonly name: string;
281
- };
282
- };
283
- readonly type: "LOAD_STATE";
284
- readonly scope: OperationScope;
285
- readonly index: number;
286
- readonly timestamp: string;
287
- readonly hash: string;
288
- } | {
289
- readonly input: {
290
- readonly end?: import("./types").InputMaybe<number>;
291
- readonly start?: import("./types").InputMaybe<number>;
292
- };
293
- readonly type: "PRUNE";
294
- readonly scope: OperationScope;
295
- readonly index: number;
296
- readonly timestamp: string;
297
- readonly hash: string;
298
- } | {
299
- readonly input: number;
300
- readonly type: "REDO";
301
- readonly scope: OperationScope;
302
- readonly index: number;
303
- readonly timestamp: string;
304
- readonly hash: string;
305
- } | {
306
- readonly input: string;
307
- readonly type: "SET_NAME";
308
- readonly scope: "global";
309
- readonly index: number;
310
- readonly timestamp: string;
311
- readonly hash: string;
312
- } | {
313
- readonly input: number;
314
- readonly type: "UNDO";
315
- readonly scope: OperationScope;
316
- readonly index: number;
317
- readonly timestamp: string;
318
- readonly hash: string;
319
- } | import("immer").Immutable<A & {
320
- index: number;
321
- timestamp: string;
322
- hash: string;
323
- }>)[];
324
- };
325
- readonly initialState: {
326
- readonly name: string;
327
- readonly revision: {
328
- readonly global: number;
329
- readonly local: number;
330
- };
331
- readonly documentType: string;
332
- readonly created: string;
333
- readonly lastModified: string;
334
- readonly state: {
335
- readonly global: import("immer").Immutable<T>;
336
- readonly local: import("immer").Immutable<L>;
337
- };
338
- readonly attachments: {
339
- readonly [x: string]: {
340
- readonly data: string;
341
- readonly mimeType: string;
342
- readonly extension?: string | null | undefined;
343
- readonly fileName?: string | null | undefined;
344
- };
345
- };
346
- };
347
- };
348
- /**
349
- * Gets the attachment associated with the given key.
350
- * @param attachment - The key of the attachment to retrieve.
351
- */
352
- getAttachment(attachment: AttachmentRef): import("./types").Attachment;
353
- /**
354
- * Sets the name of the document.
355
- * @param name - The new name of the document.
356
- */
357
- setName(name: string): this;
358
- /**
359
- * Reverts a number of actions from the document.
360
- * @param count - The number of actions to revert.
361
- */
362
- undo(count: number): this;
363
- /**
364
- * Reapplies a number of actions to the document.
365
- * @param count - The number of actions to reapply.
366
- */
367
- redo(count: number): this;
368
- /**
369
- * Removes a range of operations from the document.
370
- * @param start - The starting index of the range to remove.
371
- * @param end - The ending index of the range to remove.
372
- */
373
- prune(start?: number | undefined, end?: number | undefined): this;
374
- /**
375
- * Loads a document state and a set of operations.
376
- * @param state - The state to load.
377
- * @param operations - The operations to apply to the document.
378
- */
379
- loadState(state: Pick<ExtendedState<T, L>, 'state' | 'name'>, operations: number): this;
380
- }
381
- /**
382
- * Applies multiple mixins to a base class.
383
- * Used to have separate mixins to group methods by actions.
384
- *
385
- * @remarks
386
- * {@link https://www.typescriptlang.org/docs/handbook/mixins.html#alternative-pattern}
387
- *
388
- * @param derivedCtor - The class to apply the mixins to.
389
- * @param constructors - The constructors of the mixins.
390
- */
391
- export declare function applyMixins(derivedCtor: any, constructors: any[]): void;
@@ -1,16 +0,0 @@
1
- import { BaseAction } from './actions/types';
2
- import { Action, Document, ImmutableStateReducer } from './types';
3
- import { SignalDispatch } from './signal';
4
- /**
5
- * Base document reducer that wraps a custom document reducer and handles
6
- * document-level actions such as undo, redo, prune, and set name.
7
- *
8
- * @template T - The type of the state of the custom reducer.
9
- * @template A - The type of the actions of the custom reducer.
10
- * @param state - The current state of the document.
11
- * @param action - The action object to apply to the state.
12
- * @param customReducer - The custom reducer that implements the application logic
13
- * specific to the document's state.
14
- * @returns The new state of the document.
15
- */
16
- export declare function baseReducer<T, A extends Action, L>(document: Document<T, A, L>, action: A | BaseAction, customReducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch): Document<T, A, L>;
@@ -1,2 +0,0 @@
1
- export * from "./types";
2
- export * as z from "./zod";
@@ -1,174 +0,0 @@
1
- import { OperationScope } from "..";
2
- export type Maybe<T> = T | null;
3
- export type InputMaybe<T> = T | null | undefined;
4
- export type Exact<T extends {
5
- [key: string]: unknown;
6
- }> = {
7
- [K in keyof T]: T[K];
8
- };
9
- export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
- [SubKey in K]?: Maybe<T[SubKey]>;
11
- };
12
- export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
- [SubKey in K]: Maybe<T[SubKey]>;
14
- };
15
- export type MakeEmpty<T extends {
16
- [key: string]: unknown;
17
- }, K extends keyof T> = {
18
- [_ in K]?: never;
19
- };
20
- export type Incremental<T> = T | {
21
- [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never;
22
- };
23
- /** All built-in and custom scalars, mapped to their actual values */
24
- export type Scalars = {
25
- ID: {
26
- input: string;
27
- output: string;
28
- };
29
- String: {
30
- input: string;
31
- output: string;
32
- };
33
- Boolean: {
34
- input: boolean;
35
- output: boolean;
36
- };
37
- Int: {
38
- input: number;
39
- output: number;
40
- };
41
- Float: {
42
- input: number;
43
- output: number;
44
- };
45
- Address: {
46
- input: `${string}:0x${string}`;
47
- output: `${string}:0x${string}`;
48
- };
49
- Attachment: {
50
- input: string;
51
- output: string;
52
- };
53
- DateTime: {
54
- input: string;
55
- output: string;
56
- };
57
- Unknown: {
58
- input: unknown;
59
- output: unknown;
60
- };
61
- };
62
- export type Action = IAction & {
63
- __typename?: 'Action';
64
- type: Scalars['String']['output'];
65
- };
66
- export type BaseAction = LoadStateAction | PruneAction | RedoAction | SetNameAction | UndoAction;
67
- export type DocumentFile = {
68
- __typename?: 'DocumentFile';
69
- data: Scalars['String']['output'];
70
- extension: Maybe<Scalars['String']['output']>;
71
- fileName: Maybe<Scalars['String']['output']>;
72
- mimeType: Scalars['String']['output'];
73
- };
74
- export type IAction = {
75
- type: Scalars['String']['output'];
76
- };
77
- export type IDocument = {
78
- created: Scalars['DateTime']['output'];
79
- documentType: Scalars['String']['output'];
80
- lastModified: Scalars['DateTime']['output'];
81
- name: Scalars['String']['output'];
82
- operations: Array<IOperation>;
83
- revision: Scalars['Int']['output'];
84
- };
85
- export type IOperation = {
86
- hash: Scalars['String']['output'];
87
- index: Scalars['Int']['output'];
88
- timestamp: Scalars['DateTime']['output'];
89
- type: Scalars['String']['output'];
90
- };
91
- export type Load_State = 'LOAD_STATE';
92
- export type LoadStateAction = {
93
- input: LoadStateActionInput;
94
- type: Load_State | `${Load_State}`;
95
- scope: OperationScope;
96
- };
97
- export type LoadStateActionInput = {
98
- operations: Scalars['Int']['input'];
99
- state: LoadStateActionStateInput;
100
- };
101
- export type LoadStateActionStateInput = {
102
- data?: InputMaybe<Scalars['Unknown']['input']>;
103
- name: Scalars['String']['input'];
104
- };
105
- export type Mutation = {
106
- __typename?: 'Mutation';
107
- loadState: Maybe<IDocument>;
108
- prune: Maybe<IDocument>;
109
- redo: Maybe<IDocument>;
110
- setName: Maybe<IDocument>;
111
- undo: Maybe<IDocument>;
112
- };
113
- export type MutationLoadStateArgs = {
114
- input: LoadStateAction;
115
- };
116
- export type MutationPruneArgs = {
117
- input: PruneAction;
118
- };
119
- export type MutationRedoArgs = {
120
- input: RedoAction;
121
- };
122
- export type MutationSetNameArgs = {
123
- input: SetNameAction;
124
- };
125
- export type MutationUndoArgs = {
126
- input: UndoAction;
127
- };
128
- export type Operation = IOperation & {
129
- __typename?: 'Operation';
130
- hash: Scalars['String']['output'];
131
- index: Scalars['Int']['output'];
132
- timestamp: Scalars['DateTime']['output'];
133
- type: Scalars['String']['output'];
134
- };
135
- export type Prune = 'PRUNE';
136
- export type PruneAction = {
137
- input: PruneActionInput;
138
- type: Prune | `${Prune}`;
139
- scope: OperationScope;
140
- };
141
- export type PruneActionInput = {
142
- end?: InputMaybe<Scalars['Int']['input']>;
143
- start?: InputMaybe<Scalars['Int']['input']>;
144
- };
145
- export type Query = {
146
- __typename?: 'Query';
147
- document: Maybe<IDocument>;
148
- };
149
- export type Redo = 'REDO';
150
- export type RedoAction = {
151
- input: Scalars['Int']['input'];
152
- type: Redo | `${Redo}`;
153
- scope: OperationScope;
154
- };
155
- export type Set_Name = 'SET_NAME';
156
- export type SetNameAction = {
157
- input: Scalars['String']['input'];
158
- type: Set_Name | `${Set_Name}`;
159
- scope: "global";
160
- };
161
- export type SetNameOperation = IOperation & {
162
- __typename?: 'SetNameOperation';
163
- hash: Scalars['String']['output'];
164
- index: Scalars['Int']['output'];
165
- input: Scalars['String']['output'];
166
- timestamp: Scalars['DateTime']['output'];
167
- type: Scalars['String']['output'];
168
- };
169
- export type Undo = 'UNDO';
170
- export type UndoAction = {
171
- input: Scalars['Int']['input'];
172
- type: Undo | `${Undo}`;
173
- scope: OperationScope;
174
- };