Skip to content

Commit

Permalink
Type Erase Shared object kinds (#21081)
Browse files Browse the repository at this point in the history
## Description

Make ISharedObjectKind, IChannel, IChannelFactory,
IFluidDataStoreRuntime and more alpha by tweaking fluid-static APIs
typing.

## Breaking Changes

Access to these now less public types should not be required for users
of the `@public` "declarative API" exposed in the `fluid-framework`
package, but can still be accessed for those who need them under the
`/legacy` import paths.
The full list of such types is:

- `SharedTree` as exported from `@fluidframwork/tree`: It is still
exported as `@public` from `fluid-framework` as `SharedObjectKind`.
- `ISharedObjectKind`: See new `SharedObjectKind` type for use in
`@public` APIs.
    `ISharedObject`
-   `IChannel`
-   `IChannelAttributes`
-   `IChannelFactory`
-   `IExperimentalIncrementalSummaryContext`
-   `IGarbageCollectionData`
-   `ISummaryStats`
-   `ISummaryTreeWithStats`
-   `ITelemetryContext`
-   `IDeltaManagerErased`
-   `IFluidDataStoreRuntimeEvents`
-   `IFluidHandleContext`
-   `IProvideFluidHandleContext`

Removed APIs:

-   `DataObjectClass`: Usages replaced with `SharedObjectKind`.
-   `LoadableObjectClass`: Replaced with `SharedObjectKind`.
- `LoadableObjectClassRecord`: Replaced with `Record<string,
SharedObjectKind>`.
  • Loading branch information
CraigMacomber authored May 17, 2024
1 parent a758a08 commit 78f228e
Show file tree
Hide file tree
Showing 251 changed files with 1,207 additions and 769 deletions.
44 changes: 44 additions & 0 deletions .changeset/bright-icons-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
"@fluidframework/container-runtime": minor
"@fluidframework/core-interfaces": minor
"@fluidframework/datastore-definitions": minor
"fluid-framework": minor
"@fluidframework/fluid-static": minor
"@fluidframework/runtime-definitions": minor
"@fluidframework/shared-object-base": minor
"@fluidframework/tree": minor
---

Type Erase ISharedObjectKind

A new type, `SharedObjectKind` is added as a type erased version of `ISharedObjectKind` and `DataObjectClass`.

This type fills the role of both `ISharedObjectKind` and `DataObjectClass` in the `@public` "declarative API" exposed in the `fluid-framework` package.

This allows several types referenced by `ISharedObjectKind` to be made `@alpha` as they should only need to be used by legacy code and users of the unstable/alpha/legacy "encapsulated API".

Access to these now less public types should not be required for users of the `@public` "declarative API" exposed in the `fluid-framework` package, but can still be accessed for those who need them under the `/legacy` import paths.
The full list of such types is:

- `SharedTree` as exported from `@fluidframwork/tree`: It is still exported as `@public` from `fluid-framework` as `SharedObjectKind`.
- `ISharedObjectKind`: See new `SharedObjectKind` type for use in `@public` APIs.
`ISharedObject`
- `IChannel`
- `IChannelAttributes`
- `IChannelFactory`
- `IExperimentalIncrementalSummaryContext`
- `IGarbageCollectionData`
- `ISummaryStats`
- `ISummaryTreeWithStats`
- `ITelemetryContext`
- `IDeltaManagerErased`
- `IFluidDataStoreRuntimeEvents`
- `IFluidHandleContext`
- `IProvideFluidHandleContext`

Removed APIs:

- `DataObjectClass`: Usages replaced with `SharedObjectKind`.
- `LoadableObjectClass`: Replaced with `SharedObjectKind`.
- `LoadableObjectClassRecord`: Replaced with `Record<string, SharedObjectKind>`.
-
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
SharedTree,
Tree,
TreeConfiguration,
} from "@fluidframework/tree";
} from "@fluidframework/tree/internal";
import { TypedEmitter } from "tiny-typed-emitter";
import { v4 as uuid } from "uuid";

Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/tablebench/src/azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { AzureClient, AzureLocalConnectionConfig } from "@fluidframework/azure-client";
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils/internal";
import { SharedTree } from "@fluidframework/tree";
import { SharedTree } from "@fluidframework/tree/internal";

const userId = Math.random().toString(36).slice(2);

Expand Down
9 changes: 7 additions & 2 deletions examples/benchmarks/tablebench/src/test/table.bench.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@
*/

import { BenchmarkType, benchmark, isInPerformanceTestingMode } from "@fluid-tools/benchmark";
import { IChannel } from "@fluidframework/datastore-definitions";
import { IChannel } from "@fluidframework/datastore-definitions/internal";
import { SharedMatrix } from "@fluidframework/matrix/internal";
import { type ITree, NodeFromSchema, SharedTree, TreeConfiguration } from "@fluidframework/tree";
import {
type ITree,
NodeFromSchema,
SharedTree,
TreeConfiguration,
} from "@fluidframework/tree/internal";

import { Table, generateTable } from "../index.js";

Expand Down
2 changes: 1 addition & 1 deletion examples/benchmarks/tablebench/src/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IsoBuffer } from "@fluid-internal/client-utils";
import { makeRandom } from "@fluid-private/stochastic-test-utils";
import { IChannel, IChannelFactory } from "@fluidframework/datastore-definitions";
import { IChannel, IChannelFactory } from "@fluidframework/datastore-definitions/internal";
import { SessionId } from "@fluidframework/id-compressor";
import { createIdCompressor } from "@fluidframework/id-compressor/internal";
import {
Expand Down
2 changes: 1 addition & 1 deletion examples/data-objects/codemirror/src/codeMirror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FluidObjectHandle,
mixinRequestHandler,
} from "@fluidframework/datastore/internal";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
import { ISharedMap, SharedMap } from "@fluidframework/map/internal";
import {
IFluidDataStoreContext,
Expand Down
2 changes: 1 addition & 1 deletion examples/data-objects/codemirror/src/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { EventEmitter } from "@fluid-example/example-utils";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
import { IInboundSignalMessage } from "@fluidframework/runtime-definitions";
import CodeMirror from "codemirror";

Expand Down
2 changes: 1 addition & 1 deletion examples/data-objects/prosemirror/src/prosemirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FluidObjectHandle,
mixinRequestHandler,
} from "@fluidframework/datastore/internal";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
import { ISharedMap, SharedMap } from "@fluidframework/map/internal";
import {
IFluidDataStoreContext,
Expand Down
2 changes: 1 addition & 1 deletion examples/data-objects/smde/src/smde.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { EventEmitter } from "@fluid-example/example-utils";
import { IFluidHandle, IFluidLoadable } from "@fluidframework/core-interfaces";
import { assert } from "@fluidframework/core-utils/internal";
import { FluidDataStoreRuntime, FluidObjectHandle } from "@fluidframework/datastore/internal";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
import { ISharedMap, SharedMap } from "@fluidframework/map/internal";
import {
IFluidDataStoreContext,
Expand Down
2 changes: 1 addition & 1 deletion examples/utils/bundle-size-tests/src/fluidFramework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
import { SharedTree } from "fluid-framework";

export function apisToBundle() {
SharedTree.getFactory();
return SharedTree;
}
4 changes: 2 additions & 2 deletions examples/utils/bundle-size-tests/src/sharedTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License.
*/

import { SharedTree } from "@fluidframework/tree";
import { SharedTree } from "@fluidframework/tree/internal";

export function apisToBundle() {
SharedTree.getFactory();
return SharedTree;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { EditLog } from "@fluid-experimental/tree/test/EditLog";
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/internal";
import { IFluidHandle } from "@fluidframework/core-interfaces";
import { ITree, SharedTree } from "@fluidframework/tree";
import { ITree, SharedTree } from "@fluidframework/tree/internal";

import type { IInventoryItem, IInventoryList, IMigrateBackingData } from "../modelInterfaces.js";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
```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 { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import { IChannelStorageService } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { IsoBuffer } from '@fluid-internal/client-utils';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
import { NodeProperty } from '@fluid-experimental/property-properties';
import { SharedObject } from '@fluidframework/shared-object-base/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base/internal';

// @internal (undocumented)
export abstract class CompressedPropertyTreeFactory implements IChannelFactory {
Expand Down Expand Up @@ -260,7 +261,7 @@ export class SharedPropertyTree extends SharedObject {
}

// @internal
export const SharedPropertyTreeKind: ISharedObjectKind<SharedPropertyTree>;
export const SharedPropertyTreeKind: ISharedObjectKind<SharedPropertyTree> & SharedObjectKind<SharedPropertyTree>;

// @internal (undocumented)
export interface SharedPropertyTreeOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import {
IChannelFactory,
IChannelStorageService,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { SharedObject } from "@fluidframework/shared-object-base/internal";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
* Licensed under the MIT License.
*/

import { IChannelFactory, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import {
IChannelFactory,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions/internal";

import { SharedPropertyTree } from "./propertyTree.js";
import { DeflatedPropertyTreeFactory, LZ4PropertyTreeFactory } from "./propertyTreeExtFactories.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
IChannelFactory,
IChannelServices,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import { compress, decompress } from "lz4js";
import { deflate, inflate } from "pako";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IChannelFactory,
IChannelServices,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import { createSharedObjectKind } from "@fluidframework/shared-object-base/internal";

import { SharedPropertyTree, SharedPropertyTreeOptions } from "./propertyTree.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { AttributionKey } from '@fluidframework/runtime-definitions/internal';
import { IEventThisPlaceHolder } from '@fluidframework/core-interfaces';
import { IFluidHandle } from '@fluidframework/core-interfaces';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { ISharedObject } from '@fluidframework/shared-object-base';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base';
import { ISharedObjectKind } from '@fluidframework/shared-object-base';
import { ISharedObject } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectEvents } from '@fluidframework/shared-object-base/internal';
import { ISharedObjectKind } from '@fluidframework/shared-object-base/internal';
import { SharedObjectKind } from '@fluidframework/shared-object-base';

// @internal
export const AttributableMap: ISharedObjectKind<ISharedMap>;
export const AttributableMap: ISharedObjectKind<ISharedMap> & SharedObjectKind<ISharedMap>;

// @internal
export interface ILocalValue {
Expand Down
2 changes: 1 addition & 1 deletion experimental/dds/attributable-map/src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IEventThisPlaceHolder } from "@fluidframework/core-interfaces";
import { AttributionKey } from "@fluidframework/runtime-definitions/internal";
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base";
import { ISharedObject, ISharedObjectEvents } from "@fluidframework/shared-object-base/internal";
/**
* Type of "valueChanged" event parameter.
* @internal
Expand Down
9 changes: 6 additions & 3 deletions experimental/dds/attributable-map/src/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ import {
IChannelServices,
IChannelStorageService,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import { readAndParse } from "@fluidframework/driver-utils/internal";
import { ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
import { ISummaryTreeWithStats, ITelemetryContext } from "@fluidframework/runtime-definitions";
import { AttributionKey } from "@fluidframework/runtime-definitions/internal";
import {
ISummaryTreeWithStats,
ITelemetryContext,
AttributionKey,
} from "@fluidframework/runtime-definitions/internal";
import { SummaryTreeBuilder } from "@fluidframework/runtime-utils/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { SharedObject, createSharedObjectKind } from "@fluidframework/shared-object-base/internal";
Expand Down
8 changes: 4 additions & 4 deletions experimental/dds/ot/ot/api-report/ot.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
```ts

import { IChannelAttributes } from '@fluidframework/datastore-definitions';
import { IChannelStorageService } from '@fluidframework/datastore-definitions';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelStorageService } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { IFluidSerializer } from '@fluidframework/shared-object-base';
import { ISequencedDocumentMessage } from '@fluidframework/protocol-definitions';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions';
import { ISummaryTreeWithStats } from '@fluidframework/runtime-definitions/internal';
import { SharedObject } from '@fluidframework/shared-object-base/internal';

// @internal (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions experimental/dds/ot/ot/src/ot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
IChannelAttributes,
IChannelStorageService,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions";
import { ISummaryTreeWithStats } from "@fluidframework/runtime-definitions/internal";
import { IFluidSerializer } from "@fluidframework/shared-object-base";
import { SharedObject, createSingleBlobSummary } from "@fluidframework/shared-object-base/internal";

Expand Down
2 changes: 1 addition & 1 deletion experimental/dds/ot/ot/src/test/delta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
IChannelFactory,
IChannelServices,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";
import Delta from "quill-delta";

import { SharedOT } from "../index.js";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
```ts

import { Doc } from 'ot-json1';
import { IChannel } from '@fluidframework/datastore-definitions';
import { IChannelAttributes } from '@fluidframework/datastore-definitions';
import { IChannelFactory } from '@fluidframework/datastore-definitions';
import { IChannelServices } from '@fluidframework/datastore-definitions';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions';
import { IChannel } from '@fluidframework/datastore-definitions/internal';
import { IChannelAttributes } from '@fluidframework/datastore-definitions/internal';
import { IChannelFactory } from '@fluidframework/datastore-definitions/internal';
import { IChannelServices } from '@fluidframework/datastore-definitions/internal';
import { IFluidDataStoreRuntime } from '@fluidframework/datastore-definitions/internal';
import { JSONOp } from 'ot-json1';
import { Path } from 'ot-json1';
import { Serializable } from '@fluidframework/datastore-definitions/internal';
Expand Down
2 changes: 1 addition & 1 deletion experimental/dds/ot/sharejs/json1/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
IChannelFactory,
IChannelServices,
IFluidDataStoreRuntime,
} from "@fluidframework/datastore-definitions";
} from "@fluidframework/datastore-definitions/internal";

import { SharedJson1 } from "./json1.js";
import { pkgVersion } from "./packageVersion.js";
Expand Down
7 changes: 5 additions & 2 deletions experimental/dds/ot/sharejs/json1/src/json1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
*/

import { SharedOT } from "@fluid-experimental/ot";
import { IChannelAttributes, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { Serializable } from "@fluidframework/datastore-definitions/internal";
import {
IChannelAttributes,
IFluidDataStoreRuntime,
Serializable,
} from "@fluidframework/datastore-definitions/internal";
import {
Doc,
JSONOp,
Expand Down
Loading

0 comments on commit 78f228e

Please sign in to comment.