Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move migration-tools to separate example package #22267

Merged
merged 27 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
cb75038
Copy migration-tools directory
ChumpChief Aug 16, 2024
d235021
Trim migration-tools, add dependency in example
ChumpChief Aug 16, 2024
d6e142c
Prefer import from migration-tools
ChumpChief Aug 16, 2024
52e5c46
Trim example-utils
ChumpChief Aug 16, 2024
31a367b
Tests too
ChumpChief Aug 16, 2024
e2de3bb
README
ChumpChief Aug 16, 2024
a4b7a11
Trim dependencies
ChumpChief Aug 17, 2024
323a706
Switch to MigratableTinyliciousModelLoader
ChumpChief Aug 19, 2024
5ed2dd8
Remove IDetachedModel and StaticCodeLoader
ChumpChief Aug 19, 2024
de2877e
Collapse migrationTool and migrator directories, rename to interfaces…
ChumpChief Aug 19, 2024
3ff0131
Rename example
ChumpChief Aug 19, 2024
0242a59
Upgrade eslint strictness
ChumpChief Aug 19, 2024
3efcd3a
Fix version number
ChumpChief Aug 19, 2024
b95496b
Remove changelog
ChumpChief Aug 19, 2024
9a9e3e8
Update package descriptions
ChumpChief Aug 19, 2024
56bfa77
Merge remote-tracking branch 'upstream/main' into MigrationRearrange
ChumpChief Aug 20, 2024
897d0f9
Regenerate pnpm-lock.yaml
ChumpChief Aug 20, 2024
429070f
Manually correct pnpm-lock.yaml
ChumpChief Aug 20, 2024
593cd8e
Remove React dependencies
ChumpChief Aug 20, 2024
23363c7
Remove build docs commands, switch from internal to alpha tagging
ChumpChief Aug 20, 2024
d5e14fc
Add export entries and extractor command
ChumpChief Aug 20, 2024
f191409
Fix import paths
ChumpChief Aug 20, 2024
7a192af
Remove common build, reduce exports to minimal set
ChumpChief Aug 20, 2024
9af5cea
Fix devtool namespace
ChumpChief Aug 22, 2024
5c05c54
Update PACKAGES.md
ChumpChief Aug 22, 2024
e0a393e
Restore cjs build
ChumpChief Aug 22, 2024
cbcfb54
Merge remote-tracking branch 'upstream/main' into MigrationRearrange
ChumpChief Aug 22, 2024
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
18 changes: 1 addition & 17 deletions examples/utils/example-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,25 @@ export {
} from "./containerViewRuntimeFactory.js";
export type {
DataTransformationCallback,
IAcceptedMigrationDetails,
IImportExportModel,
IMigratableModel,
IMigrationTool,
IMigrationToolEvents,
IMigrator,
IMigratorEvents,
ISameContainerMigratableModel,
ISameContainerMigratableModelEvents,
ISameContainerMigrationTool,
ISameContainerMigrationToolEvents,
ISameContainerMigrator,
ISameContainerMigratorEvents,
IVersionedModel,
MigrationState,
SameContainerMigrationState,
} from "./migrationInterfaces/index.js";
export {
MigrationToolFactory,
SameContainerMigrationTool,
SameContainerMigrationToolInstantiationFactory,
} from "./migrationTool/index.js";
export { Migrator, SameContainerMigrator } from "./migrator/index.js";
export { SameContainerMigrator } from "./migrator/index.js";
export {
CreateModelCallback,
IAttachedMigratableModel,
IDetachedMigratableModel,
IDetachedModel,
IMigratableModelContainerRuntimeEntryPoint,
IMigratableModelLoader,
IModelContainerRuntimeEntryPoint,
IModelLoader,
instantiateMigratableRuntime,
MigratableModelLoader,
MigratableSessionStorageModelLoader,
ModelContainerRuntimeFactory,
ModelLoader,
SessionStorageModelLoader,
Expand Down
17 changes: 2 additions & 15 deletions examples/utils/example-utils/src/migrationInterfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,17 @@

export {
IImportExportModel,
IMigratableModel,
IVersionedModel,
} from "./migratableModel.js";
export {
IAcceptedMigrationDetails,
IMigrationTool,
IMigrationToolEvents,
MigrationState,
} from "./migrationTool.js";
export {
DataTransformationCallback,
IMigrator,
IMigratorEvents,
} from "./migrator.js";
export {
ISameContainerMigratableModel,
ISameContainerMigratableModelEvents,
IVersionedModel,
} from "./sameContainerMigratableModel.js";
export {
ISameContainerMigrationTool,
ISameContainerMigrationToolEvents,
SameContainerMigrationState,
} from "./sameContainerMigrationTool.js";
export {
DataTransformationCallback,
ISameContainerMigrator,
ISameContainerMigratorEvents,
} from "./sameContainerMigrator.js";
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,45 @@
import type { IContainer } from "@fluidframework/container-definitions/internal";
import type { IEvent, IEventProvider } from "@fluidframework/core-interfaces";

import type { IImportExportModel, IVersionedModel } from "./migratableModel.js";
import type { ISameContainerMigrationTool } from "./sameContainerMigrationTool.js";

/**
* A model with a detectable version.
*
* @remarks
* It's appropriate to use this version to deduce the more specific type of model.
* @internal
*/
export interface IVersionedModel {
/**
* The string version of the model, matching the version of the container code it's paired with.
*/
readonly version: string;
}

/**
* A model that can import data of ImportType when in detached state, and can also export its data to ExportType.
* @internal
*/
export interface IImportExportModel<ImportType, ExportType> {
/**
* Permit format checking in a generic manner - without knowing the type of our data or the type of the model,
* we can still check whether the model supports that data.
*/
supportsDataFormat: (initialData: unknown) => initialData is ImportType;

/**
* importData must be called after initialization but before modifying or attaching the model (i.e. can only
* be called on an unaltered, detached model).
*/
importData: (initialData: ImportType) => Promise<void>;

/**
* Export the data from the model. Can be passed into importData() for a new container to replicate the data.
*/
exportData: () => Promise<ExportType>;
}

/**
* @internal
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {
* The DataTransformationCallback gives an opportunity to modify the exported data before attempting an import
* to the new model. The modelVersion is also provided to inform the appropriate transformation to perform.
* It is async to permit network calls or lazy-loading the transform logic within the function.
* @internal
*/
export type DataTransformationCallback = (
exportedData: unknown,
Expand Down
1 change: 0 additions & 1 deletion examples/utils/example-utils/src/migrationTool/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License.
*/

export { MigrationToolFactory } from "./migrationTool.js";
export {
SameContainerMigrationTool,
SameContainerMigrationToolInstantiationFactory,
Expand Down
1 change: 0 additions & 1 deletion examples/utils/example-utils/src/migrator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
*/

export { SameContainerMigrator } from "./sameContainerMigrator.js";
export { Migrator } from "./migrator.js";
10 changes: 0 additions & 10 deletions examples/utils/example-utils/src/modelLoader/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@
*/

export {
CreateModelCallback,
IMigratableModelContainerRuntimeEntryPoint,
instantiateMigratableRuntime,
} from "./instantiateMigratableRuntime.js";
export {
IAttachedMigratableModel,
IDetachedModel,
IDetachedMigratableModel,
IMigratableModelLoader,
IModelLoader,
} from "./interfaces.js";
export { MigratableModelLoader } from "./migratableModelLoader.js";
export { MigratableSessionStorageModelLoader } from "./migratableSessionStorageModelLoader.js";
export {
ModelContainerRuntimeFactory,
IModelContainerRuntimeEntryPoint,
Expand Down
76 changes: 0 additions & 76 deletions examples/utils/example-utils/src/modelLoader/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,82 +3,6 @@
* Licensed under the MIT License.
*/

import type { IMigrationTool } from "../migrationInterfaces/index.js";

// TODO: Consider just extending IAttachedMigratableModel
/**
* Object returned from calling IModelLoader.createDetached().
* @internal
*/
export interface IDetachedMigratableModel<ModelType> {
/**
* The newly created, detached model object.
*/
model: ModelType;
/**
* The migration tool that will be used to migrate away from this model.
*/
migrationTool: IMigrationTool;
/**
* A function that will attach the model object to the service when called.
* @returns a Promise that will resolve after attach completes with the container ID of the newly attached
* container.
*/
attach: () => Promise<string>;
}

/**
* Object returned from calling IModelLoader.createDetached().
* @internal
*/
export interface IAttachedMigratableModel<ModelType> {
/**
* The newly created, detached model object.
*/
model: ModelType;
/**
* The migration tool that will be used to migrate away from this model.
*/
migrationTool: IMigrationTool;
}

/**
* @internal
*/
export interface IMigratableModelLoader<ModelType> {
/**
* Check if the IMigratableModelLoader knows how to instantiate an appropriate model for the provided container code version.
* It is async to permit dynamic model loading - e.g. referring to a remote service to determine if the requested
* model is available.
* @param version - the container code version to check
*/
supportsVersion(version: string): Promise<boolean>;

/**
* Create a detached model using the specified version of container code.
* Returns an object containing the detached model plus an attach callback. When invoked, the attach callback
* returns a promise that will resolve after attach has completed with the id of the container.
* @param version - the container code version to create a model for
*/
createDetached(version: string): Promise<IDetachedMigratableModel<ModelType>>;

/**
* Load a model for the container with the given id.
* @param id - the id of the container to load
*/
loadExisting(id: string): Promise<IAttachedMigratableModel<ModelType>>;

/**
* Load a model for the container with the given id.
* @param id - the id of the container to load
* @param sequenceNumber - the sequence number we want to load to and pause at
*/
loadExistingPaused(
id: string,
sequenceNumber: number,
): Promise<IAttachedMigratableModel<ModelType>>;
}

/**
* Object returned from calling IModelLoader.createDetached().
* @internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
*/

module.exports = {
extends: [
require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
"prettier",
],
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
rules: {},
};
52 changes: 52 additions & 0 deletions examples/utils/migration-tools/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Compiled TypeScript and CSS
dist
lib

# Babel
public/scripts/es5

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
.cache-loader

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Typings
typings

# Debug log from npm
npm-debug.log

# Code coverage
nyc
.nyc_output/

# Chart dependencies
**/charts/*.tgz

# Generated modules
intel_modules/
temp_modules/
48 changes: 48 additions & 0 deletions examples/utils/migration-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# @fluid-example/migration-tools

This package contains tools for migrating data from one version to another, used by Fluid examples. They are not currently intended for use in production scenarios.

See [GitHub](https://github.com/microsoft/FluidFramework) for more details on the Fluid Framework and packages within.

<!-- AUTO-GENERATED-CONTENT:START (README_FOOTER) -->

<!-- prettier-ignore-start -->
<!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->

## Contribution Guidelines

There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.

- Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
- [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
- Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
- [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).

Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.

This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.

## Help

Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).

Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).

Thank you!

## Trademark

This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.

Use of these trademarks or logos must follow Microsoft's [Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).

Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.

<!-- prettier-ignore-end -->

<!-- AUTO-GENERATED-CONTENT:END -->
4 changes: 4 additions & 0 deletions examples/utils/migration-tools/api-extractor-lint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../common/build/build-common/api-extractor-lint.esm.primary.json"
}
4 changes: 4 additions & 0 deletions examples/utils/migration-tools/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../../common/build/build-common/api-extractor-base.esm.no-legacy.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Alpha API Report File for "@fluid-example/migration-tools"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Beta API Report File for "@fluid-example/migration-tools"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// (No @packageDocumentation comment for this package)

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Public API Report File for "@fluid-example/migration-tools"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts

// (No @packageDocumentation comment for this package)

```
Loading
Loading