@@ -11,6 +11,9 @@ import type { Static, TAnySchema, TSchema } from "@sinclair/typebox";
1111import type { ChangeEncodingContext } from "../core/index.js" ;
1212import type { JsonCompatibleReadOnly } from "../util/index.js" ;
1313import { noopValidator } from "./noopValidator.js" ;
14+ import type { MinimumVersionForCollab } from "@fluidframework/runtime-definitions/internal" ;
15+ import { pkgVersion } from "../packageVersion.js" ;
16+ import { defaultMinVersionForCollab } from "@fluidframework/runtime-utils/internal" ;
1417
1518/**
1619 * Translates decoded data to encoded data.
@@ -145,7 +148,7 @@ export interface CodecWriteOptions extends ICodecOptions {
145148 * Note that versions older than this should not result in data corruption if they access the data:
146149 * the data's format should be versioned and if they can't handle the format they should error.
147150 */
148- readonly oldestCompatibleClient : FluidClientVersion ;
151+ readonly oldestCompatibleClient : MinimumVersionForCollab ;
149152}
150153
151154/**
@@ -414,16 +417,6 @@ export function withSchemaValidation<
414417 * For example, document if there is an encoding efficiency improvement of oping into that version or newer.
415418 * Versions with no notable impact can be omitted.
416419 *
417- * These use numeric values for easy threshold comparisons.
418- * Without zero padding, version 2.10 is treated as 2.1, which is numerically less than 2.2.
419- * Adding leading zeros to the minor version ensures correct comparisons.
420- * For example, version 2.20.0 is encoded as 2.020, and version 2.2.0 is encoded as 2.002.
421- * For example FF 2.20.0 is encoded as 2.020 and FF 2.2.0 is encoded as 2.002.
422- *
423- * Three digits was selected as that will likely be enough, while two digits could easily be too few.
424- * If three digits ends up being too few, minor releases of 1000 and higher
425- * could still be handled using something like 2.999_00001 without having to change the lower releases.
426- *
427420 * This scheme assumes a single version will always be enough to communicate compatibility.
428421 * For this to work, compatibility has to be strictly increasing.
429422 * If this is violated (for example a subset of incompatible features from 3.x that are not in 3.0 are back ported to 2.x),
@@ -435,7 +428,7 @@ export function withSchemaValidation<
435428 * For example, if needed, would adding more leading zeros to the minor version break things.
436429 * @alpha
437430 */
438- export enum FluidClientVersion {
431+ export const FluidClientVersion = {
439432 /**
440433 * Fluid Framework Client 1.4 and newer.
441434 * @remarks
@@ -445,8 +438,10 @@ export enum FluidClientVersion {
445438 */
446439 // v1_4 = 1.004,
447440
448- /** Fluid Framework Client 2.0 and newer. */
449- v2_0 = 2.0 ,
441+ /**
442+ * Fluid Framework Client 2.0 and newer.
443+ */
444+ v2_0 : defaultMinVersionForCollab ,
450445
451446 /** Fluid Framework Client 2.1 and newer. */
452447 // If we think we might want to start allowing opting into something that landed in 2.1 (without opting into something newer),
@@ -457,19 +452,21 @@ export enum FluidClientVersion {
457452 /** Fluid Framework Client 2.52 and newer. */
458453 // New formats introduced in 2.52:
459454 // - DetachedFieldIndex FormatV2
460- v2_52 = 2.052 ,
455+ v2_52 : "2.52.0" as MinimumVersionForCollab ,
461456
462457 /**
463458 * Enable unreleased and unfinished features.
464459 * @remarks
460+ * pkgVersion will always be the latest version, therefore the version that enables all features.
461+ *
465462 * Using this value can result in documents which can not be opened in future versions of the framework.
466463 * It can also result in data corruption by enabling unfinished features which may not handle all cases correctly.
467464 *
468465 * This can be used with specific APIs when the caller has knowledge of what specific features those APIs will be opted into with it.
469466 * This is useful for testing features before they are released, but should not be used in production code.
470467 */
471- EnableUnstableFeatures = Number . POSITIVE_INFINITY ,
472- }
468+ EnableUnstableFeatures : pkgVersion as MinimumVersionForCollab ,
469+ } ;
473470
474471/**
475472 * An up to date version which includes all the important stable features.
@@ -480,4 +477,4 @@ export enum FluidClientVersion {
480477 * Update as needed.
481478 * TODO: Consider using packageVersion.ts to keep this current.
482479 */
483- export const currentVersion : FluidClientVersion = FluidClientVersion . v2_0 ;
480+ export const currentVersion : MinimumVersionForCollab = FluidClientVersion . v2_0 ;
0 commit comments