@fluidframework/sequence 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.0

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 (203) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +8 -3
  4. package/api-report/sequence.api.md +87 -84
  5. package/dist/defaultMap.d.ts +3 -3
  6. package/dist/defaultMap.d.ts.map +1 -1
  7. package/dist/defaultMap.js +7 -2
  8. package/dist/defaultMap.js.map +1 -1
  9. package/dist/defaultMapInterfaces.d.ts +11 -10
  10. package/dist/defaultMapInterfaces.d.ts.map +1 -1
  11. package/dist/defaultMapInterfaces.js.map +1 -1
  12. package/dist/intervalCollection.d.ts +66 -12
  13. package/dist/intervalCollection.d.ts.map +1 -1
  14. package/dist/intervalCollection.js +50 -45
  15. package/dist/intervalCollection.js.map +1 -1
  16. package/dist/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  17. package/dist/intervalIndex/endpointInRangeIndex.js +1 -1
  18. package/dist/intervalIndex/endpointInRangeIndex.js.map +1 -1
  19. package/dist/intervalIndex/endpointIndex.d.ts +2 -2
  20. package/dist/intervalIndex/endpointIndex.js +1 -1
  21. package/dist/intervalIndex/endpointIndex.js.map +1 -1
  22. package/dist/intervalIndex/idIntervalIndex.d.ts +2 -2
  23. package/dist/intervalIndex/idIntervalIndex.js +1 -1
  24. package/dist/intervalIndex/idIntervalIndex.js.map +1 -1
  25. package/dist/intervalIndex/intervalIndex.d.ts +1 -1
  26. package/dist/intervalIndex/intervalIndex.js.map +1 -1
  27. package/dist/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  28. package/dist/intervalIndex/overlappingIntervalsIndex.js +1 -1
  29. package/dist/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  30. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
  31. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js +1 -1
  32. package/dist/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  33. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  34. package/dist/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  35. package/dist/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  36. package/dist/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  37. package/dist/intervalIndex/startpointInRangeIndex.js +1 -1
  38. package/dist/intervalIndex/startpointInRangeIndex.js.map +1 -1
  39. package/dist/intervals/interval.d.ts +2 -7
  40. package/dist/intervals/interval.d.ts.map +1 -1
  41. package/dist/intervals/interval.js +1 -5
  42. package/dist/intervals/interval.js.map +1 -1
  43. package/dist/intervals/intervalUtils.d.ts +15 -14
  44. package/dist/intervals/intervalUtils.d.ts.map +1 -1
  45. package/dist/intervals/intervalUtils.js +3 -3
  46. package/dist/intervals/intervalUtils.js.map +1 -1
  47. package/dist/intervals/sequenceInterval.d.ts +3 -12
  48. package/dist/intervals/sequenceInterval.d.ts.map +1 -1
  49. package/dist/intervals/sequenceInterval.js +3 -11
  50. package/dist/intervals/sequenceInterval.js.map +1 -1
  51. package/dist/localValues.d.ts +2 -1
  52. package/dist/localValues.d.ts.map +1 -1
  53. package/dist/localValues.js.map +1 -1
  54. package/dist/packageVersion.d.ts +1 -1
  55. package/dist/packageVersion.js +1 -1
  56. package/dist/packageVersion.js.map +1 -1
  57. package/dist/revertibles.d.ts +9 -15
  58. package/dist/revertibles.d.ts.map +1 -1
  59. package/dist/revertibles.js +7 -9
  60. package/dist/revertibles.js.map +1 -1
  61. package/dist/sequence-alpha.d.ts +226 -507
  62. package/dist/sequence-beta.d.ts +131 -1368
  63. package/dist/sequence-public.d.ts +131 -1368
  64. package/dist/sequence-untrimmed.d.ts +121 -90
  65. package/dist/sequence.d.ts +2 -3
  66. package/dist/sequence.d.ts.map +1 -1
  67. package/dist/sequence.js +1 -1
  68. package/dist/sequence.js.map +1 -1
  69. package/dist/sequenceDeltaEvent.d.ts +4 -4
  70. package/dist/sequenceDeltaEvent.js +3 -3
  71. package/dist/sequenceDeltaEvent.js.map +1 -1
  72. package/dist/sequenceFactory.d.ts +1 -1
  73. package/dist/sequenceFactory.js +1 -1
  74. package/dist/sequenceFactory.js.map +1 -1
  75. package/dist/sharedIntervalCollection.d.ts +3 -3
  76. package/dist/sharedIntervalCollection.js +2 -2
  77. package/dist/sharedIntervalCollection.js.map +1 -1
  78. package/dist/sharedSequence.d.ts +3 -3
  79. package/dist/sharedSequence.js +2 -2
  80. package/dist/sharedSequence.js.map +1 -1
  81. package/dist/sharedString.d.ts +8 -5
  82. package/dist/sharedString.d.ts.map +1 -1
  83. package/dist/sharedString.js +6 -3
  84. package/dist/sharedString.js.map +1 -1
  85. package/lib/defaultMap.d.ts +3 -3
  86. package/lib/defaultMap.d.ts.map +1 -1
  87. package/lib/defaultMap.js +29 -20
  88. package/lib/defaultMap.js.map +1 -1
  89. package/lib/defaultMapInterfaces.d.ts +11 -10
  90. package/lib/defaultMapInterfaces.d.ts.map +1 -1
  91. package/lib/defaultMapInterfaces.js +2 -1
  92. package/lib/defaultMapInterfaces.js.map +1 -1
  93. package/lib/index.js +45 -10
  94. package/lib/index.js.map +1 -1
  95. package/lib/intervalCollection.d.ts +66 -12
  96. package/lib/intervalCollection.d.ts.map +1 -1
  97. package/lib/intervalCollection.js +174 -156
  98. package/lib/intervalCollection.js.map +1 -1
  99. package/lib/intervalIndex/endpointInRangeIndex.d.ts +2 -2
  100. package/lib/intervalIndex/endpointInRangeIndex.js +18 -13
  101. package/lib/intervalIndex/endpointInRangeIndex.js.map +1 -1
  102. package/lib/intervalIndex/endpointIndex.d.ts +2 -2
  103. package/lib/intervalIndex/endpointIndex.js +14 -9
  104. package/lib/intervalIndex/endpointIndex.js.map +1 -1
  105. package/lib/intervalIndex/idIntervalIndex.d.ts +2 -2
  106. package/lib/intervalIndex/idIntervalIndex.js +9 -5
  107. package/lib/intervalIndex/idIntervalIndex.js.map +1 -1
  108. package/lib/intervalIndex/index.js +19 -6
  109. package/lib/intervalIndex/index.js.map +1 -1
  110. package/lib/intervalIndex/intervalIndex.d.ts +1 -1
  111. package/lib/intervalIndex/intervalIndex.js +2 -1
  112. package/lib/intervalIndex/intervalIndex.js.map +1 -1
  113. package/lib/intervalIndex/intervalIndexUtils.js +8 -4
  114. package/lib/intervalIndex/intervalIndexUtils.js.map +1 -1
  115. package/lib/intervalIndex/overlappingIntervalsIndex.d.ts +2 -2
  116. package/lib/intervalIndex/overlappingIntervalsIndex.js +16 -11
  117. package/lib/intervalIndex/overlappingIntervalsIndex.js.map +1 -1
  118. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.d.ts +1 -1
  119. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js +15 -11
  120. package/lib/intervalIndex/overlappingSequenceIntervalsIndex.js.map +1 -1
  121. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts +2 -1
  122. package/lib/intervalIndex/sequenceIntervalIndexes.d.ts.map +1 -1
  123. package/lib/intervalIndex/sequenceIntervalIndexes.js +2 -1
  124. package/lib/intervalIndex/sequenceIntervalIndexes.js.map +1 -1
  125. package/lib/intervalIndex/startpointInRangeIndex.d.ts +2 -2
  126. package/lib/intervalIndex/startpointInRangeIndex.js +18 -13
  127. package/lib/intervalIndex/startpointInRangeIndex.js.map +1 -1
  128. package/lib/intervalTree.js +9 -4
  129. package/lib/intervalTree.js.map +1 -1
  130. package/lib/intervals/index.js +18 -3
  131. package/lib/intervals/index.js.map +1 -1
  132. package/lib/intervals/interval.d.ts +2 -7
  133. package/lib/intervals/interval.d.ts.map +1 -1
  134. package/lib/intervals/interval.js +19 -18
  135. package/lib/intervals/interval.js.map +1 -1
  136. package/lib/intervals/intervalUtils.d.ts +15 -14
  137. package/lib/intervals/intervalUtils.d.ts.map +1 -1
  138. package/lib/intervals/intervalUtils.js +21 -16
  139. package/lib/intervals/intervalUtils.js.map +1 -1
  140. package/lib/intervals/sequenceInterval.d.ts +3 -12
  141. package/lib/intervals/sequenceInterval.d.ts.map +1 -1
  142. package/lib/intervals/sequenceInterval.js +68 -70
  143. package/lib/intervals/sequenceInterval.js.map +1 -1
  144. package/lib/localValues.d.ts +2 -1
  145. package/lib/localValues.d.ts.map +1 -1
  146. package/lib/localValues.js +9 -4
  147. package/lib/localValues.js.map +1 -1
  148. package/lib/packageVersion.d.ts +1 -1
  149. package/lib/packageVersion.js +5 -2
  150. package/lib/packageVersion.js.map +1 -1
  151. package/lib/revertibles.d.ts +9 -15
  152. package/lib/revertibles.d.ts.map +1 -1
  153. package/lib/revertibles.js +76 -68
  154. package/lib/revertibles.js.map +1 -1
  155. package/lib/sequence-alpha.d.ts +226 -507
  156. package/lib/sequence-beta.d.ts +131 -1368
  157. package/lib/sequence-public.d.ts +131 -1368
  158. package/lib/sequence-untrimmed.d.ts +121 -90
  159. package/lib/sequence.d.ts +2 -3
  160. package/lib/sequence.d.ts.map +1 -1
  161. package/lib/sequence.js +45 -40
  162. package/lib/sequence.js.map +1 -1
  163. package/lib/sequenceDeltaEvent.d.ts +4 -4
  164. package/lib/sequenceDeltaEvent.js +16 -10
  165. package/lib/sequenceDeltaEvent.js.map +1 -1
  166. package/lib/sequenceFactory.d.ts +1 -1
  167. package/lib/sequenceFactory.js +14 -10
  168. package/lib/sequenceFactory.js.map +1 -1
  169. package/lib/sharedIntervalCollection.d.ts +3 -3
  170. package/lib/sharedIntervalCollection.js +20 -15
  171. package/lib/sharedIntervalCollection.js.map +1 -1
  172. package/lib/sharedSequence.d.ts +3 -3
  173. package/lib/sharedSequence.js +13 -8
  174. package/lib/sharedSequence.js.map +1 -1
  175. package/lib/sharedString.d.ts +8 -5
  176. package/lib/sharedString.d.ts.map +1 -1
  177. package/lib/sharedString.js +27 -19
  178. package/lib/sharedString.js.map +1 -1
  179. package/package.json +22 -20
  180. package/sequence.test-files.tar +0 -0
  181. package/src/defaultMap.ts +22 -16
  182. package/src/defaultMapInterfaces.ts +15 -12
  183. package/src/intervalCollection.ts +131 -67
  184. package/src/intervalIndex/endpointInRangeIndex.ts +2 -2
  185. package/src/intervalIndex/endpointIndex.ts +2 -2
  186. package/src/intervalIndex/idIntervalIndex.ts +2 -2
  187. package/src/intervalIndex/intervalIndex.ts +1 -1
  188. package/src/intervalIndex/overlappingIntervalsIndex.ts +2 -2
  189. package/src/intervalIndex/overlappingSequenceIntervalsIndex.ts +1 -1
  190. package/src/intervalIndex/sequenceIntervalIndexes.ts +2 -1
  191. package/src/intervalIndex/startpointInRangeIndex.ts +2 -2
  192. package/src/intervals/interval.ts +2 -7
  193. package/src/intervals/intervalUtils.ts +15 -15
  194. package/src/intervals/sequenceInterval.ts +3 -12
  195. package/src/localValues.ts +2 -1
  196. package/src/packageVersion.ts +1 -1
  197. package/src/revertibles.ts +9 -15
  198. package/src/sequence.ts +2 -3
  199. package/src/sequenceDeltaEvent.ts +4 -4
  200. package/src/sequenceFactory.ts +1 -1
  201. package/src/sharedIntervalCollection.ts +3 -3
  202. package/src/sharedSequence.ts +3 -3
  203. package/src/sharedString.ts +8 -5
@@ -35,7 +35,6 @@ import {
35
35
  IValueOpEmitter,
36
36
  IValueOperation,
37
37
  IValueType,
38
- IValueTypeOperationValue,
39
38
  SequenceOptions,
40
39
  } from "./defaultMapInterfaces";
41
40
  import {
@@ -88,7 +87,7 @@ import {
88
87
  * If a SequencePlace is the endpoint of a range (e.g. start/end of an interval or search range),
89
88
  * the Side value means it is exclusive if it is nearer to the other position and inclusive if it is farther.
90
89
  * E.g. the start of a range with Side.After is exclusive of the character at the position.
91
- * @public
90
+ * @alpha
92
91
  */
93
92
  export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
94
93
 
@@ -96,7 +95,7 @@ export type SequencePlace = number | "start" | "end" | InteriorSequencePlace;
96
95
  * A sequence place that does not refer to the special endpoint segments.
97
96
  *
98
97
  * See {@link SequencePlace} for additional context.
99
- * @public
98
+ * @alpha
100
99
  */
101
100
  export interface InteriorSequencePlace {
102
101
  pos: number;
@@ -107,7 +106,7 @@ export interface InteriorSequencePlace {
107
106
  * Defines a side relative to a character in a sequence.
108
107
  *
109
108
  * @remarks See {@link SequencePlace} for additional context on usage.
110
- * @public
109
+ * @alpha
111
110
  */
112
111
  export enum Side {
113
112
  Before = 0,
@@ -512,7 +511,7 @@ export class SequenceIntervalCollectionValueType
512
511
  return SequenceIntervalCollectionValueType._factory;
513
512
  }
514
513
 
515
- public get ops(): Map<string, IValueOperation<IntervalCollection<SequenceInterval>>> {
514
+ public get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<SequenceInterval>>> {
516
515
  return SequenceIntervalCollectionValueType._ops;
517
516
  }
518
517
 
@@ -552,7 +551,7 @@ export class IntervalCollectionValueType implements IValueType<IntervalCollectio
552
551
  return IntervalCollectionValueType._factory;
553
552
  }
554
553
 
555
- public get ops(): Map<string, IValueOperation<IntervalCollection<Interval>>> {
554
+ public get ops(): Map<IntervalOpType, IValueOperation<IntervalCollection<Interval>>> {
556
555
  return IntervalCollectionValueType._ops;
557
556
  }
558
557
 
@@ -562,21 +561,24 @@ export class IntervalCollectionValueType implements IValueType<IntervalCollectio
562
561
  }
563
562
 
564
563
  export function makeOpsMap<T extends ISerializableInterval>(): Map<
565
- string,
564
+ IntervalOpType,
566
565
  IValueOperation<IntervalCollection<T>>
567
566
  > {
568
- const rebase = (
569
- collection: IntervalCollection<T>,
570
- op: IValueTypeOperationValue,
571
- localOpMetadata: IMapMessageLocalMetadata,
567
+ const rebase: IValueOperation<IntervalCollection<T>>["rebase"] = (
568
+ collection,
569
+ op,
570
+ localOpMetadata,
572
571
  ) => {
573
572
  const { localSeq } = localOpMetadata;
574
573
  const rebasedValue = collection.rebaseLocalInterval(op.opName, op.value, localSeq);
574
+ if (rebasedValue === undefined) {
575
+ return undefined;
576
+ }
575
577
  const rebasedOp = { ...op, value: rebasedValue };
576
578
  return { rebasedOp, rebasedLocalOpMetadata: localOpMetadata };
577
579
  };
578
580
 
579
- return new Map<string, IValueOperation<IntervalCollection<T>>>([
581
+ return new Map<IntervalOpType, IValueOperation<IntervalCollection<T>>>([
580
582
  [
581
583
  IntervalOpType.ADD,
582
584
  {
@@ -624,7 +626,7 @@ export function makeOpsMap<T extends ISerializableInterval>(): Map<
624
626
  }
625
627
 
626
628
  /**
627
- * @public
629
+ * @alpha
628
630
  */
629
631
  export type DeserializeCallback = (properties: PropertySet) => void;
630
632
 
@@ -663,7 +665,7 @@ class IntervalCollectionIterator<TInterval extends ISerializableInterval>
663
665
 
664
666
  /**
665
667
  * Change events emitted by `IntervalCollection`s
666
- * @public
668
+ * @alpha
667
669
  */
668
670
  export interface IIntervalCollectionEvent<TInterval extends ISerializableInterval> extends IEvent {
669
671
  /**
@@ -731,7 +733,7 @@ const isSequencePlace = (place: any): place is SequencePlace => {
731
733
  /**
732
734
  * Collection of intervals that supports addition, modification, removal, and efficient spatial querying.
733
735
  * Changes to this collection will be incur updates on collaborating clients (i.e. they are not local-only).
734
- * @public
736
+ * @alpha
735
737
  */
736
738
  export interface IIntervalCollection<TInterval extends ISerializableInterval>
737
739
  extends TypedEventEmitter<IIntervalCollectionEvent<TInterval>> {
@@ -863,6 +865,7 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
863
865
  removeIntervalById(id: string): TInterval | undefined;
864
866
  /**
865
867
  * Changes the properties on an existing interval.
868
+ * @deprecated - call change with the id and and object containing the new properties
866
869
  * @param id - Id of the interval whose properties should be changed
867
870
  * @param props - Property set to apply to the interval. Shallow merging is used between any existing properties
868
871
  * and `prop`, i.e. the interval will end up with a property object equivalent to `{ ...oldProps, ...props }`.
@@ -870,12 +873,25 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
870
873
  changeProperties(id: string, props: PropertySet);
871
874
  /**
872
875
  * Changes the endpoints of an existing interval.
876
+ * @deprecated - call change with the start and end parameters encapsulated in an object
873
877
  * @param id - Id of the interval to change
874
878
  * @param start - New start value. To leave the endpoint unchanged, pass the current value.
875
879
  * @param end - New end value. To leave the endpoint unchanged, pass the current value.
876
880
  * @returns the interval that was changed, if it existed in the collection.
877
881
  */
878
882
  change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
883
+ /**
884
+ * Changes the endpoints, properties, or both of an existing interval.
885
+ * @param id - Id of the Interval to change
886
+ * @returns the interval that was changed, if it existed in the collection.
887
+ * Pass the desired new start position, end position, and/or properties in an object. Start and end positions must be changed
888
+ * simultaneously - they must either both be specified or both undefined. To only change the properties, leave both endpoints
889
+ * undefined. To only change the endpoints, leave the properties undefined.
890
+ */
891
+ change(
892
+ id: string,
893
+ { start, end, props }: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet },
894
+ ): TInterval | undefined;
879
895
 
880
896
  attachDeserializer(onDeserialize: DeserializeCallback): void;
881
897
  /**
@@ -919,6 +935,14 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
919
935
  ): void;
920
936
 
921
937
  /**
938
+ * @deprecated - Users must manually attach the corresponding interval index to utilize this functionality, for instance:
939
+ *
940
+ * ```typescript
941
+ * const overlappingIntervalsIndex = createOverlappingIntervalsIndex(sharedString);
942
+ * collection.attachIndex(overlappingIntervalsIndex)
943
+ * const result = overlappingIntervalsIndex.findOverlappingIntervals(start, end);
944
+ * ```
945
+ *
922
946
  * @returns an array of all intervals in this collection that overlap with the interval
923
947
  * `[startPosition, endPosition]`.
924
948
  */
@@ -929,8 +953,29 @@ export interface IIntervalCollection<TInterval extends ISerializableInterval>
929
953
  */
930
954
  map(fn: (interval: TInterval) => void): void;
931
955
 
956
+ /**
957
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
958
+ * automatically added to the collection. Users are advised to independently attach the
959
+ * index to the collection and utilize the API accordingly, for instance:
960
+ * ```typescript
961
+ * const endpointIndex = createEndpointIndex(sharedString);
962
+ * collection.attachIndex(endpointIndex);
963
+ * const result1 = endpointIndex.previousInterval(pos);
964
+ * ```
965
+ * If an index is used repeatedly, applications should generally attach it once and store it in memory.
966
+ */
932
967
  previousInterval(pos: number): TInterval | undefined;
933
968
 
969
+ /**
970
+ * @deprecated - due to the forthcoming change where the endpointIndex will no longer be
971
+ * automatically added to the collection. Users are advised to independently attach the
972
+ * index to the collection and utilize the API accordingly, for instance:
973
+ * ```typescript
974
+ * const endpointIndex = createEndpointIndex(sharedString);
975
+ * collection.attachIndex(endpointIndex);
976
+ * const result2 = endpointIndex.nextInterval(pos);
977
+ * ```
978
+ */
934
979
  nextInterval(pos: number): TInterval | undefined;
935
980
  }
936
981
 
@@ -1359,70 +1404,83 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1359
1404
 
1360
1405
  /**
1361
1406
  * {@inheritdoc IIntervalCollection.changeProperties}
1407
+ * @deprecated - call change with the id and an object containing the new props values
1362
1408
  */
1363
1409
  public changeProperties(id: string, props: PropertySet) {
1364
- if (!this.attached) {
1365
- throw new LoggingError("Attach must be called before accessing intervals");
1366
- }
1367
- if (typeof id !== "string") {
1368
- throw new LoggingError("Change API requires an ID that is a string");
1369
- }
1370
- if (!props) {
1371
- throw new LoggingError("changeProperties should be called with a property set");
1372
- }
1373
- // prevent the overwriting of an interval label, it should remain unchanged
1374
- // once it has been inserted into the collection.
1375
- if (props[reservedRangeLabelsKey] !== undefined) {
1376
- throw new LoggingError(
1377
- "The label property should not be modified once inserted to the collection",
1378
- );
1379
- }
1380
-
1381
- const interval = this.getIntervalById(id);
1382
- if (interval) {
1383
- const deltaProps = interval.addProperties(
1384
- props,
1385
- true,
1386
- this.isCollaborating ? UnassignedSequenceNumber : UniversalSequenceNumber,
1387
- );
1388
- const serializedInterval: ISerializedInterval = interval.serialize();
1389
-
1390
- // Emit a change op that will only change properties. Add the ID to
1391
- // the property bag provided by the caller.
1392
- serializedInterval.start = undefined as any;
1393
- serializedInterval.end = undefined as any;
1394
-
1395
- serializedInterval.properties = props;
1396
- serializedInterval.properties[reservedIntervalIdKey] = interval.getIntervalId();
1397
- const localSeq = this.getNextLocalSeq();
1398
- this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
1399
- this.emitter.emit("change", undefined, serializedInterval, { localSeq });
1400
- this.emit("propertyChanged", interval, deltaProps, true, undefined);
1401
- }
1410
+ this.change(id, { props });
1402
1411
  }
1403
1412
 
1404
1413
  /**
1405
1414
  * {@inheritdoc IIntervalCollection.change}
1415
+ * @deprecated - call change with the id and an object containing the new start, end, and/or props values
1406
1416
  */
1407
- public change(id: string, start: SequencePlace, end: SequencePlace) {
1417
+ public change(id: string, start: SequencePlace, end: SequencePlace): TInterval | undefined;
1418
+ /**
1419
+ * {@inheritdoc IIntervalCollection.change}
1420
+ */
1421
+ public change(
1422
+ id: string,
1423
+ { start, end, props }: { start?: SequencePlace; end?: SequencePlace; props?: PropertySet },
1424
+ ): TInterval | undefined;
1425
+ public change(
1426
+ arg1: string,
1427
+ arg2: SequencePlace | { start?: SequencePlace; end?: SequencePlace; props?: PropertySet },
1428
+ arg3?: SequencePlace,
1429
+ ): TInterval | undefined {
1430
+ const id: string = arg1;
1431
+ let start: SequencePlace | undefined;
1432
+ let end: SequencePlace | undefined;
1433
+ let props: PropertySet | undefined;
1434
+ if (isSequencePlace(arg2)) {
1435
+ start = arg2;
1436
+ end = arg3;
1437
+ } else {
1438
+ start = arg2.start;
1439
+ end = arg2.end;
1440
+ props = arg2.props;
1441
+ }
1442
+
1408
1443
  if (!this.localCollection) {
1409
1444
  throw new LoggingError("Attach must be called before accessing intervals");
1410
1445
  }
1411
1446
 
1412
1447
  // Force id to be a string.
1413
1448
  if (typeof id !== "string") {
1414
- throw new LoggingError("Change API requires an ID that is a string");
1449
+ throw new UsageError("Change API requires an ID that is a string");
1450
+ }
1451
+
1452
+ // Ensure that both start and end are defined or both are undefined.
1453
+ if ((start === undefined) !== (end === undefined)) {
1454
+ throw new UsageError(
1455
+ "Change API requires both start and end to be defined or undefined",
1456
+ );
1457
+ }
1458
+
1459
+ // prevent the overwriting of an interval label, it should remain unchanged
1460
+ // once it has been inserted into the collection.
1461
+ if (props?.[reservedRangeLabelsKey] !== undefined) {
1462
+ throw new UsageError(
1463
+ "The label property should not be modified once inserted to the collection",
1464
+ );
1415
1465
  }
1416
1466
 
1417
1467
  const interval = this.getIntervalById(id);
1418
1468
  if (interval) {
1419
- const newInterval = this.localCollection.changeInterval(interval, start, end);
1420
- if (!newInterval) {
1421
- return undefined;
1469
+ let deltaProps: PropertySet | undefined;
1470
+ let newInterval: TInterval | undefined;
1471
+ if (props !== undefined) {
1472
+ deltaProps = interval.addProperties(
1473
+ props,
1474
+ true,
1475
+ this.isCollaborating ? UnassignedSequenceNumber : UniversalSequenceNumber,
1476
+ );
1422
1477
  }
1423
- if (!this.isCollaborating && newInterval instanceof SequenceInterval) {
1424
- setSlideOnRemove(newInterval.start);
1425
- setSlideOnRemove(newInterval.end);
1478
+ if (start !== undefined && end !== undefined) {
1479
+ newInterval = this.localCollection.changeInterval(interval, start, end);
1480
+ if (!this.isCollaborating && newInterval instanceof SequenceInterval) {
1481
+ setSlideOnRemove(newInterval.start);
1482
+ setSlideOnRemove(newInterval.end);
1483
+ }
1426
1484
  }
1427
1485
  const serializedInterval: SerializedIntervalDelta = interval.serialize();
1428
1486
  const { startPos, startSide, endPos, endSide } = endpointPosAndSide(start, end);
@@ -1432,15 +1490,21 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1432
1490
  serializedInterval.startSide = startSide;
1433
1491
  serializedInterval.endSide = endSide;
1434
1492
  serializedInterval.stickiness = stickiness;
1435
- // Emit a property bag containing only the ID, as we don't intend for this op to change any properties.
1493
+ // Emit a property bag containing the ID and the other (if any) properties changed
1436
1494
  serializedInterval.properties = {
1437
1495
  [reservedIntervalIdKey]: interval.getIntervalId(),
1496
+ ...props,
1438
1497
  };
1439
1498
  const localSeq = this.getNextLocalSeq();
1440
1499
  this.localSeqToSerializedInterval.set(localSeq, serializedInterval);
1441
1500
  this.emitter.emit("change", undefined, serializedInterval, { localSeq });
1442
- this.addPendingChange(id, serializedInterval);
1443
- this.emitChange(newInterval, interval, true, false);
1501
+ if (deltaProps !== undefined) {
1502
+ this.emit("propertyChanged", interval, deltaProps, true, undefined);
1503
+ }
1504
+ if (newInterval) {
1505
+ this.addPendingChange(id, serializedInterval);
1506
+ this.emitChange(newInterval, interval, true, false);
1507
+ }
1444
1508
  return newInterval;
1445
1509
  }
1446
1510
  // No interval to change
@@ -1867,7 +1931,7 @@ export class IntervalCollection<TInterval extends ISerializableInterval>
1867
1931
  ): void {
1868
1932
  if (local) {
1869
1933
  // Local ops were applied when the message was created and there's no "pending delete"
1870
- // state to bookkeep: remote operation application takes into account possibility of
1934
+ // state to book keep: remote operation application takes into account possibility of
1871
1935
  // locally deleted interval whenever a lookup happens.
1872
1936
  return;
1873
1937
  }
@@ -2032,7 +2096,7 @@ function setSlideOnRemove(lref: LocalReferencePosition) {
2032
2096
 
2033
2097
  /**
2034
2098
  * Information that identifies an interval within a `Sequence`.
2035
- * @public
2099
+ * @internal
2036
2100
  */
2037
2101
  export interface IntervalLocator {
2038
2102
  /**
@@ -2050,7 +2114,7 @@ export interface IntervalLocator {
2050
2114
  * @returns undefined if the reference position is not the endpoint of any interval (e.g. it was created
2051
2115
  * on the merge tree directly by app code), otherwise an {@link IntervalLocator} for the interval this
2052
2116
  * endpoint is a part of.
2053
- * @public
2117
+ * @internal
2054
2118
  */
2055
2119
  export function intervalLocatorFromEndpoint(
2056
2120
  potentialEndpoint: LocalReferencePosition,
@@ -20,7 +20,7 @@ import { HasComparisonOverride, compareOverrideables, forceCompare } from "./int
20
20
  * Collection of intervals.
21
21
  *
22
22
  * Provide additional APIs to support efficiently querying a collection of intervals whose endpoints fall within a specified range.
23
- * @public
23
+ * @internal
24
24
  */
25
25
  export interface IEndpointInRangeIndex<TInterval extends ISerializableInterval>
26
26
  extends IntervalIndex<TInterval> {
@@ -106,7 +106,7 @@ export class EndpointInRangeIndex<TInterval extends ISerializableInterval>
106
106
  }
107
107
 
108
108
  /**
109
- * @public
109
+ * @internal
110
110
  */
111
111
  export function createEndpointInRangeIndex(
112
112
  sharedString: SharedString,
@@ -16,7 +16,7 @@ import { SharedString } from "../sharedString";
16
16
  import { IntervalIndex } from "./intervalIndex";
17
17
 
18
18
  /**
19
- * @public
19
+ * @internal
20
20
  */
21
21
  export interface IEndpointIndex<TInterval extends ISerializableInterval>
22
22
  extends IntervalIndex<TInterval> {
@@ -83,7 +83,7 @@ export class EndpointIndex<TInterval extends ISerializableInterval>
83
83
  }
84
84
 
85
85
  /**
86
- * @public
86
+ * @internal
87
87
  */
88
88
  export function createEndpointIndex(sharedString: SharedString): IEndpointIndex<SequenceInterval> {
89
89
  const client = (sharedString as unknown as { client: Client }).client;
@@ -10,7 +10,7 @@ import { IntervalIndex } from "./intervalIndex";
10
10
  const reservedIntervalIdKey = "intervalId";
11
11
 
12
12
  /**
13
- * @public
13
+ * @internal
14
14
  */
15
15
  export interface IIdIntervalIndex<TInterval extends ISerializableInterval>
16
16
  extends IntervalIndex<TInterval>,
@@ -55,7 +55,7 @@ class IdIntervalIndex<TInterval extends ISerializableInterval>
55
55
  }
56
56
 
57
57
  /**
58
- * @public
58
+ * @internal
59
59
  */
60
60
  export function createIdIntervalIndex<
61
61
  TInterval extends ISerializableInterval,
@@ -13,7 +13,7 @@ import { ISerializableInterval } from "../intervals";
13
13
  * - "find all intervals with start endpoint between these two points"
14
14
  * - "find all intervals which overlap this range"
15
15
  * etc.
16
- * @public
16
+ * @alpha
17
17
  */
18
18
  export interface IntervalIndex<TInterval extends ISerializableInterval> {
19
19
  /**
@@ -18,7 +18,7 @@ import { SequencePlace, endpointPosAndSide } from "../intervalCollection";
18
18
  import { IntervalIndex } from "./intervalIndex";
19
19
 
20
20
  /**
21
- * @public
21
+ * @internal
22
22
  */
23
23
  export interface IOverlappingIntervalsIndex<TInterval extends ISerializableInterval>
24
24
  extends IntervalIndex<TInterval> {
@@ -177,7 +177,7 @@ export class OverlappingIntervalsIndex<TInterval extends ISerializableInterval>
177
177
  }
178
178
 
179
179
  /**
180
- * @public
180
+ * @internal
181
181
  */
182
182
  export function createOverlappingIntervalsIndex(
183
183
  sharedString: SharedString,
@@ -70,7 +70,7 @@ class OverlappingSequenceIntervalsIndex
70
70
  }
71
71
 
72
72
  /**
73
- * @public
73
+ * @internal
74
74
  */
75
75
  export function createOverlappingSequenceIntervalsIndex(
76
76
  sharedString: SharedString,
@@ -10,7 +10,7 @@ import { IOverlappingIntervalsIndex } from "./overlappingIntervalsIndex";
10
10
  /**
11
11
  * This namespace contains specialiazations of indexes which support spatial queries
12
12
  * specifically for `SequenceInterval`s.
13
- * @public
13
+ * @internal
14
14
  */
15
15
  // eslint-disable-next-line @typescript-eslint/no-namespace
16
16
  export namespace SequenceIntervalIndexes {
@@ -18,6 +18,7 @@ export namespace SequenceIntervalIndexes {
18
18
  * Collection of intervals.
19
19
  *
20
20
  * Provides additional APIs to support efficiently querying a collection of intervals based on segments and offset.
21
+ * @internal
21
22
  */
22
23
  export interface Overlapping extends IOverlappingIntervalsIndex<SequenceInterval> {
23
24
  /**
@@ -20,7 +20,7 @@ import { HasComparisonOverride, compareOverrideables, forceCompare } from "./int
20
20
  * Collection of intervals.
21
21
  *
22
22
  * Provide additional APIs to support efficiently querying a collection of intervals whose startpoints fall within a specified range.
23
- * @public
23
+ * @internal
24
24
  */
25
25
  export interface IStartpointInRangeIndex<TInterval extends ISerializableInterval>
26
26
  extends IntervalIndex<TInterval> {
@@ -104,7 +104,7 @@ export class StartpointInRangeIndex<TInterval extends ISerializableInterval>
104
104
  }
105
105
  }
106
106
  /**
107
- * @public
107
+ * @internal
108
108
  */
109
109
  export function createStartpointInRangeIndex(
110
110
  sharedString: SharedString,
@@ -21,18 +21,17 @@ const reservedIntervalIdKey = "intervalId";
21
21
 
22
22
  /**
23
23
  * Serializable interval whose endpoints are plain-old numbers.
24
- * @public
24
+ * @internal
25
25
  */
26
26
  export class Interval implements ISerializableInterval {
27
27
  /**
28
28
  * {@inheritDoc ISerializableInterval.properties}
29
29
  */
30
30
  public properties: PropertySet;
31
- /** @internal */
31
+ /***/
32
32
  public auxProps: PropertySet[] | undefined;
33
33
  /**
34
34
  * {@inheritDoc ISerializableInterval.propertyManager}
35
- * @internal
36
35
  */
37
36
  public propertyManager: PropertiesManager;
38
37
  constructor(
@@ -81,7 +80,6 @@ export class Interval implements ISerializableInterval {
81
80
 
82
81
  /**
83
82
  * {@inheritDoc ISerializableInterval.serialize}
84
- * @internal
85
83
  */
86
84
  public serialize(): ISerializedInterval {
87
85
  const serializedInterval: ISerializedInterval = {
@@ -152,7 +150,6 @@ export class Interval implements ISerializableInterval {
152
150
 
153
151
  /**
154
152
  * {@inheritDoc IInterval.union}
155
- * @internal
156
153
  */
157
154
  public union(b: Interval) {
158
155
  return new Interval(
@@ -168,7 +165,6 @@ export class Interval implements ISerializableInterval {
168
165
 
169
166
  /**
170
167
  * {@inheritDoc ISerializableInterval.addProperties}
171
- * @internal
172
168
  */
173
169
  public addProperties(
174
170
  newProps: PropertySet,
@@ -190,7 +186,6 @@ export class Interval implements ISerializableInterval {
190
186
 
191
187
  /**
192
188
  * {@inheritDoc IInterval.modify}
193
- * @internal
194
189
  */
195
190
  public modify(
196
191
  label: string,
@@ -17,7 +17,7 @@ import { SequencePlace, Side } from "../intervalCollection";
17
17
 
18
18
  /**
19
19
  * Basic interval abstraction
20
- * @public
20
+ * @alpha
21
21
  */
22
22
  export interface IInterval {
23
23
  /**
@@ -46,7 +46,6 @@ export interface IInterval {
46
46
  compareEnd(b: IInterval): number;
47
47
  /**
48
48
  * Modifies one or more of the endpoints of this interval, returning a new interval representing the result.
49
- * @internal
50
49
  */
51
50
  modify(
52
51
  label: string,
@@ -65,14 +64,13 @@ export interface IInterval {
65
64
  * Unions this interval with `b`, returning a new interval.
66
65
  * The union operates as a convex hull, i.e. if the two intervals are disjoint, the return value includes
67
66
  * intermediate values between the two intervals.
68
- * @internal
69
67
  */
70
68
  union(b: IInterval): IInterval;
71
69
  }
72
70
 
73
71
  /**
74
72
  * Values are used in persisted formats (ops) and revertibles.
75
- * @alpha
73
+ * @internal
76
74
  */
77
75
  export const IntervalOpType = {
78
76
  ADD: "add",
@@ -81,9 +79,12 @@ export const IntervalOpType = {
81
79
  PROPERTY_CHANGED: "propertyChanged",
82
80
  POSITION_REMOVE: "positionRemove",
83
81
  } as const;
84
-
85
82
  /**
86
- * @public
83
+ * @internal
84
+ */
85
+ export type IntervalOpType = (typeof IntervalOpType)[keyof typeof IntervalOpType];
86
+ /**
87
+ * @alpha
87
88
  */
88
89
  export enum IntervalType {
89
90
  Simple = 0x0,
@@ -110,7 +111,7 @@ export enum IntervalType {
110
111
  /**
111
112
  * Serialized object representation of an interval.
112
113
  * This representation is used for ops that create or change intervals.
113
- * @internal
114
+ * @alpha
114
115
  */
115
116
  export interface ISerializedInterval {
116
117
  /**
@@ -138,16 +139,16 @@ export interface ISerializedInterval {
138
139
  }
139
140
 
140
141
  /**
141
- * @public
142
+ * @alpha
142
143
  */
143
144
  export interface ISerializableInterval extends IInterval {
144
145
  /** Serializable bag of properties associated with the interval. */
145
146
  properties: PropertySet;
146
- /** @internal */
147
+ /***/
147
148
  propertyManager: PropertiesManager;
148
- /** @internal */
149
+ /***/
149
150
  serialize(): ISerializedInterval;
150
- /** @internal */
151
+ /***/
151
152
  addProperties(
152
153
  props: PropertySet,
153
154
  collaborating?: boolean,
@@ -202,7 +203,7 @@ export type CompressedSerializedInterval =
202
203
  /**
203
204
  * @sealed
204
205
  * @deprecated The methods within have substitutions
205
- * @public
206
+ * @internal
206
207
  */
207
208
  export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
208
209
  /**
@@ -239,7 +240,7 @@ export interface IIntervalHelpers<TInterval extends ISerializableInterval> {
239
240
  * Note that interval stickiness is currently an experimental feature and must
240
241
  * be explicitly enabled with the `intervalStickinessEnabled` flag
241
242
  *
242
- * @internal
243
+ * @alpha
243
244
  */
244
245
  export const IntervalStickiness = {
245
246
  /**
@@ -271,8 +272,7 @@ export const IntervalStickiness = {
271
272
  *
272
273
  * Note that interval stickiness is currently an experimental feature and must
273
274
  * be explicitly enabled with the `intervalStickinessEnabled` flag
274
- *
275
- * @internal
275
+ * @alpha
276
276
  */
277
277
  export type IntervalStickiness = (typeof IntervalStickiness)[keyof typeof IntervalStickiness];
278
278