Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
// @beta @legacy
export type AliasResult = "Success" | "Conflict" | "AlreadyAliased";

// @alpha @sealed @legacy
export function asAlpha(base: IContainerRuntimeBase): ContainerRuntimeBaseAlpha;

// @beta @legacy
export interface AttributionInfo {
timestamp: number;
Expand Down
13 changes: 7 additions & 6 deletions packages/runtime/runtime-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ export {
} from "./summary.js";
export type { MinimumVersionForCollab } from "./compatibilityDefinitions.js";

export type {
ContainerRuntimeBaseAlpha,
StageControlsAlpha,
CommitStagedChangesOptionsExperimental,
IContainerRuntimeBaseExperimental,
StageControlsExperimental,
export {
type ContainerRuntimeBaseAlpha,
type StageControlsAlpha,
type CommitStagedChangesOptionsExperimental,
type IContainerRuntimeBaseExperimental,
type StageControlsExperimental,
asAlpha,
} from "./stagingMode.js";
9 changes: 9 additions & 0 deletions packages/runtime/runtime-definitions/src/stagingMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,12 @@ export interface ContainerRuntimeBaseAlpha extends IContainerRuntimeBase {
*/
readonly inStagingMode: boolean;
}

/**
* Converts types to their alpha counterparts to expose alpha functionality.
* @legacy @alpha
* @sealed
*/
export function asAlpha(base: IContainerRuntimeBase): ContainerRuntimeBaseAlpha {
return base as ContainerRuntimeBaseAlpha;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ import type {
// eslint-disable-next-line import/no-internal-modules
import { modifyClusterSize } from "@fluidframework/id-compressor/internal/test-utils";
import { ISharedMap, SharedMap } from "@fluidframework/map/internal";
import type {
ContainerRuntimeBaseAlpha,
StageControlsAlpha,
import {
asAlpha,
type StageControlsAlpha,
} from "@fluidframework/runtime-definitions/internal";
import { RuntimeHeaders, toFluidHandleInternal } from "@fluidframework/runtime-utils/internal";
import { timeoutAwait } from "@fluidframework/test-utils/internal";
Expand Down Expand Up @@ -304,8 +304,7 @@ export class DefaultStressDataObject extends StressDataObject {
}

private stageControls: StageControlsAlpha | undefined;
private readonly containerRuntimeExp = this.context
.containerRuntime as ContainerRuntimeBaseAlpha;
private readonly containerRuntimeExp = asAlpha(this.context.containerRuntime);
public enterStagingMode() {
assert(
this.containerRuntimeExp.enterStagingMode !== undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
LocalResolver,
} from "@fluidframework/local-driver/internal";
import { type ISharedMap, SharedMap } from "@fluidframework/map/internal";
import type { ContainerRuntimeBaseAlpha } from "@fluidframework/runtime-definitions/internal";
import { asAlpha } from "@fluidframework/runtime-definitions/internal";
import {
ILocalDeltaConnectionServer,
LocalDeltaConnectionServer,
Expand Down Expand Up @@ -299,9 +299,7 @@ describe("Document Dirty", () => {
// Submit a non-dirtyable op
containerRuntime.submit(nonDirtyableOp);

const stageControls = (
containerRuntime as unknown as ContainerRuntimeBaseAlpha
).enterStagingMode();
const stageControls = asAlpha(containerRuntime).enterStagingMode();

// Submit an op in staging mode - we will discard it later
sharedMap.set("key", "value");
Expand Down
9 changes: 4 additions & 5 deletions packages/test/local-server-tests/src/test/stagingMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import {
} from "@fluidframework/core-interfaces/internal";
import type { SessionSpaceCompressedId } from "@fluidframework/id-compressor/internal";
import { SharedMap } from "@fluidframework/map/internal";
import type {
ContainerRuntimeBaseAlpha,
StageControlsExperimental,
import {
asAlpha,
type StageControlsExperimental,
} from "@fluidframework/runtime-definitions/internal";
import {
encodeHandleForSerialization,
Expand Down Expand Up @@ -58,8 +58,7 @@ class DataObjectWithStagingMode extends DataObject {
? -1
: DataObjectWithStagingMode.instanceCount++;

private readonly containerRuntimeExp = this.context
.containerRuntime as ContainerRuntimeBaseAlpha;
private readonly containerRuntimeExp = asAlpha(this.context.containerRuntime);
get DataObjectWithStagingMode() {
return this;
}
Expand Down
12 changes: 6 additions & 6 deletions packages/test/test-end-to-end-tests/src/test/stagingMode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { ITestDataObject, describeCompat, itExpects } from "@fluid-private/test-
import { DataObjectFactory } from "@fluidframework/aqueduct/internal";
import type { IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions/internal";
import type { ISharedDirectory } from "@fluidframework/map/internal";
import type {
ContainerRuntimeBaseAlpha,
IFluidDataStoreChannel,
IFluidDataStoreContext,
IFluidDataStorePolicies,
import {
asAlpha,
type IFluidDataStoreChannel,
type IFluidDataStoreContext,
type IFluidDataStorePolicies,
} from "@fluidframework/runtime-definitions/internal";
import {
getContainerEntryPointBackCompat,
Expand Down Expand Up @@ -74,7 +74,7 @@ describeCompat(
const { _context, _runtime, _root } =
await getContainerEntryPointBackCompat<ITestDataObject>(container);

const containerRuntime = _context.containerRuntime as ContainerRuntimeBaseAlpha;
const containerRuntime = asAlpha(_context.containerRuntime);
return {
container,
containerRuntime,
Expand Down
Loading