@fluidframework/telemetry-utils 2.0.0-rc.1.0.0 → 2.0.0-rc.1.0.2
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.
- package/README.md +1 -1
- package/api-report/telemetry-utils.api.md +4 -0
- package/dist/config.d.ts +12 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +16 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/telemetry-utils-alpha.d.ts +3 -0
- package/dist/telemetry-utils-beta.d.ts +3 -0
- package/dist/telemetry-utils-public.d.ts +3 -0
- package/dist/telemetry-utils-untrimmed.d.ts +14 -0
- package/lib/config.d.ts +12 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +14 -0
- package/lib/config.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/telemetry-utils-alpha.d.mts +3 -0
- package/lib/telemetry-utils-beta.d.mts +3 -0
- package/lib/telemetry-utils-public.d.mts +3 -0
- package/lib/telemetry-utils-untrimmed.d.mts +14 -0
- package/package.json +5 -5
- package/src/config.ts +18 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ npm i @fluidframework/telemetry-utils
|
|
|
23
23
|
|
|
24
24
|
## API Documentation
|
|
25
25
|
|
|
26
|
-
API documentation for **@fluidframework/telemetry-utils** is available at <https://fluidframework.com/docs/
|
|
26
|
+
API documentation for **@fluidframework/telemetry-utils** is available at <https://fluidframework.com/docs/apis/telemetry-utils>.
|
|
27
27
|
|
|
28
28
|
## Contribution Guidelines
|
|
29
29
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
/// <reference types="node" />
|
|
8
8
|
|
|
9
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
9
10
|
import { EventEmitter } from 'events';
|
|
10
11
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
11
12
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -433,6 +434,9 @@ export class UsageError extends LoggingError implements IUsageError, IFluidError
|
|
|
433
434
|
// @internal
|
|
434
435
|
export function validatePrecondition(condition: boolean, message: string, props?: ITelemetryBaseProperties): asserts condition;
|
|
435
436
|
|
|
437
|
+
// @internal
|
|
438
|
+
export const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
439
|
+
|
|
436
440
|
// @internal
|
|
437
441
|
export function wrapError<T extends LoggingError>(innerError: unknown, newErrorFn: (message: string) => T): T;
|
|
438
442
|
|
package/dist/config.d.ts
CHANGED
|
@@ -35,6 +35,18 @@ export declare const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
|
|
|
35
35
|
* the supplied `Storage` instance as the underlying config store
|
|
36
36
|
*/
|
|
37
37
|
export declare const inMemoryConfigProvider: (storage: Storage | undefined) => IConfigProviderBase;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
40
|
+
* specifying feature gates if not present in the original provider.
|
|
41
|
+
*
|
|
42
|
+
* @param original - the original config provider
|
|
43
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
44
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
45
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
38
50
|
/**
|
|
39
51
|
* Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances
|
|
40
52
|
*/
|
package/dist/config.d.ts.map
CHANGED
|
@@ -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GAAG,SAAS,CAAC,EAAE,GAC7C,iBAAiB,CAAC,CAAC,CAAC,CAgBtB;AAOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAC5C,iBAAiB,CAEnB"}
|
package/dist/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createChildMonitoringContext = exports.mixinMonitoringContext = exports.loggerToMonitoringContext = exports.loggerIsMonitoringContext = exports.CachedConfigProvider = exports.inMemoryConfigProvider = exports.sessionStorageConfigProvider = void 0;
|
|
3
|
+
exports.createChildMonitoringContext = exports.mixinMonitoringContext = exports.loggerToMonitoringContext = exports.loggerIsMonitoringContext = exports.CachedConfigProvider = exports.wrapConfigProviderWithDefaults = exports.inMemoryConfigProvider = exports.sessionStorageConfigProvider = void 0;
|
|
4
4
|
const core_utils_1 = require("@fluidframework/core-utils");
|
|
5
5
|
const logger_1 = require("./logger");
|
|
6
6
|
/**
|
|
@@ -123,6 +123,21 @@ const safeSessionStorage = () => {
|
|
|
123
123
|
return undefined;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
+
/**
|
|
127
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
128
|
+
* specifying feature gates if not present in the original provider.
|
|
129
|
+
*
|
|
130
|
+
* @param original - the original config provider
|
|
131
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
132
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
133
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
134
|
+
*
|
|
135
|
+
* @internal
|
|
136
|
+
*/
|
|
137
|
+
const wrapConfigProviderWithDefaults = (original, defaults) => ({
|
|
138
|
+
getRawConfig: (name) => original?.getRawConfig(name) ?? defaults[name],
|
|
139
|
+
});
|
|
140
|
+
exports.wrapConfigProviderWithDefaults = wrapConfigProviderWithDefaults;
|
|
126
141
|
/**
|
|
127
142
|
* Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances
|
|
128
143
|
*/
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AASA,2DAAkD;AAClD,qCAA+D;AAgB/D;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,IAAI,iBAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC9C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI;oBACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;iBACnE;gBAAC,MAAM;oBACP,OAAO,SAAS,CAAC;iBACjB;YACF,CAAC;SACD,CAAC,CAAC;KACH;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAbW,QAAA,sBAAsB,0BAajC;AAaF,SAAS,eAAe,CAAC,IAAY;IACpC,QAAQ,IAAI,EAAE;QACb,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC,CAAC;YACd,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,CAAC,CAAC;YACR,OAAO,KAAK,CAAC;SACb;KACD;AACF,CAAC;AAKD;;;;;;;;GAQG;AACH,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A4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC;AAJD,oEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseLogger,\n\tIConfigProviderBase,\n\tConfigTypes,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AASA,2DAAkD;AAClD,qCAA+D;AAgB/D;;;;;;GAMG;AACU,QAAA,4BAA4B,GAAG,IAAI,iBAAI,CAAsB,GAAG,EAAE,CAC9E,IAAA,8BAAsB,EAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC9C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI;oBACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;i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D,OAAO,sBAAsB,CAAI,MAAM,EAAE,oCAA4B,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAPD,8DAOC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CACrC,MAAS,EACT,GAAG,OAA4C;IAE/C,IAAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC1D;IACD;;;;;;;OAOG;IACH,MAAM,EAAE,GAAsC,MAAM,CAAC;IACrD,EAAE,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAnBD,wDAmBC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,WAAW,EAAE,YAAY,KAAK,UAAU,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,SAAgB,4BAA4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,IAAA,0BAAiB,EAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC;AAJD,oEAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseLogger,\n\tIConfigProviderBase,\n\tConfigTypes,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, } from "./config";
|
|
5
|
+
export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, wrapConfigProviderWithDefaults, } from "./config";
|
|
6
6
|
export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, } from "./error";
|
|
7
7
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
8
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,GAC9B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,YAAY,EACZ,UAAU,EACV,oBAAoB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EACnB,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EACV,wBAAwB,EACxB,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC3B,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClG,OAAO,EACN,6BAA6B,EAC7B,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,6BAA6B,EAC7B,mBAAmB,EACnB,+BAA+B,EAC/B,uBAAuB,EACvB,sBAAsB,GACtB,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createSampledLogger = exports.logIfFalse = exports.SampledTelemetryHelper = exports.ThresholdCounter = exports.MockLogger = exports.TelemetryNullLogger = exports.TelemetryDataTag = exports.tagCodeArtifacts = exports.tagData = exports.TaggedLoggerAdapter = exports.PerformanceEvent = exports.numberFromString = exports.formatTick = exports.createMultiSinkLogger = exports.createChildLogger = exports.eventNamespaceSeparator = exports.isValidLegacyError = exports.isFluidError = exports.hasErrorInstanceId = exports.safeRaiseEvent = exports.raiseConnectedEvent = exports.disconnectedEventName = exports.connectedEventName = exports.EventEmitterWithErrorHandling = exports.wrapErrorAndLog = exports.wrapError = exports.overwriteStack = exports.normalizeError = exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.isTaggedTelemetryPropertyValue = exports.isILoggingError = exports.isExternalError = exports.getCircularReplacer = exports.generateStack = exports.generateErrorWithStack = exports.extractLogSafeErrorProperties = exports.validatePrecondition = exports.UsageError = exports.GenericError = exports.extractSafePropertiesFromMessage = exports.DataProcessingError = exports.DataCorruptionError = exports.loggerToMonitoringContext = exports.mixinMonitoringContext = exports.sessionStorageConfigProvider = exports.createChildMonitoringContext = void 0;
|
|
3
|
+
exports.createSampledLogger = exports.logIfFalse = exports.SampledTelemetryHelper = exports.ThresholdCounter = exports.MockLogger = exports.TelemetryNullLogger = exports.TelemetryDataTag = exports.tagCodeArtifacts = exports.tagData = exports.TaggedLoggerAdapter = exports.PerformanceEvent = exports.numberFromString = exports.formatTick = exports.createMultiSinkLogger = exports.createChildLogger = exports.eventNamespaceSeparator = exports.isValidLegacyError = exports.isFluidError = exports.hasErrorInstanceId = exports.safeRaiseEvent = exports.raiseConnectedEvent = exports.disconnectedEventName = exports.connectedEventName = exports.EventEmitterWithErrorHandling = exports.wrapErrorAndLog = exports.wrapError = exports.overwriteStack = exports.normalizeError = exports.NORMALIZED_ERROR_TYPE = exports.LoggingError = exports.isTaggedTelemetryPropertyValue = exports.isILoggingError = exports.isExternalError = exports.getCircularReplacer = exports.generateStack = exports.generateErrorWithStack = exports.extractLogSafeErrorProperties = exports.validatePrecondition = exports.UsageError = exports.GenericError = exports.extractSafePropertiesFromMessage = exports.DataProcessingError = exports.DataCorruptionError = exports.wrapConfigProviderWithDefaults = exports.loggerToMonitoringContext = exports.mixinMonitoringContext = exports.sessionStorageConfigProvider = exports.createChildMonitoringContext = void 0;
|
|
4
4
|
/*!
|
|
5
5
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
6
6
|
* Licensed under the MIT License.
|
|
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "createChildMonitoringContext", { enumerable: tru
|
|
|
10
10
|
Object.defineProperty(exports, "sessionStorageConfigProvider", { enumerable: true, get: function () { return config_1.sessionStorageConfigProvider; } });
|
|
11
11
|
Object.defineProperty(exports, "mixinMonitoringContext", { enumerable: true, get: function () { return config_1.mixinMonitoringContext; } });
|
|
12
12
|
Object.defineProperty(exports, "loggerToMonitoringContext", { enumerable: true, get: function () { return config_1.loggerToMonitoringContext; } });
|
|
13
|
+
Object.defineProperty(exports, "wrapConfigProviderWithDefaults", { enumerable: true, get: function () { return config_1.wrapConfigProviderWithDefaults; } });
|
|
13
14
|
var error_1 = require("./error");
|
|
14
15
|
Object.defineProperty(exports, "DataCorruptionError", { enumerable: true, get: function () { return error_1.DataCorruptionError; } });
|
|
15
16
|
Object.defineProperty(exports, "DataProcessingError", { enumerable: true, get: function () { return error_1.DataProcessingError; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAQkB;AAPjB,sHAAA,4BAA4B,OAAA;AAE5B,sHAAA,4BAA4B,OAAA;AAC5B,gHAAA,sBAAsB,OAAA;AAEtB,mHAAA,yBAAyB,OAAA;AACzB,wHAAA,8BAA8B,OAAA;AAE/B,iCAOiB;AANhB,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,yHAAA,gCAAgC,OAAA;AAChC,qGAAA,YAAY,OAAA;AACZ,mGAAA,UAAU,OAAA;AACV,6GAAA,oBAAoB,OAAA;AAErB,+CAewB;AAdvB,6HAAA,6BAA6B,OAAA;AAC7B,sHAAA,sBAAsB,OAAA;AACtB,6GAAA,aAAa,OAAA;AACb,mHAAA,mBAAmB,OAAA;AAEnB,+GAAA,eAAe,OAAA;AACf,+GAAA,eAAe,OAAA;AACf,8HAAA,8BAA8B,OAAA;AAC9B,4GAAA,YAAY,OAAA;AACZ,qHAAA,qBAAqB,OAAA;AACrB,8GAAA,cAAc,OAAA;AACd,8GAAA,cAAc,OAAA;AACd,yGAAA,SAAS,OAAA;AACT,+GAAA,eAAe,OAAA;AAEhB,iFAAgF;AAAvE,8IAAA,6BAA6B,OAAA;AACtC,mCAKkB;AAJjB,4GAAA,kBAAkB,OAAA;AAClB,+GAAA,qBAAqB,OAAA;AACrB,6GAAA,mBAAmB,OAAA;AACnB,wGAAA,cAAc,OAAA;AAEf,mDAK0B;AAJzB,oHAAA,kBAAkB,OAAA;AAElB,8GAAA,YAAY,OAAA;AACZ,oHAAA,kBAAkB,OAAA;AAEnB,mCAiBkB;AAhBjB,iHAAA,uBAAuB,OAAA;AACvB,2GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,oGAAA,UAAU,OAAA;AAKV,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,iGAAA,OAAO,OAAA;AACP,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAEhB,6GAAA,mBAAmB,OAAA;AAEpB,2CAA0C;AAAjC,wGAAA,UAAU,OAAA;AACnB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,iCAAkG;AAAzF,mGAAA,UAAU,OAAA;AAAE,4GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tloggerToMonitoringContext,\n\twrapConfigProviderWithDefaults,\n} from \"./config\";\nexport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n\tGenericError,\n\tUsageError,\n\tvalidatePrecondition,\n} from \"./error\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\toverwriteStack,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\tformatTick,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tMultiSinkLoggerProperties,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n\tTelemetryNullLogger,\n} from \"./logger\";\nexport { MockLogger } from \"./mockLogger\";\nexport { ThresholdCounter } from \"./thresholdCounter\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper\";\nexport { logIfFalse, createSampledLogger, IEventSampler, ISampledTelemetryLogger } from \"./utils\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes\";\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -283,6 +284,8 @@ export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[strin
|
|
|
283
284
|
|
|
284
285
|
/* Excluded from this release type: validatePrecondition */
|
|
285
286
|
|
|
287
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
288
|
+
|
|
286
289
|
/* Excluded from this release type: wrapError */
|
|
287
290
|
|
|
288
291
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -257,6 +258,8 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
|
|
|
257
258
|
|
|
258
259
|
/* Excluded from this release type: validatePrecondition */
|
|
259
260
|
|
|
261
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
262
|
+
|
|
260
263
|
/* Excluded from this release type: wrapError */
|
|
261
264
|
|
|
262
265
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -257,6 +258,8 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
|
|
|
257
258
|
|
|
258
259
|
/* Excluded from this release type: validatePrecondition */
|
|
259
260
|
|
|
261
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
262
|
+
|
|
260
263
|
/* Excluded from this release type: wrapError */
|
|
261
264
|
|
|
262
265
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -1079,6 +1080,19 @@ export declare class UsageError extends LoggingError implements IUsageError, IFl
|
|
|
1079
1080
|
*/
|
|
1080
1081
|
export declare function validatePrecondition(condition: boolean, message: string, props?: ITelemetryBaseProperties): asserts condition;
|
|
1081
1082
|
|
|
1083
|
+
/**
|
|
1084
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
1085
|
+
* specifying feature gates if not present in the original provider.
|
|
1086
|
+
*
|
|
1087
|
+
* @param original - the original config provider
|
|
1088
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
1089
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
1090
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
1091
|
+
*
|
|
1092
|
+
* @internal
|
|
1093
|
+
*/
|
|
1094
|
+
export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
1095
|
+
|
|
1082
1096
|
/**
|
|
1083
1097
|
* Create a new error using newErrorFn, wrapping and caused by the given unknown error.
|
|
1084
1098
|
* Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present
|
package/lib/config.d.ts
CHANGED
|
@@ -35,6 +35,18 @@ export declare const sessionStorageConfigProvider: Lazy<IConfigProviderBase>;
|
|
|
35
35
|
* the supplied `Storage` instance as the underlying config store
|
|
36
36
|
*/
|
|
37
37
|
export declare const inMemoryConfigProvider: (storage: Storage | undefined) => IConfigProviderBase;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
40
|
+
* specifying feature gates if not present in the original provider.
|
|
41
|
+
*
|
|
42
|
+
* @param original - the original config provider
|
|
43
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
44
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
45
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
38
50
|
/**
|
|
39
51
|
* Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances
|
|
40
52
|
*/
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAoB,MAAM,UAAU,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC3D,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IAC5C,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;IACrD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;IACnD,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;CACnD;AACD;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,2BAExC,CAAC;AAMF;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,YAAa,OAAO,GAAG,SAAS,KAAG,mBAarE,CAAC;AA2GF;;GAEG;AACH,qBAAa,oBAAqB,YAAW,eAAe;IA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B,GAAG,mBAAmB,EAC7F,MAAM,EAAE,CAAC,GACP,iBAAiB,CAAC,CAAC,CAAC,CAKtB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,oBAAoB,GAAG,mBAAmB,EAC1F,MAAM,EAAE,CAAC,EACT,GAAG,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,CAAC,EAAE,GAC7C,iBAAiB,CAAC,CAAC,CAAC,CAgBtB;AAOD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAC3C,KAAK,EAAE,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,CAAC,CAAC,GAC5C,iBAAiB,CAEnB"}
|
package/lib/config.js
CHANGED
|
@@ -119,6 +119,20 @@ const safeSessionStorage = () => {
|
|
|
119
119
|
return undefined;
|
|
120
120
|
}
|
|
121
121
|
};
|
|
122
|
+
/**
|
|
123
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
124
|
+
* specifying feature gates if not present in the original provider.
|
|
125
|
+
*
|
|
126
|
+
* @param original - the original config provider
|
|
127
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
128
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
129
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
*/
|
|
133
|
+
export const wrapConfigProviderWithDefaults = (original, defaults) => ({
|
|
134
|
+
getRawConfig: (name) => original?.getRawConfig(name) ?? defaults[name],
|
|
135
|
+
});
|
|
122
136
|
/**
|
|
123
137
|
* Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances
|
|
124
138
|
*/
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iB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GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,GAAM;IAEN,MAAM,WAAW,GAAG,GAAgD,CAAC;IACrE,OAAO,oBAAoB,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,WAAW,EAAE,MAAM,KAAK,SAAS,CAAC;AACvF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACxC,MAAS;IAET,IAAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,OAAO,MAAM,CAAC;KACd;IACD,OAAO,sBAAsB,CAAI,MAAM,EAAE,4BAA4B,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CACrC,MAAS,EACT,GAAG,OAA4C;IAE/C,IAAI,yBAAyB,CAAI,MAAM,CAAC,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC1D;IACD;;;;;;;OAOG;IACH,MAAM,EAAE,GAAsC,MAAM,CAAC;IACrD,EAAE,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,WAAW,EAAE,YAAY,KAAK,UAAU,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseLogger,\n\tIConfigProviderBase,\n\tConfigTypes,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAgB/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,IAAI,CAAsB,GAAG,EAAE,CAC9E,sBAAsB,CAAC,kBAAkB,EAAE,CAAC,CAC5C,CAAC;AAEF,MAAM,kBAAkB,GAAwB;IAC/C,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,OAA4B,EAAuB,EAAE;IAC3F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,KAAK,IAAI,EAAE;QAC9C,OAAO,IAAI,oBAAoB,CAAC,SAAS,EAAE;YAC1C,YAAY,EAAE,CAAC,IAAY,EAA2B,EAAE;gBACvD,IAAI;oBACH,OAAO,kBAAkB,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,SAAS,CAAC,EAAE,GAAG,CAAC;iBACnE;gBAAC,MAAM;oBACP,OAAO,SAAS,CAAC;iBACjB;YACF,CAAC;SACD,CAAC,CAAC;KACH;IACD,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAaF,SAAS,eAAe,CAAC,IAAY;IACpC,QAAQ,IAAI,EAAE;QACb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,CAAC;KAC1D;IACD;;;;;;;OAOG;IACH,MAAM,EAAE,GAAsC,MAAM,CAAC;IACrD,EAAE,CAAC,MAAM,GAAG,IAAI,oBAAoB,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC;IACzD,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC;IACnB,OAAO,EAA0B,CAAC;AACnC,CAAC;AAED,SAAS,oBAAoB,CAAC,GAAY;IACzC,MAAM,WAAW,GAAG,GAA+C,CAAC;IACpE,OAAO,OAAO,WAAW,EAAE,YAAY,KAAK,UAAU,CAAC;AACxD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAC3C,KAA8C;IAE9C,OAAO,yBAAyB,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport {\n\tITelemetryBaseLogger,\n\tIConfigProviderBase,\n\tConfigTypes,\n} from \"@fluidframework/core-interfaces\";\nimport { Lazy } from \"@fluidframework/core-utils\";\nimport { createChildLogger, tagCodeArtifacts } from \"./logger\";\nimport { ITelemetryLoggerExt } from \"./telemetryTypes\";\n\n/**\n * Explicitly typed interface for reading configurations.\n *\n * @internal\n */\nexport interface IConfigProvider extends IConfigProviderBase {\n\tgetBoolean(name: string): boolean | undefined;\n\tgetNumber(name: string): number | undefined;\n\tgetString(name: string): string | undefined;\n\tgetBooleanArray(name: string): boolean[] | undefined;\n\tgetNumberArray(name: string): number[] | undefined;\n\tgetStringArray(name: string): string[] | undefined;\n}\n/**\n * Creates a base configuration provider based on `sessionStorage`\n *\n * @returns A lazy initialized base configuration provider with `sessionStorage` as the underlying config store\n *\n * @internal\n */\nexport const sessionStorageConfigProvider = new Lazy<IConfigProviderBase>(() =>\n\tinMemoryConfigProvider(safeSessionStorage()),\n);\n\nconst NullConfigProvider: IConfigProviderBase = {\n\tgetRawConfig: () => undefined,\n};\n\n/**\n * Creates a base configuration provider based on the supplied `Storage` instance\n *\n * @param storage - instance of `Storage` to be used as storage media for the config\n * @returns A base configuration provider with\n * the supplied `Storage` instance as the underlying config store\n */\nexport const inMemoryConfigProvider = (storage: Storage | undefined): IConfigProviderBase => {\n\tif (storage !== undefined && storage !== null) {\n\t\treturn new CachedConfigProvider(undefined, {\n\t\t\tgetRawConfig: (name: string): ConfigTypes | undefined => {\n\t\t\t\ttry {\n\t\t\t\t\treturn stronglyTypedParse(storage.getItem(name) ?? undefined)?.raw;\n\t\t\t\t} catch {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\t\t\t},\n\t\t});\n\t}\n\treturn NullConfigProvider;\n};\n\ninterface ConfigTypeStringToType {\n\tnumber: number;\n\tstring: string;\n\tboolean: boolean;\n\t[\"number[]\"]: number[];\n\t[\"string[]\"]: string[];\n\t[\"boolean[]\"]: boolean[];\n}\n\ntype PrimitiveTypeStrings = \"number\" | \"string\" | \"boolean\";\n\nfunction isPrimitiveType(type: string): type is PrimitiveTypeStrings {\n\tswitch (type) {\n\t\tcase \"boolean\":\n\t\tcase \"number\":\n\t\tcase \"string\": {\n\t\t\treturn true;\n\t\t}\n\t\tdefault: {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\ninterface StronglyTypedValue extends Partial<ConfigTypeStringToType> {\n\traw: ConfigTypes;\n}\n/**\n * Takes any supported config type, and returns the value with a strong type. If the type of\n * the config is not a supported type undefined will be returned.\n * The user of this function should cache the result to avoid duplicated work.\n *\n * Strings will be attempted to be parsed and coerced into a strong config type.\n * if it is not possible to parsed and coerce a string to a strong config type the original string\n * will be return with a string type for the consumer to handle further if necessary.\n */\nfunction stronglyTypedParse(input: ConfigTypes): StronglyTypedValue | undefined {\n\tlet output: ConfigTypes = input;\n\tlet defaultReturn: Pick<StronglyTypedValue, \"raw\" | \"string\"> | undefined;\n\t// we do special handling for strings to try and coerce\n\t// them into a config type if we can. This makes it easy\n\t// for config sources like sessionStorage which only\n\t// holds strings\n\tif (typeof input === \"string\") {\n\t\ttry {\n\t\t\toutput = JSON.parse(input) as ConfigTypes;\n\t\t\t// we succeeded in parsing, but we don't support parsing\n\t\t\t// for any object as we can't do it type safely\n\t\t\t// so in this case, the default return will be string\n\t\t\t// rather than undefined, and the consumer\n\t\t\t// can parse, as we don't want to provide\n\t\t\t// a false sense of security by just\n\t\t\t// casting.\n\t\t\tdefaultReturn = { raw: input, string: input };\n\t\t} catch {\n\t\t\t// No-op\n\t\t}\n\t}\n\n\tif (output === undefined) {\n\t\treturn defaultReturn;\n\t}\n\n\tconst outputType = typeof output;\n\tif (isPrimitiveType(outputType)) {\n\t\treturn { ...defaultReturn, raw: input, [outputType]: output };\n\t}\n\n\tif (Array.isArray(output)) {\n\t\tconst firstType = typeof output[0];\n\t\t// ensure the first elements is a primitive type\n\t\tif (!isPrimitiveType(firstType)) {\n\t\t\treturn defaultReturn;\n\t\t}\n\t\t// ensue all the elements types are homogeneous\n\t\t// aka they all have the same type as the first\n\t\tfor (const v of output) {\n\t\t\tif (typeof v !== firstType) {\n\t\t\t\treturn defaultReturn;\n\t\t\t}\n\t\t}\n\t\treturn { ...defaultReturn, raw: input, [`${firstType}[]`]: output };\n\t}\n\n\treturn defaultReturn;\n}\n\n/**\n * `sessionStorage` is undefined in some environments such as Node and web pages with session storage disabled.\n */\nconst safeSessionStorage = (): Storage | undefined => {\n\t// For some configurations accessing \"globalThis.sessionStorage\" throws\n\t// \"'sessionStorage' property from 'Window': Access is denied for this document\" rather than returning undefined.\n\t// Therefor check for it before accessing.\n\ttry {\n\t\t// Using globalThis and checking for undefined is preferred over just accessing global sessionStorage\n\t\t// since it avoids an exception when running in node.\n\t\t// In some cases this has returned null when disabled in the browser, so ensure its undefined in that case:\n\t\treturn globalThis.sessionStorage ?? undefined;\n\t} catch {\n\t\t// For browsers which error on the above when session storage is disabled:\n\t\treturn undefined;\n\t}\n};\n\n/**\n * Creates a wrapper on top of an existing config provider which allows for\n * specifying feature gates if not present in the original provider.\n *\n * @param original - the original config provider\n * @param defaults - default feature gate configs to be used if not specified by the original provider\n * @returns A config provider that looks for any requested feature gates in the original provider and falls\n * back to the values specified in the `defaults` feature gates if they're not present in the original.\n *\n * @internal\n */\nexport const wrapConfigProviderWithDefaults = (\n\toriginal: IConfigProviderBase | undefined,\n\tdefaults: Record<string, ConfigTypes>,\n): IConfigProviderBase => ({\n\tgetRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],\n});\n\n/**\n * Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances\n */\nexport class CachedConfigProvider implements IConfigProvider {\n\tprivate readonly configCache = new Map<string, StronglyTypedValue>();\n\tprivate readonly orderedBaseProviders: (IConfigProviderBase | undefined)[];\n\n\tconstructor(\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t\t...orderedBaseProviders: (IConfigProviderBase | undefined)[]\n\t) {\n\t\tthis.orderedBaseProviders = [];\n\t\tconst knownProviders = new Set<IConfigProviderBase>();\n\t\tconst candidateProviders = [...orderedBaseProviders];\n\t\twhile (candidateProviders.length > 0) {\n\t\t\tconst baseProvider = candidateProviders.shift()!;\n\t\t\tif (\n\t\t\t\tbaseProvider !== undefined &&\n\t\t\t\tisConfigProviderBase(baseProvider) &&\n\t\t\t\t!knownProviders.has(baseProvider)\n\t\t\t) {\n\t\t\t\tknownProviders.add(baseProvider);\n\t\t\t\tif (baseProvider instanceof CachedConfigProvider) {\n\t\t\t\t\tcandidateProviders.push(...baseProvider.orderedBaseProviders);\n\t\t\t\t} else {\n\t\t\t\t\tthis.orderedBaseProviders.push(baseProvider);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tgetBoolean(name: string): boolean | undefined {\n\t\treturn this.getCacheEntry(name)?.boolean;\n\t}\n\tgetNumber(name: string): number | undefined {\n\t\treturn this.getCacheEntry(name)?.number;\n\t}\n\tgetString(name: string): string | undefined {\n\t\treturn this.getCacheEntry(name)?.string;\n\t}\n\tgetBooleanArray(name: string): boolean[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"boolean[]\"];\n\t}\n\tgetNumberArray(name: string): number[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"number[]\"];\n\t}\n\tgetStringArray(name: string): string[] | undefined {\n\t\treturn this.getCacheEntry(name)?.[\"string[]\"];\n\t}\n\n\tgetRawConfig(name: string): ConfigTypes {\n\t\treturn this.getCacheEntry(name)?.raw;\n\t}\n\n\tprivate getCacheEntry(name: string): StronglyTypedValue | undefined {\n\t\tif (!this.configCache.has(name)) {\n\t\t\tfor (const provider of this.orderedBaseProviders) {\n\t\t\t\tconst parsed = stronglyTypedParse(provider?.getRawConfig(name));\n\t\t\t\tif (parsed !== undefined) {\n\t\t\t\t\tthis.configCache.set(name, parsed);\n\t\t\t\t\tthis.logger?.send({\n\t\t\t\t\t\tcategory: \"generic\",\n\t\t\t\t\t\teventName: \"ConfigRead\",\n\t\t\t\t\t\t...tagCodeArtifacts({\n\t\t\t\t\t\t\tconfigName: name,\n\t\t\t\t\t\t\tconfigValue: JSON.stringify(parsed),\n\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t\treturn parsed;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// configs are immutable, if the first lookup returned no results, all lookups should\n\t\t\tthis.configCache.set(name, { raw: undefined });\n\t\t}\n\t\treturn this.configCache.get(name);\n\t}\n}\n\n/**\n * A type containing both a telemetry logger and a configuration provider.\n *\n * @internal\n */\nexport interface MonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt> {\n\tconfig: IConfigProvider;\n\tlogger: L;\n}\n\n/**\n * Determines whether or not the provided object is a {@link MonitoringContext}.\n * @remarks Can be used for type-narrowing.\n *\n * @internal\n */\nexport function loggerIsMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tobj: L,\n): obj is L & MonitoringContext<L> {\n\tconst maybeConfig = obj as Partial<MonitoringContext<L>> | undefined;\n\treturn isConfigProviderBase(maybeConfig?.config) && maybeConfig?.logger !== undefined;\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger, if it isn't already one.\n *\n * @internal\n */\nexport function loggerToMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\treturn logger;\n\t}\n\treturn mixinMonitoringContext<L>(logger, sessionStorageConfigProvider.value);\n}\n\n/**\n * Creates a {@link MonitoringContext} from the provided logger.\n *\n * @remarks\n * Assumes that the provided logger is not itself already a {@link MonitoringContext}, and will throw an error if it is.\n * If you are unsure, use {@link loggerToMonitoringContext} instead.\n *\n * @throws If the provided logger is already a {@link MonitoringContext}.\n *\n * @internal\n */\nexport function mixinMonitoringContext<L extends ITelemetryBaseLogger = ITelemetryLoggerExt>(\n\tlogger: L,\n\t...configs: (IConfigProviderBase | undefined)[]\n): MonitoringContext<L> {\n\tif (loggerIsMonitoringContext<L>(logger)) {\n\t\tthrow new Error(\"Logger is already a monitoring context\");\n\t}\n\t/**\n\t * this is the tricky bit we use for now to smuggle monitoring context around.\n\t * To the logger we mixin both config and itself, so mc.logger === logger as it is self-referential.\n\t * We then expose it as a Monitoring context, so via types we hide the outer logger methods.\n\t * To layers that expect just a logger we can pass mc.logger, but this is still a MonitoringContext\n\t * so if a deeper layer then converts that logger to a monitoring context it can find the smuggled properties\n\t * of the MonitoringContext and get the config provider.\n\t */\n\tconst mc: L & Partial<MonitoringContext<L>> = logger;\n\tmc.config = new CachedConfigProvider(logger, ...configs);\n\tmc.logger = logger;\n\treturn mc as MonitoringContext<L>;\n}\n\nfunction isConfigProviderBase(obj: unknown): obj is IConfigProviderBase {\n\tconst maybeConfig = obj as Partial<IConfigProviderBase> | undefined;\n\treturn typeof maybeConfig?.getRawConfig === \"function\";\n}\n\n/**\n * Creates a child logger with a {@link MonitoringContext}.\n *\n * @see {@link loggerToMonitoringContext}\n * @internal\n */\nexport function createChildMonitoringContext(\n\tprops: Parameters<typeof createChildLogger>[0],\n): MonitoringContext {\n\treturn loggerToMonitoringContext(createChildLogger(props));\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, } from "./config";
|
|
5
|
+
export { createChildMonitoringContext, MonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, IConfigProvider, loggerToMonitoringContext, wrapConfigProviderWithDefaults, } from "./config";
|
|
6
6
|
export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, } from "./error";
|
|
7
7
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, IFluidErrorAnnotations, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
8
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAC5B,iBAAiB,EACjB,4BAA4B,EAC5B,sBAAsB,EACtB,eAAe,EACf,yBAAyB,EACzB,8BAA8B,GAC9B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,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/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
export { createChildMonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, loggerToMonitoringContext, } from "./config";
|
|
5
|
+
export { createChildMonitoringContext, sessionStorageConfigProvider, mixinMonitoringContext, loggerToMonitoringContext, wrapConfigProviderWithDefaults, } from "./config";
|
|
6
6
|
export { DataCorruptionError, DataProcessingError, extractSafePropertiesFromMessage, GenericError, UsageError, validatePrecondition, } from "./error";
|
|
7
7
|
export { extractLogSafeErrorProperties, generateErrorWithStack, generateStack, getCircularReplacer, isExternalError, isILoggingError, isTaggedTelemetryPropertyValue, LoggingError, NORMALIZED_ERROR_TYPE, normalizeError, overwriteStack, wrapError, wrapErrorAndLog, } from "./errorLogging";
|
|
8
8
|
export { EventEmitterWithErrorHandling } from "./eventEmitterWithErrorHandling";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAE5B,4BAA4B,EAC5B,sBAAsB,EAEtB,yBAAyB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACN,4BAA4B,EAE5B,4BAA4B,EAC5B,sBAAsB,EAEtB,yBAAyB,EACzB,8BAA8B,GAC9B,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,gCAAgC,EAChC,YAAY,EACZ,UAAU,EACV,oBAAoB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EACN,6BAA6B,EAC7B,sBAAsB,EACtB,aAAa,EACb,mBAAmB,EAEnB,eAAe,EACf,eAAe,EACf,8BAA8B,EAC9B,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,cAAc,EACd,SAAS,EACT,eAAe,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACN,kBAAkB,EAClB,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,GACd,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,kBAAkB,EAElB,YAAY,EACZ,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,uBAAuB,EACvB,iBAAiB,EACjB,qBAAqB,EACrB,UAAU,EAKV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAEhB,mBAAmB,GACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAA0C,MAAM,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nexport {\n\tcreateChildMonitoringContext,\n\tMonitoringContext,\n\tsessionStorageConfigProvider,\n\tmixinMonitoringContext,\n\tIConfigProvider,\n\tloggerToMonitoringContext,\n\twrapConfigProviderWithDefaults,\n} from \"./config\";\nexport {\n\tDataCorruptionError,\n\tDataProcessingError,\n\textractSafePropertiesFromMessage,\n\tGenericError,\n\tUsageError,\n\tvalidatePrecondition,\n} from \"./error\";\nexport {\n\textractLogSafeErrorProperties,\n\tgenerateErrorWithStack,\n\tgenerateStack,\n\tgetCircularReplacer,\n\tIFluidErrorAnnotations,\n\tisExternalError,\n\tisILoggingError,\n\tisTaggedTelemetryPropertyValue,\n\tLoggingError,\n\tNORMALIZED_ERROR_TYPE,\n\tnormalizeError,\n\toverwriteStack,\n\twrapError,\n\twrapErrorAndLog,\n} from \"./errorLogging\";\nexport { EventEmitterWithErrorHandling } from \"./eventEmitterWithErrorHandling\";\nexport {\n\tconnectedEventName,\n\tdisconnectedEventName,\n\traiseConnectedEvent,\n\tsafeRaiseEvent,\n} from \"./events\";\nexport {\n\thasErrorInstanceId,\n\tIFluidErrorBase,\n\tisFluidError,\n\tisValidLegacyError,\n} from \"./fluidErrorBase\";\nexport {\n\teventNamespaceSeparator,\n\tcreateChildLogger,\n\tcreateMultiSinkLogger,\n\tformatTick,\n\tIPerformanceEventMarkers,\n\tITelemetryLoggerPropertyBag,\n\tITelemetryLoggerPropertyBags,\n\tMultiSinkLoggerProperties,\n\tnumberFromString,\n\tPerformanceEvent,\n\tTaggedLoggerAdapter,\n\ttagData,\n\ttagCodeArtifacts,\n\tTelemetryDataTag,\n\tTelemetryEventPropertyTypes,\n\tTelemetryNullLogger,\n} from \"./logger\";\nexport { MockLogger } from \"./mockLogger\";\nexport { ThresholdCounter } from \"./thresholdCounter\";\nexport { SampledTelemetryHelper } from \"./sampledTelemetryHelper\";\nexport { logIfFalse, createSampledLogger, IEventSampler, ISampledTelemetryLogger } from \"./utils\";\nexport {\n\tTelemetryEventPropertyTypeExt,\n\tITelemetryEventExt,\n\tITelemetryGenericEventExt,\n\tITelemetryErrorEventExt,\n\tITelemetryPerformanceEventExt,\n\tITelemetryLoggerExt,\n\tITaggedTelemetryPropertyTypeExt,\n\tITelemetryPropertiesExt,\n\tTelemetryEventCategory,\n} from \"./telemetryTypes\";\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -283,6 +284,8 @@ export declare type TelemetryEventPropertyTypes = ITelemetryBaseProperties[strin
|
|
|
283
284
|
|
|
284
285
|
/* Excluded from this release type: validatePrecondition */
|
|
285
286
|
|
|
287
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
288
|
+
|
|
286
289
|
/* Excluded from this release type: wrapError */
|
|
287
290
|
|
|
288
291
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -257,6 +258,8 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
|
|
|
257
258
|
|
|
258
259
|
/* Excluded from this release type: validatePrecondition */
|
|
259
260
|
|
|
261
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
262
|
+
|
|
260
263
|
/* Excluded from this release type: wrapError */
|
|
261
264
|
|
|
262
265
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -257,6 +258,8 @@ export declare type TelemetryEventPropertyTypeExt = string | number | boolean |
|
|
|
257
258
|
|
|
258
259
|
/* Excluded from this release type: validatePrecondition */
|
|
259
260
|
|
|
261
|
+
/* Excluded from this release type: wrapConfigProviderWithDefaults */
|
|
262
|
+
|
|
260
263
|
/* Excluded from this release type: wrapError */
|
|
261
264
|
|
|
262
265
|
/* Excluded from this release type: wrapErrorAndLog */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
|
|
3
|
+
import { ConfigTypes } from '@fluidframework/core-interfaces';
|
|
3
4
|
import { EventEmitter } from 'events';
|
|
4
5
|
import { EventEmitterEventType } from '@fluid-internal/client-utils';
|
|
5
6
|
import { IConfigProviderBase } from '@fluidframework/core-interfaces';
|
|
@@ -1079,6 +1080,19 @@ export declare class UsageError extends LoggingError implements IUsageError, IFl
|
|
|
1079
1080
|
*/
|
|
1080
1081
|
export declare function validatePrecondition(condition: boolean, message: string, props?: ITelemetryBaseProperties): asserts condition;
|
|
1081
1082
|
|
|
1083
|
+
/**
|
|
1084
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
1085
|
+
* specifying feature gates if not present in the original provider.
|
|
1086
|
+
*
|
|
1087
|
+
* @param original - the original config provider
|
|
1088
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
1089
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
1090
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
1091
|
+
*
|
|
1092
|
+
* @internal
|
|
1093
|
+
*/
|
|
1094
|
+
export declare const wrapConfigProviderWithDefaults: (original: IConfigProviderBase | undefined, defaults: Record<string, ConfigTypes>) => IConfigProviderBase;
|
|
1095
|
+
|
|
1082
1096
|
/**
|
|
1083
1097
|
* Create a new error using newErrorFn, wrapping and caused by the given unknown error.
|
|
1084
1098
|
* Copies the inner error's stack, errorInstanceId and telemetry props over to the new error if present
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/telemetry-utils",
|
|
3
|
-
"version": "2.0.0-rc.1.0.
|
|
3
|
+
"version": "2.0.0-rc.1.0.2",
|
|
4
4
|
"description": "Collection of telemetry relates utilities for Fluid",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"temp-directory": "nyc/.nyc_output"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fluid-internal/client-utils": ">=2.0.0-rc.1.0.
|
|
43
|
-
"@fluidframework/core-interfaces": ">=2.0.0-rc.1.0.
|
|
44
|
-
"@fluidframework/core-utils": ">=2.0.0-rc.1.0.
|
|
42
|
+
"@fluid-internal/client-utils": ">=2.0.0-rc.1.0.2 <2.0.0-rc.1.1.0",
|
|
43
|
+
"@fluidframework/core-interfaces": ">=2.0.0-rc.1.0.2 <2.0.0-rc.1.1.0",
|
|
44
|
+
"@fluidframework/core-utils": ">=2.0.0-rc.1.0.2 <2.0.0-rc.1.1.0",
|
|
45
45
|
"@fluidframework/protocol-definitions": "^3.1.0",
|
|
46
46
|
"debug": "^4.3.4",
|
|
47
47
|
"events": "^3.1.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@fluidframework/build-common": "^2.0.3",
|
|
54
54
|
"@fluidframework/build-tools": "^0.29.0",
|
|
55
55
|
"@fluidframework/eslint-config-fluid": "^3.2.0",
|
|
56
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.
|
|
56
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-rc.1.0.2 <2.0.0-rc.1.1.0",
|
|
57
57
|
"@fluidframework/telemetry-utils-previous": "npm:@fluidframework/telemetry-utils@2.0.0-internal.8.0.0",
|
|
58
58
|
"@microsoft/api-extractor": "^7.38.3",
|
|
59
59
|
"@types/debug": "^4.1.5",
|
package/src/config.ts
CHANGED
|
@@ -166,6 +166,24 @@ const safeSessionStorage = (): Storage | undefined => {
|
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Creates a wrapper on top of an existing config provider which allows for
|
|
171
|
+
* specifying feature gates if not present in the original provider.
|
|
172
|
+
*
|
|
173
|
+
* @param original - the original config provider
|
|
174
|
+
* @param defaults - default feature gate configs to be used if not specified by the original provider
|
|
175
|
+
* @returns A config provider that looks for any requested feature gates in the original provider and falls
|
|
176
|
+
* back to the values specified in the `defaults` feature gates if they're not present in the original.
|
|
177
|
+
*
|
|
178
|
+
* @internal
|
|
179
|
+
*/
|
|
180
|
+
export const wrapConfigProviderWithDefaults = (
|
|
181
|
+
original: IConfigProviderBase | undefined,
|
|
182
|
+
defaults: Record<string, ConfigTypes>,
|
|
183
|
+
): IConfigProviderBase => ({
|
|
184
|
+
getRawConfig: (name: string): ConfigTypes => original?.getRawConfig(name) ?? defaults[name],
|
|
185
|
+
});
|
|
186
|
+
|
|
169
187
|
/**
|
|
170
188
|
* Implementation of {@link IConfigProvider} which contains nested {@link IConfigProviderBase} instances
|
|
171
189
|
*/
|