You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* This uses the {@linkhttps://semver.org/#spec-item-11|ordering defined by semver}.
261
-
* It is only compared against the version from previous snapshots (taken from this version when they were created by setting `mode` to "update") and the `minVersionForCollaboration`.
264
+
* Can use any format supported by {@linkSchemaCompatibilitySnapshotsOptions.versionComparer}.
265
+
* Only compared against the version from previous snapshots (taken from this version when they were created by setting `mode` to "update") and the `minVersionForCollaboration`.
262
266
*
263
267
* Typically `minVersionForCollaboration` should be set to the oldest version currently in use, so it's helpful to use a version which can be easily measured to tell if clients are still using it.
264
268
* It is also important that this version increases with every new versions of the application or library that is released (and thus might persist content which needs to be supported).
* and this corresponds to whatever versioning scheme is used with {@link SchemaCompatibilitySnapshotsOptions.version}.
299
301
*/
300
302
readonlyminVersionForCollaboration: string;
303
+
304
+
/**
305
+
* A comparison function for version strings.
306
+
* @remarks
307
+
* A comparison function like that provided to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#comparefn | Array.sort}.
308
+
* This is used to partition snapshots into those less than `minVersionForCollaboration` and those greater than or equal to it, as well as to sanity check `version` against the versions of the snapshots.
309
+
* If not provided, the ordering is defined by {@link https://semver.org/#spec-item-11|semver}.
310
+
* @returns A negative number if `a` is less than `b`, zero if they are equal, or a positive number if `a` is greater than `b`.
* Check `currentViewSchema` for compatibility with a collection of historical schema snapshots stored in `snapshotDirectory`.
327
340
*
328
-
* @throws Throws errors if the input version strings (including those in snapshot file names) are not valid semver versions.
341
+
* @throws Throws errors if the input version strings (including those in snapshot file names) are not valid semver versions when using default semver version comparison.
329
342
* @throws Throws errors if the input version strings (including those in snapshot file names) are not ordered as expected (current being the highest, and `minVersionForCollaboration` corresponding to the current version or a lower snapshotted version).
330
343
* @throws In `test` mode, throws an error if there is not an up to date snapshot for the current version.
331
344
* @throws Throws an error if any snapshotted schema cannot be upgraded to the current schema.
@@ -440,17 +453,23 @@ export function checkSchemaCompatibilitySnapshots(
`Invalid minVersionForCollaboration: ${JSON.stringify(minVersionForCollaboration)}. Must be less than or equal to current version ${JSON.stringify(currentVersion)}.`,
456
475
);
@@ -463,7 +482,7 @@ export function checkSchemaCompatibilitySnapshots(
`Snapshot version ${JSON.stringify(snapshotVersion)} is semantically equal but not string equal to current version ${JSON.stringify(currentVersion)}: this is not supported.`,
@@ -578,15 +597,17 @@ export function checkSchemaCompatibilitySnapshots(
578
597
`Current version ${JSON.stringify(snapshotVersion)} expected to be equivalent to its snapshot.`,
constmessage=`Historical version ${JSON.stringify(snapshotVersion)} cannot view documents from ${JSON.stringify(currentVersion)}: these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being ${JSON.stringify(selectedMinVersionForCollaborationSnapshot[0])}.`;
@@ -603,16 +624,17 @@ export function checkSchemaCompatibilitySnapshots(
603
624
}
604
625
}else{
605
626
thrownewUsageError(
606
-
`Unexpected semver comparison result between snapshot version ${JSON.stringify(snapshotVersion)} and app version ${JSON.stringify(currentVersion)}.`,
627
+
`Unexpected comparison result between snapshot version ${JSON.stringify(snapshotVersion)} and app version ${JSON.stringify(currentVersion)}.`,
- Snapshot for current version "2.0.0" is out of date: schema has changed since latest existing snapshot version "2.0.0". If this is expected, checkSchemaCompatibilitySnapshots can be rerun in "update" mode to update the snapshot.
237
237
- Current version "2.0.0" cannot upgrade documents from "2.0.0".
238
-
- Current version "2.0.0" expected to be equivalent to its snapshot.`),
238
+
- Current version "2.0.0" expected to be equivalent to its snapshot.
- Current version "2.0.0" cannot upgrade documents from "1.0.0".
254
259
- Historical version "1.0.0" cannot view documents from "2.0.0": these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being "1.0.0".
255
260
- Current version "2.0.0" cannot upgrade documents from "2.0.0".
256
-
- Current version "2.0.0" expected to be equivalent to its snapshot.`),
261
+
- Current version "2.0.0" expected to be equivalent to its snapshot.
- Historical version "1.0.0" cannot view documents from "2.0.0": these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being "1.0.0".`),
280
+
- Historical version "1.0.0" cannot view documents from "2.0.0": these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being "1.0.0".
- Snapshot for current version "1.0.0" is out of date: schema has changed since latest existing snapshot version "1.0.0". If this is expected, checkSchemaCompatibilitySnapshots can be rerun in "update" mode to update the snapshot.`),
412
+
- Snapshot for current version "1.0.0" is out of date: schema has changed since latest existing snapshot version "1.0.0". If this is expected, checkSchemaCompatibilitySnapshots can be rerun in "update" mode to update the snapshot.
413
+
Snapshots in: "dir".
414
+
Snapshots exist for versions: [
415
+
"1.0.0"
416
+
].`),
396
417
);
397
418
398
419
// If the change was desired, a new snapshot can be taken to include it in 2.0.0:
- Historical version "1.0.0" cannot view documents from "3.0.0": these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being "1.0.0".`),
453
+
- Historical version "1.0.0" cannot view documents from "3.0.0": these versions are expected to be able to collaborate due to the selected minVersionForCollaboration snapshot version being "1.0.0".
- No snapshot found for version "3.1.0": snapshotUnchangedVersions is true, so every version must be snapshotted. If this is expected, checkSchemaCompatibilitySnapshots can be rerun in "update" mode to update the snapshot.`),
498
+
- No snapshot found for version "3.1.0": snapshotUnchangedVersions is true, so every version must be snapshotted. If this is expected, checkSchemaCompatibilitySnapshots can be rerun in "update" mode to update the snapshot.
499
+
Snapshots in: "dir".
500
+
Snapshots exist for versions: [
501
+
"1.0.0",
502
+
"2.0.0",
503
+
"3.0.0"
504
+
].`),
472
505
);
473
506
474
507
// Here we confirm that even when running update, no new snapshot is taken if the schema is unchanged and snapshotUnchangedVersions is false.
0 commit comments