fluid-framework 2.0.0-dev-rc.2.0.0.246488 → 2.0.0-dev-rc.3.0.0.253463

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.
@@ -6,16 +6,15 @@
6
6
 
7
7
  import { FluidObject } from '@fluidframework/core-interfaces';
8
8
  import { IChannel } from '@fluidframework/datastore-definitions';
9
- import { IChannelFactory } from '@fluidframework/datastore-definitions';
10
9
  import type { IErrorBase } from '@fluidframework/core-interfaces';
11
10
  import { IEvent } from '@fluidframework/core-interfaces';
12
11
  import { IEventProvider } from '@fluidframework/core-interfaces';
13
12
  import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
14
- import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
15
13
  import { IFluidHandle } from '@fluidframework/core-interfaces';
16
14
  import { IFluidLoadable } from '@fluidframework/core-interfaces';
17
15
  import { ISharedObject } from '@fluidframework/shared-object-base';
18
16
  import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
17
+ import { ISharedObjectKind } from '@fluidframework/shared-object-base';
19
18
 
20
19
  // @public
21
20
  export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
@@ -23,9 +22,6 @@ export type AllowedTypes = readonly LazyItem<TreeNodeSchema>[];
23
22
  // @public
24
23
  export type ApplyKind<T, Kind extends FieldKind> = Kind extends FieldKind.Required ? T : undefined | T;
25
24
 
26
- // @public
27
- export type ArrayToUnion<T extends readonly unknown[]> = T[number];
28
-
29
25
  // @public
30
26
  export enum AttachState {
31
27
  Attached = "Attached",
@@ -42,8 +38,8 @@ export enum CommitKind {
42
38
 
43
39
  // @public
44
40
  export interface CommitMetadata {
45
- isLocal: boolean;
46
- kind: CommitKind;
41
+ readonly isLocal: boolean;
42
+ readonly kind: CommitKind;
47
43
  }
48
44
 
49
45
  // @public
@@ -88,11 +84,11 @@ export interface ContainerSchema {
88
84
  }
89
85
 
90
86
  // @public
91
- export type DataObjectClass<T extends IFluidLoadable> = {
87
+ export type DataObjectClass<T extends IFluidLoadable = IFluidLoadable> = {
92
88
  readonly factory: {
93
- IFluidDataStoreFactory: DataObjectClass<T>["factory"];
89
+ readonly IFluidDataStoreFactory: DataObjectClass<T>["factory"];
94
90
  };
95
- } & LoadableObjectCtor<T>;
91
+ } & (new (...args: any[]) => T);
96
92
 
97
93
  // @public
98
94
  export const disposeSymbol: unique symbol;
@@ -136,13 +132,21 @@ export enum FieldKind {
136
132
  Required = 1
137
133
  }
138
134
 
135
+ // @public
136
+ export interface FieldProps {
137
+ readonly key?: string;
138
+ }
139
+
139
140
  // @public @sealed
140
141
  export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types extends ImplicitAllowedTypes = ImplicitAllowedTypes> {
141
- constructor(kind: Kind, allowedTypes: Types);
142
- // (undocumented)
142
+ constructor(
143
+ kind: Kind,
144
+ allowedTypes: Types,
145
+ props?: FieldProps | undefined);
143
146
  readonly allowedTypes: Types;
144
- // (undocumented)
147
+ get allowedTypeSet(): ReadonlySet<TreeNodeSchema>;
145
148
  readonly kind: Kind;
149
+ readonly props?: FieldProps | undefined;
146
150
  protected _typeCheck?: MakeNominal;
147
151
  }
148
152
 
@@ -150,12 +154,12 @@ export class FieldSchema<out Kind extends FieldKind = FieldKind, out Types exten
150
154
  export type FlexList<Item = unknown> = readonly LazyItem<Item>[];
151
155
 
152
156
  // @public
153
- export type FlexListToUnion<TList extends FlexList> = ExtractItemType<ArrayToUnion<TList>>;
157
+ export type FlexListToUnion<TList extends FlexList> = ExtractItemType<TList[number]>;
154
158
 
155
159
  // @public
156
160
  export interface IConnection {
157
- id: string;
158
- mode: "write" | "read";
161
+ readonly id: string;
162
+ readonly mode: "write" | "read";
159
163
  }
160
164
 
161
165
  // @public
@@ -191,8 +195,8 @@ export interface IFluidContainerEvents extends IEvent {
191
195
 
192
196
  // @public
193
197
  export interface IMember {
194
- connections: IConnection[];
195
- userId: string;
198
+ readonly connections: IConnection[];
199
+ readonly userId: string;
196
200
  }
197
201
 
198
202
  // @public
@@ -224,7 +228,7 @@ export type InsertableTypedNode<T extends TreeNodeSchema> = (T extends {
224
228
 
225
229
  // @public
226
230
  export interface IServiceAudience<M extends IMember> extends IEventProvider<IServiceAudienceEvents<M>> {
227
- getMembers(): Map<string, M>;
231
+ getMembers(): ReadonlyMap<string, M>;
228
232
  getMyself(): Myself<M> | undefined;
229
233
  }
230
234
 
@@ -270,22 +274,19 @@ export interface ITree extends IChannel {
270
274
 
271
275
  // @public @sealed
272
276
  export interface IValueChanged {
273
- key: string;
274
- previousValue: any;
277
+ readonly key: string;
278
+ readonly previousValue: any;
275
279
  }
276
280
 
277
281
  // @public
278
282
  export type LazyItem<Item = unknown> = Item | (() => Item);
279
283
 
280
284
  // @public
281
- export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = SharedObjectClass<T> | DataObjectClass<T>;
285
+ export type LoadableObjectClass<T extends IFluidLoadable = IFluidLoadable> = ISharedObjectKind<T> | DataObjectClass<T>;
282
286
 
283
287
  // @public
284
288
  export type LoadableObjectClassRecord = Record<string, LoadableObjectClass>;
285
289
 
286
- // @public
287
- export type LoadableObjectCtor<T extends IFluidLoadable> = new (...args: any[]) => T;
288
-
289
290
  // @public
290
291
  export interface MakeNominal {
291
292
  }
@@ -295,7 +296,7 @@ export type MemberChangedListener<M extends IMember> = (clientId: string, member
295
296
 
296
297
  // @public
297
298
  export type Myself<M extends IMember = IMember> = M & {
298
- currentConnection: string;
299
+ readonly currentConnection: string;
299
300
  };
300
301
 
301
302
  // @public
@@ -343,15 +344,16 @@ export class SchemaFactory<out TScope extends string | undefined = string | unde
343
344
  readonly boolean: TreeNodeSchema<"com.fluidframework.leaf.boolean", NodeKind.Leaf, boolean, boolean>;
344
345
  // @deprecated
345
346
  fixRecursiveReference<T extends AllowedTypes>(...types: T): void;
346
- readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject & IFluidLoadable>, IFluidHandle<FluidObject & IFluidLoadable>>;
347
+ readonly handle: TreeNodeSchema<"com.fluidframework.leaf.handle", NodeKind.Leaf, IFluidHandle<FluidObject<unknown> & IFluidLoadable>, IFluidHandle<FluidObject<unknown> & IFluidLoadable>>;
347
348
  map<const T extends TreeNodeSchema | readonly TreeNodeSchema[]>(allowedTypes: T): TreeNodeSchema<ScopedSchemaName<TScope, `Map<${string}>`>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, `Map<${string}>`>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
348
349
  map<Name extends TName, const T extends ImplicitAllowedTypes>(name: Name, allowedTypes: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, true, T>;
349
350
  namedArray_internal<Name extends TName | string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(name: Name, allowedTypes: T, customizable: boolean, implicitlyConstructable: ImplicitlyConstructable): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Array, TreeArrayNode<T> & WithType<ScopedSchemaName<TScope, string>>, Iterable<InsertableTreeNodeFromImplicitAllowedTypes<T>>, ImplicitlyConstructable, T>;
350
351
  namedMap_internal<Name extends TName | string, const T extends ImplicitAllowedTypes, const ImplicitlyConstructable extends boolean>(name: Name, allowedTypes: T, customizable: boolean, implicitlyConstructable: ImplicitlyConstructable): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Map, TreeMapNode<T> & WithType<ScopedSchemaName<TScope, Name>>, Iterable<[string, InsertableTreeNodeFromImplicitAllowedTypes<T>]>, ImplicitlyConstructable, T>;
351
352
  readonly null: TreeNodeSchema<"com.fluidframework.leaf.null", NodeKind.Leaf, null, null>;
352
353
  readonly number: TreeNodeSchema<"com.fluidframework.leaf.number", NodeKind.Leaf, number, number>;
353
- object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, t: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeNode & ObjectFromSchemaRecord<T> & WithType<ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
354
- optional<const T extends ImplicitAllowedTypes>(t: T): FieldSchema<FieldKind.Optional, T>;
354
+ object<const Name extends TName, const T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>>(name: Name, fields: T): TreeNodeSchemaClass<ScopedSchemaName<TScope, Name>, NodeKind.Object, TreeObjectNode<T, ScopedSchemaName<TScope, Name>>, object & InsertableObjectFromSchemaRecord<T>, true, T>;
355
+ optional<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Optional, T>;
356
+ required<const T extends ImplicitAllowedTypes>(t: T, props?: FieldProps): FieldSchema<FieldKind.Required, T>;
355
357
  // (undocumented)
356
358
  readonly scope: TScope;
357
359
  readonly string: TreeNodeSchema<"com.fluidframework.leaf.string", NodeKind.Leaf, string, string>;
@@ -366,23 +368,13 @@ export interface SchemaIncompatible {
366
368
  export type ScopedSchemaName<TScope extends string | undefined, TName extends number | string> = TScope extends undefined ? `${TName}` : `${TScope}.${TName}`;
367
369
 
368
370
  // @public @deprecated
369
- export const SharedMap: {
370
- getFactory(): IChannelFactory<ISharedMap>;
371
- create(runtime: IFluidDataStoreRuntime, id?: string): ISharedMap;
372
- };
371
+ export const SharedMap: ISharedObjectKind<ISharedMap>;
373
372
 
374
373
  // @public @deprecated
375
374
  export type SharedMap = ISharedMap;
376
375
 
377
376
  // @public
378
- export interface SharedObjectClass<T extends IFluidLoadable> {
379
- readonly getFactory: () => IChannelFactory<T>;
380
- }
381
-
382
- // @public
383
- export const SharedTree: {
384
- getFactory(): IChannelFactory<ITree>;
385
- };
377
+ export const SharedTree: ISharedObjectKind<ITree>;
386
378
 
387
379
  // @public
388
380
  export const Tree: TreeApi;
@@ -394,7 +386,7 @@ export interface TreeApi extends TreeNodeApi {
394
386
  }
395
387
 
396
388
  // @public
397
- export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeNode, TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
389
+ export interface TreeArrayNode<TAllowedTypes extends ImplicitAllowedTypes = ImplicitAllowedTypes> extends TreeArrayNodeBase<TreeNodeFromImplicitAllowedTypes<TAllowedTypes>, InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes>, TreeArrayNode> {
398
390
  }
399
391
 
400
392
  // @public
@@ -423,6 +415,12 @@ export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends Readonl
423
415
  removeRange(start?: number, end?: number): void;
424
416
  }
425
417
 
418
+ // @public
419
+ export interface TreeChangeEvents {
420
+ nodeChanged(): void;
421
+ treeChanged(): void;
422
+ }
423
+
426
424
  // @public
427
425
  export class TreeConfiguration<TSchema extends ImplicitFieldSchema = ImplicitFieldSchema> {
428
426
  constructor(schema: TSchema, initialTree: () => InsertableTreeFieldFromImplicitField<TSchema>);
@@ -453,17 +451,12 @@ export abstract class TreeNode implements WithType {
453
451
  export interface TreeNodeApi {
454
452
  is<TSchema extends TreeNodeSchema>(value: unknown, schema: TSchema): value is NodeFromSchema<TSchema>;
455
453
  key(node: TreeNode): string | number;
456
- on<K extends keyof TreeNodeEvents>(node: TreeNode, eventName: K, listener: TreeNodeEvents[K]): () => void;
454
+ on<K extends keyof TreeChangeEvents>(node: TreeNode, eventName: K, listener: TreeChangeEvents[K]): () => void;
457
455
  parent(node: TreeNode): TreeNode | undefined;
458
456
  schema<T extends TreeNode | TreeLeafValue>(node: T): TreeNodeSchema<string, NodeKind, unknown, T>;
459
457
  readonly status: (node: TreeNode) => TreeStatus;
460
458
  }
461
459
 
462
- // @public
463
- export interface TreeNodeEvents {
464
- afterChange(): void;
465
- }
466
-
467
460
  // @public
468
461
  export type TreeNodeFromImplicitAllowedTypes<TSchema extends ImplicitAllowedTypes = TreeNodeSchema> = TSchema extends TreeNodeSchema ? NodeFromSchema<TSchema> : TSchema extends AllowedTypes ? NodeFromSchema<FlexListToUnion<TSchema>> : unknown;
469
462
 
@@ -492,6 +485,9 @@ export interface TreeNodeSchemaNonClass<out Name extends string = string, out Ki
492
485
  create(data: TInsertable): TNode;
493
486
  }
494
487
 
488
+ // @public
489
+ export type TreeObjectNode<T extends RestrictiveReadonlyRecord<string, ImplicitFieldSchema>, TypeName extends string = string> = TreeNode & ObjectFromSchemaRecord<T> & WithType<TypeName>;
490
+
495
491
  // @public
496
492
  export enum TreeStatus {
497
493
  Deleted = 2,