document-model 1.0.18 → 1.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/document/actions/creators.d.ts +4 -4
- package/dist/browser/document/actions/index.d.ts +4 -4
- package/dist/browser/document/object.d.ts +119 -13
- package/dist/browser/document/schema/types.d.ts +5 -4
- package/dist/browser/document/schema/zod.d.ts +14 -12
- package/dist/browser/document/types.d.ts +2 -5
- package/dist/browser/document/utils/base.d.ts +6 -2
- package/dist/browser/document-model/gen/schema/zod.d.ts +5 -3
- package/dist/browser/document-model/index.d.ts +3 -3
- package/dist/browser/document-model.cjs +1 -1
- package/dist/browser/document-model.js +2 -2
- package/dist/browser/document.cjs +1 -1
- package/dist/browser/document.js +6 -6
- package/dist/browser/index.cjs +1 -1
- package/dist/browser/index.js +4 -4
- package/dist/browser/internal/{index-10a12861.js → index-22f88bf2.js} +361 -357
- package/dist/browser/internal/index-3607fd07.js +34 -0
- package/dist/browser/internal/index-79fde5f3.js +1 -0
- package/dist/browser/internal/index-dda5d688.js +22 -0
- package/dist/browser/internal/object-32802eed.js +6 -0
- package/dist/browser/internal/object-d03c84c9.js +1779 -0
- package/dist/node/document/actions/creators.d.ts +4 -4
- package/dist/node/document/actions/index.d.ts +4 -4
- package/dist/node/document/object.d.ts +119 -13
- package/dist/node/document/schema/types.d.ts +5 -4
- package/dist/node/document/schema/zod.d.ts +14 -12
- package/dist/node/document/types.d.ts +2 -5
- package/dist/node/document/utils/base.d.ts +6 -2
- package/dist/node/document-model/gen/schema/zod.d.ts +5 -3
- package/dist/node/document-model/index.d.ts +3 -3
- package/dist/node/document-model.cjs +1 -1
- package/dist/node/document-model.js +3 -3
- package/dist/node/document.cjs +1 -1
- package/dist/node/document.js +5 -5
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.js +4 -4
- package/dist/node/internal/{index-09364517.js → index-14279b3a.js} +362 -358
- package/dist/node/internal/index-4b25c8a5.js +1 -0
- package/dist/node/internal/index-bfc402ef.js +22 -0
- package/dist/node/internal/index-e02d7854.js +34 -0
- package/dist/node/internal/object-ac706c4a.js +1 -0
- package/dist/node/internal/{object-c32ea0a0.js → object-b97efc1b.js} +469 -402
- package/package.json +1 -1
- package/dist/browser/internal/index-2aee8ea9.js +0 -1
- package/dist/browser/internal/index-a1282d5c.js +0 -31
- package/dist/browser/internal/index-ec8cd58f.js +0 -22
- package/dist/browser/internal/object-24df9d92.js +0 -6
- package/dist/browser/internal/object-7e8eaff4.js +0 -1712
- package/dist/node/internal/index-284511b8.js +0 -22
- package/dist/node/internal/index-2d4783d9.js +0 -1
- package/dist/node/internal/index-5ef0c6b0.js +0 -31
- package/dist/node/internal/object-21f3d2ee.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ExtendedState } from '../types';
|
|
1
|
+
import { ExtendedState, OperationScope } from '../types';
|
|
2
2
|
import { LoadStateAction, PruneAction, RedoAction, SetNameAction, UndoAction } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* Changes the name of the document.
|
|
@@ -13,14 +13,14 @@ export declare const setName: (name: string) => SetNameAction;
|
|
|
13
13
|
* @param count - Number of operations to cancel
|
|
14
14
|
* @category Actions
|
|
15
15
|
*/
|
|
16
|
-
export declare const undo: (count?: number) => UndoAction;
|
|
16
|
+
export declare const undo: (count?: number, scope?: OperationScope) => UndoAction;
|
|
17
17
|
/**
|
|
18
18
|
* Cancels the last `count` {@link undo | UNDO} operations.
|
|
19
19
|
*
|
|
20
20
|
* @param count - Number of UNDO operations to cancel
|
|
21
21
|
* @category Actions
|
|
22
22
|
*/
|
|
23
|
-
export declare const redo: (count?: number) => RedoAction;
|
|
23
|
+
export declare const redo: (count?: number, scope?: OperationScope) => RedoAction;
|
|
24
24
|
/**
|
|
25
25
|
* Joins multiple operations into a single {@link loadState | LOAD_STATE} operation.
|
|
26
26
|
*
|
|
@@ -32,7 +32,7 @@ export declare const redo: (count?: number) => RedoAction;
|
|
|
32
32
|
* @param end - Index of the last operation to prune
|
|
33
33
|
* @category Actions
|
|
34
34
|
*/
|
|
35
|
-
export declare const prune: (start?: number | undefined, end?: number | undefined) => PruneAction;
|
|
35
|
+
export declare const prune: (start?: number | undefined, end?: number | undefined, scope?: OperationScope) => PruneAction;
|
|
36
36
|
/**
|
|
37
37
|
* Replaces the state of the document.
|
|
38
38
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Action, Document, ImmutableStateReducer, State } from '../types';
|
|
1
|
+
import { Action, Document, ImmutableStateReducer, PruneAction, RedoAction, State, UndoAction } from '../types';
|
|
2
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>,
|
|
4
|
-
export declare function redoOperation<T, A extends Action, L>(document: Document<T, A, L>,
|
|
5
|
-
export declare function pruneOperation<T, A extends Action, L>(document: Document<T, A, L>,
|
|
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
6
|
export declare function loadStateOperation<T, A extends Action, L>(oldDocument: Document<T, A, L>, newDocument: {
|
|
7
7
|
name: string;
|
|
8
8
|
state?: State<T, L>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BaseAction } from './actions/types';
|
|
2
2
|
import type { SignalDispatch } from './signal';
|
|
3
|
-
import type { Action, AttachmentRef, Document, ExtendedState, Reducer } from './types';
|
|
3
|
+
import type { Action, AttachmentRef, Document, ExtendedState, OperationScope, Reducer } from './types';
|
|
4
4
|
/**
|
|
5
5
|
* This is an abstract class representing a document and provides methods
|
|
6
6
|
* for creating and manipulating documents.
|
|
@@ -62,7 +62,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
62
62
|
};
|
|
63
63
|
};
|
|
64
64
|
readonly type: "LOAD_STATE";
|
|
65
|
-
readonly scope:
|
|
65
|
+
readonly scope: OperationScope;
|
|
66
66
|
readonly index: number;
|
|
67
67
|
readonly timestamp: string;
|
|
68
68
|
readonly hash: string;
|
|
@@ -72,14 +72,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
72
72
|
readonly start?: import("./types").InputMaybe<number>;
|
|
73
73
|
};
|
|
74
74
|
readonly type: "PRUNE";
|
|
75
|
-
readonly scope:
|
|
75
|
+
readonly scope: OperationScope;
|
|
76
76
|
readonly index: number;
|
|
77
77
|
readonly timestamp: string;
|
|
78
78
|
readonly hash: string;
|
|
79
79
|
} | {
|
|
80
80
|
readonly input: number;
|
|
81
81
|
readonly type: "REDO";
|
|
82
|
-
readonly scope:
|
|
82
|
+
readonly scope: OperationScope;
|
|
83
83
|
readonly index: number;
|
|
84
84
|
readonly timestamp: string;
|
|
85
85
|
readonly hash: string;
|
|
@@ -93,16 +93,64 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
93
93
|
} | {
|
|
94
94
|
readonly input: number;
|
|
95
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";
|
|
96
138
|
readonly scope: "global";
|
|
97
139
|
readonly index: number;
|
|
98
140
|
readonly timestamp: string;
|
|
99
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;
|
|
100
149
|
} | import("immer").Immutable<A & {
|
|
101
150
|
index: number;
|
|
102
151
|
timestamp: string;
|
|
103
152
|
hash: string;
|
|
104
153
|
}>)[];
|
|
105
|
-
readonly local: readonly import("immer").Immutable<import("./types").Operation<A>>[];
|
|
106
154
|
};
|
|
107
155
|
/**
|
|
108
156
|
* Gets the name of the document.
|
|
@@ -121,15 +169,19 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
121
169
|
*/
|
|
122
170
|
get lastModified(): string;
|
|
123
171
|
/**
|
|
124
|
-
* Gets the revision number of the document.
|
|
172
|
+
* Gets the global revision number of the document.
|
|
125
173
|
*/
|
|
126
174
|
get revision(): number;
|
|
175
|
+
getRevision(scope: OperationScope): number;
|
|
127
176
|
/**
|
|
128
177
|
* Gets the initial state of the document.
|
|
129
178
|
*/
|
|
130
179
|
get initialState(): {
|
|
131
180
|
readonly name: string;
|
|
132
|
-
readonly revision:
|
|
181
|
+
readonly revision: {
|
|
182
|
+
readonly global: number;
|
|
183
|
+
readonly local: number;
|
|
184
|
+
};
|
|
133
185
|
readonly documentType: string;
|
|
134
186
|
readonly created: string;
|
|
135
187
|
readonly lastModified: string;
|
|
@@ -151,7 +203,10 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
151
203
|
*/
|
|
152
204
|
toDocument(): {
|
|
153
205
|
readonly name: string;
|
|
154
|
-
readonly revision:
|
|
206
|
+
readonly revision: {
|
|
207
|
+
readonly global: number;
|
|
208
|
+
readonly local: number;
|
|
209
|
+
};
|
|
155
210
|
readonly documentType: string;
|
|
156
211
|
readonly created: string;
|
|
157
212
|
readonly lastModified: string;
|
|
@@ -177,7 +232,7 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
177
232
|
};
|
|
178
233
|
};
|
|
179
234
|
readonly type: "LOAD_STATE";
|
|
180
|
-
readonly scope:
|
|
235
|
+
readonly scope: OperationScope;
|
|
181
236
|
readonly index: number;
|
|
182
237
|
readonly timestamp: string;
|
|
183
238
|
readonly hash: string;
|
|
@@ -187,14 +242,14 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
187
242
|
readonly start?: import("./types").InputMaybe<number>;
|
|
188
243
|
};
|
|
189
244
|
readonly type: "PRUNE";
|
|
190
|
-
readonly scope:
|
|
245
|
+
readonly scope: OperationScope;
|
|
191
246
|
readonly index: number;
|
|
192
247
|
readonly timestamp: string;
|
|
193
248
|
readonly hash: string;
|
|
194
249
|
} | {
|
|
195
250
|
readonly input: number;
|
|
196
251
|
readonly type: "REDO";
|
|
197
|
-
readonly scope:
|
|
252
|
+
readonly scope: OperationScope;
|
|
198
253
|
readonly index: number;
|
|
199
254
|
readonly timestamp: string;
|
|
200
255
|
readonly hash: string;
|
|
@@ -208,20 +263,71 @@ export declare abstract class BaseDocument<T, A extends Action, L = unknown> {
|
|
|
208
263
|
} | {
|
|
209
264
|
readonly input: number;
|
|
210
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";
|
|
211
308
|
readonly scope: "global";
|
|
212
309
|
readonly index: number;
|
|
213
310
|
readonly timestamp: string;
|
|
214
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;
|
|
215
319
|
} | import("immer").Immutable<A & {
|
|
216
320
|
index: number;
|
|
217
321
|
timestamp: string;
|
|
218
322
|
hash: string;
|
|
219
323
|
}>)[];
|
|
220
|
-
readonly local: readonly import("immer").Immutable<import("./types").Operation<A>>[];
|
|
221
324
|
};
|
|
222
325
|
readonly initialState: {
|
|
223
326
|
readonly name: string;
|
|
224
|
-
readonly revision:
|
|
327
|
+
readonly revision: {
|
|
328
|
+
readonly global: number;
|
|
329
|
+
readonly local: number;
|
|
330
|
+
};
|
|
225
331
|
readonly documentType: string;
|
|
226
332
|
readonly created: string;
|
|
227
333
|
readonly lastModified: string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OperationScope } from "..";
|
|
1
2
|
export type Maybe<T> = T | null;
|
|
2
3
|
export type InputMaybe<T> = T | null | undefined;
|
|
3
4
|
export type Exact<T extends {
|
|
@@ -91,7 +92,7 @@ export type Load_State = 'LOAD_STATE';
|
|
|
91
92
|
export type LoadStateAction = {
|
|
92
93
|
input: LoadStateActionInput;
|
|
93
94
|
type: Load_State | `${Load_State}`;
|
|
94
|
-
scope:
|
|
95
|
+
scope: OperationScope;
|
|
95
96
|
};
|
|
96
97
|
export type LoadStateActionInput = {
|
|
97
98
|
operations: Scalars['Int']['input'];
|
|
@@ -135,7 +136,7 @@ export type Prune = 'PRUNE';
|
|
|
135
136
|
export type PruneAction = {
|
|
136
137
|
input: PruneActionInput;
|
|
137
138
|
type: Prune | `${Prune}`;
|
|
138
|
-
scope:
|
|
139
|
+
scope: OperationScope;
|
|
139
140
|
};
|
|
140
141
|
export type PruneActionInput = {
|
|
141
142
|
end?: InputMaybe<Scalars['Int']['input']>;
|
|
@@ -149,7 +150,7 @@ export type Redo = 'REDO';
|
|
|
149
150
|
export type RedoAction = {
|
|
150
151
|
input: Scalars['Int']['input'];
|
|
151
152
|
type: Redo | `${Redo}`;
|
|
152
|
-
scope:
|
|
153
|
+
scope: OperationScope;
|
|
153
154
|
};
|
|
154
155
|
export type Set_Name = 'SET_NAME';
|
|
155
156
|
export type SetNameAction = {
|
|
@@ -169,5 +170,5 @@ export type Undo = 'UNDO';
|
|
|
169
170
|
export type UndoAction = {
|
|
170
171
|
input: Scalars['Int']['input'];
|
|
171
172
|
type: Undo | `${Undo}`;
|
|
172
|
-
scope:
|
|
173
|
+
scope: OperationScope;
|
|
173
174
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { Action, DocumentFile, LoadStateAction, LoadStateActionInput, LoadStateActionStateInput, Operation, PruneAction, PruneActionInput, RedoAction, SetNameAction, SetNameOperation, UndoAction } from '.';
|
|
3
|
+
import { OperationScope } from '../types';
|
|
3
4
|
type Properties<T> = Required<{
|
|
4
5
|
[K in keyof T]: z.ZodType<T[K], any, T[K]>;
|
|
5
6
|
}>;
|
|
@@ -12,42 +13,43 @@ export declare const RedoSchema: z.ZodEnum<["REDO"]>;
|
|
|
12
13
|
export declare const Set_NameSchema: z.ZodEnum<["SET_NAME"]>;
|
|
13
14
|
export declare const UndoSchema: z.ZodEnum<["UNDO"]>;
|
|
14
15
|
export declare function ActionSchema(): z.ZodObject<Properties<Action>>;
|
|
16
|
+
export declare function OperationScopeSchema(): z.ZodType<OperationScope>;
|
|
15
17
|
export declare function BaseActionSchema(): z.ZodUnion<[z.ZodObject<Required<{
|
|
16
18
|
input: z.ZodType<LoadStateActionInput, any, LoadStateActionInput>;
|
|
17
19
|
type: z.ZodType<"LOAD_STATE", any, "LOAD_STATE">;
|
|
18
|
-
scope: z.ZodType<
|
|
20
|
+
scope: z.ZodType<OperationScope, any, OperationScope>;
|
|
19
21
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
20
22
|
input: LoadStateActionInput;
|
|
21
23
|
type: "LOAD_STATE";
|
|
22
|
-
scope: "global";
|
|
24
|
+
scope: "global" | "local";
|
|
23
25
|
}, {
|
|
24
26
|
input: LoadStateActionInput;
|
|
25
27
|
type: "LOAD_STATE";
|
|
26
|
-
scope: "global";
|
|
28
|
+
scope: "global" | "local";
|
|
27
29
|
}>, z.ZodObject<Required<{
|
|
28
30
|
input: z.ZodType<PruneActionInput, any, PruneActionInput>;
|
|
29
31
|
type: z.ZodType<"PRUNE", any, "PRUNE">;
|
|
30
|
-
scope: z.ZodType<
|
|
32
|
+
scope: z.ZodType<OperationScope, any, OperationScope>;
|
|
31
33
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
32
34
|
input: PruneActionInput;
|
|
33
35
|
type: "PRUNE";
|
|
34
|
-
scope: "global";
|
|
36
|
+
scope: "global" | "local";
|
|
35
37
|
}, {
|
|
36
38
|
input: PruneActionInput;
|
|
37
39
|
type: "PRUNE";
|
|
38
|
-
scope: "global";
|
|
40
|
+
scope: "global" | "local";
|
|
39
41
|
}>, z.ZodObject<Required<{
|
|
40
42
|
input: z.ZodType<number, any, number>;
|
|
41
43
|
type: z.ZodType<"REDO", any, "REDO">;
|
|
42
|
-
scope: z.ZodType<
|
|
44
|
+
scope: z.ZodType<OperationScope, any, OperationScope>;
|
|
43
45
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
44
46
|
input: number;
|
|
45
47
|
type: "REDO";
|
|
46
|
-
scope: "global";
|
|
48
|
+
scope: "global" | "local";
|
|
47
49
|
}, {
|
|
48
50
|
input: number;
|
|
49
51
|
type: "REDO";
|
|
50
|
-
scope: "global";
|
|
52
|
+
scope: "global" | "local";
|
|
51
53
|
}>, z.ZodObject<Required<{
|
|
52
54
|
input: z.ZodType<string, any, string>;
|
|
53
55
|
type: z.ZodType<"SET_NAME", any, "SET_NAME">;
|
|
@@ -63,15 +65,15 @@ export declare function BaseActionSchema(): z.ZodUnion<[z.ZodObject<Required<{
|
|
|
63
65
|
}>, z.ZodObject<Required<{
|
|
64
66
|
input: z.ZodType<number, any, number>;
|
|
65
67
|
type: z.ZodType<"UNDO", any, "UNDO">;
|
|
66
|
-
scope: z.ZodType<
|
|
68
|
+
scope: z.ZodType<OperationScope, any, OperationScope>;
|
|
67
69
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
68
70
|
input: number;
|
|
69
71
|
type: "UNDO";
|
|
70
|
-
scope: "global";
|
|
72
|
+
scope: "global" | "local";
|
|
71
73
|
}, {
|
|
72
74
|
input: number;
|
|
73
75
|
type: "UNDO";
|
|
74
|
-
scope: "global";
|
|
76
|
+
scope: "global" | "local";
|
|
75
77
|
}>]>;
|
|
76
78
|
export declare function DocumentFileSchema(): z.ZodObject<Properties<DocumentFile>>;
|
|
77
79
|
export declare function LoadStateActionSchema(): z.ZodObject<Properties<LoadStateAction>>;
|
|
@@ -80,7 +80,7 @@ export type DocumentHeader = {
|
|
|
80
80
|
/** The name of the document. */
|
|
81
81
|
name: string;
|
|
82
82
|
/** The number of operations applied to the document. */
|
|
83
|
-
revision: number
|
|
83
|
+
revision: Required<Record<OperationScope, number>>;
|
|
84
84
|
/** The type of the document model. */
|
|
85
85
|
documentType: string;
|
|
86
86
|
/** The timestamp of the creation date of the document. */
|
|
@@ -123,10 +123,7 @@ export type ExtendedState<GlobalState, LocalState = unknown> = DocumentHeader &
|
|
|
123
123
|
/** The index of document attachments. */
|
|
124
124
|
attachments: FileRegistry;
|
|
125
125
|
};
|
|
126
|
-
export type DocumentOperations<A extends Action> =
|
|
127
|
-
global: Operation<A | BaseAction>[];
|
|
128
|
-
local: Operation<A>[];
|
|
129
|
-
};
|
|
126
|
+
export type DocumentOperations<A extends Action> = Required<Record<OperationScope, Operation<A | BaseAction>[]>>;
|
|
130
127
|
/**
|
|
131
128
|
* The base type of a document model.
|
|
132
129
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { baseReducer } from '../reducer';
|
|
2
|
-
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState } from '../types';
|
|
2
|
+
import { Action, BaseAction, Document, ExtendedState, ImmutableStateReducer, Reducer, Immutable, OperationScope, State, CreateState, PartialState, DocumentOperations, DocumentHeader } from '../types';
|
|
3
|
+
import { SignalDispatch } from '../signal';
|
|
3
4
|
export declare function isBaseAction(action: Action): action is BaseAction;
|
|
4
5
|
/**
|
|
5
6
|
* Helper function to be used by action creators.
|
|
@@ -52,6 +53,9 @@ export declare const createExtendedState: <S, L>(initialState?: Partial<Extended
|
|
|
52
53
|
* @returns The new document state.
|
|
53
54
|
*/
|
|
54
55
|
export declare const createDocument: <S, A extends Action, L = unknown>(initialState?: Partial<ExtendedState<PartialState<S>, PartialState<L>>> | undefined, createState?: ((state?: Partial<State<PartialState<S>, PartialState<L>>> | undefined) => State<S, L>) | undefined) => Document<S, A, L>;
|
|
55
|
-
export declare const hashDocument: (document: Document, scope?: OperationScope) => string;
|
|
56
|
+
export declare const hashDocument: (document: Pick<Document, 'state'>, scope?: OperationScope) => string;
|
|
56
57
|
export declare const hashKey: (date?: Date, randomLimit?: number) => string;
|
|
57
58
|
export declare function readOnly<T>(value: T): Immutable<T>;
|
|
59
|
+
export declare function sortOperations<A extends Action>(operations: DocumentOperations<A>): import("../types").Operation<BaseAction | A>[];
|
|
60
|
+
export declare function replayOperations<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: ImmutableStateReducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader, documentReducer?: typeof baseReducer): Document<T, A, L>;
|
|
61
|
+
export declare function replayDocument<T, A extends Action, L>(initialState: ExtendedState<T, L>, operations: DocumentOperations<A>, reducer: Reducer<T, A, L>, dispatch?: SignalDispatch, header?: DocumentHeader): Document<T, A, L>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { AddChangeLogItemInput, AddModuleInput, AddOperationErrorInput, AddOperationExampleInput, AddOperationInput, AddStateExampleInput, Author, CodeExample, DeleteChangeLogItemInput, DeleteModuleInput, DeleteOperationErrorInput, DeleteOperationExampleInput, DeleteOperationInput, DeleteStateExampleInput, DocumentModelState, DocumentSpecification, Module, MoveOperationInput, Operation, OperationError, ReorderChangeLogItemsInput, ReorderModuleOperationsInput, ReorderModulesInput, ReorderOperationErrorsInput, ReorderOperationExamplesInput, ReorderStateExamplesInput, ScopeState, SetAuthorNameInput, SetAuthorWebsiteInput, SetInitialStateInput, SetModelDescriptionInput, SetModelExtensionInput, SetModelIdInput, SetModelNameInput, SetModuleDescriptionInput, SetModuleNameInput, SetOperationDescriptionInput, SetOperationErrorCodeInput, SetOperationErrorDescriptionInput, SetOperationErrorNameInput, SetOperationErrorTemplateInput, SetOperationNameInput, SetOperationReducerInput, SetOperationSchemaInput, SetOperationScopeInput, SetOperationTemplateInput, SetStateSchemaInput, State, UpdateChangeLogItemInput, UpdateOperationExampleInput, UpdateStateExampleInput } from '.';
|
|
3
|
+
import { OperationScope } from '../../../document';
|
|
3
4
|
type Properties<T> = Required<{
|
|
4
5
|
[K in keyof T]: z.ZodType<T[K], any, T[K]>;
|
|
5
6
|
}>;
|
|
@@ -20,6 +21,7 @@ export declare function DeleteOperationErrorInputSchema(): z.ZodObject<Propertie
|
|
|
20
21
|
export declare function DeleteOperationExampleInputSchema(): z.ZodObject<Properties<DeleteOperationExampleInput>>;
|
|
21
22
|
export declare function DeleteOperationInputSchema(): z.ZodObject<Properties<DeleteOperationInput>>;
|
|
22
23
|
export declare function DeleteStateExampleInputSchema(): z.ZodObject<Properties<DeleteStateExampleInput>>;
|
|
24
|
+
export declare function OperationScopeSchema(): z.ZodType<OperationScope>;
|
|
23
25
|
export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Required<{
|
|
24
26
|
__typename?: z.ZodType<"AddChangeLogItemInput" | undefined, any, "AddChangeLogItemInput" | undefined> | undefined;
|
|
25
27
|
content: z.ZodType<string, any, string>;
|
|
@@ -88,7 +90,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
|
|
|
88
90
|
reducer?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
|
|
89
91
|
schema?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
|
|
90
92
|
template?: z.ZodType<import("./types").InputMaybe<string>, any, import("./types").InputMaybe<string>> | undefined;
|
|
91
|
-
scope?: z.ZodType<import("./types").InputMaybe<
|
|
93
|
+
scope?: z.ZodType<import("./types").InputMaybe<OperationScope>, any, import("./types").InputMaybe<OperationScope>> | undefined;
|
|
92
94
|
}>, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
93
95
|
id: string;
|
|
94
96
|
name: string;
|
|
@@ -97,7 +99,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
|
|
|
97
99
|
reducer?: import("./types").InputMaybe<string>;
|
|
98
100
|
schema?: import("./types").InputMaybe<string>;
|
|
99
101
|
template?: import("./types").InputMaybe<string>;
|
|
100
|
-
scope?: import("./types").InputMaybe<
|
|
102
|
+
scope?: import("./types").InputMaybe<OperationScope>;
|
|
101
103
|
}, {
|
|
102
104
|
id: string;
|
|
103
105
|
name: string;
|
|
@@ -106,7 +108,7 @@ export declare function DocumentModelInputSchema(): z.ZodUnion<[z.ZodObject<Requ
|
|
|
106
108
|
reducer?: import("./types").InputMaybe<string>;
|
|
107
109
|
schema?: import("./types").InputMaybe<string>;
|
|
108
110
|
template?: import("./types").InputMaybe<string>;
|
|
109
|
-
scope?: import("./types").InputMaybe<
|
|
111
|
+
scope?: import("./types").InputMaybe<OperationScope>;
|
|
110
112
|
}>, z.ZodObject<Required<{
|
|
111
113
|
scope: z.ZodType<string, any, string>;
|
|
112
114
|
example: z.ZodType<string, any, string>;
|
|
@@ -63,9 +63,9 @@ declare const actions: {
|
|
|
63
63
|
deleteStateExample: (input: import("./gen").DeleteStateExampleInput) => import("./gen").DeleteStateExampleAction;
|
|
64
64
|
reorderStateExamples: (input: import("./gen").ReorderStateExamplesInput) => import("./gen").ReorderStateExamplesAction;
|
|
65
65
|
setName: (name: string) => import("../document").SetNameAction;
|
|
66
|
-
undo: (count?: number) => import("../document").UndoAction;
|
|
67
|
-
redo: (count?: number) => import("../document").RedoAction;
|
|
68
|
-
prune: (start?: number | undefined, end?: number | undefined) => import("../document").PruneAction;
|
|
66
|
+
undo: (count?: number, scope?: import("../document").OperationScope) => import("../document").UndoAction;
|
|
67
|
+
redo: (count?: number, scope?: import("../document").OperationScope) => import("../document").RedoAction;
|
|
68
|
+
prune: (start?: number | undefined, end?: number | undefined, scope?: import("../document").OperationScope) => import("../document").PruneAction;
|
|
69
69
|
loadState: <S, T>(state: Pick<import("../document").ExtendedState<S, T>, "name" | "state">, operations: number) => import("../document").LoadStateAction;
|
|
70
70
|
};
|
|
71
71
|
export declare const module: _DocumentModel<DocumentModelState, DocumentModelAction, DocumentModelLocalState, DocumentModel>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./internal/object-ac706c4a.js");require("json-stringify-deterministic");require("immer");require("jszip");require("crypto");require("fs");require("https");require("path");const e=require("./internal/index-bfc402ef.js");require("zod");exports.Document=e.Document;exports.DocumentModel=e.DocumentModel$1;exports.actions=e.actions;exports.documentModel=e.documentModel;exports.module=e.module;exports.reducer=e.reducer;exports.utils=e.utils;exports.z=e.zod;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import "./internal/object-
|
|
1
|
+
import "./internal/object-b97efc1b.js";
|
|
2
2
|
import "json-stringify-deterministic";
|
|
3
3
|
import "immer";
|
|
4
|
+
import "jszip";
|
|
4
5
|
import "crypto";
|
|
5
6
|
import "fs";
|
|
6
7
|
import "https";
|
|
7
8
|
import "path";
|
|
8
|
-
import "
|
|
9
|
-
import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-09364517.js";
|
|
9
|
+
import { b as d, a as l, c as n, d as D, m as M, r as b, u as f, z as x } from "./internal/index-14279b3a.js";
|
|
10
10
|
import "zod";
|
|
11
11
|
export {
|
|
12
12
|
d as Document,
|
package/dist/node/document.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./internal/object-ac706c4a.js"),r=require("./internal/index-4b25c8a5.js");require("json-stringify-deterministic");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");exports.BaseDocument=e.BaseDocument;exports.actions=e.BaseActions;exports.applyMixins=e.applyMixins;exports.baseReducer=e.baseReducer;exports.z=e.zod;exports.utils=r.index;
|
package/dist/node/document.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { B as
|
|
2
|
-
import { i as b } from "./internal/index-
|
|
1
|
+
import { B as c, h as n, g as x, u as f, z as l } from "./internal/object-b97efc1b.js";
|
|
2
|
+
import { i as b } from "./internal/index-e02d7854.js";
|
|
3
3
|
import "json-stringify-deterministic";
|
|
4
4
|
import "immer";
|
|
5
|
+
import "zod";
|
|
5
6
|
import "jszip";
|
|
6
7
|
import "crypto";
|
|
7
8
|
import "fs";
|
|
8
9
|
import "https";
|
|
9
10
|
import "path";
|
|
10
|
-
import "zod";
|
|
11
11
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
c as BaseDocument,
|
|
13
|
+
n as actions,
|
|
14
14
|
x as applyMixins,
|
|
15
15
|
f as baseReducer,
|
|
16
16
|
b as utils,
|
package/dist/node/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./internal/index-4b25c8a5.js"),o=require("./internal/index-bfc402ef.js");require("./internal/object-ac706c4a.js");require("json-stringify-deterministic");require("immer");require("zod");require("jszip");require("crypto");require("fs");require("https");require("path");const u={"powerhouse/document":e.Document,"powerhouse/document-model":o.DocumentModel},r={Document:e.Document,DocumentModel:o.DocumentModel};exports.Document=e.Document;exports.DocumentModel=o.DocumentModel;exports.DocumentModels=u;exports.default=r;
|
package/dist/node/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { D as o } from "./internal/index-
|
|
2
|
-
import { D as t } from "./internal/index-
|
|
3
|
-
import "./internal/object-
|
|
1
|
+
import { D as o } from "./internal/index-e02d7854.js";
|
|
2
|
+
import { D as t } from "./internal/index-14279b3a.js";
|
|
3
|
+
import "./internal/object-b97efc1b.js";
|
|
4
4
|
import "json-stringify-deterministic";
|
|
5
5
|
import "immer";
|
|
6
|
+
import "zod";
|
|
6
7
|
import "jszip";
|
|
7
8
|
import "crypto";
|
|
8
9
|
import "fs";
|
|
9
10
|
import "https";
|
|
10
11
|
import "path";
|
|
11
|
-
import "zod";
|
|
12
12
|
const a = {
|
|
13
13
|
"powerhouse/document": o,
|
|
14
14
|
"powerhouse/document-model": t
|