@fluidframework/shared-object-base 2.0.0-rc.2.0.1 → 2.0.0-rc.3.0.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 (87) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/api-report/shared-object-base.api.md +8 -1
  3. package/dist/handle.d.ts +1 -1
  4. package/dist/handle.d.ts.map +1 -1
  5. package/dist/handle.js +2 -2
  6. package/dist/handle.js.map +1 -1
  7. package/dist/index.d.ts +1 -1
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/legacy.d.ts +23 -0
  11. package/dist/packageVersion.d.ts +1 -1
  12. package/dist/packageVersion.js +1 -1
  13. package/dist/packageVersion.js.map +1 -1
  14. package/dist/public.d.ts +17 -0
  15. package/dist/remoteObjectHandle.d.ts.map +1 -1
  16. package/dist/remoteObjectHandle.js +6 -6
  17. package/dist/remoteObjectHandle.js.map +1 -1
  18. package/dist/serializer.d.ts.map +1 -1
  19. package/dist/serializer.js +3 -5
  20. package/dist/serializer.js.map +1 -1
  21. package/dist/sharedObject.d.ts +52 -4
  22. package/dist/sharedObject.d.ts.map +1 -1
  23. package/dist/sharedObject.js +22 -22
  24. package/dist/sharedObject.js.map +1 -1
  25. package/dist/summarySerializer.d.ts.map +1 -1
  26. package/dist/summarySerializer.js.map +1 -1
  27. package/dist/utils.d.ts.map +1 -1
  28. package/dist/utils.js +2 -2
  29. package/dist/utils.js.map +1 -1
  30. package/internal.d.ts +11 -0
  31. package/legacy.d.ts +11 -0
  32. package/lib/handle.d.ts +1 -1
  33. package/lib/handle.d.ts.map +1 -1
  34. package/lib/handle.js +1 -1
  35. package/lib/handle.js.map +1 -1
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.d.ts.map +1 -1
  38. package/lib/index.js.map +1 -1
  39. package/lib/legacy.d.ts +23 -0
  40. package/lib/packageVersion.d.ts +1 -1
  41. package/lib/packageVersion.js +1 -1
  42. package/lib/packageVersion.js.map +1 -1
  43. package/lib/public.d.ts +17 -0
  44. package/lib/remoteObjectHandle.d.ts.map +1 -1
  45. package/lib/remoteObjectHandle.js +3 -3
  46. package/lib/remoteObjectHandle.js.map +1 -1
  47. package/lib/serializer.d.ts.map +1 -1
  48. package/lib/serializer.js +1 -3
  49. package/lib/serializer.js.map +1 -1
  50. package/lib/sharedObject.d.ts +52 -4
  51. package/lib/sharedObject.d.ts.map +1 -1
  52. package/lib/sharedObject.js +5 -5
  53. package/lib/sharedObject.js.map +1 -1
  54. package/lib/summarySerializer.d.ts.map +1 -1
  55. package/lib/summarySerializer.js.map +1 -1
  56. package/lib/utils.d.ts.map +1 -1
  57. package/lib/utils.js +1 -1
  58. package/lib/utils.js.map +1 -1
  59. package/package.json +36 -57
  60. package/src/handle.ts +2 -1
  61. package/src/index.ts +1 -1
  62. package/src/packageVersion.ts +1 -1
  63. package/src/remoteObjectHandle.ts +4 -4
  64. package/src/serializer.ts +5 -1
  65. package/src/sharedObject.ts +71 -18
  66. package/src/summarySerializer.ts +1 -0
  67. package/src/utils.ts +2 -1
  68. package/api-extractor-cjs.json +0 -8
  69. package/dist/shared-object-base-alpha.d.ts +0 -427
  70. package/dist/shared-object-base-beta.d.ts +0 -118
  71. package/dist/shared-object-base-public.d.ts +0 -118
  72. package/dist/shared-object-base-untrimmed.d.ts +0 -513
  73. package/lib/shared-object-base-alpha.d.ts +0 -427
  74. package/lib/shared-object-base-beta.d.ts +0 -118
  75. package/lib/shared-object-base-public.d.ts +0 -118
  76. package/lib/shared-object-base-untrimmed.d.ts +0 -513
  77. package/lib/test/attachingBindingAndConnecting.spec.js +0 -334
  78. package/lib/test/attachingBindingAndConnecting.spec.js.map +0 -1
  79. package/lib/test/serializer.spec.js +0 -166
  80. package/lib/test/serializer.spec.js.map +0 -1
  81. package/lib/test/sharedObject.spec.js +0 -72
  82. package/lib/test/sharedObject.spec.js.map +0 -1
  83. package/lib/test/types/validateSharedObjectBasePrevious.generated.js +0 -26
  84. package/lib/test/types/validateSharedObjectBasePrevious.generated.js.map +0 -1
  85. package/lib/test/utils.js +0 -37
  86. package/lib/test/utils.js.map +0 -1
  87. /package/{dist → lib}/tsdoc-metadata.json +0 -0
@@ -3,38 +3,42 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { v4 as uuid } from "uuid";
7
- import { IFluidHandle, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
8
- import {
9
- ITelemetryLoggerExt,
10
- createChildLogger,
11
- DataProcessingError,
12
- EventEmitterWithErrorHandling,
13
- loggerToMonitoringContext,
14
- MonitoringContext,
15
- SampledTelemetryHelper,
16
- tagCodeArtifacts,
17
- } from "@fluidframework/telemetry-utils";
18
- import { assert } from "@fluidframework/core-utils";
19
6
  import { EventEmitterEventType } from "@fluid-internal/client-utils";
20
7
  import { AttachState } from "@fluidframework/container-definitions";
8
+ import { IFluidHandle, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
9
+ import { assert } from "@fluidframework/core-utils/internal";
21
10
  import {
22
11
  IChannelAttributes,
23
- IFluidDataStoreRuntime,
24
- IChannelStorageService,
12
+ type IChannelFactory,
25
13
  IChannelServices,
14
+ IChannelStorageService,
15
+ IFluidDataStoreRuntime,
26
16
  } from "@fluidframework/datastore-definitions";
27
17
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
28
18
  import {
19
+ IExperimentalIncrementalSummaryContext,
29
20
  IGarbageCollectionData,
30
21
  ISummaryTreeWithStats,
31
22
  ITelemetryContext,
23
+ } from "@fluidframework/runtime-definitions";
24
+ import {
32
25
  blobCountPropertyName,
33
26
  totalBlobSizePropertyName,
34
- IExperimentalIncrementalSummaryContext,
35
- } from "@fluidframework/runtime-definitions";
36
- import { FluidSerializer, IFluidSerializer } from "./serializer.js";
27
+ } from "@fluidframework/runtime-definitions/internal";
28
+ import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
29
+ import {
30
+ DataProcessingError,
31
+ EventEmitterWithErrorHandling,
32
+ MonitoringContext,
33
+ SampledTelemetryHelper,
34
+ createChildLogger,
35
+ loggerToMonitoringContext,
36
+ tagCodeArtifacts,
37
+ } from "@fluidframework/telemetry-utils/internal";
38
+ import { v4 as uuid } from "uuid";
39
+
37
40
  import { SharedObjectHandle } from "./handle.js";
41
+ import { FluidSerializer, IFluidSerializer } from "./serializer.js";
38
42
  import { SummarySerializer } from "./summarySerializer.js";
39
43
  import { ISharedObject, ISharedObjectEvents } from "./types.js";
40
44
  import { makeHandlesSerializable, parseHandles } from "./utils.js";
@@ -774,3 +778,52 @@ export abstract class SharedObject<
774
778
  telemetryContext?.set(this.telemetryContextPrefix, propertyName, prevTotal + incrementBy);
775
779
  }
776
780
  }
781
+
782
+ /**
783
+ * Defines a kind of shared object.
784
+ * Used in containers to register a shared object implementation, and to create new instances of a given type of shared object.
785
+ * @public
786
+ */
787
+ export interface ISharedObjectKind<TSharedObject> {
788
+ /**
789
+ * Get a factory which can be used by the Fluid Framework to programmatically instantiate shared objects within containers.
790
+ * @remarks
791
+ * The produced factory is intended for use with the FluidDataStoreRegistry and is used by the Fluid Framework to instantiate already existing Channels.
792
+ * To create new shared objects use:
793
+ *
794
+ * - {@link @fluidframework/fluid-static#IFluidContainer.create} if using `@fluidframework/fluid-static`, for example via `@fluidframework/azure-client`.
795
+ *
796
+ * - {@link ISharedObjectKind.create} if using a custom container definitions (and thus not using {@link @fluidframework/fluid-static#IFluidContainer}).
797
+ *
798
+ * @privateRemarks
799
+ * TODO:
800
+ * Many tests use this and can't use {@link ISharedObjectKind.create}.
801
+ * The docs should make it clear why that's ok, and why {@link ISharedObjectKind.create} isn't in such a way that when reading non app code (like tests in this package)
802
+ * someone can tell if the wrong one is being used without running it and seeing if it works.
803
+ */
804
+ getFactory(): IChannelFactory<TSharedObject>;
805
+
806
+ /**
807
+ * Create a shared object.
808
+ * @param runtime - The data store runtime that the new shared object belongs to.
809
+ * @param id - Optional name of the shared object.
810
+ * @returns Newly created shared object.
811
+ *
812
+ * @example
813
+ * To create a `SharedTree`, call the static create method:
814
+ *
815
+ * ```typescript
816
+ * const myTree = SharedTree.create(this.runtime, id);
817
+ * ```
818
+ * @remarks
819
+ * If using `@fluidframework/fluid-static` (for example via `@fluidframework/azure-client`), use {@link @fluidframework/fluid-static#IFluidContainer.create} instead of calling this directly.
820
+ *
821
+ * @privateRemarks
822
+ * TODO:
823
+ * This returns null when used with MockFluidDataStoreRuntime, so its unclear how tests should create DDS instances unless using `RootDataObject.create` (which most tests shouldn't to minimize dependencies).
824
+ * In practice tests either avoid mock runtimes, use getFactory(), or call the DDS constructor directly. It is unclear (from docs) how getFactory().create differs but it does not rely on runtime.createChannel so it works with mock runtimes.
825
+ * TODO:
826
+ * See note on ISharedObjectKind.getFactory.
827
+ */
828
+ create(runtime: IFluidDataStoreRuntime, id?: string): TSharedObject;
829
+ }
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { IFluidHandle } from "@fluidframework/core-interfaces";
7
+
7
8
  import { FluidSerializer } from "./serializer.js";
8
9
 
9
10
  /**
package/src/utils.ts CHANGED
@@ -5,7 +5,8 @@
5
5
 
6
6
  import { IFluidHandle } from "@fluidframework/core-interfaces";
7
7
  import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
8
- import { SummaryTreeBuilder } from "@fluidframework/runtime-utils";
8
+ import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
9
+
9
10
  import { IFluidSerializer } from "./serializer.js";
10
11
 
11
12
  /**
@@ -1,8 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.cjs.primary.json",
4
- // CJS is actually secondary; so, no report.
5
- "apiReport": {
6
- "enabled": false
7
- }
8
- }
@@ -1,427 +0,0 @@
1
- import { EventEmitterEventType } from '@fluid-internal/client-utils';
2
- import { EventEmitterWithErrorHandling } from '@fluidframework/telemetry-utils';
3
- import { IChannel } from '@fluidframework/datastore-definitions';
4
- import { IChannelAttributes } from '@fluidframework/datastore-definitions';
5
- import { IChannelServices } from '@fluidframework/datastore-definitions';
6
- import { IChannelStorageService } from '@fluidframework/datastore-definitions';
7
- import { IErrorEvent } from '@fluidframework/core-interfaces';
8
- import { IEventProvider } from '@fluidframework/core-interfaces';
9
- import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
10
- import { IExperimentalIncrementalSummaryContext } from '@fluidframework/runtime-definitions';
11
- import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
12
- import { IFluidHandle } from '@fluidframework/core-interfaces';
13
- import { IFluidHandleContext } from '@fluidframework/core-interfaces';
14
- import { IGarbageCollectionData } from '@fluidframework/runtime-definitions';
15
- import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
16
- import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
17
- import { ITelemetryContext } from '@fluidframework/runtime-definitions';
18
- import { ITelemetryLoggerExt } from '@fluidframework/telemetry-utils';
19
-
20
- /* Excluded from this release type: bindHandles */
21
-
22
- /* Excluded from this release type: createSingleBlobSummary */
23
-
24
- /* Excluded from this release type: FluidSerializer */
25
-
26
- /**
27
- * @public
28
- */
29
- export declare interface IFluidSerializer {
30
- /**
31
- * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
32
- * where any embedded IFluidHandles have been replaced with a serializable form.
33
- *
34
- * The original `input` object is not mutated. This method will shallowly clones all objects in the path from
35
- * the root to any replaced handles. (If no handles are found, returns the original object.)
36
- */
37
- encode(value: any, bind: IFluidHandle): any;
38
- /**
39
- * Given a fully-jsonable object tree that may have encoded handle objects embedded within, will return an
40
- * equivalent object tree where any encoded IFluidHandles have been replaced with their decoded form.
41
- *
42
- * The original `input` object is not mutated. This method will shallowly clone all objects in the path from
43
- * the root to any replaced handles. (If no handles are found, returns the original object.)
44
- *
45
- * The decoded handles are implicitly bound to the handle context of this serializer.
46
- */
47
- decode(input: any): any;
48
- /**
49
- * Stringifies a given value. Converts any IFluidHandle to its stringified equivalent.
50
- */
51
- stringify(value: any, bind: IFluidHandle): string;
52
- /**
53
- * Parses the given JSON input string and returns the JavaScript object defined by it. Any Fluid
54
- * handles will be realized as part of the parse
55
- */
56
- parse(value: string): any;
57
- }
58
-
59
- /**
60
- * Base interface for shared objects from which other interfaces derive. Implemented by SharedObject
61
- * @public
62
- */
63
- export declare interface ISharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends IChannel, IEventProvider<TEvent> {
64
- /**
65
- * Binds the given shared object to its containing data store runtime, causing it to attach once
66
- * the runtime attaches.
67
- */
68
- bindToContext(): void;
69
- /**
70
- * Returns the GC data for this shared object. It contains a list of GC nodes that contains references to
71
- * other GC nodes.
72
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
73
- */
74
- getGCData(fullGC?: boolean): IGarbageCollectionData;
75
- }
76
-
77
- /**
78
- * Events emitted by {@link ISharedObject}.
79
- * @public
80
- */
81
- export declare interface ISharedObjectEvents extends IErrorEvent {
82
- /**
83
- * Fires before an incoming operation (op) is applied to the shared object.
84
- *
85
- * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
86
- * use.
87
- *
88
- * @eventProperty
89
- */
90
- (event: "pre-op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
91
- /**
92
- * Fires after an incoming op is applied to the shared object.
93
- *
94
- * @remarks Note: this should be considered an internal implementation detail. It is not recommended for external
95
- * use.
96
- *
97
- * @eventProperty
98
- */
99
- (event: "op", listener: (op: ISequencedDocumentMessage, local: boolean, target: IEventThisPlaceHolder) => void): any;
100
- }
101
-
102
- /**
103
- * Given a mostly-plain object that may have handle objects embedded within, will return a fully-plain object
104
- * where any embedded IFluidHandles have been replaced with a serializable form.
105
- *
106
- * The original `input` object is not mutated. This method will shallowly clones all objects in the path from
107
- * the root to any replaced handles. (If no handles are found, returns the original object.)
108
- *
109
- * @param input - The mostly-plain object
110
- * @param context - The handle context for the container
111
- * @param bind - Bind any other handles we find in the object against this given handle.
112
- * @returns The fully-plain object
113
- * @alpha
114
- */
115
- export declare function makeHandlesSerializable(value: any, serializer: IFluidSerializer, bind: IFluidHandle): any;
116
-
117
- /**
118
- * Given a fully-plain object that may have serializable-form handles within, will return the mostly-plain object
119
- * with handle objects created instead.
120
- * @param value - The fully-plain object
121
- * @param serializer - The serializer that knows how to convert serializable-form handles into handle objects
122
- * @param context - The handle context for the container
123
- * @returns The mostly-plain object with handle objects within
124
- * @alpha
125
- */
126
- export declare function parseHandles(value: any, serializer: IFluidSerializer): any;
127
-
128
- /* Excluded from this release type: serializeHandles */
129
-
130
- /**
131
- * SharedObject with simplified, synchronous summarization and GC.
132
- * DDS implementations with async and incremental summarization should extend SharedObjectCore directly instead.
133
- * @alpha
134
- */
135
- export declare abstract class SharedObject<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends SharedObjectCore<TEvent> {
136
- private readonly telemetryContextPrefix;
137
- /**
138
- * True while we are garbage collecting this object's data.
139
- */
140
- private _isGCing;
141
- /**
142
- * The serializer to use to serialize / parse handles, if any.
143
- */
144
- private readonly _serializer;
145
- protected get serializer(): IFluidSerializer;
146
- /**
147
- * @param id - The id of the shared object
148
- * @param runtime - The IFluidDataStoreRuntime which contains the shared object
149
- * @param attributes - Attributes of the shared object
150
- */
151
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string);
152
- /**
153
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
154
- */
155
- getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
156
- /**
157
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
158
- */
159
- summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): Promise<ISummaryTreeWithStats>;
160
- /**
161
- * {@inheritDoc (ISharedObject:interface).getGCData}
162
- */
163
- getGCData(fullGC?: boolean): IGarbageCollectionData;
164
- /**
165
- * Calls the serializer over all data in this object that reference other GC nodes.
166
- * Derived classes must override this to provide custom list of references to other GC nodes.
167
- */
168
- protected processGCDataCore(serializer: IFluidSerializer): void;
169
- /**
170
- * Gets a form of the object that can be serialized.
171
- * @returns A tree representing the snapshot of the shared object.
172
- */
173
- protected abstract summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
174
- private incrementTelemetryMetric;
175
- }
176
-
177
- /**
178
- * Base class from which all shared objects derive.
179
- * @alpha
180
- */
181
- export declare abstract class SharedObjectCore<TEvent extends ISharedObjectEvents = ISharedObjectEvents> extends EventEmitterWithErrorHandling<TEvent> implements ISharedObject<TEvent> {
182
- id: string;
183
- protected runtime: IFluidDataStoreRuntime;
184
- readonly attributes: IChannelAttributes;
185
- get IFluidLoadable(): this;
186
- private readonly opProcessingHelper;
187
- private readonly callbacksHelper;
188
- /**
189
- * The handle referring to this SharedObject
190
- */
191
- readonly handle: IFluidHandle;
192
- /**
193
- * Telemetry logger for the shared object
194
- */
195
- protected readonly logger: ITelemetryLoggerExt;
196
- private readonly mc;
197
- /**
198
- * Connection state
199
- */
200
- private _connected;
201
- /**
202
- * Services used by the shared object
203
- */
204
- private services;
205
- /**
206
- * True if the dds is bound to its parent.
207
- */
208
- private _isBoundToContext;
209
- /**
210
- * Tracks error that closed this object.
211
- */
212
- private closeError?;
213
- /**
214
- * Gets the connection state
215
- * @returns The state of the connection
216
- */
217
- get connected(): boolean;
218
- /**
219
- * @param id - The id of the shared object
220
- * @param runtime - The IFluidDataStoreRuntime which contains the shared object
221
- * @param attributes - Attributes of the shared object
222
- */
223
- constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
224
- /**
225
- * This function is only supposed to be called from SharedObjectCore's constructor and
226
- * depends on a few things being set already. assert() calls make sure of it.
227
- * @returns The telemetry sampling helpers, so the constructor can be the one to assign them
228
- * to variables to avoid complaints from TypeScript.
229
- */
230
- private setUpSampledTelemetryHelpers;
231
- /**
232
- * Marks this objects as closed. Any attempt to change it (local changes or processing remote ops)
233
- * would result in same error thrown. If called multiple times, only first error is remembered.
234
- * @param error - error object that is thrown whenever an attempt is made to modify this object
235
- */
236
- private closeWithError;
237
- /**
238
- * Verifies that this object is not closed via closeWithError(). If it is, throws an error used to close it.
239
- */
240
- private verifyNotClosed;
241
- /**
242
- * Event listener handler helper that can be used to react to exceptions thrown from event listeners
243
- * It wraps error with DataProcessingError, closes this object and throws resulting error.
244
- * See closeWithError() for more details
245
- * Ideally such situation never happens, as consumers of DDS should never throw exceptions
246
- * in event listeners (i.e. catch any of the issues and make determination on how to handle it).
247
- * When such exceptions propagate through, most likely data model is no longer consistent, i.e.
248
- * DDS state does not match what user sees. Because of it DDS moves to "corrupted state" and does not
249
- * allow processing of ops or local changes, which very quickly results in container closure.
250
- */
251
- private eventListenerErrorHandler;
252
- private setBoundAndHandleAttach;
253
- /**
254
- * A shared object, after construction, can either be loaded in the case that it is already part of
255
- * a shared document. Or later attached if it is being newly added.
256
- * @param services - Services used by the shared object
257
- */
258
- load(services: IChannelServices): Promise<void>;
259
- /**
260
- * Initializes the object as a local, non-shared object. This object can become shared after
261
- * it is attached to the document.
262
- */
263
- initializeLocal(): void;
264
- /**
265
- * {@inheritDoc (ISharedObject:interface).bindToContext}
266
- */
267
- bindToContext(): void;
268
- /**
269
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).connect}
270
- */
271
- connect(services: IChannelServices): void;
272
- /**
273
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).isAttached}
274
- */
275
- isAttached(): boolean;
276
- /**
277
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
278
- */
279
- abstract getAttachSummary(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
280
- /**
281
- * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
282
- */
283
- abstract summarize(fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
284
- /**
285
- * {@inheritDoc (ISharedObject:interface).getGCData}
286
- */
287
- abstract getGCData(fullGC?: boolean): IGarbageCollectionData;
288
- /**
289
- * Called when a handle is decoded by this object. A handle in the object's data represents an outbound reference
290
- * to another object in the container.
291
- * @param decodedHandle - The handle of the Fluid object that is decoded.
292
- */
293
- protected handleDecoded(decodedHandle: IFluidHandle): void;
294
- /**
295
- * Allows the distributed data type to perform custom loading
296
- * @param services - Storage used by the shared object
297
- */
298
- protected abstract loadCore(services: IChannelStorageService): Promise<void>;
299
- /**
300
- * Allows the distributed data type to perform custom local loading.
301
- */
302
- protected initializeLocalCore(): void;
303
- /**
304
- * Allows the distributive data type the ability to perform custom processing once an attach has happened.
305
- * Also called after non-local data type get loaded.
306
- */
307
- protected didAttach(): void;
308
- /**
309
- * Derived classes must override this to do custom processing on a remote message.
310
- * @param message - The message to process
311
- * @param local - True if the shared object is local
312
- * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
313
- * For messages from a remote client, this will be undefined.
314
- */
315
- protected abstract processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): any;
316
- /**
317
- * Called when the object has disconnected from the delta stream.
318
- */
319
- protected abstract onDisconnect(): any;
320
- /**
321
- * The serializer to serialize / parse handles.
322
- */
323
- protected abstract get serializer(): IFluidSerializer;
324
- /**
325
- * Submits a message by the local client to the runtime.
326
- * @param content - Content of the message. Note: handles contained in the
327
- * message object should not be encoded in any way
328
- * @param localOpMetadata - The local metadata associated with the message. This is kept locally by the runtime
329
- * and not sent to the server. This will be sent back when this message is received back from the server. This is
330
- * also sent if we are asked to resubmit the message.
331
- */
332
- protected submitLocalMessage(content: any, localOpMetadata?: unknown): void;
333
- /**
334
- * Marks this object as dirty so that it is part of the next summary. It is called by a SharedSummaryBlock
335
- * that want to be part of summary but does not generate ops.
336
- */
337
- protected dirty(): void;
338
- /**
339
- * Called when the object has fully connected to the delta stream
340
- * Default implementation for DDS, override if different behavior is required.
341
- */
342
- protected onConnect(): void;
343
- /**
344
- * Called when a message has to be resubmitted. This typically happens after a reconnection for unacked messages.
345
- * The default implementation here is to resubmit the same message. The client can override if different behavior
346
- * is required. It can choose to resubmit the same message, submit different / multiple messages or not submit
347
- * anything at all.
348
- * @param content - The content of the original message.
349
- * @param localOpMetadata - The local metadata associated with the original message.
350
- */
351
- protected reSubmitCore(content: any, localOpMetadata: unknown): void;
352
- /**
353
- * Promises that are waiting for an ack from the server before resolving should use this instead of new Promise.
354
- * It ensures that if something changes that will interrupt that ack (e.g. the FluidDataStoreRuntime disposes),
355
- * the Promise will reject.
356
- * If runtime is disposed when this call is made, executor is not run and promise is rejected right away.
357
- */
358
- protected newAckBasedPromise<T>(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
359
- private attachDeltaHandler;
360
- /**
361
- * Set the state of connection to services.
362
- * @param connected - true if connected, false otherwise.
363
- */
364
- private setConnectionState;
365
- /**
366
- * Handles a message being received from the remote delta server.
367
- * @param message - The message to process
368
- * @param local - Whether the message originated from the local client
369
- * @param localOpMetadata - For local client messages, this is the metadata that was submitted with the message.
370
- * For messages from a remote client, this will be undefined.
371
- */
372
- private process;
373
- /**
374
- * Called when a message has to be resubmitted. This typically happens for unacked messages after a
375
- * reconnection.
376
- * @param content - The content of the original message.
377
- * @param localOpMetadata - The local metadata associated with the original message.
378
- */
379
- private reSubmit;
380
- /**
381
- * Revert an op
382
- */
383
- protected rollback(content: any, localOpMetadata: unknown): void;
384
- /**
385
- * Apply changes from the provided op content just as if a local client has made the change,
386
- * including submitting the op. Used when rehydrating an attached container
387
- * with pending changes. The rehydration process replays all remote ops
388
- * and applies stashed ops after the remote op with a sequence number
389
- * that matches that of the stashed op is applied. This ensures
390
- * stashed ops are applied at the same state they were originally created.
391
- *
392
- * It is possible that stashed ops have been sent in the past, and will be found when
393
- * the shared object catches up with remotes ops.
394
- * So this prepares the SharedObject for seeing potentially seeing the ACK.
395
- * If no matching remote op is found, all the applied stashed ops will go
396
- * through the normal resubmit flow upon reconnection, which allows the dds
397
- * to rebase them to the latest state, and then resubmit them.
398
- *
399
- * @param content - Contents of a stashed op.
400
- */
401
- protected abstract applyStashedOp(content: any): void;
402
- /**
403
- * Emit an event. This function is only intended for use by DDS classes that extend SharedObject/SharedObjectCore,
404
- * specifically to emit events that are part of the public interface of the DDS (i.e. those that can have listeners
405
- * attached to them by the consumers of the DDS). It should not be called from outside the class or to emit events
406
- * which are only internal to the DDS. Support for calling it from outside the DDS instance might be removed in the
407
- * future.
408
- * @param event - The event to emit.
409
- * @param args - Arguments to pass to the event listeners.
410
- * @returns `true` if the event had listeners, `false` otherwise.
411
- */
412
- emit(event: EventEmitterEventType, ...args: any[]): boolean;
413
- /**
414
- * Use to emit events inside {@link SharedObjectCore}, with no telemetry measurement
415
- * done on the duration of the callbacks. Simply calls `super.emit()`.
416
- * @param event - Event to emit
417
- * @param args - Arguments for the event
418
- * @returns Whatever `super.emit()` returns.
419
- */
420
- private emitInternal;
421
- }
422
-
423
- /* Excluded from this release type: SummarySerializer */
424
-
425
- /* Excluded from this release type: ValueType */
426
-
427
- export { }