@yorkie-js/sdk 0.6.22 → 0.6.23
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/yorkie-js-sdk.d.ts +38 -43
- package/dist/yorkie-js-sdk.es.js +282 -56
- package/dist/yorkie-js-sdk.es.js.map +1 -1
- package/dist/yorkie-js-sdk.js +282 -56
- package/dist/yorkie-js-sdk.js.map +1 -1
- package/package.json +2 -2
package/dist/yorkie-js-sdk.d.ts
CHANGED
|
@@ -47,12 +47,32 @@ declare type AddOpInfo_2 = {
|
|
|
47
47
|
/**
|
|
48
48
|
* `ArrayOperationInfo` represents the OperationInfo for the JSONArray.
|
|
49
49
|
*/
|
|
50
|
-
export declare type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo;
|
|
50
|
+
export declare type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo | ArraySetOpInfo_2;
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* `ArrayOperationInfo` represents the OperationInfo for the JSONArray.
|
|
54
54
|
*/
|
|
55
|
-
declare type ArrayOperationInfo_2 =
|
|
55
|
+
declare type ArrayOperationInfo_2 =
|
|
56
|
+
| AddOpInfo_2
|
|
57
|
+
| RemoveOpInfo_2
|
|
58
|
+
| MoveOpInfo_2
|
|
59
|
+
| ArraySetOpInfo;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* `ArraySetOpInfo` represents the information of the array set operation.
|
|
63
|
+
*/
|
|
64
|
+
declare type ArraySetOpInfo = {
|
|
65
|
+
type: 'array-set';
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* `ArraySetOpInfo` represents the information of the array set operation.
|
|
71
|
+
*/
|
|
72
|
+
declare type ArraySetOpInfo_2 = {
|
|
73
|
+
type: 'array-set';
|
|
74
|
+
path: string;
|
|
75
|
+
};
|
|
56
76
|
|
|
57
77
|
/**
|
|
58
78
|
* `AttachOptions` are user-settable options used when attaching documents.
|
|
@@ -3195,6 +3215,14 @@ export declare type JSONArray<T> = {
|
|
|
3195
3215
|
* `getLast` returns the last element of this array.
|
|
3196
3216
|
*/
|
|
3197
3217
|
getLast?(): WrappedElement<T>;
|
|
3218
|
+
/**
|
|
3219
|
+
* `setInteger` sets the element of the given index.
|
|
3220
|
+
*/
|
|
3221
|
+
setInteger?(index: number, value: number): WrappedElement<T>;
|
|
3222
|
+
/**
|
|
3223
|
+
* `delete` deletes the element of the given index.
|
|
3224
|
+
*/
|
|
3225
|
+
delete?(index: number): WrappedElement<T>;
|
|
3198
3226
|
/**
|
|
3199
3227
|
* `deleteByID` deletes the element of the given ID.
|
|
3200
3228
|
*/
|
|
@@ -3207,6 +3235,10 @@ export declare type JSONArray<T> = {
|
|
|
3207
3235
|
* `insertAfter` inserts a value after the given previous element.
|
|
3208
3236
|
*/
|
|
3209
3237
|
insertAfter?(prevID: TimeTicket, value: any): WrappedElement<T>;
|
|
3238
|
+
/**
|
|
3239
|
+
* `insertIntegerAfter` inserts a value after the given index.
|
|
3240
|
+
*/
|
|
3241
|
+
insertIntegerAfter?(index: number, value: number): WrappedElement<T>;
|
|
3210
3242
|
/**
|
|
3211
3243
|
* `moveBefore` moves the element before the given next element.
|
|
3212
3244
|
*/
|
|
@@ -3215,6 +3247,10 @@ export declare type JSONArray<T> = {
|
|
|
3215
3247
|
* `moveAfter` moves the element after the given previous element.
|
|
3216
3248
|
*/
|
|
3217
3249
|
moveAfter?(prevID: TimeTicket, id: TimeTicket): void;
|
|
3250
|
+
/**
|
|
3251
|
+
* `moveAfterByIndex` moves the element after the given index.
|
|
3252
|
+
*/
|
|
3253
|
+
moveAfterByIndex?(prevIndex: number, targetIndex: number): void;
|
|
3218
3254
|
/**
|
|
3219
3255
|
* `moveFront` moves the element before the first element.
|
|
3220
3256
|
*/
|
|
@@ -3657,12 +3693,6 @@ declare class Operation_2 extends Message<Operation_2> {
|
|
|
3657
3693
|
*/
|
|
3658
3694
|
value: Operation_Edit;
|
|
3659
3695
|
case: "edit";
|
|
3660
|
-
} | {
|
|
3661
|
-
/**
|
|
3662
|
-
* @generated from field: yorkie.v1.Operation.Select select = 6;
|
|
3663
|
-
*/
|
|
3664
|
-
value: Operation_Select;
|
|
3665
|
-
case: "select";
|
|
3666
3696
|
} | {
|
|
3667
3697
|
/**
|
|
3668
3698
|
* @generated from field: yorkie.v1.Operation.Style style = 7;
|
|
@@ -3897,41 +3927,6 @@ declare class Operation_Remove extends Message<Operation_Remove> {
|
|
|
3897
3927
|
static equals(a: Operation_Remove | PlainMessage<Operation_Remove> | undefined, b: Operation_Remove | PlainMessage<Operation_Remove> | undefined): boolean;
|
|
3898
3928
|
}
|
|
3899
3929
|
|
|
3900
|
-
/**
|
|
3901
|
-
* NOTE(hackerwins): Select Operation is not used in the current version.
|
|
3902
|
-
* In the previous version, it was used to represent selection of Text.
|
|
3903
|
-
* However, it has been replaced by Presence now. It is retained for backward
|
|
3904
|
-
* compatibility purposes.
|
|
3905
|
-
*
|
|
3906
|
-
* @generated from message yorkie.v1.Operation.Select
|
|
3907
|
-
*/
|
|
3908
|
-
declare class Operation_Select extends Message<Operation_Select> {
|
|
3909
|
-
/**
|
|
3910
|
-
* @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;
|
|
3911
|
-
*/
|
|
3912
|
-
parentCreatedAt?: TimeTicket_2;
|
|
3913
|
-
/**
|
|
3914
|
-
* @generated from field: yorkie.v1.TextNodePos from = 2;
|
|
3915
|
-
*/
|
|
3916
|
-
from?: TextNodePos;
|
|
3917
|
-
/**
|
|
3918
|
-
* @generated from field: yorkie.v1.TextNodePos to = 3;
|
|
3919
|
-
*/
|
|
3920
|
-
to?: TextNodePos;
|
|
3921
|
-
/**
|
|
3922
|
-
* @generated from field: yorkie.v1.TimeTicket executed_at = 4;
|
|
3923
|
-
*/
|
|
3924
|
-
executedAt?: TimeTicket_2;
|
|
3925
|
-
constructor(data?: PartialMessage<Operation_Select>);
|
|
3926
|
-
static readonly runtime: typeof proto3;
|
|
3927
|
-
static readonly typeName = "yorkie.v1.Operation.Select";
|
|
3928
|
-
static readonly fields: FieldList;
|
|
3929
|
-
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Select;
|
|
3930
|
-
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Select;
|
|
3931
|
-
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Select;
|
|
3932
|
-
static equals(a: Operation_Select | PlainMessage<Operation_Select> | undefined, b: Operation_Select | PlainMessage<Operation_Select> | undefined): boolean;
|
|
3933
|
-
}
|
|
3934
|
-
|
|
3935
3930
|
/**
|
|
3936
3931
|
* @generated from message yorkie.v1.Operation.Set
|
|
3937
3932
|
*/
|
package/dist/yorkie-js-sdk.es.js
CHANGED
|
@@ -4657,7 +4657,6 @@ let Operation$1 = (_e = class extends Message {
|
|
|
4657
4657
|
{ no: 3, name: "move", kind: "message", T: Operation_Move, oneof: "body" },
|
|
4658
4658
|
{ no: 4, name: "remove", kind: "message", T: Operation_Remove, oneof: "body" },
|
|
4659
4659
|
{ no: 5, name: "edit", kind: "message", T: Operation_Edit, oneof: "body" },
|
|
4660
|
-
{ no: 6, name: "select", kind: "message", T: Operation_Select, oneof: "body" },
|
|
4661
4660
|
{ no: 7, name: "style", kind: "message", T: Operation_Style, oneof: "body" },
|
|
4662
4661
|
{ no: 8, name: "increase", kind: "message", T: Operation_Increase, oneof: "body" },
|
|
4663
4662
|
{ no: 9, name: "tree_edit", kind: "message", T: Operation_TreeEdit, oneof: "body" },
|
|
@@ -4907,49 +4906,6 @@ __publicField(_Operation_Edit, "fields", proto3.util.newFieldList(() => [
|
|
|
4907
4906
|
} }
|
|
4908
4907
|
]));
|
|
4909
4908
|
let Operation_Edit = _Operation_Edit;
|
|
4910
|
-
const _Operation_Select = class _Operation_Select extends Message {
|
|
4911
|
-
constructor(data) {
|
|
4912
|
-
super();
|
|
4913
|
-
/**
|
|
4914
|
-
* @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;
|
|
4915
|
-
*/
|
|
4916
|
-
__publicField(this, "parentCreatedAt");
|
|
4917
|
-
/**
|
|
4918
|
-
* @generated from field: yorkie.v1.TextNodePos from = 2;
|
|
4919
|
-
*/
|
|
4920
|
-
__publicField(this, "from");
|
|
4921
|
-
/**
|
|
4922
|
-
* @generated from field: yorkie.v1.TextNodePos to = 3;
|
|
4923
|
-
*/
|
|
4924
|
-
__publicField(this, "to");
|
|
4925
|
-
/**
|
|
4926
|
-
* @generated from field: yorkie.v1.TimeTicket executed_at = 4;
|
|
4927
|
-
*/
|
|
4928
|
-
__publicField(this, "executedAt");
|
|
4929
|
-
proto3.util.initPartial(data, this);
|
|
4930
|
-
}
|
|
4931
|
-
static fromBinary(bytes, options) {
|
|
4932
|
-
return new _Operation_Select().fromBinary(bytes, options);
|
|
4933
|
-
}
|
|
4934
|
-
static fromJson(jsonValue, options) {
|
|
4935
|
-
return new _Operation_Select().fromJson(jsonValue, options);
|
|
4936
|
-
}
|
|
4937
|
-
static fromJsonString(jsonString, options) {
|
|
4938
|
-
return new _Operation_Select().fromJsonString(jsonString, options);
|
|
4939
|
-
}
|
|
4940
|
-
static equals(a, b) {
|
|
4941
|
-
return proto3.util.equals(_Operation_Select, a, b);
|
|
4942
|
-
}
|
|
4943
|
-
};
|
|
4944
|
-
__publicField(_Operation_Select, "runtime", proto3);
|
|
4945
|
-
__publicField(_Operation_Select, "typeName", "yorkie.v1.Operation.Select");
|
|
4946
|
-
__publicField(_Operation_Select, "fields", proto3.util.newFieldList(() => [
|
|
4947
|
-
{ no: 1, name: "parent_created_at", kind: "message", T: TimeTicket$1 },
|
|
4948
|
-
{ no: 2, name: "from", kind: "message", T: TextNodePos },
|
|
4949
|
-
{ no: 3, name: "to", kind: "message", T: TextNodePos },
|
|
4950
|
-
{ no: 4, name: "executed_at", kind: "message", T: TimeTicket$1 }
|
|
4951
|
-
]));
|
|
4952
|
-
let Operation_Select = _Operation_Select;
|
|
4953
4909
|
const _Operation_Style = class _Operation_Style extends Message {
|
|
4954
4910
|
constructor(data) {
|
|
4955
4911
|
super();
|
|
@@ -6412,9 +6368,9 @@ const _DocumentSummary = class _DocumentSummary extends Message {
|
|
|
6412
6368
|
*/
|
|
6413
6369
|
__publicField(this, "key", "");
|
|
6414
6370
|
/**
|
|
6415
|
-
* @generated from field: string
|
|
6371
|
+
* @generated from field: string root = 3;
|
|
6416
6372
|
*/
|
|
6417
|
-
__publicField(this, "
|
|
6373
|
+
__publicField(this, "root", "");
|
|
6418
6374
|
/**
|
|
6419
6375
|
* @generated from field: int32 attached_clients = 7;
|
|
6420
6376
|
*/
|
|
@@ -6427,6 +6383,10 @@ const _DocumentSummary = class _DocumentSummary extends Message {
|
|
|
6427
6383
|
* @generated from field: string schema_key = 9;
|
|
6428
6384
|
*/
|
|
6429
6385
|
__publicField(this, "schemaKey", "");
|
|
6386
|
+
/**
|
|
6387
|
+
* @generated from field: map<string, yorkie.v1.Presence> presences = 10;
|
|
6388
|
+
*/
|
|
6389
|
+
__publicField(this, "presences", {});
|
|
6430
6390
|
/**
|
|
6431
6391
|
* @generated from field: google.protobuf.Timestamp created_at = 4;
|
|
6432
6392
|
*/
|
|
@@ -6473,7 +6433,7 @@ __publicField(_DocumentSummary, "fields", proto3.util.newFieldList(() => [
|
|
|
6473
6433
|
},
|
|
6474
6434
|
{
|
|
6475
6435
|
no: 3,
|
|
6476
|
-
name: "
|
|
6436
|
+
name: "root",
|
|
6477
6437
|
kind: "scalar",
|
|
6478
6438
|
T: 9
|
|
6479
6439
|
/* ScalarType.STRING */
|
|
@@ -6493,6 +6453,7 @@ __publicField(_DocumentSummary, "fields", proto3.util.newFieldList(() => [
|
|
|
6493
6453
|
T: 9
|
|
6494
6454
|
/* ScalarType.STRING */
|
|
6495
6455
|
},
|
|
6456
|
+
{ no: 10, name: "presences", kind: "map", K: 9, V: { kind: "message", T: Presence$1 } },
|
|
6496
6457
|
{ no: 4, name: "created_at", kind: "message", T: Timestamp },
|
|
6497
6458
|
{ no: 5, name: "accessed_at", kind: "message", T: Timestamp },
|
|
6498
6459
|
{ no: 6, name: "updated_at", kind: "message", T: Timestamp }
|
|
@@ -8247,7 +8208,7 @@ class CRDTElement {
|
|
|
8247
8208
|
* `remove` removes this element.
|
|
8248
8209
|
*/
|
|
8249
8210
|
remove(removedAt) {
|
|
8250
|
-
if (removedAt && removedAt.after(this.
|
|
8211
|
+
if (removedAt && removedAt.after(this.createdAt) && (!this.removedAt || removedAt.after(this.removedAt))) {
|
|
8251
8212
|
this.removedAt = removedAt;
|
|
8252
8213
|
return true;
|
|
8253
8214
|
}
|
|
@@ -10281,6 +10242,7 @@ class RGATreeListNode extends SplayNode {
|
|
|
10281
10242
|
super(value);
|
|
10282
10243
|
__publicField(this, "prev");
|
|
10283
10244
|
__publicField(this, "next");
|
|
10245
|
+
__publicField(this, "movedFrom");
|
|
10284
10246
|
this.value = value;
|
|
10285
10247
|
}
|
|
10286
10248
|
/**
|
|
@@ -10347,6 +10309,18 @@ class RGATreeListNode extends SplayNode {
|
|
|
10347
10309
|
getNext() {
|
|
10348
10310
|
return this.next;
|
|
10349
10311
|
}
|
|
10312
|
+
/**
|
|
10313
|
+
* `getMovedFrom` returns the previous element before the element moved.
|
|
10314
|
+
*/
|
|
10315
|
+
getMovedFrom() {
|
|
10316
|
+
return this.movedFrom;
|
|
10317
|
+
}
|
|
10318
|
+
/**
|
|
10319
|
+
* `setMovedFrom` sets the previous element before the element moved.
|
|
10320
|
+
*/
|
|
10321
|
+
setMovedFrom(movedFrom) {
|
|
10322
|
+
this.movedFrom = movedFrom;
|
|
10323
|
+
}
|
|
10350
10324
|
/**
|
|
10351
10325
|
* `getValue` returns a element value.
|
|
10352
10326
|
*/
|
|
@@ -10406,6 +10380,9 @@ class RGATreeList {
|
|
|
10406
10380
|
`cant find the given node: ${createdAt.toIDString()}`
|
|
10407
10381
|
);
|
|
10408
10382
|
}
|
|
10383
|
+
while (node.getValue().getMovedAt() && node.getValue().getMovedAt().after(executedAt) && node.getMovedFrom()) {
|
|
10384
|
+
node = node.getMovedFrom();
|
|
10385
|
+
}
|
|
10409
10386
|
while (node.getNext() && node.getNext().getPositionedAt().after(executedAt)) {
|
|
10410
10387
|
node = node.getNext();
|
|
10411
10388
|
}
|
|
@@ -10430,30 +10407,51 @@ class RGATreeList {
|
|
|
10430
10407
|
}
|
|
10431
10408
|
this.nodeMapByIndex.insertAfter(prevNode, newNode);
|
|
10432
10409
|
this.nodeMapByCreatedAt.set(newNode.getCreatedAt().toIDString(), newNode);
|
|
10410
|
+
return newNode;
|
|
10433
10411
|
}
|
|
10434
10412
|
/**
|
|
10435
10413
|
* `moveAfter` moves the given `createdAt` element
|
|
10436
10414
|
* after the `prevCreatedAt` element.
|
|
10437
10415
|
*/
|
|
10438
10416
|
moveAfter(prevCreatedAt, createdAt, executedAt) {
|
|
10439
|
-
|
|
10417
|
+
let prevNode = this.nodeMapByCreatedAt.get(prevCreatedAt.toIDString());
|
|
10440
10418
|
if (!prevNode) {
|
|
10441
10419
|
throw new YorkieError(
|
|
10442
10420
|
Code.ErrInvalidArgument,
|
|
10443
10421
|
`cant find the given node: ${prevCreatedAt.toIDString()}`
|
|
10444
10422
|
);
|
|
10445
10423
|
}
|
|
10446
|
-
|
|
10424
|
+
let node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
|
|
10447
10425
|
if (!node) {
|
|
10448
10426
|
throw new YorkieError(
|
|
10449
10427
|
Code.ErrInvalidArgument,
|
|
10450
10428
|
`cant find the given node: ${createdAt.toIDString()}`
|
|
10451
10429
|
);
|
|
10452
10430
|
}
|
|
10453
|
-
if (prevNode !== node &&
|
|
10431
|
+
if (prevNode !== node && executedAt.after(node.getPositionedAt())) {
|
|
10432
|
+
const movedFrom = node.getPrev();
|
|
10433
|
+
let nextNode = node.getNext();
|
|
10454
10434
|
this.release(node);
|
|
10455
|
-
this.insertAfter(
|
|
10435
|
+
node = this.insertAfter(
|
|
10436
|
+
prevNode.getCreatedAt(),
|
|
10437
|
+
node.getValue(),
|
|
10438
|
+
executedAt
|
|
10439
|
+
);
|
|
10456
10440
|
node.getValue().setMovedAt(executedAt);
|
|
10441
|
+
node.setMovedFrom(movedFrom);
|
|
10442
|
+
while (nextNode && nextNode.getPositionedAt().after(executedAt)) {
|
|
10443
|
+
prevNode = node;
|
|
10444
|
+
node = nextNode;
|
|
10445
|
+
nextNode = node.getNext();
|
|
10446
|
+
this.release(node);
|
|
10447
|
+
node = this.insertAfter(
|
|
10448
|
+
prevNode.getCreatedAt(),
|
|
10449
|
+
node.getValue(),
|
|
10450
|
+
executedAt
|
|
10451
|
+
);
|
|
10452
|
+
node.getValue().setMovedAt(executedAt);
|
|
10453
|
+
node.setMovedFrom(movedFrom);
|
|
10454
|
+
}
|
|
10457
10455
|
}
|
|
10458
10456
|
}
|
|
10459
10457
|
/**
|
|
@@ -10532,6 +10530,20 @@ class RGATreeList {
|
|
|
10532
10530
|
}
|
|
10533
10531
|
return node.getValue();
|
|
10534
10532
|
}
|
|
10533
|
+
/**
|
|
10534
|
+
* `set` sets the given element at the given creation time.
|
|
10535
|
+
*/
|
|
10536
|
+
set(createdAt, element, executedAt) {
|
|
10537
|
+
const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());
|
|
10538
|
+
if (!node) {
|
|
10539
|
+
throw new YorkieError(
|
|
10540
|
+
Code.ErrInvalidArgument,
|
|
10541
|
+
`cant find the given node: ${createdAt.toIDString()}`
|
|
10542
|
+
);
|
|
10543
|
+
}
|
|
10544
|
+
this.insertAfter(node.getCreatedAt(), element, executedAt);
|
|
10545
|
+
return this.delete(createdAt, executedAt);
|
|
10546
|
+
}
|
|
10535
10547
|
/**
|
|
10536
10548
|
* `deleteByIndex` deletes the node of the given index.
|
|
10537
10549
|
*/
|
|
@@ -10675,6 +10687,12 @@ class CRDTArray extends CRDTContainer {
|
|
|
10675
10687
|
deleteByIndex(index, editedAt) {
|
|
10676
10688
|
return this.elements.deleteByIndex(index, editedAt);
|
|
10677
10689
|
}
|
|
10690
|
+
/**
|
|
10691
|
+
* `set` sets the given element at the given position of the creation time.
|
|
10692
|
+
*/
|
|
10693
|
+
set(createdAt, value, executedAt) {
|
|
10694
|
+
return this.elements.set(createdAt, value, executedAt);
|
|
10695
|
+
}
|
|
10678
10696
|
/**
|
|
10679
10697
|
* `getLastCreatedAt` get last created element.
|
|
10680
10698
|
*/
|
|
@@ -16091,6 +16109,77 @@ class TreeStyleOperation extends Operation {
|
|
|
16091
16109
|
return this.attributesToRemove;
|
|
16092
16110
|
}
|
|
16093
16111
|
}
|
|
16112
|
+
class ArraySetOperation extends Operation {
|
|
16113
|
+
constructor(parentCreatedAt, createdAt, value, executedAt) {
|
|
16114
|
+
super(parentCreatedAt, executedAt);
|
|
16115
|
+
__publicField(this, "createdAt");
|
|
16116
|
+
__publicField(this, "value");
|
|
16117
|
+
this.createdAt = createdAt;
|
|
16118
|
+
this.value = value;
|
|
16119
|
+
}
|
|
16120
|
+
/**
|
|
16121
|
+
* `create` creates a new instance of ArraySetOperation.
|
|
16122
|
+
*/
|
|
16123
|
+
static create(parentCreatedAt, createdAt, value, executedAt) {
|
|
16124
|
+
return new ArraySetOperation(parentCreatedAt, createdAt, value, executedAt);
|
|
16125
|
+
}
|
|
16126
|
+
/**
|
|
16127
|
+
* `execute` executes this operation on the given `CRDTRoot`.
|
|
16128
|
+
*/
|
|
16129
|
+
execute(root) {
|
|
16130
|
+
const parentObject = root.findByCreatedAt(this.getParentCreatedAt());
|
|
16131
|
+
if (!parentObject) {
|
|
16132
|
+
throw new YorkieError(
|
|
16133
|
+
Code.ErrInvalidArgument,
|
|
16134
|
+
`fail to find ${this.getParentCreatedAt()}`
|
|
16135
|
+
);
|
|
16136
|
+
}
|
|
16137
|
+
if (!(parentObject instanceof CRDTArray)) {
|
|
16138
|
+
throw new YorkieError(
|
|
16139
|
+
Code.ErrInvalidArgument,
|
|
16140
|
+
`fail to execute, only array can execute set`
|
|
16141
|
+
);
|
|
16142
|
+
}
|
|
16143
|
+
const value = this.value.deepcopy();
|
|
16144
|
+
parentObject.insertAfter(this.createdAt, value, this.getExecutedAt());
|
|
16145
|
+
parentObject.delete(this.createdAt, this.getExecutedAt());
|
|
16146
|
+
root.registerElement(value);
|
|
16147
|
+
const reverseOp = void 0;
|
|
16148
|
+
return {
|
|
16149
|
+
opInfos: [
|
|
16150
|
+
{
|
|
16151
|
+
type: "array-set",
|
|
16152
|
+
path: root.createPath(this.getParentCreatedAt())
|
|
16153
|
+
}
|
|
16154
|
+
],
|
|
16155
|
+
reverseOp
|
|
16156
|
+
};
|
|
16157
|
+
}
|
|
16158
|
+
/**
|
|
16159
|
+
* `getEffectedCreatedAt` returns the creation time of the effected element.
|
|
16160
|
+
*/
|
|
16161
|
+
getEffectedCreatedAt() {
|
|
16162
|
+
return this.createdAt;
|
|
16163
|
+
}
|
|
16164
|
+
/**
|
|
16165
|
+
* `toTestString` returns a string containing the meta data.
|
|
16166
|
+
*/
|
|
16167
|
+
toTestString() {
|
|
16168
|
+
return `${this.getParentCreatedAt().toTestString()}.ARRAY_SET.${this.createdAt.toTestString()}=${this.value.toSortedJSON()}`;
|
|
16169
|
+
}
|
|
16170
|
+
/**
|
|
16171
|
+
* `getCreatedAt` returns the creation time of the target element.
|
|
16172
|
+
*/
|
|
16173
|
+
getCreatedAt() {
|
|
16174
|
+
return this.createdAt;
|
|
16175
|
+
}
|
|
16176
|
+
/**
|
|
16177
|
+
* `getValue` returns the value of this operation.
|
|
16178
|
+
*/
|
|
16179
|
+
getValue() {
|
|
16180
|
+
return this.value;
|
|
16181
|
+
}
|
|
16182
|
+
}
|
|
16094
16183
|
function toPresence(presence) {
|
|
16095
16184
|
const pbPresence = new Presence$1();
|
|
16096
16185
|
const pbDataMap = pbPresence.data;
|
|
@@ -16388,6 +16477,21 @@ function toOperation(operation) {
|
|
|
16388
16477
|
);
|
|
16389
16478
|
pbOperation.body.case = "treeStyle";
|
|
16390
16479
|
pbOperation.body.value = pbTreeStyleOperation;
|
|
16480
|
+
} else if (operation instanceof ArraySetOperation) {
|
|
16481
|
+
const arraySetOperation = operation;
|
|
16482
|
+
const pbArraySetOperation = new Operation_ArraySet();
|
|
16483
|
+
pbArraySetOperation.parentCreatedAt = toTimeTicket(
|
|
16484
|
+
arraySetOperation.getParentCreatedAt()
|
|
16485
|
+
);
|
|
16486
|
+
pbArraySetOperation.createdAt = toTimeTicket(
|
|
16487
|
+
arraySetOperation.getCreatedAt()
|
|
16488
|
+
);
|
|
16489
|
+
pbArraySetOperation.value = toElementSimple(arraySetOperation.getValue());
|
|
16490
|
+
pbArraySetOperation.executedAt = toTimeTicket(
|
|
16491
|
+
arraySetOperation.getExecutedAt()
|
|
16492
|
+
);
|
|
16493
|
+
pbOperation.body.case = "arraySet";
|
|
16494
|
+
pbOperation.body.value = pbArraySetOperation;
|
|
16391
16495
|
} else {
|
|
16392
16496
|
throw new YorkieError(Code.ErrUnimplemented, "unimplemented operation");
|
|
16393
16497
|
}
|
|
@@ -16927,8 +17031,6 @@ function fromOperation(pbOperation) {
|
|
|
16927
17031
|
attributes,
|
|
16928
17032
|
fromTimeTicket(pbStyleOperation.executedAt)
|
|
16929
17033
|
);
|
|
16930
|
-
} else if (pbOperation.body.case === "select") {
|
|
16931
|
-
return;
|
|
16932
17034
|
} else if (pbOperation.body.case === "increase") {
|
|
16933
17035
|
const pbIncreaseOperation = pbOperation.body.value;
|
|
16934
17036
|
return IncreaseOperation.create(
|
|
@@ -16972,6 +17074,14 @@ function fromOperation(pbOperation) {
|
|
|
16972
17074
|
fromTimeTicket(pbTreeStyleOperation.executedAt)
|
|
16973
17075
|
);
|
|
16974
17076
|
}
|
|
17077
|
+
} else if (pbOperation.body.case === "arraySet") {
|
|
17078
|
+
const pbArraySetOperation = pbOperation.body.value;
|
|
17079
|
+
return ArraySetOperation.create(
|
|
17080
|
+
fromTimeTicket(pbArraySetOperation.parentCreatedAt),
|
|
17081
|
+
fromTimeTicket(pbArraySetOperation.createdAt),
|
|
17082
|
+
fromElementSimple(pbArraySetOperation.value),
|
|
17083
|
+
fromTimeTicket(pbArraySetOperation.executedAt)
|
|
17084
|
+
);
|
|
16975
17085
|
} else {
|
|
16976
17086
|
throw new YorkieError(Code.ErrUnimplemented, `unimplemented operation`);
|
|
16977
17087
|
}
|
|
@@ -18274,6 +18384,15 @@ class ArrayProxy {
|
|
|
18274
18384
|
return () => {
|
|
18275
18385
|
return toWrappedElement(context, target.getLast());
|
|
18276
18386
|
};
|
|
18387
|
+
} else if (method === "delete") {
|
|
18388
|
+
return (index) => {
|
|
18389
|
+
const deleted = ArrayProxy.deleteInternalByIndex(
|
|
18390
|
+
context,
|
|
18391
|
+
target,
|
|
18392
|
+
index
|
|
18393
|
+
);
|
|
18394
|
+
return toWrappedElement(context, deleted);
|
|
18395
|
+
};
|
|
18277
18396
|
} else if (method === "deleteByID") {
|
|
18278
18397
|
return (createdAt) => {
|
|
18279
18398
|
const deleted = ArrayProxy.deleteInternalByID(
|
|
@@ -18293,6 +18412,16 @@ class ArrayProxy {
|
|
|
18293
18412
|
);
|
|
18294
18413
|
return toWrappedElement(context, inserted);
|
|
18295
18414
|
};
|
|
18415
|
+
} else if (method === "insertIntegerAfter") {
|
|
18416
|
+
return (index, value) => {
|
|
18417
|
+
const array2 = ArrayProxy.insertIntegerAfterInternal(
|
|
18418
|
+
context,
|
|
18419
|
+
target,
|
|
18420
|
+
index,
|
|
18421
|
+
value
|
|
18422
|
+
);
|
|
18423
|
+
return toWrappedElement(context, array2);
|
|
18424
|
+
};
|
|
18296
18425
|
} else if (method === "insertBefore") {
|
|
18297
18426
|
return (nextID, value) => {
|
|
18298
18427
|
const inserted = ArrayProxy.insertBeforeInternal(
|
|
@@ -18303,6 +18432,16 @@ class ArrayProxy {
|
|
|
18303
18432
|
);
|
|
18304
18433
|
return toWrappedElement(context, inserted);
|
|
18305
18434
|
};
|
|
18435
|
+
} else if (method === "setInteger") {
|
|
18436
|
+
return (index, value) => {
|
|
18437
|
+
const array2 = ArrayProxy.setIntegerInternal(
|
|
18438
|
+
context,
|
|
18439
|
+
target,
|
|
18440
|
+
index,
|
|
18441
|
+
value
|
|
18442
|
+
);
|
|
18443
|
+
return toWrappedElement(context, array2);
|
|
18444
|
+
};
|
|
18306
18445
|
} else if (method === "moveBefore") {
|
|
18307
18446
|
return (nextID, id) => {
|
|
18308
18447
|
ArrayProxy.moveBeforeInternal(context, target, nextID, id);
|
|
@@ -18311,6 +18450,15 @@ class ArrayProxy {
|
|
|
18311
18450
|
return (prevID, id) => {
|
|
18312
18451
|
ArrayProxy.moveAfterInternal(context, target, prevID, id);
|
|
18313
18452
|
};
|
|
18453
|
+
} else if (method === "moveAfterByIndex") {
|
|
18454
|
+
return (prevIndex, targetIndex) => {
|
|
18455
|
+
ArrayProxy.moveAfterByIndexInternal(
|
|
18456
|
+
context,
|
|
18457
|
+
target,
|
|
18458
|
+
prevIndex,
|
|
18459
|
+
targetIndex
|
|
18460
|
+
);
|
|
18461
|
+
};
|
|
18314
18462
|
} else if (method === "moveFront") {
|
|
18315
18463
|
return (id) => {
|
|
18316
18464
|
ArrayProxy.moveFrontInternal(context, target, id);
|
|
@@ -18444,7 +18592,6 @@ class ArrayProxy {
|
|
|
18444
18592
|
*/
|
|
18445
18593
|
static moveAfterInternal(context, target, prevCreatedAt, createdAt) {
|
|
18446
18594
|
const ticket = context.issueTimeTicket();
|
|
18447
|
-
target.moveAfter(prevCreatedAt, createdAt, ticket);
|
|
18448
18595
|
context.push(
|
|
18449
18596
|
MoveOperation.create(
|
|
18450
18597
|
target.getCreatedAt(),
|
|
@@ -18453,6 +18600,33 @@ class ArrayProxy {
|
|
|
18453
18600
|
ticket
|
|
18454
18601
|
)
|
|
18455
18602
|
);
|
|
18603
|
+
target.moveAfter(prevCreatedAt, createdAt, ticket);
|
|
18604
|
+
}
|
|
18605
|
+
/**
|
|
18606
|
+
* `moveAfterByIndexInternal` moves the given element to its new position
|
|
18607
|
+
* after the given previous element.
|
|
18608
|
+
*/
|
|
18609
|
+
static moveAfterByIndexInternal(context, target, prevIndex, targetIndex) {
|
|
18610
|
+
const prevElem = target.get(prevIndex);
|
|
18611
|
+
if (!prevElem) {
|
|
18612
|
+
throw new YorkieError(
|
|
18613
|
+
Code.ErrInvalidArgument,
|
|
18614
|
+
`index out of bounds: ${prevIndex}`
|
|
18615
|
+
);
|
|
18616
|
+
}
|
|
18617
|
+
const targetElem = target.get(targetIndex);
|
|
18618
|
+
if (!targetElem) {
|
|
18619
|
+
throw new YorkieError(
|
|
18620
|
+
Code.ErrInvalidArgument,
|
|
18621
|
+
`index out of bounds: ${targetIndex}`
|
|
18622
|
+
);
|
|
18623
|
+
}
|
|
18624
|
+
ArrayProxy.moveAfterInternal(
|
|
18625
|
+
context,
|
|
18626
|
+
target,
|
|
18627
|
+
prevElem.getCreatedAt(),
|
|
18628
|
+
targetElem.getCreatedAt()
|
|
18629
|
+
);
|
|
18456
18630
|
}
|
|
18457
18631
|
/**
|
|
18458
18632
|
* `moveFrontInternal` moves the given `createdAt` element
|
|
@@ -18501,6 +18675,25 @@ class ArrayProxy {
|
|
|
18501
18675
|
);
|
|
18502
18676
|
return element;
|
|
18503
18677
|
}
|
|
18678
|
+
/**
|
|
18679
|
+
* `insertIntegerAfterInternal` inserts the given integer after the given previous element.
|
|
18680
|
+
*/
|
|
18681
|
+
static insertIntegerAfterInternal(context, target, index, value) {
|
|
18682
|
+
const prevElem = target.get(index);
|
|
18683
|
+
if (!prevElem) {
|
|
18684
|
+
throw new YorkieError(
|
|
18685
|
+
Code.ErrInvalidArgument,
|
|
18686
|
+
`index out of bounds: ${index}`
|
|
18687
|
+
);
|
|
18688
|
+
}
|
|
18689
|
+
ArrayProxy.insertAfterInternal(
|
|
18690
|
+
context,
|
|
18691
|
+
target,
|
|
18692
|
+
prevElem.getCreatedAt(),
|
|
18693
|
+
value
|
|
18694
|
+
);
|
|
18695
|
+
return target;
|
|
18696
|
+
}
|
|
18504
18697
|
/**
|
|
18505
18698
|
* `insertBeforeInternal` inserts the value before the previously created element.
|
|
18506
18699
|
*/
|
|
@@ -18512,6 +18705,39 @@ class ArrayProxy {
|
|
|
18512
18705
|
value
|
|
18513
18706
|
);
|
|
18514
18707
|
}
|
|
18708
|
+
/**
|
|
18709
|
+
* `setIntegerInternal` sets the given integer at the given index.
|
|
18710
|
+
*/
|
|
18711
|
+
static setIntegerInternal(context, target, index, value) {
|
|
18712
|
+
const prev = target.get(index);
|
|
18713
|
+
if (!prev) {
|
|
18714
|
+
throw new YorkieError(
|
|
18715
|
+
Code.ErrInvalidArgument,
|
|
18716
|
+
`index out of bounds: ${index}`
|
|
18717
|
+
);
|
|
18718
|
+
}
|
|
18719
|
+
ArrayProxy.setByIndexInternal(context, target, prev.getCreatedAt(), value);
|
|
18720
|
+
return target;
|
|
18721
|
+
}
|
|
18722
|
+
/**
|
|
18723
|
+
* `setByIndexInternal` sets the element of the given index.
|
|
18724
|
+
*/
|
|
18725
|
+
static setByIndexInternal(context, target, createdAt, value) {
|
|
18726
|
+
const ticket = context.issueTimeTicket();
|
|
18727
|
+
const element = buildCRDTElement(context, value, ticket);
|
|
18728
|
+
const copiedValue = element.deepcopy();
|
|
18729
|
+
context.push(
|
|
18730
|
+
ArraySetOperation.create(
|
|
18731
|
+
target.getCreatedAt(),
|
|
18732
|
+
createdAt,
|
|
18733
|
+
copiedValue,
|
|
18734
|
+
ticket
|
|
18735
|
+
)
|
|
18736
|
+
);
|
|
18737
|
+
target.set(createdAt, element, ticket);
|
|
18738
|
+
context.registerElement(element, target);
|
|
18739
|
+
return element;
|
|
18740
|
+
}
|
|
18515
18741
|
/**
|
|
18516
18742
|
* `deleteInternalByIndex` deletes target element of given index.
|
|
18517
18743
|
*/
|
|
@@ -21268,7 +21494,7 @@ function createAuthInterceptor(apiKey, token) {
|
|
|
21268
21494
|
};
|
|
21269
21495
|
}
|
|
21270
21496
|
const name = "@yorkie-js/sdk";
|
|
21271
|
-
const version = "0.6.
|
|
21497
|
+
const version = "0.6.23";
|
|
21272
21498
|
const pkg = {
|
|
21273
21499
|
name,
|
|
21274
21500
|
version
|