Skip to content

Commit

Permalink
Remove the exposure of SharedDirectory API (#20030)
Browse files Browse the repository at this point in the history
Hide the class implementation of `SharedDirectory` and update the
corresponding exports, a follow up fix of
#19717


[AB#5799](https://dev.azure.com/fluidframework/internal/_workitems/edit/5799)

---------

Co-authored-by: Scarlett Lee <90647596+scarlettjlee@users.noreply.github.com>
  • Loading branch information
clarenceli-msft and scarlettjlee authored Mar 27, 2024
1 parent 3863349 commit 2e699b8
Show file tree
Hide file tree
Showing 27 changed files with 627 additions and 908 deletions.
10 changes: 10 additions & 0 deletions .changeset/clever-cats-jump.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"fluid-framework": minor
"@fluidframework/map": minor
---

DDS classes are no longer publicly exported

SharedDirectory now only exports its factory and the interface type.
The actual concrete classes which leak implementation details are no longer exported.
Users of the `SharedDirectory` type should use `ISharedDirectory`.
155 changes: 8 additions & 147 deletions packages/dds/map/api-report/map.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,17 @@
```ts

import { IChannelAttributes } from '@fluidframework/datastore-definitions';
import { IChannelFactory } from '@fluidframework/datastore-definitions';
import { IChannelServices } from '@fluidframework/datastore-definitions';
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
import type { IChannelAttributes } from '@fluidframework/datastore-definitions';
import type { IChannelFactory } from '@fluidframework/datastore-definitions';
import type { IChannelServices } from '@fluidframework/datastore-definitions';
import { IDisposable } from '@fluidframework/core-interfaces';
import { IEvent } from '@fluidframework/core-interfaces';
import { IEventProvider } from '@fluidframework/core-interfaces';
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IFluidHandle } from '@fluidframework/core-interfaces';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import type { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { ISharedObject } from '@fluidframework/shared-object-base';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import type { ISharedObjectKind } from '@fluidframework/shared-object-base';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
import { ITelemetryContext } from '@fluidframework/runtime-definitions';
import { SharedObject } from '@fluidframework/shared-object-base';

// @alpha @sealed
export class DirectoryFactory implements IChannelFactory<ISharedDirectory> {
Expand All @@ -33,12 +26,6 @@ export class DirectoryFactory implements IChannelFactory<ISharedDirectory> {
get type(): string;
}

// @alpha
export interface ICreateInfo {
ccIds: string[];
csn: number;
}

// @alpha
export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryEvents>, Partial<IDisposable> {
readonly absolutePath: string;
Expand All @@ -53,44 +40,6 @@ export interface IDirectory extends Map<string, any>, IEventProvider<IDirectoryE
subdirectories(): IterableIterator<[string, IDirectory]>;
}

// @alpha
export interface IDirectoryClearOperation {
path: string;
type: "clear";
}

// @alpha
export interface IDirectoryCreateSubDirectoryOperation {
path: string;
subdirName: string;
type: "createSubDirectory";
}

// @alpha
export interface IDirectoryDataObject {
ci?: ICreateInfo;
storage?: {
[key: string]: ISerializableValue;
};
subdirectories?: {
[subdirName: string]: IDirectoryDataObject;
};
}

// @alpha
export interface IDirectoryDeleteOperation {
key: string;
path: string;
type: "delete";
}

// @alpha
export interface IDirectoryDeleteSubDirectoryOperation {
path: string;
subdirName: string;
type: "deleteSubDirectory";
}

// @alpha
export interface IDirectoryEvents extends IEvent {
(event: "containedValueChanged", listener: (changed: IValueChanged, local: boolean, target: IEventThisPlaceHolder) => void): any;
Expand All @@ -100,56 +49,11 @@ export interface IDirectoryEvents extends IEvent {
(event: "undisposed", listener: (target: IEventThisPlaceHolder) => void): any;
}

// @alpha
export type IDirectoryKeyOperation = IDirectorySetOperation | IDirectoryDeleteOperation;

// @internal
export interface IDirectoryNewStorageFormat {
blobs: string[];
content: IDirectoryDataObject;
}

// @alpha
export type IDirectoryOperation = IDirectoryStorageOperation | IDirectorySubDirectoryOperation;

// @alpha
export interface IDirectorySetOperation {
key: string;
path: string;
type: "set";
value: ISerializableValue;
}

// @alpha
export type IDirectoryStorageOperation = IDirectoryKeyOperation | IDirectoryClearOperation;

// @alpha
export type IDirectorySubDirectoryOperation = IDirectoryCreateSubDirectoryOperation | IDirectoryDeleteSubDirectoryOperation;

// @alpha
export interface IDirectoryValueChanged extends IValueChanged {
path: string;
}

// @alpha
export interface ILocalValue {
makeSerialized(serializer: IFluidSerializer, bind: IFluidHandle): ISerializedValue;
readonly type: string;
readonly value: any;
}

// @alpha @deprecated
export interface ISerializableValue {
type: string;
value: any;
}

// @alpha
export interface ISerializedValue {
type: string;
value: string | undefined;
}

// @alpha
export interface ISharedDirectory extends ISharedObject<ISharedDirectoryEvents & IDirectoryEvents>, Omit<IDirectory, "on" | "once" | "off"> {
// (undocumented)
Expand Down Expand Up @@ -184,13 +88,6 @@ export interface IValueChanged {
previousValue: any;
}

// @alpha
export class LocalValueMaker {
constructor();
fromInMemory(value: unknown): ILocalValue;
fromSerializable(serializable: ISerializableValue, serializer: IFluidSerializer, bind: IFluidHandle): ILocalValue;
}

// @alpha @sealed
export class MapFactory implements IChannelFactory<ISharedMap> {
static readonly Attributes: IChannelAttributes;
Expand All @@ -202,46 +99,10 @@ export class MapFactory implements IChannelFactory<ISharedMap> {
}

// @alpha @sealed
export class SharedDirectory extends SharedObject<ISharedDirectoryEvents> implements ISharedDirectory {
[Symbol.iterator](): IterableIterator<[string, any]>;
[Symbol.toStringTag]: string;
constructor(id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes);
get absolutePath(): string;
protected applyStashedOp(op: unknown): void;
clear(): void;
countSubDirectory(): number;
static create(runtime: IFluidDataStoreRuntime, id?: string): ISharedDirectory;
createSubDirectory(subdirName: string): IDirectory;
delete(key: string): boolean;
deleteSubDirectory(subdirName: string): boolean;
// (undocumented)
dispose(error?: Error): void;
// (undocumented)
get disposed(): boolean;
entries(): IterableIterator<[string, any]>;
forEach(callback: (value: any, key: string, map: Map<string, any>) => void): void;
get<T = any>(key: string): T | undefined;
static getFactory(): IChannelFactory<ISharedDirectory>;
getSubDirectory(subdirName: string): IDirectory | undefined;
getWorkingDirectory(relativePath: string): IDirectory | undefined;
has(key: string): boolean;
hasSubDirectory(subdirName: string): boolean;
keys(): IterableIterator<string>;
protected loadCore(storage: IChannelStorageService): Promise<void>;
// (undocumented)
readonly localValueMaker: LocalValueMaker;
protected onDisconnect(): void;
protected populate(data: IDirectoryDataObject): void;
protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
protected reSubmitCore(content: unknown, localOpMetadata: unknown): void;
protected rollback(content: unknown, localOpMetadata: unknown): void;
set<T = unknown>(key: string, value: T): this;
get size(): number;
subdirectories(): IterableIterator<[string, IDirectory]>;
submitDirectoryMessage(op: IDirectoryOperation, localOpMetadata: unknown): void;
protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext): ISummaryTreeWithStats;
values(): IterableIterator<any>;
}
export const SharedDirectory: ISharedObjectKind<ISharedDirectory>;

// @alpha @deprecated
export type SharedDirectory = ISharedDirectory;

// @public @deprecated
export const SharedMap: ISharedObjectKind<ISharedMap>;
Expand Down
67 changes: 67 additions & 0 deletions packages/dds/map/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,73 @@
},
"ClassDeclaration_SharedMap": {
"backCompat": false
},
"RemovedClassDeclaration_SharedDirectory": {
"backCompat": false
},
"RemovedInterfaceDeclaration_ICreateInfo": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryClearOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryCreateSubDirectoryOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryDataObject": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryDeleteOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryDeleteSubDirectoryOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedTypeAliasDeclaration_IDirectoryKeyOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectoryNewStorageFormat": {
"forwardCompat": false,
"backCompat": false
},
"RemovedTypeAliasDeclaration_IDirectoryOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_IDirectorySetOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedTypeAliasDeclaration_IDirectoryStorageOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedTypeAliasDeclaration_IDirectorySubDirectoryOperation": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_ILocalValue": {
"forwardCompat": false,
"backCompat": false
},
"RemovedClassDeclaration_LocalValueMaker": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_ISerializableValue": {
"forwardCompat": false,
"backCompat": false
},
"RemovedInterfaceDeclaration_ISerializedValue": {
"forwardCompat": false,
"backCompat": false
}
}
}
Expand Down
Loading

0 comments on commit 2e699b8

Please sign in to comment.