@fluidframework/fluid-runner 2.0.0-internal.1.2.1 → 2.0.0-internal.1.2.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 (114) hide show
  1. package/README.md +27 -2
  2. package/dist/exportFile.d.ts +2 -1
  3. package/dist/exportFile.d.ts.map +1 -1
  4. package/dist/exportFile.js +5 -7
  5. package/dist/exportFile.js.map +1 -1
  6. package/dist/fakeUrlResolver.d.ts +1 -0
  7. package/dist/fakeUrlResolver.d.ts.map +1 -1
  8. package/dist/fakeUrlResolver.js +1 -0
  9. package/dist/fakeUrlResolver.js.map +1 -1
  10. package/dist/fluidRunner.d.ts.map +1 -1
  11. package/dist/fluidRunner.js +23 -13
  12. package/dist/fluidRunner.js.map +1 -1
  13. package/dist/getArgsValidationError.d.ts.map +1 -1
  14. package/dist/getArgsValidationError.js +0 -1
  15. package/dist/getArgsValidationError.js.map +1 -1
  16. package/dist/index.d.ts +3 -1
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +9 -3
  19. package/dist/index.js.map +1 -1
  20. package/dist/logger/baseFileLogger.d.ts +28 -0
  21. package/dist/logger/baseFileLogger.d.ts.map +1 -0
  22. package/dist/logger/{FileLogger.js → baseFileLogger.js} +26 -34
  23. package/dist/logger/baseFileLogger.js.map +1 -0
  24. package/dist/logger/csvFileLogger.d.ts +18 -0
  25. package/dist/logger/csvFileLogger.d.ts.map +1 -0
  26. package/dist/logger/csvFileLogger.js +60 -0
  27. package/dist/logger/csvFileLogger.js.map +1 -0
  28. package/dist/logger/fileLogger.d.ts +38 -0
  29. package/dist/logger/fileLogger.d.ts.map +1 -0
  30. package/dist/logger/fileLogger.js +17 -0
  31. package/dist/logger/fileLogger.js.map +1 -0
  32. package/dist/logger/jsonFileLogger.d.ts +14 -0
  33. package/dist/logger/jsonFileLogger.d.ts.map +1 -0
  34. package/dist/logger/jsonFileLogger.js +44 -0
  35. package/dist/logger/jsonFileLogger.js.map +1 -0
  36. package/dist/logger/loggerUtils.d.ts +36 -0
  37. package/dist/logger/loggerUtils.d.ts.map +1 -0
  38. package/dist/logger/loggerUtils.js +90 -0
  39. package/dist/logger/loggerUtils.js.map +1 -0
  40. package/dist/parseBundleAndExportFile.d.ts +2 -1
  41. package/dist/parseBundleAndExportFile.d.ts.map +1 -1
  42. package/dist/parseBundleAndExportFile.js +6 -7
  43. package/dist/parseBundleAndExportFile.js.map +1 -1
  44. package/dist/utils.d.ts +7 -0
  45. package/dist/utils.d.ts.map +1 -1
  46. package/dist/utils.js +17 -1
  47. package/dist/utils.js.map +1 -1
  48. package/lib/exportFile.d.ts +2 -1
  49. package/lib/exportFile.d.ts.map +1 -1
  50. package/lib/exportFile.js +4 -6
  51. package/lib/exportFile.js.map +1 -1
  52. package/lib/fakeUrlResolver.d.ts +1 -0
  53. package/lib/fakeUrlResolver.d.ts.map +1 -1
  54. package/lib/fakeUrlResolver.js +1 -0
  55. package/lib/fakeUrlResolver.js.map +1 -1
  56. package/lib/fluidRunner.d.ts.map +1 -1
  57. package/lib/fluidRunner.js +23 -13
  58. package/lib/fluidRunner.js.map +1 -1
  59. package/lib/getArgsValidationError.d.ts.map +1 -1
  60. package/lib/getArgsValidationError.js +0 -1
  61. package/lib/getArgsValidationError.js.map +1 -1
  62. package/lib/index.d.ts +3 -1
  63. package/lib/index.d.ts.map +1 -1
  64. package/lib/index.js +4 -2
  65. package/lib/index.js.map +1 -1
  66. package/lib/logger/baseFileLogger.d.ts +28 -0
  67. package/lib/logger/baseFileLogger.d.ts.map +1 -0
  68. package/lib/logger/baseFileLogger.js +49 -0
  69. package/lib/logger/baseFileLogger.js.map +1 -0
  70. package/lib/logger/csvFileLogger.d.ts +18 -0
  71. package/lib/logger/csvFileLogger.d.ts.map +1 -0
  72. package/lib/logger/csvFileLogger.js +37 -0
  73. package/lib/logger/csvFileLogger.js.map +1 -0
  74. package/lib/logger/fileLogger.d.ts +38 -0
  75. package/lib/logger/fileLogger.d.ts.map +1 -0
  76. package/lib/logger/fileLogger.js +14 -0
  77. package/lib/logger/fileLogger.js.map +1 -0
  78. package/lib/logger/jsonFileLogger.d.ts +14 -0
  79. package/lib/logger/jsonFileLogger.d.ts.map +1 -0
  80. package/lib/logger/jsonFileLogger.js +21 -0
  81. package/lib/logger/jsonFileLogger.js.map +1 -0
  82. package/lib/logger/loggerUtils.d.ts +36 -0
  83. package/lib/logger/loggerUtils.d.ts.map +1 -0
  84. package/lib/logger/loggerUtils.js +65 -0
  85. package/lib/logger/loggerUtils.js.map +1 -0
  86. package/lib/parseBundleAndExportFile.d.ts +2 -1
  87. package/lib/parseBundleAndExportFile.d.ts.map +1 -1
  88. package/lib/parseBundleAndExportFile.js +5 -6
  89. package/lib/parseBundleAndExportFile.js.map +1 -1
  90. package/lib/utils.d.ts +7 -0
  91. package/lib/utils.d.ts.map +1 -1
  92. package/lib/utils.js +15 -0
  93. package/lib/utils.js.map +1 -1
  94. package/package.json +11 -10
  95. package/src/exportFile.ts +7 -5
  96. package/src/fakeUrlResolver.ts +1 -0
  97. package/src/fluidRunner.ts +24 -16
  98. package/src/getArgsValidationError.ts +0 -1
  99. package/src/index.ts +5 -2
  100. package/src/logger/baseFileLogger.ts +58 -0
  101. package/src/logger/csvFileLogger.ts +40 -0
  102. package/src/logger/fileLogger.ts +45 -0
  103. package/src/logger/jsonFileLogger.ts +27 -0
  104. package/src/logger/loggerUtils.ts +81 -0
  105. package/src/parseBundleAndExportFile.ts +7 -5
  106. package/src/utils.ts +20 -0
  107. package/dist/logger/FileLogger.d.ts +0 -32
  108. package/dist/logger/FileLogger.d.ts.map +0 -1
  109. package/dist/logger/FileLogger.js.map +0 -1
  110. package/lib/logger/FileLogger.d.ts +0 -32
  111. package/lib/logger/FileLogger.d.ts.map +0 -1
  112. package/lib/logger/FileLogger.js +0 -55
  113. package/lib/logger/FileLogger.js.map +0 -1
  114. package/src/logger/FileLogger.ts +0 -67
package/README.md CHANGED
@@ -31,10 +31,35 @@ fluidRunner({ /* IFluidFileConverter implementation here */ });
31
31
  The input file is expected to be an ODSP snapshot.
32
32
  For some examples, see the files in the [localOdspSnapshots folder](./src/test/localOdspSnapshots).
33
33
 
34
+ ### Telemetry format
35
+ There is an optional command line option `telemetryFormat` that allows you to specify the telemetry output format. The naming provided to this option is strict and must match an option in [OutputFormat](./src/logger/fileLogger.ts).
36
+ The default format is currently `JSON`
37
+
38
+ ### Additional telemetry properties
39
+ There is an optional command line option `telemetryProp` that allows you to specify additional properties that will be added to every telemetry entry. The format follows these rules:
40
+ - every key must be a string
41
+ - values may be either a string or a number
42
+ - a value may not be empty
43
+
44
+ Example of valid usages:
45
+ ```
46
+ --telemetryProp prop1 value1 --telemetryProp prop2 10.5
47
+ --telemetryProp " prop1 " " value1 " prop2 value2
48
+ --telemetryProp=prop1 value1 --telemetryProp prop2 value2
49
+ --telemetryProp
50
+ ```
51
+
52
+ Example of invalid usages:
53
+ ```
54
+ --telemetryProp "10" value1
55
+ --telemetryProp prop1
56
+ --telemetryProp= // this will be treated as ['']
57
+ ```
58
+
34
59
  ### Consumption
35
60
  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
61
+ - [`createLogger(...)`](./src/logger/fileLogger.ts)
62
+ - Creates and wraps an `IFileLogger` and adds some useful telemetry data to every entry
38
63
  - [`createContainerAndExecute(...)`](./src/exportFile.ts)
39
64
  - This is the core logic for running some action based on a local ODSP snapshot
40
65
  - [`getSnapshotFileContent(...)`](./src/utils.ts)
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
6
  import { IFluidFileConverter } from "./codeLoaderBundle";
7
+ import { ITelemetryOptions } from "./logger/fileLogger";
7
8
  export declare type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
8
9
  interface IExportFileResponseSuccess {
9
10
  success: true;
@@ -17,7 +18,7 @@ interface IExportFileResponseFailure {
17
18
  /**
18
19
  * Execute code on Container based on ODSP snapshot and write result to file
19
20
  */
20
- export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string): Promise<IExportFileResponse>;
21
+ export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: ITelemetryOptions): Promise<IExportFileResponse>;
21
22
  /**
22
23
  * Create the container based on an ODSP snapshot and execute code on it
23
24
  * @returns result of execution
@@ -1 +1 @@
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"}
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;AAIzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAIxD,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,EAChB,gBAAgB,CAAC,EAAE,iBAAiB,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAiC9B;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"}
@@ -32,20 +32,18 @@ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
32
32
  const getArgsValidationError_1 = require("./getArgsValidationError");
33
33
  const fakeUrlResolver_1 = require("./fakeUrlResolver");
34
34
  const utils_1 = require("./utils");
35
- // eslint-disable-next-line import/no-internal-modules
36
- const FileLogger_1 = require("./logger/FileLogger");
35
+ const loggerUtils_1 = require("./logger/loggerUtils");
37
36
  const clientArgsValidationError = "Client_ArgsValidationError";
38
37
  /**
39
38
  * Execute code on Container based on ODSP snapshot and write result to file
40
39
  */
41
- async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options) {
42
- const telemetryArgError = (0, FileLogger_1.getTelemetryFileValidationError)(telemetryFile);
40
+ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options, telemetryOptions) {
41
+ const telemetryArgError = (0, loggerUtils_1.getTelemetryFileValidationError)(telemetryFile);
43
42
  if (telemetryArgError) {
44
43
  const eventName = clientArgsValidationError;
45
44
  return { success: false, eventName, errorMessage: telemetryArgError };
46
45
  }
47
- const fileLogger = new FileLogger_1.FileLogger(telemetryFile);
48
- const logger = (0, FileLogger_1.createLogger)(fileLogger);
46
+ const { fileLogger, logger } = (0, loggerUtils_1.createLogger)(telemetryFile, telemetryOptions);
49
47
  try {
50
48
  return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
51
49
  const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFile);
@@ -64,7 +62,7 @@ async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFi
64
62
  return { success: false, eventName, errorMessage: "Unexpected error", error };
65
63
  }
66
64
  finally {
67
- await fileLogger.flush();
65
+ await fileLogger.close();
68
66
  }
69
67
  }
70
68
  exports.exportFile = exportFile;
@@ -1 +1 @@
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,UAAk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AAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;KACjF;YAAS;QACN,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;KAC5B;AACL,CAAC;AAxCD,gCAwCC;AAED;;;GAGG;AACI,KAAK,UAAU,yBAAyB,CAC3C,iBAAsC,EACtC,kBAAuC,EACvC,MAAwB,EACxB,OAAgB;IAEhB,MAAM,MAAM,GAAG,IAAI,yBAAM,CAAC;QACtB,WAAW,EAAE,IAAI,iCAAe,EAAE;QAClC,sBAAsB,EAAE,IAAA,mDAAqC,EAAC,iBAAiB,CAAC;QAChF,UAAU,EAAE,MAAM,kBAAkB,CAAC,aAAa,CAAC,MAAM,CAAC;QAC1D,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,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"]}
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;AAGjD,sDAAqF;AAgBrF,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;GAEG;AACI,KAAK,UAAU,UAAU,CAC5B,kBAAuC,EACvC,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB,EAChB,gBAAoC;IAEpC,MAAM,iBAAiB,GAAG,IAAA,6CAA+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,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAA,0BAAY,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAE7E,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,S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AC,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,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 import/no-internal-modules */\nimport { ITelemetryOptions } from \"./logger/fileLogger\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils\";\n/* eslint-enable import/no-internal-modules */\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 telemetryOptions?: ITelemetryOptions,\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, logger } = createLogger(telemetryFile, telemetryOptions);\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.close();\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"]}
@@ -6,6 +6,7 @@ import { IRequest } from "@fluidframework/core-interfaces";
6
6
  import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
7
7
  /**
8
8
  * Fake URL resolver that returns hard coded values on every request
9
+ * @internal
9
10
  */
10
11
  export declare class FakeUrlResolver implements IUrlResolver {
11
12
  resolve(_request: IRequest): Promise<IResolvedUrl | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"fakeUrlResolver.d.ts","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMvG;;GAEG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAyB9D,cAAc,CACvB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,kBAAkB,CAAC,EAAE,qBAAqB,GAC3C,OAAO,CAAC,MAAM,CAAC;CAGrB"}
1
+ {"version":3,"file":"fakeUrlResolver.d.ts","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAMvG;;;GAGG;AACH,qBAAa,eAAgB,YAAW,YAAY;IACnC,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;IAyB9D,cAAc,CACvB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,EACpB,kBAAkB,CAAC,EAAE,qBAAqB,GAC3C,OAAO,CAAC,MAAM,CAAC;CAGrB"}
@@ -9,6 +9,7 @@ const fakeId = "FakeUrlResolver";
9
9
  const fakeUrl = "/FakeUrlResolver/";
10
10
  /**
11
11
  * Fake URL resolver that returns hard coded values on every request
12
+ * @internal
12
13
  */
13
14
  class FakeUrlResolver {
14
15
  async resolve(_request) {
@@ -1 +1 @@
1
- {"version":3,"file":"fakeUrlResolver.js","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACjC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC;;GAEG;AACH,MAAa,eAAe;IACjB,KAAK,CAAC,OAAO,CAAC,QAAkB;QACnC,MAAM,mBAAmB,GAAqB;YAC1C,IAAI,EAAE,OAAO;YACb,eAAe,EAAE,IAAI;YACrB,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,OAAO;YACZ,gBAAgB,EAAE,MAAM;YACxB,SAAS,EAAE;gBACP,kBAAkB,EAAE,OAAO;gBAC3B,wBAAwB,EAAE,OAAO;gBACjC,uBAAuB,EAAE,OAAO;gBAChC,eAAe,EAAE,OAAO;aAC3B;YACD,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,MAAM;SACtB,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,YAA0B,EAC1B,YAAoB,EACpB,kBAA0C;QAE1C,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAjCD,0CAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\n\nconst fakeId = \"FakeUrlResolver\";\nconst fakeUrl = \"/FakeUrlResolver/\";\n\n/**\n * Fake URL resolver that returns hard coded values on every request\n */\nexport class FakeUrlResolver implements IUrlResolver {\n public async resolve(_request: IRequest): Promise<IResolvedUrl | undefined> {\n const fakeOdspResolvedUrl: IOdspResolvedUrl = {\n type: \"fluid\",\n odspResolvedUrl: true,\n id: fakeId,\n siteUrl: fakeUrl,\n driveId: fakeId,\n itemId: fakeId,\n url: fakeUrl,\n hashedDocumentId: fakeId,\n endpoints: {\n snapshotStorageUrl: fakeUrl,\n attachmentPOSTStorageUrl: fakeUrl,\n attachmentGETStorageUrl: fakeUrl,\n deltaStorageUrl: fakeUrl,\n },\n tokens: {},\n fileName: fakeId,\n summarizer: false,\n fileVersion: fakeId,\n };\n\n return fakeOdspResolvedUrl;\n }\n\n public async getAbsoluteUrl(\n _resolvedUrl: IResolvedUrl,\n _relativeUrl: string,\n _packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n return \"\";\n }\n}\n"]}
1
+ {"version":3,"file":"fakeUrlResolver.js","sourceRoot":"","sources":["../src/fakeUrlResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH,MAAM,MAAM,GAAG,iBAAiB,CAAC;AACjC,MAAM,OAAO,GAAG,mBAAmB,CAAC;AAEpC;;;GAGG;AACH,MAAa,eAAe;IACjB,KAAK,CAAC,OAAO,CAAC,QAAkB;QACnC,MAAM,mBAAmB,GAAqB;YAC1C,IAAI,EAAE,OAAO;YACb,eAAe,EAAE,IAAI;YACrB,EAAE,EAAE,MAAM;YACV,OAAO,EAAE,OAAO;YAChB,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,MAAM;YACd,GAAG,EAAE,OAAO;YACZ,gBAAgB,EAAE,MAAM;YACxB,SAAS,EAAE;gBACP,kBAAkB,EAAE,OAAO;gBAC3B,wBAAwB,EAAE,OAAO;gBACjC,uBAAuB,EAAE,OAAO;gBAChC,eAAe,EAAE,OAAO;aAC3B;YACD,MAAM,EAAE,EAAE;YACV,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,KAAK;YACjB,WAAW,EAAE,MAAM;SACtB,CAAC;QAEF,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEM,KAAK,CAAC,cAAc,CACvB,YAA0B,EAC1B,YAAoB,EACpB,kBAA0C;QAE1C,OAAO,EAAE,CAAC;IACd,CAAC;CACJ;AAjCD,0CAiCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from \"@fluidframework/driver-definitions\";\nimport { IOdspResolvedUrl } from \"@fluidframework/odsp-driver-definitions\";\n\nconst fakeId = \"FakeUrlResolver\";\nconst fakeUrl = \"/FakeUrlResolver/\";\n\n/**\n * Fake URL resolver that returns hard coded values on every request\n * @internal\n */\nexport class FakeUrlResolver implements IUrlResolver {\n public async resolve(_request: IRequest): Promise<IResolvedUrl | undefined> {\n const fakeOdspResolvedUrl: IOdspResolvedUrl = {\n type: \"fluid\",\n odspResolvedUrl: true,\n id: fakeId,\n siteUrl: fakeUrl,\n driveId: fakeId,\n itemId: fakeId,\n url: fakeUrl,\n hashedDocumentId: fakeId,\n endpoints: {\n snapshotStorageUrl: fakeUrl,\n attachmentPOSTStorageUrl: fakeUrl,\n attachmentGETStorageUrl: fakeUrl,\n deltaStorageUrl: fakeUrl,\n },\n tokens: {},\n fileName: fakeId,\n summarizer: false,\n fileVersion: fakeId,\n };\n\n return fakeOdspResolvedUrl;\n }\n\n public async getAbsoluteUrl(\n _resolvedUrl: IResolvedUrl,\n _relativeUrl: string,\n _packageInfoSource?: IContainerPackageInfo,\n ): Promise<string> {\n return \"\";\n }\n}\n"]}
@@ -1 +1 @@
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,QAoEnE"}
1
+ {"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAMzD;;GAEG;AACH,wBAAgB,WAAW,CAAC,kBAAkB,CAAC,EAAE,mBAAmB,QAqFnE"}
@@ -24,9 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.fluidRunner = void 0;
27
+ /* eslint-disable max-len */
27
28
  const yargs = __importStar(require("yargs"));
28
29
  const exportFile_1 = require("./exportFile");
29
30
  const parseBundleAndExportFile_1 = require("./parseBundleAndExportFile");
31
+ // eslint-disable-next-line import/no-internal-modules
32
+ const loggerUtils_1 = require("./logger/loggerUtils");
33
+ const utils_1 = require("./utils");
30
34
  /**
31
35
  * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
32
36
  */
@@ -39,7 +43,6 @@ function fluidRunner(fluidFileConverter) {
39
43
  // eslint-disable-next-line @typescript-eslint/no-shadow
40
44
  (yargs) => yargs
41
45
  .option("codeLoader", {
42
- // eslint-disable-next-line max-len
43
46
  describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
44
47
  type: "string",
45
48
  demandOption: false,
@@ -63,16 +66,32 @@ function fluidRunner(fluidFileConverter) {
63
66
  describe: "Additional options passed to container on execution",
64
67
  type: "string",
65
68
  demandOption: false,
69
+ })
70
+ .option("telemetryFormat", {
71
+ describe: "Output format for telemetry. Current options are: [\"JSON\", \"CSV\"]",
72
+ type: "string",
73
+ demandOption: false,
74
+ default: "JSON",
75
+ })
76
+ .option("telemetryProp", {
77
+ describe: "Property to add to every telemetry entry. Formatted like \"--telemetryProp prop1 value1 --telemetryProp prop2 \\\"value 2\\\"\".",
78
+ type: "array",
79
+ demandOption: false,
66
80
  }),
67
81
  // eslint-disable-next-line @typescript-eslint/no-misused-promises
68
82
  async (argv) => {
69
- const argsError = validateProvidedArgs(argv.codeLoader, fluidFileConverter);
83
+ const argsError = (0, utils_1.validateCommandLineArgs)(argv.codeLoader, fluidFileConverter);
70
84
  if (argsError) {
71
85
  console.error(argsError);
72
86
  process.exit(1);
73
87
  }
88
+ const telemetryOptionsResult = (0, loggerUtils_1.validateAndParseTelemetryOptions)(argv.telemetryFormat, argv.telemetryProp);
89
+ if (!telemetryOptionsResult.success) {
90
+ console.error(telemetryOptionsResult.error);
91
+ process.exit(1);
92
+ }
74
93
  const result = await (argv.codeLoader
75
- ? (0, parseBundleAndExportFile_1.parseBundleAndExportFile)(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options) : (0, exportFile_1.exportFile)(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options));
94
+ ? (0, parseBundleAndExportFile_1.parseBundleAndExportFile)(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions) : (0, exportFile_1.exportFile)(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions));
76
95
  if (!result.success) {
77
96
  console.error(`${result.eventName}: ${result.errorMessage}`);
78
97
  process.exit(1);
@@ -82,15 +101,6 @@ function fluidRunner(fluidFileConverter) {
82
101
  .demandCommand().argv;
83
102
  }
84
103
  exports.fluidRunner = fluidRunner;
85
- function validateProvidedArgs(codeLoader, fluidFileConverter) {
86
- if (codeLoader !== undefined && fluidFileConverter !== undefined) {
87
- return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See \"fluidRunner.ts\" for details.";
88
- }
89
- if (codeLoader === undefined && fluidFileConverter === undefined) {
90
- // eslint-disable-next-line max-len
91
- return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See \"fluidRunner.ts\" for details.";
92
- }
93
- return undefined;
94
- }
95
104
  fluidRunner();
105
+ /* eslint-enable max-len */
96
106
  //# sourceMappingURL=fluidRunner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,6CAA0C;AAE1C,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,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,UAAU;YACjC,CAAC,CAAC,IAAA,mDAAwB,EACtB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC,CAAC,CAAC,IAAA,uBAAU,EACV,kBAAmB,EACnB,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,OAAO,CACf,CAAC,CAAC;QAEP,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;AApED,kCAoEC;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 } 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 const result = await (argv.codeLoader\n ? parseBundleAndExportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n ) : exportFile(\n fluidFileConverter!,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\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"]}
1
+ {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,4BAA4B;AAC5B,6CAA+B;AAC/B,6CAA0C;AAE1C,yEAAsE;AACtE,sDAAsD;AACtD,sDAAwE;AACxE,mCAAkD;AAElD;;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,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;SACD,MAAM,CA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O,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;AArFD,kCAqFC;AAED,WAAW,EAAE,CAAC;AACd,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable max-len */\nimport * as yargs from \"yargs\";\nimport { exportFile } from \"./exportFile\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { parseBundleAndExportFile } from \"./parseBundleAndExportFile\";\n// eslint-disable-next-line import/no-internal-modules\nimport { validateAndParseTelemetryOptions } from \"./logger/loggerUtils\";\nimport { validateCommandLineArgs } from \"./utils\";\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 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 .option(\"telemetryFormat\", {\n describe: \"Output format for telemetry. Current options are: [\\\"JSON\\\", \\\"CSV\\\"]\",\n type: \"string\",\n demandOption: false,\n default: \"JSON\",\n })\n .option(\"telemetryProp\", {\n describe: \"Property to add to every telemetry entry. Formatted like \\\"--telemetryProp prop1 value1 --telemetryProp prop2 \\\\\\\"value 2\\\\\\\"\\\".\",\n type: \"array\",\n demandOption: false,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n const argsError = validateCommandLineArgs(argv.codeLoader, fluidFileConverter);\n if (argsError) {\n console.error(argsError);\n process.exit(1);\n }\n const telemetryOptionsResult = validateAndParseTelemetryOptions(argv.telemetryFormat, argv.telemetryProp);\n if (!telemetryOptionsResult.success) {\n console.error(telemetryOptionsResult.error);\n process.exit(1);\n }\n\n const result = await (argv.codeLoader\n ? parseBundleAndExportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n telemetryOptionsResult.telemetryOptions,\n ) : exportFile(\n fluidFileConverter!,\n argv.inputFile,\n argv.outputFile,\n argv.telemetryFile,\n argv.options,\n telemetryOptionsResult.telemetryOptions,\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\nfluidRunner();\n/* eslint-enable max-len */\n"]}
@@ -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,UAAU,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAiBpB"}
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,CAgBpB"}
@@ -28,7 +28,6 @@ const fs = __importStar(require("fs"));
28
28
  function getArgsValidationError(inputFile, outputFile) {
29
29
  // Validate input file
30
30
  if (!inputFile) {
31
- // TODO: Do not log file name. It can be customer content
32
31
  return "Input file name argument is missing.";
33
32
  }
34
33
  else if (!fs.existsSync(inputFile)) {
@@ -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,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"]}
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,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;AAnBD,wDAmBC","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 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
@@ -5,6 +5,8 @@
5
5
  export { ICodeLoaderBundle, IFluidFileConverter } from "./codeLoaderBundle";
6
6
  export * from "./exportFile";
7
7
  export { fluidRunner } from "./fluidRunner";
8
- export * from "./logger/FileLogger";
8
+ export { OutputFormat } from "./logger/fileLogger";
9
+ export { createLogger, getTelemetryFileValidationError } from "./logger/loggerUtils";
9
10
  export * from "./parseBundleAndExportFile";
11
+ export { getSnapshotFileContent } from "./utils";
10
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AACrF,cAAc,4BAA4B,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -14,11 +14,17 @@ 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
- exports.fluidRunner = void 0;
17
+ exports.getSnapshotFileContent = exports.getTelemetryFileValidationError = exports.createLogger = exports.OutputFormat = exports.fluidRunner = void 0;
18
18
  __exportStar(require("./exportFile"), exports);
19
19
  var fluidRunner_1 = require("./fluidRunner");
20
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);
21
+ var fileLogger_1 = require("./logger/fileLogger");
22
+ Object.defineProperty(exports, "OutputFormat", { enumerable: true, get: function () { return fileLogger_1.OutputFormat; } });
23
+ var loggerUtils_1 = require("./logger/loggerUtils");
24
+ Object.defineProperty(exports, "createLogger", { enumerable: true, get: function () { return loggerUtils_1.createLogger; } });
25
+ Object.defineProperty(exports, "getTelemetryFileValidationError", { enumerable: true, get: function () { return loggerUtils_1.getTelemetryFileValidationError; } });
23
26
  __exportStar(require("./parseBundleAndExportFile"), exports);
27
+ var utils_1 = require("./utils");
28
+ Object.defineProperty(exports, "getSnapshotFileContent", { enumerable: true, get: function () { return utils_1.getSnapshotFileContent; } });
29
+ /* eslint-enable import/no-internal-modules */
24
30
  //# 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;;;;;;;;;;;;;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"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;AAIH,+CAA6B;AAC7B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,kDAAmD;AAA1C,0GAAA,YAAY,OAAA;AACrB,oDAAqF;AAA5E,2GAAA,YAAY,OAAA;AAAE,8HAAA,+BAA+B,OAAA;AACtD,6DAA2C;AAC3C,iCAAiD;AAAxC,+GAAA,sBAAsB,OAAA;AAC/B,8CAA8C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/* eslint-disable import/no-internal-modules */\nexport { ICodeLoaderBundle, IFluidFileConverter } from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\nexport { fluidRunner } from \"./fluidRunner\";\nexport { OutputFormat } from \"./logger/fileLogger\";\nexport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils\";\nexport * from \"./parseBundleAndExportFile\";\nexport { getSnapshotFileContent } from \"./utils\";\n/* eslint-enable import/no-internal-modules */\n"]}
@@ -0,0 +1,28 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryBaseEvent } from "@fluidframework/common-definitions";
6
+ import { IFileLogger } from "./fileLogger";
7
+ /**
8
+ * @internal
9
+ */
10
+ export declare abstract class BaseFileLogger implements IFileLogger {
11
+ protected readonly filePath: string;
12
+ protected readonly eventsPerFlush: number;
13
+ protected readonly defaultProps?: Record<string, string | number> | undefined;
14
+ supportsTags?: true | undefined;
15
+ /** Hold events in memory until flushed */
16
+ protected events: any[];
17
+ protected hasWrittenToFile: boolean;
18
+ /**
19
+ * @param filePath - file path to write logs to
20
+ * @param eventsPerFlush - number of events per flush
21
+ * @param defaultProps - default properties to add to every telemetry event
22
+ */
23
+ constructor(filePath: string, eventsPerFlush?: number, defaultProps?: Record<string, string | number> | undefined);
24
+ send(event: ITelemetryBaseEvent): void;
25
+ protected flush(): Promise<void>;
26
+ close(): Promise<void>;
27
+ }
28
+ //# sourceMappingURL=baseFileLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/baseFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,8BAAsB,cAAe,YAAW,WAAW;IAanD,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACnC,SAAS,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM;IACzC,SAAS,CAAC,QAAQ,CAAC,YAAY,CAAC;IAd7B,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CAAM;IAC7B,SAAS,CAAC,gBAAgB,UAAS;IAEnC;;;;OAIG;gBAEoB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW,EAC3B,YAAY,CAAC,6CAAiC;IAG9D,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;cAW7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAazB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAGtC"}
@@ -23,58 +23,50 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getTelemetryFileValidationError = exports.createLogger = exports.FileLogger = void 0;
26
+ exports.BaseFileLogger = void 0;
27
27
  const fs = __importStar(require("fs"));
28
- const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
29
28
  /**
30
- * Logger that writes events into a defined file
29
+ * @internal
31
30
  */
32
- class FileLogger {
31
+ class BaseFileLogger {
33
32
  /**
34
33
  * @param filePath - file path to write logs to
35
34
  * @param eventsPerFlush - number of events per flush
35
+ * @param defaultProps - default properties to add to every telemetry event
36
36
  */
37
- constructor(filePath, eventsPerFlush = 50) {
37
+ constructor(filePath, eventsPerFlush = 50, defaultProps) {
38
38
  this.filePath = filePath;
39
39
  this.eventsPerFlush = eventsPerFlush;
40
+ this.defaultProps = defaultProps;
40
41
  /** Hold events in memory until flushed */
41
42
  this.events = [];
42
- }
43
- async flush() {
44
- if (this.events.length > 0) {
45
- fs.appendFileSync(this.filePath, this.events.join("\n"));
46
- this.events = [];
47
- }
43
+ this.hasWrittenToFile = false;
48
44
  }
49
45
  send(event) {
50
- const logEvent = JSON.stringify(event);
51
- this.events.push(logEvent);
46
+ // eslint-disable-next-line no-param-reassign
47
+ event = Object.assign(Object.assign({}, event), this.defaultProps);
48
+ this.events.push(event);
52
49
  if (this.events.length >= this.eventsPerFlush || event.category === "error") {
53
50
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
54
51
  this.flush();
55
52
  }
56
53
  }
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
- */
70
- function getTelemetryFileValidationError(telemetryFile) {
71
- if (!telemetryFile) {
72
- return "Telemetry file argument is missing.";
54
+ async flush() {
55
+ if (this.events.length > 0) {
56
+ const contentToWrite = this.events.map((it) => JSON.stringify(it)).join(",");
57
+ if (this.hasWrittenToFile) {
58
+ fs.appendFileSync(this.filePath, `,${contentToWrite}`);
59
+ }
60
+ else {
61
+ fs.appendFileSync(this.filePath, contentToWrite);
62
+ }
63
+ this.events = [];
64
+ this.hasWrittenToFile = true;
65
+ }
73
66
  }
74
- else if (fs.existsSync(telemetryFile)) {
75
- return `Telemetry file already exists [${telemetryFile}].`;
67
+ async close() {
68
+ await this.flush();
76
69
  }
77
- return undefined;
78
70
  }
79
- exports.getTelemetryFileValidationError = getTelemetryFileValidationError;
80
- //# sourceMappingURL=FileLogger.js.map
71
+ exports.BaseFileLogger = BaseFileLogger;
72
+ //# sourceMappingURL=baseFileLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseFileLogger.js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MAAM,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAChC;IACL,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACJ;AA7CD,wCA6CC","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 { ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { IFileLogger } from \"./fileLogger\";\n\n/**\n * @internal\n */\nexport abstract class BaseFileLogger implements IFileLogger {\n public supportsTags?: true | undefined;\n\n /** Hold events in memory until flushed */\n protected events: any[] = [];\n protected hasWrittenToFile = false;\n\n /**\n * @param filePath - file path to write logs to\n * @param eventsPerFlush - number of events per flush\n * @param defaultProps - default properties to add to every telemetry event\n */\n public constructor(\n protected readonly filePath: string,\n protected readonly eventsPerFlush: number = 50,\n protected readonly defaultProps?: Record<string, string | number>,\n ) { }\n\n public send(event: ITelemetryBaseEvent): void {\n // eslint-disable-next-line no-param-reassign\n event = { ...event, ...this.defaultProps };\n this.events.push(event);\n\n if (this.events.length >= this.eventsPerFlush || event.category === \"error\") {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.flush();\n }\n }\n\n protected async flush(): Promise<void> {\n if (this.events.length > 0) {\n const contentToWrite = this.events.map((it) => JSON.stringify(it)).join(\",\");\n if (this.hasWrittenToFile) {\n fs.appendFileSync(this.filePath, `,${contentToWrite}`);\n } else {\n fs.appendFileSync(this.filePath, contentToWrite);\n }\n this.events = [];\n this.hasWrittenToFile = true;\n }\n }\n\n public async close(): Promise<void> {\n await this.flush();\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryBaseEvent } from "@fluidframework/common-definitions";
6
+ import { BaseFileLogger } from "./baseFileLogger";
7
+ /**
8
+ * FileLogger that writes events into a defined CSV file
9
+ * @internal
10
+ */
11
+ export declare class CSVFileLogger extends BaseFileLogger {
12
+ /** Store the column names to write as the CSV header */
13
+ private readonly columns;
14
+ flush(): Promise<void>;
15
+ send(event: ITelemetryBaseEvent): void;
16
+ close(): Promise<void>;
17
+ }
18
+ //# sourceMappingURL=csvFileLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csvFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAC7C,wDAAwD;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IAExB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAQhC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAStC"}
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.CSVFileLogger = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const json2csv_1 = require("json2csv");
29
+ const baseFileLogger_1 = require("./baseFileLogger");
30
+ /**
31
+ * FileLogger that writes events into a defined CSV file
32
+ * @internal
33
+ */
34
+ class CSVFileLogger extends baseFileLogger_1.BaseFileLogger {
35
+ constructor() {
36
+ super(...arguments);
37
+ /** Store the column names to write as the CSV header */
38
+ this.columns = new Set();
39
+ }
40
+ async flush() {
41
+ // Do nothing
42
+ }
43
+ send(event) {
44
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
45
+ for (const prop in event) {
46
+ this.columns.add(prop);
47
+ }
48
+ super.send(event);
49
+ }
50
+ async close() {
51
+ await super.close();
52
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
53
+ for (const field in this.defaultProps) {
54
+ this.columns.add(field);
55
+ }
56
+ fs.writeFileSync(this.filePath, (0, json2csv_1.parse)(this.events, Array.from(this.columns)));
57
+ }
58
+ }
59
+ exports.CSVFileLogger = CSVFileLogger;
60
+ //# sourceMappingURL=csvFileLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"csvFileLogger.js","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,uCAAiC;AAEjC,qDAAkD;AAElD;;;GAGG;AACH,MAAa,aAAc,SAAQ,+BAAc;IAAjD;;QACI,wDAAwD;QACvC,YAAO,GAAG,IAAI,GAAG,EAAE,CAAC;IAuBzC,CAAC;IArBU,KAAK,CAAC,KAAK;QACd,aAAa;IACjB,CAAC;IAEM,IAAI,CAAC,KAA0B;QAClC,8DAA8D;QAC9D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SAC1B;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACtB,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,8DAA8D;QAC9D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC3B;QAED,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAA,gBAAK,EAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;CACJ;AAzBD,sCAyBC","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 { parse } from \"json2csv\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/common-definitions\";\nimport { BaseFileLogger } from \"./baseFileLogger\";\n\n/**\n * FileLogger that writes events into a defined CSV file\n * @internal\n */\nexport class CSVFileLogger extends BaseFileLogger {\n /** Store the column names to write as the CSV header */\n private readonly columns = new Set();\n\n public async flush(): Promise<void> {\n // Do nothing\n }\n\n public send(event: ITelemetryBaseEvent): void {\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const prop in event) {\n this.columns.add(prop);\n }\n super.send(event);\n }\n\n public async close(): Promise<void> {\n await super.close();\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const field in this.defaultProps) {\n this.columns.add(field);\n }\n\n fs.writeFileSync(this.filePath, parse(this.events, Array.from(this.columns)));\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
6
+ /**
7
+ * Contract for logger that writes telemetry to a file
8
+ * @internal
9
+ */
10
+ export interface IFileLogger extends ITelemetryBaseLogger {
11
+ /**
12
+ * This method acts as a "dispose" and should be explicitly called at the end of execution
13
+ */
14
+ close(): Promise<void>;
15
+ }
16
+ /**
17
+ * Desired output format for the telemetry
18
+ */
19
+ export declare enum OutputFormat {
20
+ JSON = 0,
21
+ CSV = 1
22
+ }
23
+ /**
24
+ * Options to provide upon creation of IFileLogger
25
+ * @internal
26
+ */
27
+ export interface ITelemetryOptions {
28
+ /** Desired output format used to create a specific IFileLogger implementation */
29
+ outputFormat?: OutputFormat;
30
+ /**
31
+ * Properties that should be added to every telemetry event
32
+ * Example: { "prop1": "value1", "prop2": 10.0 }
33
+ */
34
+ defaultProps?: Record<string, string | number>;
35
+ /** Number of telemetry events per flush to telemetry file */
36
+ eventsPerFlush?: number;
37
+ }
38
+ //# sourceMappingURL=fileLogger.d.ts.map