@fluidframework/runtime-utils 2.74.0-370705 → 2.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -143,12 +143,35 @@ export function getConfigForMinVersionForCollab<T>(
143
143
  minVersionForCollab: MinimumVersionForCollab,
144
144
  config: ConfigMapEntry<T>,
145
145
  ): T {
146
- const entries: [string, unknown][] = Object.entries(config); // Assigning this to a typed variable to convert the "any" into unknown.
146
+ return getConfigForMinVersionForCollabIterable(
147
+ minVersionForCollab,
148
+ Object.entries(config) as [MinimumMinorSemanticVersion, T][],
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Returns a default configuration given minVersionForCollab and the contents of a {@link ConfigMapEntry} in an Iterable.
154
+ * @remarks
155
+ * See also {@link getConfigForMinVersionForCollab} for consuming a ConfigMapEntry directly.
156
+ *
157
+ * `ConfigMapEntry` is a nice type safe format for developers to directly author this data,
158
+ * but it is messy and less type safe to work with it in this format programmatically.
159
+ * Thus this function exists to help meet the needs of programmatic use cases,
160
+ * like cases which transform a ConfigMapEntry before selecting a value from it.
161
+ * @internal
162
+ */
163
+ export function getConfigForMinVersionForCollabIterable<T>(
164
+ minVersionForCollab: MinimumVersionForCollab,
165
+ entries: Iterable<readonly [MinimumMinorSemanticVersion | MinimumVersionForCollab, T]>, // [[typeof lowestMinVersionForCollab, T], ...[MinimumVersionForCollab, T][]],
166
+ ): T {
147
167
  // Validate and strongly type the versions from the configMap.
148
- const versions: [MinimumVersionForCollab, unknown][] = entries.map(([version, value]) => {
149
- validateMinimumVersionForCollab(version);
150
- return [version, value];
151
- });
168
+ const versions: [MinimumVersionForCollab, unknown][] = Array.from(
169
+ entries,
170
+ ([version, value]) => {
171
+ validateMinimumVersionForCollab(version);
172
+ return [version, value];
173
+ },
174
+ );
152
175
  // Sort the versions in descending order to find the largest compatible entry.
153
176
  // TODO: Enforcing a sorted order might be a good idea. For now tolerates any order.
154
177
  versions.sort((a, b) => compare(b[0], a[0]));
@@ -225,6 +248,7 @@ const parsedPackageVersion = parse(pkgVersion) ?? fail("Invalid package version"
225
248
  * Since this is used by validateMinimumVersionForCollab, the type case to MinimumVersionForCollab can not use it directly.
226
249
  * Thus this is just `as` cast here, and a test confirms it is valid according to validateMinimumVersionForCollab.
227
250
  *
251
+ * @internal
228
252
  */
229
253
  export const cleanedPackageVersion =
230
254
  `${parsedPackageVersion.major}.${parsedPackageVersion.minor}.${parsedPackageVersion.patch}` as MinimumVersionForCollab;
package/src/index.ts CHANGED
@@ -70,6 +70,8 @@ export {
70
70
  isValidMinVersionForCollab,
71
71
  validateMinimumVersionForCollab,
72
72
  lowestMinVersionForCollab,
73
+ getConfigForMinVersionForCollabIterable,
74
+ cleanedPackageVersion,
73
75
  } from "./compatibilityBase.js";
74
76
  export type {
75
77
  ConfigMap,
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/runtime-utils";
9
- export const pkgVersion = "2.74.0-370705";
9
+ export const pkgVersion = "2.80.0";
@@ -32,7 +32,11 @@ import type {
32
32
  ISummarizeResult,
33
33
  ITelemetryContextExt,
34
34
  } from "@fluidframework/runtime-definitions/internal";
35
- import { gcDataBlobKey } from "@fluidframework/runtime-definitions/internal";
35
+ import {
36
+ currentSummarizeStepPrefix,
37
+ currentSummarizeStepPropertyName,
38
+ gcDataBlobKey,
39
+ } from "@fluidframework/runtime-definitions/internal";
36
40
  import type { TelemetryEventPropertyTypeExt } from "@fluidframework/telemetry-utils/internal";
37
41
 
38
42
  /**
@@ -520,14 +524,18 @@ export class TelemetryContext implements ITelemetryContext, ITelemetryContextExt
520
524
  }
521
525
 
522
526
  /**
523
- * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.get}
527
+ * Get the telemetry data being tracked
528
+ * @param prefix - unique prefix to tag this data with (ex: "fluid:map:")
529
+ * @param property - property name of the telemetry data being tracked (ex: "DirectoryCount")
530
+ * @returns undefined if item not found
524
531
  */
525
532
  public get(prefix: string, property: string): TelemetryEventPropertyTypeExt {
526
533
  return this.telemetry.get(`${prefix}${property}`);
527
534
  }
528
535
 
529
536
  /**
530
- * {@inheritDoc @fluidframework/runtime-definitions#ITelemetryContext.serialize}
537
+ * Returns a serialized version of all the telemetry data.
538
+ * Should be used when logging in telemetry events.
531
539
  */
532
540
  public serialize(): string {
533
541
  const jsonObject = {};
@@ -536,6 +544,14 @@ export class TelemetryContext implements ITelemetryContext, ITelemetryContextExt
536
544
  }
537
545
  return JSON.stringify(jsonObject);
538
546
  }
547
+
548
+ public getCurrentSummarizeStep(): TelemetryEventPropertyTypeExt {
549
+ return this.get(currentSummarizeStepPrefix, currentSummarizeStepPropertyName);
550
+ }
551
+
552
+ public setCurrentSummarizeStep(value: TelemetryEventPropertyTypeExt): void {
553
+ this.set(currentSummarizeStepPrefix, currentSummarizeStepPropertyName, value);
554
+ }
539
555
  }
540
556
 
541
557
  /**