@fluidframework/fluid-runner 2.0.0-internal.1.1.1 → 2.0.0-internal.1.1.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.
Files changed (75) hide show
  1. package/README.md +25 -2
  2. package/bin/{fluidRunner → fluid-runner} +0 -0
  3. package/dist/codeLoaderBundle.d.ts +6 -7
  4. package/dist/codeLoaderBundle.d.ts.map +1 -1
  5. package/dist/codeLoaderBundle.js +1 -1
  6. package/dist/codeLoaderBundle.js.map +1 -1
  7. package/dist/exportFile.d.ts +9 -2
  8. package/dist/exportFile.d.ts.map +1 -1
  9. package/dist/exportFile.js +28 -30
  10. package/dist/exportFile.js.map +1 -1
  11. package/dist/fluidRunner.d.ts +5 -1
  12. package/dist/fluidRunner.d.ts.map +1 -1
  13. package/dist/fluidRunner.js +39 -26
  14. package/dist/fluidRunner.js.map +1 -1
  15. package/dist/getArgsValidationError.d.ts +1 -1
  16. package/dist/getArgsValidationError.d.ts.map +1 -1
  17. package/dist/getArgsValidationError.js +6 -10
  18. package/dist/getArgsValidationError.js.map +1 -1
  19. package/dist/index.d.ts +4 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +6 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/logger/FileLogger.d.ts +11 -1
  24. package/dist/logger/FileLogger.d.ts.map +1 -1
  25. package/dist/logger/FileLogger.js +24 -1
  26. package/dist/logger/FileLogger.js.map +1 -1
  27. package/dist/parseBundleAndExportFile.d.ts +11 -0
  28. package/dist/parseBundleAndExportFile.d.ts.map +1 -0
  29. package/dist/parseBundleAndExportFile.js +85 -0
  30. package/dist/parseBundleAndExportFile.js.map +1 -0
  31. package/dist/utils.d.ts +17 -0
  32. package/dist/utils.d.ts.map +1 -0
  33. package/dist/utils.js +47 -0
  34. package/dist/utils.js.map +1 -0
  35. package/lib/codeLoaderBundle.d.ts +6 -7
  36. package/lib/codeLoaderBundle.d.ts.map +1 -1
  37. package/lib/codeLoaderBundle.js +1 -1
  38. package/lib/codeLoaderBundle.js.map +1 -1
  39. package/lib/exportFile.d.ts +9 -2
  40. package/lib/exportFile.d.ts.map +1 -1
  41. package/lib/exportFile.js +28 -27
  42. package/lib/exportFile.js.map +1 -1
  43. package/lib/fluidRunner.d.ts +5 -1
  44. package/lib/fluidRunner.d.ts.map +1 -1
  45. package/lib/fluidRunner.js +37 -26
  46. package/lib/fluidRunner.js.map +1 -1
  47. package/lib/getArgsValidationError.d.ts +1 -1
  48. package/lib/getArgsValidationError.d.ts.map +1 -1
  49. package/lib/getArgsValidationError.js +6 -10
  50. package/lib/getArgsValidationError.js.map +1 -1
  51. package/lib/index.d.ts +4 -1
  52. package/lib/index.d.ts.map +1 -1
  53. package/lib/index.js +4 -1
  54. package/lib/index.js.map +1 -1
  55. package/lib/logger/FileLogger.d.ts +11 -1
  56. package/lib/logger/FileLogger.d.ts.map +1 -1
  57. package/lib/logger/FileLogger.js +21 -0
  58. package/lib/logger/FileLogger.js.map +1 -1
  59. package/lib/parseBundleAndExportFile.d.ts +11 -0
  60. package/lib/parseBundleAndExportFile.d.ts.map +1 -0
  61. package/lib/parseBundleAndExportFile.js +62 -0
  62. package/lib/parseBundleAndExportFile.js.map +1 -0
  63. package/lib/utils.d.ts +17 -0
  64. package/lib/utils.d.ts.map +1 -0
  65. package/lib/utils.js +23 -0
  66. package/lib/utils.js.map +1 -0
  67. package/package.json +11 -11
  68. package/src/codeLoaderBundle.ts +8 -9
  69. package/src/exportFile.ts +38 -40
  70. package/src/fluidRunner.ts +54 -35
  71. package/src/getArgsValidationError.ts +6 -12
  72. package/src/index.ts +5 -1
  73. package/src/logger/FileLogger.ts +25 -1
  74. package/src/parseBundleAndExportFile.ts +78 -0
  75. package/src/utils.ts +25 -0
package/README.md CHANGED
@@ -6,15 +6,38 @@ Allows some execution to be made on a container given a provided ODSP snapshot.
6
6
 
7
7
  ### Sample command
8
8
  If package is installed globally:
9
- `node fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFolder=outputFolderName --scenario=test --telemetryFile=telemetryFile.txt`
9
+ `node fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt`
10
10
 
11
11
  If working directly on this package:
12
- `node bin/fluidRunner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFolder=outputFolderName --scenario=test --telemetryFile=telemetryFile.txt`
12
+ ```node bin/fluid-runner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFile=result.txt --telemetryFile=telemetryFile.txt```
13
13
 
14
14
  ### Code Loader bundle format
15
15
  The Code Loader bundle should provide defined exports required for this functionality.
16
16
  For more details on what exports are needed, see [codeLoaderBundle.ts](./src/codeLoaderBundle.ts).
17
17
 
18
+ #### "codeLoader" vs "IFluidFileConverter" argument
19
+ You may notice the command line argument `codeLoader` is optional. If you choose not to provide a value for `codeLoader`, you must extend this library
20
+ and provide a [`IFluidFileConverter`](./src/codeLoaderBundle.ts) implementation to the [`fluidRunner(...)`](./src/fluidRunner.ts) method.
21
+
22
+ ```
23
+ import { fluidRunner } from "@fluidframework/fluid-runner";
24
+
25
+ fluidRunner({ /* IFluidFileConverter implementation here */ });
26
+ ```
27
+
28
+ > **Note**: Only one of `codeLoader` or `fluidRunner(...)` argument is allowed. If both or none are provided, an error will be thrown at the start of execution.
29
+
18
30
  ### Input file format
19
31
  The input file is expected to be an ODSP snapshot.
20
32
  For some examples, see the files in the [localOdspSnapshots folder](./src/test/localOdspSnapshots).
33
+
34
+ ### Consumption
35
+ The code around `exportFile` can be consumed in multiple different layers. It is not necessary to run all this code fully as is, and the following are some interesting code bits involved in this workflow:
36
+ - [`createLogger(...)`](./src/logger/FileLogger.ts)
37
+ - Wraps a provided `FileLogger` and adds some useful telemetry data to every entry
38
+ - [`createContainerAndExecute(...)`](./src/exportFile.ts)
39
+ - This is the core logic for running some action based on a local ODSP snapshot
40
+ - [`getSnapshotFileContent(...)`](./src/utils.ts)
41
+ - Reads a local ODSP snapshot from both JSON and binary formats for usage in `createContainerAndExecute(...)`
42
+
43
+ For an example of a consumption path that differs slightly to [`exportFile(...)`](./src/exportFile.ts), see [`parseBundleAndExportFile(...)`](./src/parseBundleAndExportFile.ts). In addition to running the same logic as [`exportFile`](./src/exportFile.ts) method, it implements the logic around parsing a dynamically provided bundle path into an `IFluidFileConverter` object.
File without changes
@@ -20,21 +20,20 @@ export interface ICodeLoaderBundle {
20
20
  */
21
21
  export interface IFluidFileConverter {
22
22
  /**
23
- * Code loader details to provide at Loader creation
23
+ * Get code loader details to provide at Loader creation
24
+ * @param logger - created logger object to pass to code loader
24
25
  */
25
- codeLoader: ICodeDetailsLoader;
26
+ getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
26
27
  /**
27
28
  * Scope object to provide at Loader creation
28
29
  */
29
30
  scope?: FluidObject;
30
31
  /**
31
- * Execute code and return the results
32
+ * Executes code on container and returns the result
32
33
  * @param container - container created by this application
33
- * @param scenario - scenario this execution is related to
34
- * @param logger - passed through logger object
35
- * @returns - object containing file names as property keys and file content as values
34
+ * @param options - additional options
36
35
  */
37
- execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, string>>;
36
+ execute(container: IContainer, options?: string): Promise<string>;
38
37
  }
39
38
  /**
40
39
  * Type cast to ensure necessary methods are present in the provided bundle
@@ -1 +1 @@
1
- {"version":3,"file":"codeLoaderBundle.d.ts","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;GAGG;AACF,MAAM,WAAW,iBAAiB;IAC/B;;OAEG;IACH,WAAW,EAAE,O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AAkB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,iBAAiB,CAG3E;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB,CAIzE"}
@@ -16,7 +16,7 @@ function isCodeLoaderBundle(bundle) {
16
16
  exports.isCodeLoaderBundle = isCodeLoaderBundle;
17
17
  function isFluidFileConverter(obj) {
18
18
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
19
- return (obj === null || obj === void 0 ? void 0 : obj.codeLoader) && typeof obj.codeLoader === "object"
19
+ return (obj === null || obj === void 0 ? void 0 : obj.getCodeLoader) && typeof obj.getCodeLoader === "function"
20
20
  && obj.execute && typeof obj.execute === "function";
21
21
  }
22
22
  exports.isFluidFileConverter = isFluidFileConverter;
@@ -1 +1 @@
1
- {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC1C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACzE,CAAC;AAHD,gDAGC;AAED,SAAgB,oBAAoB,CAAC,GAAQ;IACzC,+DAA+D;IAC/D,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,UAAU,KAAI,OAAO,GAAG,CAAC,UAAU,KAAK,QAAQ;WACrD,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC;AAC5D,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract that defines the necessary exports for the bundle provided at runtime\n * For an example, see \"src/test/sampleCodeLoaders/sampleCodeLoader.ts\"\n */\n export interface ICodeLoaderBundle {\n /**\n * Fluid export of all the required objects and functions\n */\n fluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n /**\n * Code loader details to provide at Loader creation\n */\n codeLoader: ICodeDetailsLoader;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Execute code and return the results\n * @param container - container created by this application\n * @param scenario - scenario this execution is related to\n * @param logger - passed through logger object\n * @returns - object containing file names as property keys and file content as values\n */\n execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, string>>;\n}\n\n/**\n * Type cast to ensure necessary methods are present in the provided bundle\n * @param bundle - bundle provided to this application\n */\nexport function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return obj?.codeLoader && typeof obj.codeLoader === \"object\"\n && obj.execute && typeof obj.execute === \"function\";\n}\n"]}
1
+ {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC1C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACzE,CAAC;AAHD,gDAGC;AAED,SAAgB,oBAAoB,CAAC,GAAQ;IACzC,+DAA+D;IAC/D,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,KAAI,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;WAC7D,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC;AAC5D,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract that defines the necessary exports for the bundle provided at runtime\n * For an example, see \"src/test/sampleCodeLoaders/sampleCodeLoader.ts\"\n */\nexport interface ICodeLoaderBundle {\n /**\n * Fluid export of all the required objects and functions\n */\n fluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n /**\n * Get code loader details to provide at Loader creation\n * @param logger - created logger object to pass to code loader\n */\n getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Executes code on container and returns the result\n * @param container - container created by this application\n * @param options - additional options\n */\n execute(container: IContainer, options?: string): Promise<string>;\n}\n\n/**\n * Type cast to ensure necessary methods are present in the provided bundle\n * @param bundle - bundle provided to this application\n */\nexport function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return obj?.getCodeLoader && typeof obj.getCodeLoader === \"function\"\n && obj.execute && typeof obj.execute === \"function\";\n}\n"]}
@@ -14,7 +14,14 @@ interface IExportFileResponseFailure {
14
14
  errorMessage: string;
15
15
  error?: any;
16
16
  }
17
- export declare function exportFile(codeLoader: string, inputFile: string, outputFolder: string, scenario: string, logger: ITelemetryLogger): Promise<IExportFileResponse>;
18
- export declare function createContainerAndExecute(localOdspSnapshot: string, fluidFileConverter: IFluidFileConverter, scenario: string, logger: ITelemetryLogger): Promise<Record<string, string>>;
17
+ /**
18
+ * Execute code on Container based on ODSP snapshot and write result to file
19
+ */
20
+ export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string): Promise<IExportFileResponse>;
21
+ /**
22
+ * Create the container based on an ODSP snapshot and execute code on it
23
+ * @returns result of execution
24
+ */
25
+ export declare function createContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, logger: ITelemetryLogger, options?: string): Promise<string>;
19
26
  export {};
20
27
  //# sourceMappingURL=exportFile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAA4C,MAAM,oBAAoB,CAAC;AAGnG,oBAAY,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F,UAAU,0BAA0B;IAChC,OAAO,EAAE,IAAI,CAAC;CACjB;AAED,UAAU,0BAA0B;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAID,wBAAsB,UAAU,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CA6C9B;AAED,wBAAsB,yBAAyB,CAC3C,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,mBAAmB,EACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAcjC"}
1
+ {"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAMzD,oBAAY,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F,UAAU,0BAA0B;IAChC,OAAO,EAAE,IAAI,CAAC;CACjB;AAED,UAAU,0BAA0B;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAID;;GAEG;AACH,wBAAsB,UAAU,CAC5B,kBAAkB,EAAE,mBAAmB,EACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,mBAAmB,CAAC,CAkC9B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC3C,iBAAiB,EAAE,MAAM,GAAG,UAAU,EACtC,kBAAkB,EAAE,mBAAmB,EACvC,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
@@ -22,70 +22,68 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
25
  Object.defineProperty(exports, "__esModule", { value: true });
29
26
  exports.createContainerAndExecute = exports.exportFile = void 0;
30
27
  const fs = __importStar(require("fs"));
31
- const path_1 = __importDefault(require("path"));
32
28
  const container_definitions_1 = require("@fluidframework/container-definitions");
33
29
  const container_loader_1 = require("@fluidframework/container-loader");
34
30
  const odsp_driver_1 = require("@fluidframework/odsp-driver");
35
31
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
36
32
  const getArgsValidationError_1 = require("./getArgsValidationError");
37
- const codeLoaderBundle_1 = require("./codeLoaderBundle");
38
33
  const fakeUrlResolver_1 = require("./fakeUrlResolver");
34
+ const utils_1 = require("./utils");
35
+ // eslint-disable-next-line import/no-internal-modules
36
+ const FileLogger_1 = require("./logger/FileLogger");
39
37
  const clientArgsValidationError = "Client_ArgsValidationError";
40
- async function exportFile(codeLoader, inputFile, outputFolder, scenario, logger) {
38
+ /**
39
+ * Execute code on Container based on ODSP snapshot and write result to file
40
+ */
41
+ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options) {
42
+ const telemetryArgError = (0, FileLogger_1.getTelemetryFileValidationError)(telemetryFile);
43
+ if (telemetryArgError) {
44
+ const eventName = clientArgsValidationError;
45
+ return { success: false, eventName, errorMessage: telemetryArgError };
46
+ }
47
+ const fileLogger = new FileLogger_1.FileLogger(telemetryFile);
48
+ const logger = (0, FileLogger_1.createLogger)(fileLogger);
41
49
  try {
42
50
  return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
43
- const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFolder, scenario);
51
+ const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFile);
44
52
  if (argsValidationError) {
45
53
  const eventName = clientArgsValidationError;
54
+ logger.sendErrorEvent({ eventName, message: argsValidationError });
46
55
  return { success: false, eventName, errorMessage: argsValidationError };
47
56
  }
48
- // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
49
- const codeLoaderBundle = require(codeLoader);
50
- if (!(0, codeLoaderBundle_1.isCodeLoaderBundle)(codeLoaderBundle)) {
51
- const eventName = clientArgsValidationError;
52
- const errorMessage = "Code loader bundle is not of type ICodeLoaderBundle";
53
- return { success: false, eventName, errorMessage };
54
- }
55
- const fluidExport = await codeLoaderBundle.fluidExport;
56
- if (!(0, codeLoaderBundle_1.isFluidFileConverter)(fluidExport)) {
57
- const eventName = clientArgsValidationError;
58
- const errorMessage = "Fluid export from CodeLoaderBundle is not of type IFluidFileConverter";
59
- return { success: false, eventName, errorMessage };
60
- }
61
- // TODO: read file stream
62
- const inputFileContent = fs.readFileSync(inputFile, { encoding: "utf-8" });
63
- const results = await createContainerAndExecute(inputFileContent, fluidExport, scenario, logger);
64
- // eslint-disable-next-line guard-for-in, no-restricted-syntax
65
- for (const key in results) {
66
- fs.appendFileSync(path_1.default.join(outputFolder, key), results[key]);
67
- }
57
+ fs.writeFileSync(outputFile, await createContainerAndExecute((0, utils_1.getSnapshotFileContent)(inputFile), fluidFileConverter, logger, options));
68
58
  return { success: true };
69
59
  });
70
60
  }
71
61
  catch (error) {
72
62
  const eventName = "Client_UnexpectedError";
63
+ logger.sendErrorEvent({ eventName }, error);
73
64
  return { success: false, eventName, errorMessage: "Unexpected error", error };
74
65
  }
66
+ finally {
67
+ await fileLogger.flush();
68
+ }
75
69
  }
76
70
  exports.exportFile = exportFile;
77
- async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, scenario, logger) {
71
+ /**
72
+ * Create the container based on an ODSP snapshot and execute code on it
73
+ * @returns result of execution
74
+ */
75
+ async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options) {
78
76
  const loader = new container_loader_1.Loader({
79
77
  urlResolver: new fakeUrlResolver_1.FakeUrlResolver(),
80
78
  documentServiceFactory: (0, odsp_driver_1.createLocalOdspDocumentServiceFactory)(localOdspSnapshot),
81
- codeLoader: fluidFileConverter.codeLoader,
79
+ codeLoader: await fluidFileConverter.getCodeLoader(logger),
82
80
  scope: fluidFileConverter.scope,
83
81
  logger,
84
82
  });
85
83
  const container = await loader.resolve({ url: "/fakeUrl/", headers: {
86
84
  [container_definitions_1.LoaderHeader.loadMode]: { opsBeforeReturn: "cached" }
87
85
  } });
88
- return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, scenario, logger));
86
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, options));
89
87
  }
90
88
  exports.createContainerAndExecute = createContainerAndExecute;
91
89
  //# sourceMappingURL=exportFile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,gDAAwB;AAExB,iFAAqE;AACrE,uEAA0D;AAC1D,6DAAoF;AACpF,qEAAmE;AACnE,qEAAkE;AAClE,yDAAmG;AACnG,uDAAoD;AAepD,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAExD,KAAK,UAAU,UAAU,CAC5B,UAAkB,EAClB,SAAiB,EACjB,YAAoB,EACpB,QAAgB,EAChB,MAAwB;IAExB,IAAI;QACA,OAAO,MAAM,kCAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACzF,MAAM,mBAAmB,GAAG,IAAA,+CAAsB,EAAC,SAAS,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;YACtF,IAAI,mBAAmB,EAAE;gBACrB,MAAM,SAAS,GAAG,yBAAyB,CAAC;gBAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,mBAAmB,EAAE,CAAC;aAC3E;YAED,qGAAqG;YACrG,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;YAC7C,IAAI,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B,MAAwB;IAExB,MAAM,MAAM,GAAG,IAAI,yBAAM,CAAC;QACtB,WAAW,EAAE,IAAI,iCAAe,EAAE;QAClC,sBAAsB,EAAE,IAAA,mDAAqC,EAAC,iBAAiB,CAAC;QAChF,UAAU,EAAE,kBAAkB,CAAC,UAAU;QACzC,KAAK,EAAE,kBAAkB,CAAC,KAAK;QAC/B,MAAM;KACT,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,OAAO,EAAE;YAChE,CAAC,oCAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;SAAE,EAAE,CAAC,CAAC;IAEhE,OAAO,kCAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE,CACnF,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;AACjE,CAAC;AAnBD,8DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport path from \"path\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\nimport { IFluidFileConverter, isCodeLoaderBundle, isFluidFileConverter } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\n\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\ninterface IExportFileResponseSuccess {\n success: true;\n}\n\ninterface IExportFileResponseFailure {\n success: false;\n eventName: string;\n errorMessage: string;\n error?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\nexport async function exportFile(\n codeLoader: string,\n inputFile: string,\n outputFolder: string,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<IExportFileResponse> {\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n const argsValidationError = getArgsValidationError(inputFile, outputFolder, scenario);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires\n const codeLoaderBundle = require(codeLoader);\n if (!isCodeLoaderBundle(codeLoaderBundle)) {\n const eventName = clientArgsValidationError;\n const errorMessage = \"Code loader bundle is not of type ICodeLoaderBundle\";\n return { success: false, eventName, errorMessage };\n }\n\n const fluidExport = await codeLoaderBundle.fluidExport;\n if (!isFluidFileConverter(fluidExport)) {\n const eventName = clientArgsValidationError;\n const errorMessage = \"Fluid export from CodeLoaderBundle is not of type IFluidFileConverter\";\n return { success: false, eventName, errorMessage };\n }\n\n // TODO: read file stream\n const inputFileContent = fs.readFileSync(inputFile, { encoding: \"utf-8\" });\n\n const results = await createContainerAndExecute(\n inputFileContent,\n fluidExport,\n scenario,\n logger,\n );\n\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const key in results) {\n fs.appendFileSync(path.join(outputFolder, key), results[key]);\n }\n\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n }\n}\n\nexport async function createContainerAndExecute(\n localOdspSnapshot: string,\n fluidFileConverter: IFluidFileConverter,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<Record<string, string>> {\n const loader = new Loader({\n urlResolver: new FakeUrlResolver(),\n documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n codeLoader: fluidFileConverter.codeLoader,\n scope: fluidFileConverter.scope,\n logger,\n });\n\n const container = await loader.resolve({ url: \"/fakeUrl/\", headers: {\n [LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" } } });\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () =>\n fluidFileConverter.execute(container, scenario, logger));\n}\n"]}
1
+ {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,iFAAqE;AACrE,uEAA0D;AAC1D,6DAAoF;AACpF,qEAAmE;AACnE,qEAAkE;AAElE,uDAAoD;AACpD,mCAAiD;AACjD,sDAAsD;AACtD,oDAAgG;AAehG,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;GAEG;AACI,KAAK,UAAU,UAAU,CAC5B,kBAAuC,EACvC,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB;IAEhB,MAAM,iBAAiB,GAAG,IAAA,4CAA+B,EAAC,aAAa,CAAC,CAAC;IACzE,IAAI,iBAAiB,EAAE;QACnB,MAAM,SAAS,GAAG,yBAAyB,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;KACzE;IACD,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,aAAa,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAA,yBAAY,EAAC,UAAU,CAAC,CAAC;IAExC,IAAI;QACA,OAAO,MAAM,kCAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACzF,MAAM,mBAAmB,GAAG,IAAA,+CAAsB,EAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YAC1E,IAAI,mBAAmB,EAAE;gBACrB,MAAM,SAAS,GAAG,yBAAyB,CAAC;gBAC5C,MAAM,CAAC,cAAc,CAAC,EAAE,SA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E,EAAE,CAAC,CAAC;IAEhE,OAAO,kCAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE,CACnF,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AACxD,CAAC;AAnBD,8DAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\nimport { getSnapshotFileContent } from \"./utils\";\n// eslint-disable-next-line import/no-internal-modules\nimport { createLogger, FileLogger, getTelemetryFileValidationError } from \"./logger/FileLogger\";\n\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\ninterface IExportFileResponseSuccess {\n success: true;\n}\n\ninterface IExportFileResponseFailure {\n success: false;\n eventName: string;\n errorMessage: string;\n error?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Execute code on Container based on ODSP snapshot and write result to file\n */\nexport async function exportFile(\n fluidFileConverter: IFluidFileConverter,\n inputFile: string,\n outputFile: string,\n telemetryFile: string,\n options?: string,\n): Promise<IExportFileResponse> {\n const telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n if (telemetryArgError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: telemetryArgError };\n }\n const fileLogger = new FileLogger(telemetryFile);\n const logger = createLogger(fileLogger);\n\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n const argsValidationError = getArgsValidationError(inputFile, outputFile);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n logger.sendErrorEvent({ eventName, message: argsValidationError });\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n fs.writeFileSync(outputFile, await createContainerAndExecute(\n getSnapshotFileContent(inputFile),\n fluidFileConverter,\n logger,\n options,\n ));\n\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n logger.sendErrorEvent({ eventName }, error);\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n } finally {\n await fileLogger.flush();\n }\n}\n\n/**\n * Create the container based on an ODSP snapshot and execute code on it\n * @returns result of execution\n */\nexport async function createContainerAndExecute(\n localOdspSnapshot: string | Uint8Array,\n fluidFileConverter: IFluidFileConverter,\n logger: ITelemetryLogger,\n options?: string,\n): Promise<string> {\n const loader = new Loader({\n urlResolver: new FakeUrlResolver(),\n documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n codeLoader: await fluidFileConverter.getCodeLoader(logger),\n scope: fluidFileConverter.scope,\n logger,\n });\n\n const container = await loader.resolve({ url: \"/fakeUrl/\", headers: {\n [LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" } } });\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () =>\n fluidFileConverter.execute(container, options));\n}\n"]}
@@ -2,5 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export {};
5
+ import { IFluidFileConverter } from "./codeLoaderBundle";
6
+ /**
7
+ * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
8
+ */
9
+ export declare function fluidRunner(fluidFileConverter?: IFluidFileConverter): void;
6
10
  //# sourceMappingURL=fluidRunner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
1
+ {"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGzD;;GAEG;AACH,wBAAgB,WAAW,CAAC,kBAAkB,CAAC,EAAE,mBAAmB,QAwEnE"}
@@ -23,66 +23,79 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("fs"));
26
+ exports.fluidRunner = void 0;
27
27
  const yargs = __importStar(require("yargs"));
28
- const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
29
28
  const exportFile_1 = require("./exportFile");
30
- // eslint-disable-next-line import/no-internal-modules
31
- const FileLogger_1 = require("./logger/FileLogger");
32
- function fluidRunner() {
29
+ const parseBundleAndExportFile_1 = require("./parseBundleAndExportFile");
30
+ /**
31
+ * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
32
+ */
33
+ function fluidRunner(fluidFileConverter) {
33
34
  // eslint-disable-next-line @typescript-eslint/no-unused-expressions
34
35
  yargs
35
36
  .strict()
36
37
  .version(false)
37
- .command("exportFile", "Generate an output for a local snapshot",
38
+ .command("exportFile", "Generate an output for a local ODSP snapshot",
38
39
  // eslint-disable-next-line @typescript-eslint/no-shadow
39
40
  (yargs) => yargs
40
41
  .option("codeLoader", {
41
- describe: "Name of the code loader bundle",
42
+ // eslint-disable-next-line max-len
43
+ describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
42
44
  type: "string",
43
- demandOption: true,
45
+ demandOption: false,
44
46
  })
45
47
  .option("inputFile", {
46
- describe: "Name of the file containing local ODSP snapshot",
48
+ describe: "Path to local ODSP snapshot",
47
49
  type: "string",
48
50
  demandOption: true,
49
51
  })
50
- .option("outputFolder", {
51
- describe: "Name of the output file",
52
+ .option("outputFile", {
53
+ describe: "Path of output file (cannot already exist).\nExecution result will be written here",
52
54
  type: "string",
53
55
  demandOption: true,
54
56
  })
55
- .option("scenario", {
56
- describe: "Name of scenario to invoke",
57
+ .option("telemetryFile", {
58
+ describe: "Path of telemetry file for config and session data (cannot already exist)",
57
59
  type: "string",
58
60
  demandOption: true,
59
61
  })
60
- .option("telemetryFile", {
61
- describe: "Config and session data for telemetry",
62
+ .option("options", {
63
+ describe: "Additional options passed to container on execution",
62
64
  type: "string",
63
- demandOption: true,
65
+ demandOption: false,
64
66
  }),
65
67
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
66
68
  async (argv) => {
67
- if (fs.existsSync(argv.telemetryFile)) {
68
- console.error(`Telemetry file already exists [${argv.telemetryFile}]`);
69
+ const argsError = validateProvidedArgs(argv.codeLoader, fluidFileConverter);
70
+ if (argsError) {
71
+ console.error(argsError);
69
72
  process.exit(1);
70
73
  }
71
- const fileLogger = new FileLogger_1.FileLogger(argv.telemetryFile);
72
- const logger = telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
73
- const result = await (0, exportFile_1.exportFile)(argv.codeLoader, argv.inputFile, argv.outputFolder, argv.scenario, logger);
74
+ let result;
75
+ if (argv.codeLoader) {
76
+ result = await (0, parseBundleAndExportFile_1.parseBundleAndExportFile)(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options);
77
+ }
78
+ else {
79
+ result = await (0, exportFile_1.exportFile)(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options);
80
+ }
74
81
  if (!result.success) {
75
82
  console.error(`${result.eventName}: ${result.errorMessage}`);
76
- logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);
77
- await fileLogger.flush();
78
83
  process.exit(1);
79
84
  }
80
- else {
81
- await fileLogger.flush();
82
- }
83
85
  })
84
86
  .help()
85
87
  .demandCommand().argv;
86
88
  }
89
+ exports.fluidRunner = fluidRunner;
90
+ function validateProvidedArgs(codeLoader, fluidFileConverter) {
91
+ if (codeLoader !== undefined && fluidFileConverter !== undefined) {
92
+ return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See \"fluidRunner.ts\" for details.";
93
+ }
94
+ if (codeLoader === undefined && fluidFileConverter === undefined) {
95
+ // eslint-disable-next-line max-len
96
+ return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See \"fluidRunner.ts\" for details.";
97
+ }
98
+ return undefined;
99
+ }
87
100
  fluidRunner();
88
101
  //# sourceMappingURL=fluidRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,6CAA+B;AAC/B,qEAA8D;AAC9D,6CAA0C;AAC1C,sDAAsD;AACtD,oDAAiD;AAEjD,SAAS,WAAW;IAChB,oEAAoE;IACpE,KAAK;SACA,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,OAAO,CACJ,YAAY,EACZ,yCAAyC;IACzC,wDAAwD;IACxD,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;SACA,MAAM,CAAC,YAAY,EAAE;QAClB,QAAQ,EAAE,gCAAgC;QAC1C,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACjB,QAAQ,EAAE,iDAAiD;QAC3D,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,cAAc,EAAE;QACpB,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAChB,QAAQ,EAAE,4BAA4B;QACtC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,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AAC,CACJ;SACA,IAAI,EAAE;SACN,aAAa,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC;AAED,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport * as yargs from \"yargs\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { exportFile } from \"./exportFile\";\n// eslint-disable-next-line import/no-internal-modules\nimport { FileLogger } from \"./logger/FileLogger\";\n\nfunction fluidRunner() {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs\n .strict()\n .version(false)\n .command(\n \"exportFile\",\n \"Generate an output for a local snapshot\",\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (yargs) =>\n yargs\n .option(\"codeLoader\", {\n describe: \"Name of the code loader bundle\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"inputFile\", {\n describe: \"Name of the file containing local ODSP snapshot\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"outputFolder\", {\n describe: \"Name of the output file\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"scenario\", {\n describe: \"Name of scenario to invoke\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"telemetryFile\", {\n describe: \"Config and session data for telemetry\",\n type: \"string\",\n demandOption: true,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n if (fs.existsSync(argv.telemetryFile)) {\n console.error(`Telemetry file already exists [${argv.telemetryFile}]`);\n process.exit(1);\n }\n\n const fileLogger = new FileLogger(argv.telemetryFile);\n\n const logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\",\n { all: { Event_Time: () => Date.now() } });\n\n const result = await exportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFolder,\n argv.scenario,\n logger,\n );\n\n if (!result.success) {\n console.error(`${result.eventName}: ${result.errorMessage}`);\n logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);\n await fileLogger.flush();\n process.exit(1);\n } else {\n await fileLogger.flush();\n }\n },\n )\n .help()\n .demandCommand().argv;\n}\n\nfluidRunner();\n"]}
1
+ {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,6CAA+D;AAE/D,yEAAsE;AAEtE;;GAEG;AACH,SAAgB,WAAW,CAAC,kBAAwC;IAChE,oEAAoE;IACpE,KAAK;SACA,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,OAAO,CACJ,YAAY,EACZ,8CAA8C;IAC9C,wDAAwD;IACxD,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;SACA,MAAM,CAAC,YAAY,EAAE;QAClB,mCAAmC;QACnC,QAAQ,EAAE,qIAAqI;QAC/I,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACtB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACjB,QAAQ,EAAE,6BAA6B;QACvC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,YAAY,EAAE;QAClB,QAAQ,EAAE,oFAAoF;QAC9F,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,eAAe,EAAE;QACrB,QAAQ,EAAE,2EAA2E;QACrF,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACf,QAAQ,EAAE,qDAAqD;QAC/D,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACtB,CAAC;IACV,kEAAkE;IAClE,KAAK,EAAE,IAAI,EAAE,EAAE;QACX,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;QAC5E,IAAI,SAAS,EAAE;YACX,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,IAAI,MAA2B,CAAC;QAChC,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,GAAG,MAAM,IAAA,mDAAwB,EACnC,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC;SACL;aAAM;YACH,MAAM,GAAG,MAAM,IAAA,uBAAU,EACrB,kBAAmB,EACnB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC;SACL;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YAC7D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;IACL,CAAC,CACJ;SACA,IAAI,EAAE;SACN,aAAa,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC;AAxED,kCAwEC;AAED,SAAS,oBAAoB,CACzB,UAAmB,EACnB,kBAAwC;IAExC,IAAI,UAAU,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAC9D,OAAO,wGAAwG,CAAC;KACnH;IACD,IAAI,UAAU,KAAK,SAAS,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAC9D,mCAAmC;QACnC,OAAO,qHAAqH,CAAC;KAChI;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as yargs from \"yargs\";\nimport { exportFile, IExportFileResponse } from \"./exportFile\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { parseBundleAndExportFile } from \"./parseBundleAndExportFile\";\n\n/**\n * @param fluidFileConverter - needs to be provided if \"codeLoaderBundle\" is not and vice versa\n */\nexport function fluidRunner(fluidFileConverter?: IFluidFileConverter) {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs\n .strict()\n .version(false)\n .command(\n \"exportFile\",\n \"Generate an output for a local ODSP snapshot\",\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (yargs) =>\n yargs\n .option(\"codeLoader\", {\n // eslint-disable-next-line max-len\n describe: \"Path to code loader bundle. Required if this application is being called without modification.\\nSee \\\"README.md\\\" for more details.\",\n type: \"string\",\n demandOption: false,\n })\n .option(\"inputFile\", {\n describe: \"Path to local ODSP snapshot\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"outputFile\", {\n describe: \"Path of output file (cannot already exist).\\nExecution result will be written here\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"telemetryFile\", {\n describe: \"Path of telemetry file for config and session data (cannot already exist)\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"options\", {\n describe: \"Additional options passed to container on execution\",\n type: \"string\",\n demandOption: false,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n const argsError = validateProvidedArgs(argv.codeLoader, fluidFileConverter);\n if (argsError) {\n console.error(argsError);\n process.exit(1);\n }\n\n let result: IExportFileResponse;\n if (argv.codeLoader) {\n result = await parseBundleAndExportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n );\n } else {\n result = await exportFile(\n fluidFileConverter!,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n );\n }\n\n if (!result.success) {\n console.error(`${result.eventName}: ${result.errorMessage}`);\n process.exit(1);\n }\n },\n )\n .help()\n .demandCommand().argv;\n}\n\nfunction validateProvidedArgs(\n codeLoader?: string,\n fluidFileConverter?: IFluidFileConverter,\n): string | undefined {\n if (codeLoader !== undefined && fluidFileConverter !== undefined) {\n return \"\\\"codeLoader\\\" and \\\"fluidFileConverter\\\" cannot both be provided. See \\\"fluidRunner.ts\\\" for details.\";\n }\n if (codeLoader === undefined && fluidFileConverter === undefined) {\n // eslint-disable-next-line max-len\n return \"\\\"codeLoader\\\" must be provided if there is no explicit \\\"fluidFileConverter\\\". See \\\"fluidRunner.ts\\\" for details.\";\n }\n return undefined;\n}\n\nfluidRunner();\n"]}
@@ -2,5 +2,5 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export declare function getArgsValidationError(inputFile: string, outputFolder: string, scenario: string): string | undefined;
5
+ export declare function getArgsValidationError(inputFile: string, outputFile: string): string | undefined;
6
6
  //# sourceMappingURL=getArgsValidationError.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getArgsValidationError.d.ts","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAsBpB"}
1
+ {"version":3,"file":"getArgsValidationError.d.ts","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAiBpB"}
@@ -25,25 +25,21 @@ var __importStar = (this && this.__importStar) || function (mod) {
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.getArgsValidationError = void 0;
27
27
  const fs = __importStar(require("fs"));
28
- function getArgsValidationError(inputFile, outputFolder, scenario) {
28
+ function getArgsValidationError(inputFile, outputFile) {
29
29
  // Validate input file
30
30
  if (!inputFile) {
31
31
  // TODO: Do not log file name. It can be customer content
32
- return "Input file name is missing.";
32
+ return "Input file name argument is missing.";
33
33
  }
34
34
  else if (!fs.existsSync(inputFile)) {
35
35
  return "Input file does not exist.";
36
36
  }
37
37
  // Validate output file
38
- if (!outputFolder) {
39
- return "Output folder name is missing.";
38
+ if (!outputFile) {
39
+ return "Output file argument is missing.";
40
40
  }
41
- else if (!fs.existsSync(outputFolder)) {
42
- return "Output folder does not exist.";
43
- }
44
- // Validate scenario name
45
- if (!scenario) {
46
- return "Scenario name is missing.";
41
+ else if (fs.existsSync(outputFile)) {
42
+ return `Output file already exists [${outputFile}].`;
47
43
  }
48
44
  return undefined;
49
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,SAAgB,sBAAsB,CAClC,SAAiB,EACjB,YAAoB,EACpB,QAAgB;IAEhB,sBAAsB;IACtB,IAAI,CAAC,SAAS,EAAE;QACZ,yDAAyD;QACzD,OAAO,6BAA6B,CAAC;KACxC;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAClC,OAAO,4BAA4B,CAAC;KACvC;IAED,uBAAuB;IACvB,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,gCAAgC,CAAC;KAC3C;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QACrC,OAAO,+BAA+B,CAAC;KAC1C;IAED,yBAAyB;IACzB,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,2BAA2B,CAAC;KACtC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AA1BD,wDA0BC","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\nexport function getArgsValidationError(\n inputFile: string,\n outputFolder: string,\n scenario: string,\n): string | undefined {\n // Validate input file\n if (!inputFile) {\n // TODO: Do not log file name. It can be customer content\n return \"Input file name is missing.\";\n } else if (!fs.existsSync(inputFile)) {\n return \"Input file does not exist.\";\n }\n\n // Validate output file\n if (!outputFolder) {\n return \"Output folder name is missing.\";\n } else if (!fs.existsSync(outputFolder)) {\n return \"Output folder does not exist.\";\n }\n\n // Validate scenario name\n if (!scenario) {\n return \"Scenario name is missing.\";\n }\n\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,SAAgB,sBAAsB,CAClC,SAAiB,EACjB,UAAkB;IAElB,sBAAsB;IACtB,IAAI,CAAC,SAAS,EAAE;QACZ,yDAAyD;QACzD,OAAO,sCAAsC,CAAC;KACjD;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAClC,OAAO,4BAA4B,CAAC;KACvC;IAED,uBAAuB;IACvB,IAAI,CAAC,UAAU,EAAE;QACb,OAAO,kCAAkC,CAAC;KAC7C;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;QAClC,OAAO,+BAA+B,UAAU,IAAI,CAAC;KACxD;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AApBD,wDAoBC","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\nexport function getArgsValidationError(\n inputFile: string,\n outputFile: string,\n): string | undefined {\n // Validate input file\n if (!inputFile) {\n // TODO: Do not log file name. It can be customer content\n return \"Input file name argument is missing.\";\n } else if (!fs.existsSync(inputFile)) {\n return \"Input file does not exist.\";\n }\n\n // Validate output file\n if (!outputFile) {\n return \"Output file argument is missing.\";\n } else if (fs.existsSync(outputFile)) {\n return `Output file already exists [${outputFile}].`;\n }\n\n return undefined;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -2,6 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export * from "./codeLoaderBundle";
5
+ export { ICodeLoaderBundle, IFluidFileConverter } from "./codeLoaderBundle";
6
6
  export * from "./exportFile";
7
+ export { fluidRunner } from "./fluidRunner";
8
+ export * from "./logger/FileLogger";
9
+ export * from "./parseBundleAndExportFile";
7
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./codeLoaderBundle"), exports);
17
+ exports.fluidRunner = void 0;
18
18
  __exportStar(require("./exportFile"), exports);
19
+ var fluidRunner_1 = require("./fluidRunner");
20
+ Object.defineProperty(exports, "fluidRunner", { enumerable: true, get: function () { return fluidRunner_1.fluidRunner; } });
21
+ // eslint-disable-next-line import/no-internal-modules
22
+ __exportStar(require("./logger/FileLogger"), exports);
23
+ __exportStar(require("./parseBundleAndExportFile"), exports);
19
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,+CAA6B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAGH,+CAA6B;AAC7B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,sDAAsD;AACtD,sDAAoC;AACpC,6DAA2C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { ICodeLoaderBundle, IFluidFileConverter } from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\nexport { fluidRunner } from \"./fluidRunner\";\n// eslint-disable-next-line import/no-internal-modules\nexport * from \"./logger/FileLogger\";\nexport * from \"./parseBundleAndExportFile\";\n"]}
@@ -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
- import { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/common-definitions";
5
+ import { ITelemetryBaseEvent, ITelemetryBaseLogger, ITelemetryLogger } from "@fluidframework/common-definitions";
6
6
  /**
7
7
  * Logger that writes events into a defined file
8
8
  */
@@ -20,4 +20,14 @@ export declare class FileLogger implements ITelemetryBaseLogger {
20
20
  flush(): Promise<void>;
21
21
  send(event: ITelemetryBaseEvent): void;
22
22
  }
23
+ /**
24
+ * Create a ITelemetryLogger wrapped around provided FileLogger
25
+ */
26
+ export declare function createLogger(fileLogger: FileLogger): ITelemetryLogger;
27
+ /**
28
+ * Validate the telemetryFile command line argument
29
+ * @param telemetryFile - path where telemetry will be written
30
+ * @returns
31
+ */
32
+ export declare function getTelemetryFileValidationError(telemetryFile: string): string | undefined;
23
33
  //# sourceMappingURL=FileLogger.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/F;;GAEG;AACH,qBAAa,UAAW,YAAW,oBAAoB;IAW/C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAX5B,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;OAGG;gBAEkB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW;IAGnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAUhD"}
1
+ {"version":3,"file":"FileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/FileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGjH;;GAEG;AACH,qBAAa,UAAW,YAAW,oBAAoB;IAW/C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAX5B,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;OAGG;gBAEkB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW;IAGnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAUhD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,UAAU,GAAG,gBAAgB,CAGrE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzF"}
@@ -23,8 +23,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.FileLogger = void 0;
26
+ exports.getTelemetryFileValidationError = exports.createLogger = exports.FileLogger = void 0;
27
27
  const fs = __importStar(require("fs"));
28
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
28
29
  /**
29
30
  * Logger that writes events into a defined file
30
31
  */
@@ -55,4 +56,26 @@ class FileLogger {
55
56
  }
56
57
  }
57
58
  exports.FileLogger = FileLogger;
59
+ /**
60
+ * Create a ITelemetryLogger wrapped around provided FileLogger
61
+ */
62
+ function createLogger(fileLogger) {
63
+ return telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
64
+ }
65
+ exports.createLogger = createLogger;
66
+ /**
67
+ * Validate the telemetryFile command line argument
68
+ * @param telemetryFile - path where telemetry will be written
69
+ * @returns
70
+ */
71
+ function getTelemetryFileValidationError(telemetryFile) {
72
+ if (!telemetryFile) {
73
+ return "Telemetry file argument is missing.";
74
+ }
75
+ else if (fs.existsSync(telemetryFile)) {
76
+ return `Telemetry file already exists [${telemetryFile}].`;
77
+ }
78
+ return undefined;
79
+ }
80
+ exports.getTelemetryFileValidationError = getTelemetryFileValidationError;
58
81
  //# sourceMappingURL=FileLogger.js.map