document-drive 1.0.0-alpha.51 → 1.0.0-alpha.52
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/package.json
CHANGED
package/src/server/index.ts
CHANGED
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
} from '../utils/document-helpers';
|
|
44
44
|
import { requestPublicDrive } from '../utils/graphql';
|
|
45
45
|
import { logger } from '../utils/logger';
|
|
46
|
-
import { OperationError } from './error';
|
|
46
|
+
import { ConflictOperationError, OperationError } from './error';
|
|
47
47
|
import { ListenerManager } from './listener/manager';
|
|
48
48
|
import {
|
|
49
49
|
CancelPullLoop,
|
|
@@ -113,13 +113,8 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
113
113
|
|
|
114
114
|
private async saveStrand(strand: StrandUpdate) {
|
|
115
115
|
const operations: Operation[] = strand.operations.map(
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
type,
|
|
119
|
-
hash,
|
|
120
|
-
input,
|
|
121
|
-
skip,
|
|
122
|
-
timestamp,
|
|
116
|
+
(op) => ({
|
|
117
|
+
...op,
|
|
123
118
|
scope: strand.scope,
|
|
124
119
|
branch: strand.branch
|
|
125
120
|
})
|
|
@@ -411,7 +406,8 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
411
406
|
timestamp: operation.timestamp,
|
|
412
407
|
type: operation.type,
|
|
413
408
|
input: operation.input as object,
|
|
414
|
-
skip: operation.skip
|
|
409
|
+
skip: operation.skip,
|
|
410
|
+
context: operation.context
|
|
415
411
|
}));
|
|
416
412
|
}
|
|
417
413
|
|
|
@@ -771,10 +767,9 @@ export class DocumentDriveServer extends BaseDocumentDriveServer {
|
|
|
771
767
|
appliedOperation[0]!.hash !== operation.hash &&
|
|
772
768
|
!skipHashValidation
|
|
773
769
|
) {
|
|
774
|
-
throw new
|
|
775
|
-
'CONFLICT',
|
|
770
|
+
throw new ConflictOperationError(
|
|
776
771
|
operation,
|
|
777
|
-
|
|
772
|
+
appliedOperation[0]!
|
|
778
773
|
);
|
|
779
774
|
}
|
|
780
775
|
|
|
@@ -159,6 +159,20 @@ export class PullResponderTransmitter implements IPullResponderTransmitter {
|
|
|
159
159
|
input
|
|
160
160
|
hash
|
|
161
161
|
index
|
|
162
|
+
context {
|
|
163
|
+
signer {
|
|
164
|
+
user {
|
|
165
|
+
address
|
|
166
|
+
networkId
|
|
167
|
+
chainId
|
|
168
|
+
}
|
|
169
|
+
app {
|
|
170
|
+
name
|
|
171
|
+
key
|
|
172
|
+
}
|
|
173
|
+
signature
|
|
174
|
+
}
|
|
175
|
+
}
|
|
162
176
|
}
|
|
163
177
|
}
|
|
164
178
|
}
|
|
@@ -224,13 +238,8 @@ export class PullResponderTransmitter implements IPullResponderTransmitter {
|
|
|
224
238
|
|
|
225
239
|
for (const strand of strands) {
|
|
226
240
|
const operations: Operation[] = strand.operations.map(
|
|
227
|
-
(
|
|
228
|
-
|
|
229
|
-
type,
|
|
230
|
-
hash,
|
|
231
|
-
input,
|
|
232
|
-
skip,
|
|
233
|
-
timestamp,
|
|
241
|
+
(op) => ({
|
|
242
|
+
...op,
|
|
234
243
|
scope: strand.scope,
|
|
235
244
|
branch: strand.branch
|
|
236
245
|
})
|
package/src/server/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
} from 'document-model-libs/document-drive';
|
|
9
9
|
import type {
|
|
10
10
|
Action,
|
|
11
|
+
ActionContext,
|
|
11
12
|
BaseAction,
|
|
12
13
|
CreateChildDocumentInput,
|
|
13
14
|
Document,
|
|
@@ -114,6 +115,7 @@ export type OperationUpdate = {
|
|
|
114
115
|
type: string;
|
|
115
116
|
input: object;
|
|
116
117
|
hash: string;
|
|
118
|
+
context?: ActionContext;
|
|
117
119
|
};
|
|
118
120
|
|
|
119
121
|
export type StrandUpdate = {
|
package/src/storage/prisma.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
DocumentDriveState
|
|
8
8
|
} from 'document-model-libs/document-drive';
|
|
9
9
|
import type {
|
|
10
|
+
ActionContext,
|
|
10
11
|
BaseAction,
|
|
11
12
|
DocumentHeader,
|
|
12
13
|
ExtendedState,
|
|
@@ -33,7 +34,8 @@ function storageToOperation(
|
|
|
33
34
|
timestamp: new Date(op.timestamp).toISOString(),
|
|
34
35
|
input: op.input,
|
|
35
36
|
type: op.type,
|
|
36
|
-
scope: op.scope as OperationScope
|
|
37
|
+
scope: op.scope as OperationScope,
|
|
38
|
+
context: op.context ? op.context as ActionContext : undefined,
|
|
37
39
|
// attachments: fileRegistry
|
|
38
40
|
};
|
|
39
41
|
}
|
|
@@ -151,7 +153,8 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
151
153
|
type: op.type,
|
|
152
154
|
scope: op.scope,
|
|
153
155
|
branch: 'main',
|
|
154
|
-
skip: op.skip
|
|
156
|
+
skip: op.skip,
|
|
157
|
+
context: op.context
|
|
155
158
|
}))
|
|
156
159
|
});
|
|
157
160
|
|
|
@@ -177,7 +180,8 @@ export class PrismaStorage implements IDriveStorage {
|
|
|
177
180
|
type: op.type,
|
|
178
181
|
scope: op.scope,
|
|
179
182
|
branch: 'main',
|
|
180
|
-
skip: op.skip
|
|
183
|
+
skip: op.skip,
|
|
184
|
+
context: op.context
|
|
181
185
|
}
|
|
182
186
|
})
|
|
183
187
|
)
|