Skip to content

Commit

Permalink
node 16 debt: remove ./test/EditLog export (#23244)
Browse files Browse the repository at this point in the history
## Description

Exposes `getLocalEdits` method in `OrderedEditSet` to remove the need
for importing `EditLog` and casting for access to that method. Removed
`./test/EditLog` export.

## Breaking Changes

Although unlikely, it is possible that external users may have used this
export, so marked as breaking change.
  • Loading branch information
daesunp authored Mar 10, 2025
1 parent 2971790 commit 429c0b7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
10 changes: 10 additions & 0 deletions .changeset/gentle-needles-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
"@fluid-experimental/tree": minor
---
---
"section": other
---

Adds `getLocalEdits` method to OrderedEditSet interface and removed `./test/EditLog` export

Previously, `EditLog` was imported to cast to this type for access to the `getLocalEdits` method. This change removes the need for this cast, so we can get rid of the `./test/EditLog` export.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
SharedTreeShim,
SharedTreeShimFactory,
} from "@fluid-experimental/tree";
import { EditLog } from "@fluid-experimental/tree/test/EditLog";
import { DataObject, DataObjectFactory } from "@fluidframework/aqueduct/legacy";
import { IFluidHandle } from "@fluidframework/core-interfaces";
import { ITree } from "@fluidframework/tree";
Expand Down Expand Up @@ -39,7 +38,7 @@ const newTreeFactory = SharedTree.getFactory();

function migrate(legacyTree: LegacySharedTree, newTree: ITree) {
// Revert local edits - otherwise we will be eventually inconsistent
const edits = legacyTree.edits as EditLog;
const edits = legacyTree.edits;
const localEdits = [...edits.getLocalEdits()].reverse();
for (const edit of localEdits) {
legacyTree.revert(edit.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ export interface OrderedEditSet<TChange = unknown> {
getIdAtIndex(index: number): EditId;
// (undocumented)
getIndexOfId(editId: EditId): number;
getLocalEdits(): Iterable<Edit<TChange>>;
readonly length: number;
// @deprecated (undocumented)
tryGetEdit(editId: EditId): Promise<Edit<TChange> | undefined>;
Expand Down
12 changes: 1 addition & 11 deletions experimental/dds/tree/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
},
"./test/EditLog": {
"import": {
"types": "./lib/EditLog.d.ts",
"default": "./lib/EditLog.js"
},
"require": {
"types": "./dist/EditLog.d.ts",
"default": "./dist/EditLog.js"
}
}
},
"main": "lib/index.js",
Expand All @@ -41,7 +31,7 @@
"build:compile": "fluid-build . --task compile",
"build:docs": "api-extractor run --local",
"build:esnext": "tsc --project ./tsconfig.esnext.json",
"check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./test/EditLog",
"check:are-the-types-wrong": "attw --pack .",
"check:biome": "biome check .",
"check:exports": "concurrently \"npm:check:exports:*\"",
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
Expand Down
5 changes: 5 additions & 0 deletions experimental/dds/tree/src/EditLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export interface OrderedEditSet<TChange = unknown> {
* @deprecated this will be removed in favor of {@link OrderedEditSet.tryGetEditAtIndex}
*/
getEditInSessionAtIndex(index: number): Edit<TChange>;

/**
* Gets all local edits.
*/
getLocalEdits(): Iterable<Edit<TChange>>;
}

/**
Expand Down
2 changes: 0 additions & 2 deletions fluidBuild.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,6 @@ module.exports = {
// Packages that violate the API linting rules
// ae-missing-release-tags, ae-incompatible-release-tags
"^examples/data-objects/table-document/",
// AB#8147: ./test/EditLog export should be ./internal/... or tagged for support
"^experimental/dds/tree/",

// Packages with APIs that don't need strict API linting
"^build-tools/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
StablePlace,
type TraitLabel,
} from "@fluid-experimental/tree";
// eslint-disable-next-line import/no-internal-modules
import { type EditLog } from "@fluid-experimental/tree/test/EditLog";
import { describeCompat } from "@fluid-private/test-version-utils";
import { LoaderHeader } from "@fluidframework/container-definitions/internal";
import { type IContainerExperimental } from "@fluidframework/container-loader/internal";
Expand Down Expand Up @@ -158,7 +156,7 @@ describeCompat("Stamped v2 ops", "NoCompat", (getTestObjectProvider, apis) => {
(legacyTree, newTree) => {
// Migration code that the customer writes
// Revert local edits - otherwise we will be eventually inconsistent
const edits = legacyTree.edits as EditLog;
const edits = legacyTree.edits;
const localEdits = [...edits.getLocalEdits()].reverse();
for (const edit of localEdits) {
legacyTree.revert(edit.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
StablePlace,
type TraitLabel,
} from "@fluid-experimental/tree";
import { type EditLog } from "@fluid-experimental/tree/test/EditLog";
import { describeCompat } from "@fluid-private/test-version-utils";
import { LoaderHeader } from "@fluidframework/container-definitions/internal";
import { type IContainerRuntimeOptions } from "@fluidframework/container-runtime/internal";
Expand Down Expand Up @@ -151,7 +150,7 @@ describeCompat("Stamped v2 ops", "NoCompat", (getTestObjectProvider, apis) => {
(legacyTree, newTree) => {
// Migration code that the customer writes
// Revert local edits - otherwise we will be eventually inconsistent
const edits = legacyTree.edits as EditLog;
const edits = legacyTree.edits;
const localEdits = [...edits.getLocalEdits()].reverse();
for (const edit of localEdits) {
legacyTree.revert(edit.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
StablePlace,
type TraitLabel,
} from "@fluid-experimental/tree";
// eslint-disable-next-line import/no-internal-modules
import { type EditLog } from "@fluid-experimental/tree/test/EditLog";
import { bufferToString, stringToBuffer } from "@fluid-internal/client-utils";
import { describeCompat } from "@fluid-private/test-version-utils";
import { LoaderHeader } from "@fluidframework/container-definitions/internal";
Expand Down Expand Up @@ -171,7 +169,7 @@ describeCompat("Storing handles", "NoCompat", (getTestObjectProvider, apis) => {
(legacyTree, newTree) => {
// Migration code that the customer writes
// Revert local edits - otherwise we will be eventually inconsistent
const edits = legacyTree.edits as EditLog;
const edits = legacyTree.edits;
const localEdits = [...edits.getLocalEdits()].reverse();
for (const edit of localEdits) {
legacyTree.revert(edit.id);
Expand Down

0 comments on commit 429c0b7

Please sign in to comment.