@fluidframework/fluid-runner 2.102.0 → 2.110.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.
- package/CHANGELOG.md +34 -0
- package/api-report/fluid-runner.legacy.beta.api.md +21 -0
- package/dist/exportFile.d.ts +33 -5
- package/dist/exportFile.d.ts.map +1 -1
- package/dist/exportFile.js +36 -4
- package/dist/exportFile.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +5 -1
- package/dist/logger/fileLogger.d.ts +11 -3
- package/dist/logger/fileLogger.d.ts.map +1 -1
- package/dist/logger/fileLogger.js.map +1 -1
- package/dist/logger/loggerUtils.d.ts +35 -7
- package/dist/logger/loggerUtils.d.ts.map +1 -1
- package/dist/logger/loggerUtils.js +30 -3
- package/dist/logger/loggerUtils.js.map +1 -1
- package/dist/parseBundleAndExportFile.d.ts +2 -2
- package/dist/parseBundleAndExportFile.d.ts.map +1 -1
- package/dist/parseBundleAndExportFile.js +4 -2
- package/dist/parseBundleAndExportFile.js.map +1 -1
- package/lib/exportFile.d.ts +33 -5
- package/lib/exportFile.d.ts.map +1 -1
- package/lib/exportFile.js +36 -5
- package/lib/exportFile.js.map +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +5 -1
- package/lib/logger/fileLogger.d.ts +11 -3
- package/lib/logger/fileLogger.d.ts.map +1 -1
- package/lib/logger/fileLogger.js.map +1 -1
- package/lib/logger/loggerUtils.d.ts +35 -7
- package/lib/logger/loggerUtils.d.ts.map +1 -1
- package/lib/logger/loggerUtils.js +29 -3
- package/lib/logger/loggerUtils.js.map +1 -1
- package/lib/parseBundleAndExportFile.d.ts +2 -2
- package/lib/parseBundleAndExportFile.d.ts.map +1 -1
- package/lib/parseBundleAndExportFile.js +7 -5
- package/lib/parseBundleAndExportFile.js.map +1 -1
- package/package.json +12 -12
- package/src/exportFile.ts +63 -9
- package/src/index.ts +4 -1
- package/src/logger/fileLogger.ts +12 -3
- package/src/logger/loggerUtils.ts +44 -7
- package/src/parseBundleAndExportFile.ts +18 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @fluidframework/fluid-runner
|
|
2
2
|
|
|
3
|
+
## 2.110.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- New public APIs for loading containers from ODSP snapshots and collecting telemetry ([#27182](https://github.com/microsoft/FluidFramework/pull/27182)) [7291a381bba](https://github.com/microsoft/FluidFramework/commit/7291a381bbaca33f1458c59ad85da8401f5cfec6)
|
|
8
|
+
|
|
9
|
+
Two new functions and their supporting types are now available in `@fluidframework/fluid-runner`:
|
|
10
|
+
|
|
11
|
+
**`createFluidRunnerLogger(filePath, options?)`** — Creates a file-backed telemetry logger that writes events to disk in JSON (default) or CSV format. Returns a `logger` (an `ITelemetryBaseLogger` to send events through) and a `fileLogger` (an `IFileLogger` whose `close()` method must be called when done to flush buffered events).
|
|
12
|
+
|
|
13
|
+
**`createFluidRunnerContainerAndExecute(snapshot, converter, logger, ...)`** — Loads a Fluid container from an ODSP snapshot (JSON string or binary `Uint8Array`), waits for it to catch up, then runs caller-provided code via an `IFluidFileConverter`. The container is automatically disposed after execution. Supports an optional timeout and the ability to disable network fetch to ensure fully offline operation.
|
|
14
|
+
|
|
15
|
+
**Typical usage:**
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
const { logger, fileLogger } = createFluidRunnerLogger("./telemetry.json");
|
|
19
|
+
const result = await createFluidRunnerContainerAndExecute(
|
|
20
|
+
snapshotContent,
|
|
21
|
+
myConverter,
|
|
22
|
+
logger,
|
|
23
|
+
options,
|
|
24
|
+
timeout,
|
|
25
|
+
);
|
|
26
|
+
await fileLogger.close();
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Supporting types:**
|
|
30
|
+
- `IFileLogger` — A telemetry logger that writes to a file and exposes a `close()` method to flush buffered events.
|
|
31
|
+
- `IFileLoggerTelemetryOptions` — Configuration for the logger: output format (`JSON` or `CSV`), default properties added to every event, and flush batch size.
|
|
32
|
+
|
|
33
|
+
## 2.103.0
|
|
34
|
+
|
|
35
|
+
Dependency updates only.
|
|
36
|
+
|
|
3
37
|
## 2.102.0
|
|
4
38
|
|
|
5
39
|
Dependency updates only.
|
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
6
|
|
|
7
|
+
// @beta @legacy
|
|
8
|
+
export function createFluidRunnerContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, baseLogger: ITelemetryBaseLogger, options?: string, timeout?: number, disableNetworkFetch?: boolean): Promise<string>;
|
|
9
|
+
|
|
10
|
+
// @beta @legacy
|
|
11
|
+
export function createFluidRunnerLogger(filePath: string, options?: IFileLoggerTelemetryOptions): {
|
|
12
|
+
logger: ITelemetryBaseLogger;
|
|
13
|
+
fileLogger: IFileLogger;
|
|
14
|
+
};
|
|
15
|
+
|
|
7
16
|
// @beta @legacy (undocumented)
|
|
8
17
|
export type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
|
|
9
18
|
|
|
@@ -25,6 +34,18 @@ export interface IExportFileResponseSuccess {
|
|
|
25
34
|
success: true;
|
|
26
35
|
}
|
|
27
36
|
|
|
37
|
+
// @beta @legacy
|
|
38
|
+
export interface IFileLogger extends ITelemetryBaseLogger {
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @beta @legacy
|
|
43
|
+
export interface IFileLoggerTelemetryOptions {
|
|
44
|
+
defaultProps?: Record<string, string | number>;
|
|
45
|
+
eventsPerFlush?: number;
|
|
46
|
+
outputFormat?: OutputFormat;
|
|
47
|
+
}
|
|
48
|
+
|
|
28
49
|
// @beta @legacy
|
|
29
50
|
export interface IFluidFileConverter {
|
|
30
51
|
execute(container: IContainer, options?: string): Promise<string>;
|
package/dist/exportFile.d.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
6
7
|
import type { IFluidFileConverter } from "./codeLoaderBundle.js";
|
|
7
|
-
import type {
|
|
8
|
+
import type { IFileLoggerTelemetryOptions } from "./logger/fileLogger.js";
|
|
8
9
|
/**
|
|
9
10
|
* @legacy @beta
|
|
10
11
|
*/
|
|
@@ -25,14 +26,41 @@ export interface IExportFileResponseFailure {
|
|
|
25
26
|
error?: any;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
* Execute code on
|
|
29
|
+
* Execute code on a Fluid {@link @fluidframework/container-definitions#IContainer} loaded from an ODSP snapshot
|
|
30
|
+
* file and write the resulting string to disk.
|
|
29
31
|
* @internal
|
|
30
32
|
*/
|
|
31
|
-
export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?:
|
|
33
|
+
export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: IFileLoggerTelemetryOptions, timeout?: number, disableNetworkFetch?: boolean): Promise<IExportFileResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a Fluid {@link @fluidframework/container-definitions#IContainer} from an ODSP snapshot and run
|
|
36
|
+
* caller-provided code against it.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* The container is loaded with `opsBeforeReturn: "cached"` and {@link @fluidframework/container-loader#waitContainerToCatchUp}
|
|
40
|
+
* is invoked before {@link IFluidFileConverter.execute} runs. The container is disposed once `execute` resolves
|
|
41
|
+
* (or rejects).
|
|
42
|
+
*
|
|
43
|
+
* @param localOdspSnapshot - The ODSP snapshot to load the container from. May be either the JSON snapshot
|
|
44
|
+
* as a string or the binary snapshot as a `Uint8Array`.
|
|
45
|
+
* @param fluidFileConverter - Caller-provided code loader and execution logic. See {@link IFluidFileConverter}.
|
|
46
|
+
* @param baseLogger - Telemetry logger that will receive events emitted during load and execution. Typically
|
|
47
|
+
* obtained from {@link createFluidRunnerLogger}.
|
|
48
|
+
* @param options - Opaque, caller-defined string passed through to {@link IFluidFileConverter.execute}.
|
|
49
|
+
* @param timeout - Optional timeout in milliseconds. If the operation does not complete within this period
|
|
50
|
+
* the returned promise rejects. When omitted, no timeout is applied.
|
|
51
|
+
* @param disableNetworkFetch - When `true`, replaces `global.fetch` with an implementation that throws,
|
|
52
|
+
* ensuring the container load is fully serviced from the provided snapshot. Defaults to `false`.
|
|
53
|
+
* @returns The string result returned by {@link IFluidFileConverter.execute}.
|
|
54
|
+
*
|
|
55
|
+
* @legacy
|
|
56
|
+
* @beta
|
|
57
|
+
*/
|
|
58
|
+
export declare function createFluidRunnerContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, baseLogger: ITelemetryBaseLogger, options?: string, timeout?: number, disableNetworkFetch?: boolean): Promise<string>;
|
|
32
59
|
/**
|
|
33
60
|
* Create the container based on an ODSP snapshot and execute code on it
|
|
34
61
|
* @returns result of execution
|
|
62
|
+
* @deprecated Use {@link createFluidRunnerContainerAndExecute}.
|
|
35
63
|
* @internal
|
|
36
64
|
*/
|
|
37
|
-
export declare function createContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, logger:
|
|
65
|
+
export declare function createContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, logger: TelemetryLoggerExt, options?: string, timeout?: number, disableNetworkFetch?: boolean): Promise<string>;
|
|
38
66
|
//# sourceMappingURL=exportFile.d.ts.map
|
package/dist/exportFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E,OAAO,EACN,KAAK,kBAAkB,EAGvB,MAAM,0CAA0C,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAGjE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAQ1E;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,IAAI,CAAC;CACd;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ;AAID;;;;GAIG;AACH,wBAAsB,UAAU,CAC/B,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,2BAA2B,EAC9C,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CA8C9B;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,oCAAoC,CACzD,iBAAiB,EAAE,MAAM,GAAG,UAAU,EACtC,kBAAkB,EAAE,mBAAmB,EACvC,UAAU,EAAE,oBAAoB,EAChC,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,MAAM,CAAC,CAUjB;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC9C,iBAAiB,EAAE,MAAM,GAAG,UAAU,EACtC,kBAAkB,EAAE,mBAAmB,EACvC,MAAM,EAAE,kBAAkB,EAC1B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,GAAE,OAAe,GAClC,OAAO,CAAC,MAAM,CAAC,CA8CjB"}
|
package/dist/exportFile.js
CHANGED
|
@@ -27,7 +27,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.createContainerAndExecute = exports.exportFile = void 0;
|
|
30
|
+
exports.createContainerAndExecute = exports.createFluidRunnerContainerAndExecute = exports.exportFile = void 0;
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const internal_1 = require("@fluidframework/container-definitions/internal");
|
|
33
33
|
const internal_2 = require("@fluidframework/container-loader/internal");
|
|
@@ -38,7 +38,8 @@ const loggerUtils_js_1 = require("./logger/loggerUtils.js");
|
|
|
38
38
|
const utils_js_1 = require("./utils.js");
|
|
39
39
|
const clientArgsValidationError = "Client_ArgsValidationError";
|
|
40
40
|
/**
|
|
41
|
-
* Execute code on
|
|
41
|
+
* Execute code on a Fluid {@link @fluidframework/container-definitions#IContainer} loaded from an ODSP snapshot
|
|
42
|
+
* file and write the resulting string to disk.
|
|
42
43
|
* @internal
|
|
43
44
|
*/
|
|
44
45
|
async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options, telemetryOptions, timeout, disableNetworkFetch) {
|
|
@@ -47,7 +48,8 @@ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFi
|
|
|
47
48
|
const eventName = clientArgsValidationError;
|
|
48
49
|
return { success: false, eventName, errorMessage: telemetryArgError };
|
|
49
50
|
}
|
|
50
|
-
const { fileLogger, logger } = (0, loggerUtils_js_1.
|
|
51
|
+
const { fileLogger, logger: baseLogger } = (0, loggerUtils_js_1.createFluidRunnerLogger)(telemetryFile, telemetryOptions);
|
|
52
|
+
const logger = (0, internal_4.createChildLogger)({ logger: baseLogger });
|
|
51
53
|
try {
|
|
52
54
|
return await internal_4.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
|
53
55
|
const argsValidationError = (0, utils_js_1.getArgsValidationError)(inputFile, outputFile, timeout);
|
|
@@ -56,7 +58,7 @@ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFi
|
|
|
56
58
|
logger.sendErrorEvent({ eventName, message: argsValidationError });
|
|
57
59
|
return { success: false, eventName, errorMessage: argsValidationError };
|
|
58
60
|
}
|
|
59
|
-
fs.writeFileSync(outputFile, await
|
|
61
|
+
fs.writeFileSync(outputFile, await createFluidRunnerContainerAndExecute((0, utils_js_1.getSnapshotFileContent)(inputFile), fluidFileConverter, baseLogger, options, timeout, disableNetworkFetch));
|
|
60
62
|
return { success: true };
|
|
61
63
|
});
|
|
62
64
|
}
|
|
@@ -70,9 +72,39 @@ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFi
|
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
74
|
exports.exportFile = exportFile;
|
|
75
|
+
/**
|
|
76
|
+
* Create a Fluid {@link @fluidframework/container-definitions#IContainer} from an ODSP snapshot and run
|
|
77
|
+
* caller-provided code against it.
|
|
78
|
+
*
|
|
79
|
+
* @remarks
|
|
80
|
+
* The container is loaded with `opsBeforeReturn: "cached"` and {@link @fluidframework/container-loader#waitContainerToCatchUp}
|
|
81
|
+
* is invoked before {@link IFluidFileConverter.execute} runs. The container is disposed once `execute` resolves
|
|
82
|
+
* (or rejects).
|
|
83
|
+
*
|
|
84
|
+
* @param localOdspSnapshot - The ODSP snapshot to load the container from. May be either the JSON snapshot
|
|
85
|
+
* as a string or the binary snapshot as a `Uint8Array`.
|
|
86
|
+
* @param fluidFileConverter - Caller-provided code loader and execution logic. See {@link IFluidFileConverter}.
|
|
87
|
+
* @param baseLogger - Telemetry logger that will receive events emitted during load and execution. Typically
|
|
88
|
+
* obtained from {@link createFluidRunnerLogger}.
|
|
89
|
+
* @param options - Opaque, caller-defined string passed through to {@link IFluidFileConverter.execute}.
|
|
90
|
+
* @param timeout - Optional timeout in milliseconds. If the operation does not complete within this period
|
|
91
|
+
* the returned promise rejects. When omitted, no timeout is applied.
|
|
92
|
+
* @param disableNetworkFetch - When `true`, replaces `global.fetch` with an implementation that throws,
|
|
93
|
+
* ensuring the container load is fully serviced from the provided snapshot. Defaults to `false`.
|
|
94
|
+
* @returns The string result returned by {@link IFluidFileConverter.execute}.
|
|
95
|
+
*
|
|
96
|
+
* @legacy
|
|
97
|
+
* @beta
|
|
98
|
+
*/
|
|
99
|
+
async function createFluidRunnerContainerAndExecute(localOdspSnapshot, fluidFileConverter, baseLogger, options, timeout, disableNetworkFetch) {
|
|
100
|
+
const logger = (0, internal_4.createChildLogger)({ logger: baseLogger });
|
|
101
|
+
return createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options, timeout, disableNetworkFetch);
|
|
102
|
+
}
|
|
103
|
+
exports.createFluidRunnerContainerAndExecute = createFluidRunnerContainerAndExecute;
|
|
73
104
|
/**
|
|
74
105
|
* Create the container based on an ODSP snapshot and execute code on it
|
|
75
106
|
* @returns result of execution
|
|
107
|
+
* @deprecated Use {@link createFluidRunnerContainerAndExecute}.
|
|
76
108
|
* @internal
|
|
77
109
|
*/
|
|
78
110
|
async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options, timeout, disableNetworkFetch = false) {
|
package/dist/exportFile.js.map
CHANGED
|
@@ -1 +1 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C;QAEF,MAAM,SAAS,GAAG,MAAM,IAAA,gCAAqB,EAAC;YAC7C,GAAG,WAAW;YACd,OAAO,EAAE;gBACR,GAAG,EAAE,WAAW;gBAChB,OAAO,EAAE;oBACR,CAAC,uBAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;iBACtD;aACD;SACD,CAAC,CAAC;QACH,MAAM,IAAA,iCAAsB,EAAC,SAAS,CAAC,CAAC;QAExC,OAAO,2BAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACtF,IAAI,CAAC;gBACJ,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7D,CAAC;oBAAS,CAAC;gBACV,SAAS,CAAC,OAAO,EAAE,CAAC;YACrB,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,kDAAkD;IAClD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAA,yBAAc,EAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,EAAE,EAAE;iBACF,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC/B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC,EAAE,OAAO,CAAC,CAAC;IACb,CAAC;SAAM,CAAC;QACP,OAAO,EAAE,EAAE,CAAC;IACb,CAAC;AACF,CAAC;AArDD,8DAqDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\n\nimport { LoaderHeader } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tloadExistingContainer,\n\twaitContainerToCatchUp,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver/internal\";\nimport {\n\ttype ITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidFileConverter } from \"./codeLoaderBundle.js\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver.js\";\n/* eslint-disable import-x/no-internal-modules */\nimport type { ITelemetryOptions } from \"./logger/fileLogger.js\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils.js\";\nimport { getArgsValidationError, getSnapshotFileContent, timeoutPromise } from \"./utils.js\";\n/* eslint-enable import-x/no-internal-modules */\n\n/**\n * @legacy @beta\n */\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\n/**\n * @legacy @beta\n */\nexport interface IExportFileResponseSuccess {\n\tsuccess: true;\n}\n\n/**\n * @legacy @beta\n */\nexport interface IExportFileResponseFailure {\n\tsuccess: false;\n\teventName: string;\n\terrorMessage: string;\n\terror?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Execute code on Container based on ODSP snapshot and write result to file\n * @internal\n */\nexport async function exportFile(\n\tfluidFileConverter: IFluidFileConverter,\n\tinputFile: string,\n\toutputFile: string,\n\ttelemetryFile: string,\n\toptions?: string,\n\ttelemetryOptions?: ITelemetryOptions,\n\ttimeout?: number,\n\tdisableNetworkFetch?: boolean,\n): Promise<IExportFileResponse> {\n\tconst telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n\tif (telemetryArgError) {\n\t\tconst eventName = clientArgsValidationError;\n\t\treturn { success: false, eventName, errorMessage: telemetryArgError };\n\t}\n\tconst { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);\n\n\ttry {\n\t\treturn await PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"ExportFile\" },\n\t\t\tasync () => {\n\t\t\t\tconst argsValidationError = getArgsValidationError(inputFile, outputFile, timeout);\n\t\t\t\tif (argsValidationError) {\n\t\t\t\t\tconst eventName = clientArgsValidationError;\n\t\t\t\t\tlogger.sendErrorEvent({ eventName, message: argsValidationError });\n\t\t\t\t\treturn { success: false, eventName, errorMessage: argsValidationError };\n\t\t\t\t}\n\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputFile,\n\t\t\t\t\tawait createContainerAndExecute(\n\t\t\t\t\t\tgetSnapshotFileContent(inputFile),\n\t\t\t\t\t\tfluidFileConverter,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tdisableNetworkFetch,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn { success: true };\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tconst eventName = \"Client_UnexpectedError\";\n\t\tlogger.sendErrorEvent({ eventName }, error);\n\t\treturn { success: false, eventName, errorMessage: \"Unexpected error\", error };\n\t} finally {\n\t\tawait fileLogger.close();\n\t}\n}\n\n/**\n * Create the container based on an ODSP snapshot and execute code on it\n * @returns result of execution\n * @internal\n */\nexport async function createContainerAndExecute(\n\tlocalOdspSnapshot: string | Uint8Array,\n\tfluidFileConverter: IFluidFileConverter,\n\tlogger: ITelemetryLoggerExt,\n\toptions?: string,\n\ttimeout?: number,\n\tdisableNetworkFetch: boolean = false,\n): Promise<string> {\n\tconst fn = async (): Promise<string> => {\n\t\tif (disableNetworkFetch) {\n\t\t\tglobal.fetch = async () => {\n\t\t\t\tthrow new Error(\"Network fetch is not allowed\");\n\t\t\t};\n\t\t}\n\n\t\tconst loaderProps: ILoaderProps = {\n\t\t\turlResolver: new FakeUrlResolver(),\n\t\t\tdocumentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n\t\t\tcodeLoader: await fluidFileConverter.getCodeLoader(logger),\n\t\t\tscope: await fluidFileConverter.getScope?.(logger),\n\t\t\tlogger,\n\t\t};\n\n\t\tconst container = await loadExistingContainer({\n\t\t\t...loaderProps,\n\t\t\trequest: {\n\t\t\t\turl: \"/fakeUrl/\",\n\t\t\t\theaders: {\n\t\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tawait waitContainerToCatchUp(container);\n\n\t\treturn PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n\t\t\ttry {\n\t\t\t\treturn await fluidFileConverter.execute(container, options);\n\t\t\t} finally {\n\t\t\t\tcontainer.dispose();\n\t\t\t}\n\t\t});\n\t};\n\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (timeout !== undefined) {\n\t\treturn timeoutPromise<string>((resolve, reject) => {\n\t\t\tfn()\n\t\t\t\t.then((value) => resolve(value))\n\t\t\t\t.catch((error) => reject(error));\n\t\t}, timeout);\n\t} else {\n\t\treturn fn();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,6EAA8E;AAC9E,wEAImD;AAEnD,mEAA6F;AAC7F,uEAIkD;AAGlD,6DAAuD;AAGvD,4DAGiC;AACjC,yCAA4F;AAyB5F,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;;;GAIG;AACI,KAAK,UAAU,UAAU,CAC/B,kBAAuC,EACvC,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB,EAChB,gBAA8C,EAC9C,OAAgB,EAChB,mBAA6B;IAE7B,MAAM,iBAAiB,GAAG,IAAA,gDAA+B,EAAC,aAAa,CAAC,CAAC;IACzE,IAAI,iBAAiB,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,yBAAyB,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;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AAQ,EAAE;iBACtD;aACD;SACD,CAAC,CAAC;QACH,MAAM,IAAA,iCAAsB,EAAC,SAAS,CAAC,CAAC;QAExC,OAAO,2BAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACtF,IAAI,CAAC;gBACJ,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7D,CAAC;oBAAS,CAAC;gBACV,SAAS,CAAC,OAAO,EAAE,CAAC;YACrB,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,kDAAkD;IAClD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,IAAA,yBAAc,EAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,EAAE,EAAE;iBACF,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC/B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC,EAAE,OAAO,CAAC,CAAC;IACb,CAAC;SAAM,CAAC;QACP,OAAO,EAAE,EAAE,CAAC;IACb,CAAC;AACF,CAAC;AArDD,8DAqDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\n\nimport { LoaderHeader } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tloadExistingContainer,\n\twaitContainerToCatchUp,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver/internal\";\nimport {\n\ttype TelemetryLoggerExt,\n\tPerformanceEvent,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport type { IFluidFileConverter } from \"./codeLoaderBundle.js\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver.js\";\n/* eslint-disable import-x/no-internal-modules */\nimport type { IFileLoggerTelemetryOptions } from \"./logger/fileLogger.js\";\nimport {\n\tcreateFluidRunnerLogger,\n\tgetTelemetryFileValidationError,\n} from \"./logger/loggerUtils.js\";\nimport { getArgsValidationError, getSnapshotFileContent, timeoutPromise } from \"./utils.js\";\n/* eslint-enable import-x/no-internal-modules */\n\n/**\n * @legacy @beta\n */\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\n/**\n * @legacy @beta\n */\nexport interface IExportFileResponseSuccess {\n\tsuccess: true;\n}\n\n/**\n * @legacy @beta\n */\nexport interface IExportFileResponseFailure {\n\tsuccess: false;\n\teventName: string;\n\terrorMessage: string;\n\terror?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Execute code on a Fluid {@link @fluidframework/container-definitions#IContainer} loaded from an ODSP snapshot\n * file and write the resulting string to disk.\n * @internal\n */\nexport async function exportFile(\n\tfluidFileConverter: IFluidFileConverter,\n\tinputFile: string,\n\toutputFile: string,\n\ttelemetryFile: string,\n\toptions?: string,\n\ttelemetryOptions?: IFileLoggerTelemetryOptions,\n\ttimeout?: number,\n\tdisableNetworkFetch?: boolean,\n): Promise<IExportFileResponse> {\n\tconst telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n\tif (telemetryArgError) {\n\t\tconst eventName = clientArgsValidationError;\n\t\treturn { success: false, eventName, errorMessage: telemetryArgError };\n\t}\n\tconst { fileLogger, logger: baseLogger } = createFluidRunnerLogger(\n\t\ttelemetryFile,\n\t\ttelemetryOptions,\n\t);\n\tconst logger = createChildLogger({ logger: baseLogger });\n\n\ttry {\n\t\treturn await PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"ExportFile\" },\n\t\t\tasync () => {\n\t\t\t\tconst argsValidationError = getArgsValidationError(inputFile, outputFile, timeout);\n\t\t\t\tif (argsValidationError) {\n\t\t\t\t\tconst eventName = clientArgsValidationError;\n\t\t\t\t\tlogger.sendErrorEvent({ eventName, message: argsValidationError });\n\t\t\t\t\treturn { success: false, eventName, errorMessage: argsValidationError };\n\t\t\t\t}\n\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputFile,\n\t\t\t\t\tawait createFluidRunnerContainerAndExecute(\n\t\t\t\t\t\tgetSnapshotFileContent(inputFile),\n\t\t\t\t\t\tfluidFileConverter,\n\t\t\t\t\t\tbaseLogger,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tdisableNetworkFetch,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn { success: true };\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tconst eventName = \"Client_UnexpectedError\";\n\t\tlogger.sendErrorEvent({ eventName }, error);\n\t\treturn { success: false, eventName, errorMessage: \"Unexpected error\", error };\n\t} finally {\n\t\tawait fileLogger.close();\n\t}\n}\n\n/**\n * Create a Fluid {@link @fluidframework/container-definitions#IContainer} from an ODSP snapshot and run\n * caller-provided code against it.\n *\n * @remarks\n * The container is loaded with `opsBeforeReturn: \"cached\"` and {@link @fluidframework/container-loader#waitContainerToCatchUp}\n * is invoked before {@link IFluidFileConverter.execute} runs. The container is disposed once `execute` resolves\n * (or rejects).\n *\n * @param localOdspSnapshot - The ODSP snapshot to load the container from. May be either the JSON snapshot\n * as a string or the binary snapshot as a `Uint8Array`.\n * @param fluidFileConverter - Caller-provided code loader and execution logic. See {@link IFluidFileConverter}.\n * @param baseLogger - Telemetry logger that will receive events emitted during load and execution. Typically\n * obtained from {@link createFluidRunnerLogger}.\n * @param options - Opaque, caller-defined string passed through to {@link IFluidFileConverter.execute}.\n * @param timeout - Optional timeout in milliseconds. If the operation does not complete within this period\n * the returned promise rejects. When omitted, no timeout is applied.\n * @param disableNetworkFetch - When `true`, replaces `global.fetch` with an implementation that throws,\n * ensuring the container load is fully serviced from the provided snapshot. Defaults to `false`.\n * @returns The string result returned by {@link IFluidFileConverter.execute}.\n *\n * @legacy\n * @beta\n */\nexport async function createFluidRunnerContainerAndExecute(\n\tlocalOdspSnapshot: string | Uint8Array,\n\tfluidFileConverter: IFluidFileConverter,\n\tbaseLogger: ITelemetryBaseLogger,\n\toptions?: string,\n\ttimeout?: number,\n\tdisableNetworkFetch?: boolean,\n): Promise<string> {\n\tconst logger = createChildLogger({ logger: baseLogger });\n\treturn createContainerAndExecute(\n\t\tlocalOdspSnapshot,\n\t\tfluidFileConverter,\n\t\tlogger,\n\t\toptions,\n\t\ttimeout,\n\t\tdisableNetworkFetch,\n\t);\n}\n\n/**\n * Create the container based on an ODSP snapshot and execute code on it\n * @returns result of execution\n * @deprecated Use {@link createFluidRunnerContainerAndExecute}.\n * @internal\n */\nexport async function createContainerAndExecute(\n\tlocalOdspSnapshot: string | Uint8Array,\n\tfluidFileConverter: IFluidFileConverter,\n\tlogger: TelemetryLoggerExt,\n\toptions?: string,\n\ttimeout?: number,\n\tdisableNetworkFetch: boolean = false,\n): Promise<string> {\n\tconst fn = async (): Promise<string> => {\n\t\tif (disableNetworkFetch) {\n\t\t\tglobal.fetch = async () => {\n\t\t\t\tthrow new Error(\"Network fetch is not allowed\");\n\t\t\t};\n\t\t}\n\n\t\tconst loaderProps: ILoaderProps = {\n\t\t\turlResolver: new FakeUrlResolver(),\n\t\t\tdocumentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n\t\t\tcodeLoader: await fluidFileConverter.getCodeLoader(logger),\n\t\t\tscope: await fluidFileConverter.getScope?.(logger),\n\t\t\tlogger,\n\t\t};\n\n\t\tconst container = await loadExistingContainer({\n\t\t\t...loaderProps,\n\t\t\trequest: {\n\t\t\t\turl: \"/fakeUrl/\",\n\t\t\t\theaders: {\n\t\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t\t},\n\t\t\t},\n\t\t});\n\t\tawait waitContainerToCatchUp(container);\n\n\t\treturn PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n\t\t\ttry {\n\t\t\t\treturn await fluidFileConverter.execute(container, options);\n\t\t\t} finally {\n\t\t\t\tcontainer.dispose();\n\t\t\t}\n\t\t});\n\t};\n\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (timeout !== undefined) {\n\t\treturn timeoutPromise<string>((resolve, reject) => {\n\t\t\tfn()\n\t\t\t\t.then((value) => resolve(value))\n\t\t\t\t.catch((error) => reject(error));\n\t\t}, timeout);\n\t} else {\n\t\treturn fn();\n\t}\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
export type { ICodeLoaderBundle, IFluidFileConverter } from "./codeLoaderBundle.js";
|
|
6
|
-
export { createContainerAndExecute, exportFile, type IExportFileResponse, type IExportFileResponseSuccess, type IExportFileResponseFailure, } from "./exportFile.js";
|
|
6
|
+
export { createContainerAndExecute, createFluidRunnerContainerAndExecute, exportFile, type IExportFileResponse, type IExportFileResponseSuccess, type IExportFileResponseFailure, } from "./exportFile.js";
|
|
7
7
|
export { fluidRunner } from "./fluidRunner.js";
|
|
8
|
-
export { OutputFormat, type
|
|
9
|
-
export { createLogger, getTelemetryFileValidationError, validateAndParseTelemetryOptions, } from "./logger/loggerUtils.js";
|
|
8
|
+
export { OutputFormat, type IFileLoggerTelemetryOptions, type IFileLogger, type ITelemetryOptions, } from "./logger/fileLogger.js";
|
|
9
|
+
export { createFluidRunnerLogger, createLogger, getTelemetryFileValidationError, validateAndParseTelemetryOptions, } from "./logger/loggerUtils.js";
|
|
10
10
|
export { parseBundleAndExportFile } from "./parseBundleAndExportFile.js";
|
|
11
11
|
export { getSnapshotFileContent } from "./utils.js";
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
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;AAGH,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EACN,yBAAyB,EACzB,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACN,YAAY,EACZ,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EACN,yBAAyB,EACzB,oCAAoC,EACpC,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,0BAA0B,GAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACN,YAAY,EACZ,KAAK,2BAA2B,EAChC,KAAK,WAAW,EAChB,KAAK,iBAAiB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACN,uBAAuB,EACvB,YAAY,EACZ,+BAA+B,EAC/B,gCAAgC,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,15 +4,17 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.getSnapshotFileContent = exports.parseBundleAndExportFile = exports.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = exports.OutputFormat = exports.fluidRunner = exports.exportFile = exports.createContainerAndExecute = void 0;
|
|
7
|
+
exports.getSnapshotFileContent = exports.parseBundleAndExportFile = exports.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = exports.createFluidRunnerLogger = exports.OutputFormat = exports.fluidRunner = exports.exportFile = exports.createFluidRunnerContainerAndExecute = exports.createContainerAndExecute = void 0;
|
|
8
8
|
var exportFile_js_1 = require("./exportFile.js");
|
|
9
9
|
Object.defineProperty(exports, "createContainerAndExecute", { enumerable: true, get: function () { return exportFile_js_1.createContainerAndExecute; } });
|
|
10
|
+
Object.defineProperty(exports, "createFluidRunnerContainerAndExecute", { enumerable: true, get: function () { return exportFile_js_1.createFluidRunnerContainerAndExecute; } });
|
|
10
11
|
Object.defineProperty(exports, "exportFile", { enumerable: true, get: function () { return exportFile_js_1.exportFile; } });
|
|
11
12
|
var fluidRunner_js_1 = require("./fluidRunner.js");
|
|
12
13
|
Object.defineProperty(exports, "fluidRunner", { enumerable: true, get: function () { return fluidRunner_js_1.fluidRunner; } });
|
|
13
14
|
var fileLogger_js_1 = require("./logger/fileLogger.js");
|
|
14
15
|
Object.defineProperty(exports, "OutputFormat", { enumerable: true, get: function () { return fileLogger_js_1.OutputFormat; } });
|
|
15
16
|
var loggerUtils_js_1 = require("./logger/loggerUtils.js");
|
|
17
|
+
Object.defineProperty(exports, "createFluidRunnerLogger", { enumerable: true, get: function () { return loggerUtils_js_1.createFluidRunnerLogger; } });
|
|
16
18
|
Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return loggerUtils_js_1.createLogger; } });
|
|
17
19
|
Object.defineProperty(exports, "getTelemetryFileValidationError", { enumerable: true, get: function () { return loggerUtils_js_1.getTelemetryFileValidationError; } });
|
|
18
20
|
Object.defineProperty(exports, "validateAndParseTelemetryOptions", { enumerable: true, get: function () { return loggerUtils_js_1.validateAndParseTelemetryOptions; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,iDAOyB;AANxB,0HAAA,yBAAyB,OAAA;AACzB,qIAAA,oCAAoC,OAAA;AACpC,2GAAA,UAAU,OAAA;AAKX,mDAA+C;AAAtC,6GAAA,WAAW,OAAA;AACpB,wDAKgC;AAJ/B,6GAAA,YAAY,OAAA;AAKb,0DAKiC;AAJhC,yHAAA,uBAAuB,OAAA;AACvB,8GAAA,YAAY,OAAA;AACZ,iIAAA,+BAA+B,OAAA;AAC/B,kIAAA,gCAAgC,OAAA;AAEjC,6EAAyE;AAAhE,uIAAA,wBAAwB,OAAA;AACjC,uCAAoD;AAA3C,kHAAA,sBAAsB,OAAA;AAC/B,gDAAgD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import-x/no-internal-modules */\nexport type { ICodeLoaderBundle, IFluidFileConverter } from \"./codeLoaderBundle.js\";\nexport {\n\tcreateContainerAndExecute,\n\tcreateFluidRunnerContainerAndExecute,\n\texportFile,\n\ttype IExportFileResponse,\n\ttype IExportFileResponseSuccess,\n\ttype IExportFileResponseFailure,\n} from \"./exportFile.js\";\nexport { fluidRunner } from \"./fluidRunner.js\";\nexport {\n\tOutputFormat,\n\ttype IFileLoggerTelemetryOptions,\n\ttype IFileLogger,\n\ttype ITelemetryOptions,\n} from \"./logger/fileLogger.js\";\nexport {\n\tcreateFluidRunnerLogger,\n\tcreateLogger,\n\tgetTelemetryFileValidationError,\n\tvalidateAndParseTelemetryOptions,\n} from \"./logger/loggerUtils.js\";\nexport { parseBundleAndExportFile } from \"./parseBundleAndExportFile.js\";\nexport { getSnapshotFileContent } from \"./utils.js\";\n/* eslint-enable import-x/no-internal-modules */\n"]}
|
package/dist/legacy.d.ts
CHANGED
|
@@ -13,7 +13,11 @@ export {
|
|
|
13
13
|
IExportFileResponse,
|
|
14
14
|
IExportFileResponseFailure,
|
|
15
15
|
IExportFileResponseSuccess,
|
|
16
|
+
IFileLogger,
|
|
17
|
+
IFileLoggerTelemetryOptions,
|
|
16
18
|
IFluidFileConverter,
|
|
17
|
-
OutputFormat
|
|
19
|
+
OutputFormat,
|
|
20
|
+
createFluidRunnerContainerAndExecute,
|
|
21
|
+
createFluidRunnerLogger
|
|
18
22
|
// #endregion
|
|
19
23
|
} from "./index.js";
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
6
|
/**
|
|
7
7
|
* Contract for logger that writes telemetry to a file
|
|
8
|
-
* @
|
|
8
|
+
* @legacy
|
|
9
|
+
* @beta
|
|
9
10
|
*/
|
|
10
11
|
export interface IFileLogger extends ITelemetryBaseLogger {
|
|
11
12
|
/**
|
|
@@ -23,9 +24,10 @@ export declare enum OutputFormat {
|
|
|
23
24
|
}
|
|
24
25
|
/**
|
|
25
26
|
* Options to provide upon creation of IFileLogger
|
|
26
|
-
* @
|
|
27
|
+
* @legacy
|
|
28
|
+
* @beta
|
|
27
29
|
*/
|
|
28
|
-
export interface
|
|
30
|
+
export interface IFileLoggerTelemetryOptions {
|
|
29
31
|
/** Desired output format used to create a specific IFileLogger implementation */
|
|
30
32
|
outputFormat?: OutputFormat;
|
|
31
33
|
/**
|
|
@@ -41,4 +43,10 @@ export interface ITelemetryOptions {
|
|
|
41
43
|
/** Number of telemetry events per flush to telemetry file */
|
|
42
44
|
eventsPerFlush?: number;
|
|
43
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Options to provide upon creation of IFileLogger
|
|
48
|
+
* @deprecated Use {@link IFileLoggerTelemetryOptions}.
|
|
49
|
+
* @internal
|
|
50
|
+
*/
|
|
51
|
+
export type ITelemetryOptions = IFileLoggerTelemetryOptions;
|
|
44
52
|
//# sourceMappingURL=fileLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E
|
|
1
|
+
{"version":3,"file":"fileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACxD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED;;;GAGG;AACH,oBAAY,YAAY;IACvB,IAAI,IAAA;IACJ,GAAG,IAAA;CACH;AAED;;;;GAIG;AACH,MAAM,WAAW,2BAA2B;IAC3C,iFAAiF;IACjF,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;;;;;OAQG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAE/C,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileLogger.js","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"fileLogger.js","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAgBH;;;GAGG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACvB,+CAAI,CAAA;IACJ,6CAAG,CAAA;AACJ,CAAC,EAHW,YAAY,4BAAZ,YAAY,QAGvB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract for logger that writes telemetry to a file\n * @legacy\n * @beta\n */\nexport interface IFileLogger extends ITelemetryBaseLogger {\n\t/**\n\t * This method acts as a \"dispose\" and should be explicitly called at the end of execution\n\t */\n\tclose(): Promise<void>;\n}\n\n/**\n * Desired output format for the telemetry\n * @legacy @beta\n */\nexport enum OutputFormat {\n\tJSON,\n\tCSV,\n}\n\n/**\n * Options to provide upon creation of IFileLogger\n * @legacy\n * @beta\n */\nexport interface IFileLoggerTelemetryOptions {\n\t/** Desired output format used to create a specific IFileLogger implementation */\n\toutputFormat?: OutputFormat;\n\n\t/**\n\t * Properties that should be added to every telemetry event\n\t *\n\t * @example\n\t *\n\t * ```JSON\n\t * { \"prop1\": \"value1\", \"prop2\": 10.0 }\n\t * ```\n\t */\n\tdefaultProps?: Record<string, string | number>;\n\n\t/** Number of telemetry events per flush to telemetry file */\n\teventsPerFlush?: number;\n}\n\n/**\n * Options to provide upon creation of IFileLogger\n * @deprecated Use {@link IFileLoggerTelemetryOptions}.\n * @internal\n */\nexport type ITelemetryOptions = IFileLoggerTelemetryOptions;\n"]}
|
|
@@ -2,10 +2,36 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { type
|
|
5
|
+
import type { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
|
|
6
|
+
import { type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
import { type IFileLogger, type IFileLoggerTelemetryOptions } from "./fileLogger.js";
|
|
7
8
|
/**
|
|
8
|
-
* Create
|
|
9
|
+
* Create a telemetry logger wrapped around an {@link IFileLogger} that writes to the given file path.
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* All telemetry events should be sent through the returned `logger`. The returned `fileLogger` is the
|
|
13
|
+
* underlying sink — its `close()` method must be called at the end of execution to flush any buffered
|
|
14
|
+
* events to disk.
|
|
15
|
+
*
|
|
16
|
+
* If `options.outputFormat` is not supplied, telemetry is written as JSON. Use {@link OutputFormat.CSV}
|
|
17
|
+
* to write CSV instead. See {@link IFileLoggerTelemetryOptions} for supported options including default
|
|
18
|
+
* properties applied to every event and flush batching.
|
|
19
|
+
*
|
|
20
|
+
* @param filePath - Path to the file telemetry will be written to. If the file already exists its
|
|
21
|
+
* contents will be overwritten or corrupted — callers should verify the path is unused before calling.
|
|
22
|
+
* @param options - Optional telemetry configuration. See {@link IFileLoggerTelemetryOptions}.
|
|
23
|
+
* @returns The wrapped telemetry logger to send events through, and the underlying `IFileLogger`
|
|
24
|
+
* which must be closed when telemetry collection is finished.
|
|
25
|
+
*
|
|
26
|
+
* @legacy
|
|
27
|
+
* @beta
|
|
28
|
+
*/
|
|
29
|
+
export declare function createFluidRunnerLogger(filePath: string, options?: IFileLoggerTelemetryOptions): {
|
|
30
|
+
logger: ITelemetryBaseLogger;
|
|
31
|
+
fileLogger: IFileLogger;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create an {@link @fluidframework/telemetry-utils#TelemetryLoggerExt} wrapped around provided {@link IFileLogger}.
|
|
9
35
|
*
|
|
10
36
|
* @remarks
|
|
11
37
|
*
|
|
@@ -15,11 +41,13 @@ import { type IFileLogger, type ITelemetryOptions } from "./fileLogger.js";
|
|
|
15
41
|
*
|
|
16
42
|
* Note: if an output format is not supplied, default is JSON.
|
|
17
43
|
*
|
|
18
|
-
* @returns Both the `IFileLogger` implementation and `
|
|
44
|
+
* @returns Both the `IFileLogger` implementation and `TelemetryLoggerExt` wrapper to be called.
|
|
45
|
+
*
|
|
46
|
+
* @deprecated Use {@link createFluidRunnerLogger}.
|
|
19
47
|
* @internal
|
|
20
48
|
*/
|
|
21
|
-
export declare function createLogger(filePath: string, options?:
|
|
22
|
-
logger:
|
|
49
|
+
export declare function createLogger(filePath: string, options?: IFileLoggerTelemetryOptions): {
|
|
50
|
+
logger: TelemetryLoggerExt;
|
|
23
51
|
fileLogger: IFileLogger;
|
|
24
52
|
};
|
|
25
53
|
/**
|
|
@@ -39,6 +67,6 @@ export declare function validateAndParseTelemetryOptions(format?: string, props?
|
|
|
39
67
|
error: string;
|
|
40
68
|
} | {
|
|
41
69
|
success: true;
|
|
42
|
-
telemetryOptions:
|
|
70
|
+
telemetryOptions: IFileLoggerTelemetryOptions;
|
|
43
71
|
};
|
|
44
72
|
//# sourceMappingURL=loggerUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerUtils.d.ts","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,KAAK,
|
|
1
|
+
{"version":3,"file":"loggerUtils.d.ts","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EACN,KAAK,kBAAkB,EAEvB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EACN,KAAK,WAAW,EAChB,KAAK,2BAA2B,EAEhC,MAAM,iBAAiB,CAAC;AAGzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,2BAA2B,GACnC;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAE3D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,2BAA2B,GACnC;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,UAAU,EAAE,WAAW,CAAA;CAAE,CAezD;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzF;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC/C,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,EAC3B,cAAc,CAAC,EAAE,MAAM,GAErB;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,2BAA2B,CAAA;CAAE,CAqClE"}
|
|
@@ -27,14 +27,39 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
27
27
|
return result;
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
exports.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = void 0;
|
|
30
|
+
exports.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = exports.createFluidRunnerLogger = void 0;
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
32
|
const internal_1 = require("@fluidframework/telemetry-utils/internal");
|
|
33
33
|
const csvFileLogger_js_1 = require("./csvFileLogger.js");
|
|
34
34
|
const fileLogger_js_1 = require("./fileLogger.js");
|
|
35
35
|
const jsonFileLogger_js_1 = require("./jsonFileLogger.js");
|
|
36
36
|
/**
|
|
37
|
-
* Create
|
|
37
|
+
* Create a telemetry logger wrapped around an {@link IFileLogger} that writes to the given file path.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* All telemetry events should be sent through the returned `logger`. The returned `fileLogger` is the
|
|
41
|
+
* underlying sink — its `close()` method must be called at the end of execution to flush any buffered
|
|
42
|
+
* events to disk.
|
|
43
|
+
*
|
|
44
|
+
* If `options.outputFormat` is not supplied, telemetry is written as JSON. Use {@link OutputFormat.CSV}
|
|
45
|
+
* to write CSV instead. See {@link IFileLoggerTelemetryOptions} for supported options including default
|
|
46
|
+
* properties applied to every event and flush batching.
|
|
47
|
+
*
|
|
48
|
+
* @param filePath - Path to the file telemetry will be written to. If the file already exists its
|
|
49
|
+
* contents will be overwritten or corrupted — callers should verify the path is unused before calling.
|
|
50
|
+
* @param options - Optional telemetry configuration. See {@link IFileLoggerTelemetryOptions}.
|
|
51
|
+
* @returns The wrapped telemetry logger to send events through, and the underlying `IFileLogger`
|
|
52
|
+
* which must be closed when telemetry collection is finished.
|
|
53
|
+
*
|
|
54
|
+
* @legacy
|
|
55
|
+
* @beta
|
|
56
|
+
*/
|
|
57
|
+
function createFluidRunnerLogger(filePath, options) {
|
|
58
|
+
return createLogger(filePath, options);
|
|
59
|
+
}
|
|
60
|
+
exports.createFluidRunnerLogger = createFluidRunnerLogger;
|
|
61
|
+
/**
|
|
62
|
+
* Create an {@link @fluidframework/telemetry-utils#TelemetryLoggerExt} wrapped around provided {@link IFileLogger}.
|
|
38
63
|
*
|
|
39
64
|
* @remarks
|
|
40
65
|
*
|
|
@@ -44,7 +69,9 @@ const jsonFileLogger_js_1 = require("./jsonFileLogger.js");
|
|
|
44
69
|
*
|
|
45
70
|
* Note: if an output format is not supplied, default is JSON.
|
|
46
71
|
*
|
|
47
|
-
* @returns Both the `IFileLogger` implementation and `
|
|
72
|
+
* @returns Both the `IFileLogger` implementation and `TelemetryLoggerExt` wrapper to be called.
|
|
73
|
+
*
|
|
74
|
+
* @deprecated Use {@link createFluidRunnerLogger}.
|
|
48
75
|
* @internal
|
|
49
76
|
*/
|
|
50
77
|
function createLogger(filePath, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggerUtils.js","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;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AAK,EAAE,wBAAwB;SAC/B,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC;AAC5F,CAAC;AA3CD,4EA2CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport {\n\ttype TelemetryLoggerExt,\n\tcreateChildLogger,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { CSVFileLogger } from \"./csvFileLogger.js\";\nimport {\n\ttype IFileLogger,\n\ttype IFileLoggerTelemetryOptions,\n\tOutputFormat,\n} from \"./fileLogger.js\";\nimport { JSONFileLogger } from \"./jsonFileLogger.js\";\n\n/**\n * Create a telemetry logger wrapped around an {@link IFileLogger} that writes to the given file path.\n *\n * @remarks\n * All telemetry events should be sent through the returned `logger`. The returned `fileLogger` is the\n * underlying sink — its `close()` method must be called at the end of execution to flush any buffered\n * events to disk.\n *\n * If `options.outputFormat` is not supplied, telemetry is written as JSON. Use {@link OutputFormat.CSV}\n * to write CSV instead. See {@link IFileLoggerTelemetryOptions} for supported options including default\n * properties applied to every event and flush batching.\n *\n * @param filePath - Path to the file telemetry will be written to. If the file already exists its\n * contents will be overwritten or corrupted — callers should verify the path is unused before calling.\n * @param options - Optional telemetry configuration. See {@link IFileLoggerTelemetryOptions}.\n * @returns The wrapped telemetry logger to send events through, and the underlying `IFileLogger`\n * which must be closed when telemetry collection is finished.\n *\n * @legacy\n * @beta\n */\nexport function createFluidRunnerLogger(\n\tfilePath: string,\n\toptions?: IFileLoggerTelemetryOptions,\n): { logger: ITelemetryBaseLogger; fileLogger: IFileLogger } {\n\treturn createLogger(filePath, options);\n}\n\n/**\n * Create an {@link @fluidframework/telemetry-utils#TelemetryLoggerExt} wrapped around provided {@link IFileLogger}.\n *\n * @remarks\n *\n * It is expected that all events be sent through the returned \"logger\" value.\n *\n * The \"fileLogger\" value should have its \"close()\" method called at the end of execution.\n *\n * Note: if an output format is not supplied, default is JSON.\n *\n * @returns Both the `IFileLogger` implementation and `TelemetryLoggerExt` wrapper to be called.\n *\n * @deprecated Use {@link createFluidRunnerLogger}.\n * @internal\n */\nexport function createLogger(\n\tfilePath: string,\n\toptions?: IFileLoggerTelemetryOptions,\n): { logger: TelemetryLoggerExt; fileLogger: IFileLogger } {\n\tconst fileLogger =\n\t\toptions?.outputFormat === OutputFormat.CSV\n\t\t\t? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)\n\t\t\t: new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);\n\n\tconst logger = createChildLogger({\n\t\tlogger: fileLogger,\n\t\tnamespace: \"LocalSnapshotRunnerApp\",\n\t\tproperties: {\n\t\t\tall: { Event_Time: () => Date.now() },\n\t\t},\n\t});\n\n\treturn { logger, fileLogger };\n}\n\n/**\n * Validate the telemetryFile command line argument\n * @param telemetryFile - path where telemetry will be written\n * @internal\n */\nexport function getTelemetryFileValidationError(telemetryFile: string): string | undefined {\n\tif (!telemetryFile) {\n\t\treturn \"Telemetry file argument is missing.\";\n\t} else if (fs.existsSync(telemetryFile)) {\n\t\treturn `Telemetry file already exists [${telemetryFile}].`;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validate the provided output format and default properties\n * @param format - desired output format of the telemetry\n * @param props - default properties to be added to every telemetry entry\n * @internal\n */\nexport function validateAndParseTelemetryOptions(\n\tformat?: string,\n\tprops?: (string | number)[],\n\teventsPerFlush?: number,\n):\n\t| { success: false; error: string }\n\t| { success: true; telemetryOptions: IFileLoggerTelemetryOptions } {\n\tlet outputFormat: OutputFormat | undefined;\n\tconst defaultProps: Record<string, string | number> = {};\n\n\tif (format) {\n\t\toutputFormat = OutputFormat[format];\n\t\tif (outputFormat === undefined) {\n\t\t\treturn { success: false, error: `Invalid telemetry format [${format}]` };\n\t\t}\n\t}\n\n\tif (props && props.length > 0) {\n\t\tif (props.length % 2 !== 0) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `Invalid number of telemetry properties to add [${props.length}]`,\n\t\t\t};\n\t\t}\n\t\tfor (let i = 0; i < props.length; i += 2) {\n\t\t\tif (typeof props[i] === \"number\") {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Property name cannot be number at index [${i}] -> [${props[i]}]`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefaultProps[props[i]] = props[i + 1];\n\t\t}\n\t}\n\n\tif (eventsPerFlush !== undefined && isNaN(eventsPerFlush)) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: \"Invalid eventsPerFlush\",\n\t\t};\n\t}\n\n\treturn { success: true, telemetryOptions: { outputFormat, defaultProps, eventsPerFlush } };\n}\n"]}
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { type IExportFileResponse } from "./exportFile.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { IFileLoggerTelemetryOptions } from "./logger/fileLogger.js";
|
|
7
7
|
/**
|
|
8
8
|
* Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file
|
|
9
9
|
* @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)
|
|
10
10
|
* @internal
|
|
11
11
|
*/
|
|
12
|
-
export declare function parseBundleAndExportFile(codeLoader: string, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?:
|
|
12
|
+
export declare function parseBundleAndExportFile(codeLoader: string, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: IFileLoggerTelemetryOptions, timeout?: number, disableNetworkFetch?: boolean): Promise<IExportFileResponse>;
|
|
13
13
|
//# sourceMappingURL=parseBundleAndExportFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseBundleAndExportFile.d.ts","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,
|
|
1
|
+
{"version":3,"file":"parseBundleAndExportFile.d.ts","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAU1E;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC7C,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,gBAAgB,CAAC,EAAE,2BAA2B,EAC9C,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CAoE9B"}
|
|
@@ -48,7 +48,8 @@ async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telem
|
|
|
48
48
|
const eventName = clientArgsValidationError;
|
|
49
49
|
return { success: false, eventName, errorMessage: telemetryArgError };
|
|
50
50
|
}
|
|
51
|
-
const { fileLogger, logger } = (0, loggerUtils_js_1.
|
|
51
|
+
const { fileLogger, logger: baseLogger } = (0, loggerUtils_js_1.createFluidRunnerLogger)(telemetryFile, telemetryOptions);
|
|
52
|
+
const logger = (0, internal_1.createChildLogger)({ logger: baseLogger });
|
|
52
53
|
try {
|
|
53
54
|
return await internal_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ParseBundleAndExportFile" }, async () => {
|
|
54
55
|
// codeLoader is expected to be a file path. On Windows this also requires
|
|
@@ -76,7 +77,8 @@ async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telem
|
|
|
76
77
|
logger.sendErrorEvent({ eventName, message: argsValidationError });
|
|
77
78
|
return { success: false, eventName, errorMessage: argsValidationError };
|
|
78
79
|
}
|
|
79
|
-
fs.writeFileSync(outputFile, await (0, exportFile_js_1.
|
|
80
|
+
fs.writeFileSync(outputFile, await (0, exportFile_js_1.createFluidRunnerContainerAndExecute)((0, utils_js_1.getSnapshotFileContent)(inputFile), fluidExport, baseLogger, // Pass baseLogger with ITelemetryBaseLogger type
|
|
81
|
+
options, timeout, disableNetworkFetch));
|
|
80
82
|
return { success: true };
|
|
81
83
|
});
|
|
82
84
|
}
|