@fluidframework/fluid-runner 2.0.0-dev.1.3.0.96595

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 (134) hide show
  1. package/.eslintrc.js +18 -0
  2. package/.mocharc.js +12 -0
  3. package/LICENSE +21 -0
  4. package/README.md +68 -0
  5. package/bin/fluid-runner +2 -0
  6. package/dist/codeLoaderBundle.d.ts +44 -0
  7. package/dist/codeLoaderBundle.d.ts.map +1 -0
  8. package/dist/codeLoaderBundle.js +23 -0
  9. package/dist/codeLoaderBundle.js.map +1 -0
  10. package/dist/exportFile.d.ts +28 -0
  11. package/dist/exportFile.d.ts.map +1 -0
  12. package/dist/exportFile.js +87 -0
  13. package/dist/exportFile.js.map +1 -0
  14. package/dist/fakeUrlResolver.d.ts +15 -0
  15. package/dist/fakeUrlResolver.d.ts.map +1 -0
  16. package/dist/fakeUrlResolver.js +43 -0
  17. package/dist/fakeUrlResolver.js.map +1 -0
  18. package/dist/fluidRunner.d.ts +10 -0
  19. package/dist/fluidRunner.d.ts.map +1 -0
  20. package/dist/fluidRunner.js +106 -0
  21. package/dist/fluidRunner.js.map +1 -0
  22. package/dist/getArgsValidationError.d.ts +6 -0
  23. package/dist/getArgsValidationError.d.ts.map +1 -0
  24. package/dist/getArgsValidationError.js +46 -0
  25. package/dist/getArgsValidationError.js.map +1 -0
  26. package/dist/index.d.ts +12 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +30 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/logger/baseFileLogger.d.ts +28 -0
  31. package/dist/logger/baseFileLogger.d.ts.map +1 -0
  32. package/dist/logger/baseFileLogger.js +72 -0
  33. package/dist/logger/baseFileLogger.js.map +1 -0
  34. package/dist/logger/csvFileLogger.d.ts +18 -0
  35. package/dist/logger/csvFileLogger.d.ts.map +1 -0
  36. package/dist/logger/csvFileLogger.js +60 -0
  37. package/dist/logger/csvFileLogger.js.map +1 -0
  38. package/dist/logger/fileLogger.d.ts +38 -0
  39. package/dist/logger/fileLogger.d.ts.map +1 -0
  40. package/dist/logger/fileLogger.js +17 -0
  41. package/dist/logger/fileLogger.js.map +1 -0
  42. package/dist/logger/jsonFileLogger.d.ts +14 -0
  43. package/dist/logger/jsonFileLogger.d.ts.map +1 -0
  44. package/dist/logger/jsonFileLogger.js +44 -0
  45. package/dist/logger/jsonFileLogger.js.map +1 -0
  46. package/dist/logger/loggerUtils.d.ts +36 -0
  47. package/dist/logger/loggerUtils.d.ts.map +1 -0
  48. package/dist/logger/loggerUtils.js +90 -0
  49. package/dist/logger/loggerUtils.js.map +1 -0
  50. package/dist/packageVersion.d.ts +9 -0
  51. package/dist/packageVersion.d.ts.map +1 -0
  52. package/dist/packageVersion.js +12 -0
  53. package/dist/packageVersion.js.map +1 -0
  54. package/dist/parseBundleAndExportFile.d.ts +12 -0
  55. package/dist/parseBundleAndExportFile.d.ts.map +1 -0
  56. package/dist/parseBundleAndExportFile.js +84 -0
  57. package/dist/parseBundleAndExportFile.js.map +1 -0
  58. package/dist/utils.d.ts +24 -0
  59. package/dist/utils.d.ts.map +1 -0
  60. package/dist/utils.js +63 -0
  61. package/dist/utils.js.map +1 -0
  62. package/lib/codeLoaderBundle.d.ts +44 -0
  63. package/lib/codeLoaderBundle.d.ts.map +1 -0
  64. package/lib/codeLoaderBundle.js +18 -0
  65. package/lib/codeLoaderBundle.js.map +1 -0
  66. package/lib/exportFile.d.ts +28 -0
  67. package/lib/exportFile.d.ts.map +1 -0
  68. package/lib/exportFile.js +63 -0
  69. package/lib/exportFile.js.map +1 -0
  70. package/lib/fakeUrlResolver.d.ts +15 -0
  71. package/lib/fakeUrlResolver.d.ts.map +1 -0
  72. package/lib/fakeUrlResolver.js +39 -0
  73. package/lib/fakeUrlResolver.js.map +1 -0
  74. package/lib/fluidRunner.d.ts +10 -0
  75. package/lib/fluidRunner.d.ts.map +1 -0
  76. package/lib/fluidRunner.js +83 -0
  77. package/lib/fluidRunner.js.map +1 -0
  78. package/lib/getArgsValidationError.d.ts +6 -0
  79. package/lib/getArgsValidationError.d.ts.map +1 -0
  80. package/lib/getArgsValidationError.js +23 -0
  81. package/lib/getArgsValidationError.js.map +1 -0
  82. package/lib/index.d.ts +12 -0
  83. package/lib/index.d.ts.map +1 -0
  84. package/lib/index.js +12 -0
  85. package/lib/index.js.map +1 -0
  86. package/lib/logger/baseFileLogger.d.ts +28 -0
  87. package/lib/logger/baseFileLogger.d.ts.map +1 -0
  88. package/lib/logger/baseFileLogger.js +49 -0
  89. package/lib/logger/baseFileLogger.js.map +1 -0
  90. package/lib/logger/csvFileLogger.d.ts +18 -0
  91. package/lib/logger/csvFileLogger.d.ts.map +1 -0
  92. package/lib/logger/csvFileLogger.js +37 -0
  93. package/lib/logger/csvFileLogger.js.map +1 -0
  94. package/lib/logger/fileLogger.d.ts +38 -0
  95. package/lib/logger/fileLogger.d.ts.map +1 -0
  96. package/lib/logger/fileLogger.js +14 -0
  97. package/lib/logger/fileLogger.js.map +1 -0
  98. package/lib/logger/jsonFileLogger.d.ts +14 -0
  99. package/lib/logger/jsonFileLogger.d.ts.map +1 -0
  100. package/lib/logger/jsonFileLogger.js +21 -0
  101. package/lib/logger/jsonFileLogger.js.map +1 -0
  102. package/lib/logger/loggerUtils.d.ts +36 -0
  103. package/lib/logger/loggerUtils.d.ts.map +1 -0
  104. package/lib/logger/loggerUtils.js +65 -0
  105. package/lib/logger/loggerUtils.js.map +1 -0
  106. package/lib/packageVersion.d.ts +9 -0
  107. package/lib/packageVersion.d.ts.map +1 -0
  108. package/lib/packageVersion.js +9 -0
  109. package/lib/packageVersion.js.map +1 -0
  110. package/lib/parseBundleAndExportFile.d.ts +12 -0
  111. package/lib/parseBundleAndExportFile.d.ts.map +1 -0
  112. package/lib/parseBundleAndExportFile.js +61 -0
  113. package/lib/parseBundleAndExportFile.js.map +1 -0
  114. package/lib/utils.d.ts +24 -0
  115. package/lib/utils.d.ts.map +1 -0
  116. package/lib/utils.js +38 -0
  117. package/lib/utils.js.map +1 -0
  118. package/package.json +87 -0
  119. package/src/codeLoaderBundle.ts +57 -0
  120. package/src/exportFile.ts +104 -0
  121. package/src/fakeUrlResolver.ts +50 -0
  122. package/src/fluidRunner.ts +106 -0
  123. package/src/getArgsValidationError.ts +27 -0
  124. package/src/index.ts +14 -0
  125. package/src/logger/baseFileLogger.ts +58 -0
  126. package/src/logger/csvFileLogger.ts +40 -0
  127. package/src/logger/fileLogger.ts +45 -0
  128. package/src/logger/jsonFileLogger.ts +27 -0
  129. package/src/logger/loggerUtils.ts +81 -0
  130. package/src/packageVersion.ts +9 -0
  131. package/src/parseBundleAndExportFile.ts +80 -0
  132. package/src/utils.ts +45 -0
  133. package/tsconfig.esnext.json +7 -0
  134. package/tsconfig.json +14 -0
@@ -0,0 +1 @@
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 ADDED
@@ -0,0 +1,30 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getSnapshotFileContent = exports.getTelemetryFileValidationError = exports.createLogger = exports.OutputFormat = exports.fluidRunner = void 0;
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
+ 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; } });
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 */
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,72 @@
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.BaseFileLogger = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ /**
29
+ * @internal
30
+ */
31
+ class BaseFileLogger {
32
+ /**
33
+ * @param filePath - file path to write logs to
34
+ * @param eventsPerFlush - number of events per flush
35
+ * @param defaultProps - default properties to add to every telemetry event
36
+ */
37
+ constructor(filePath, eventsPerFlush = 50, defaultProps) {
38
+ this.filePath = filePath;
39
+ this.eventsPerFlush = eventsPerFlush;
40
+ this.defaultProps = defaultProps;
41
+ /** Hold events in memory until flushed */
42
+ this.events = [];
43
+ this.hasWrittenToFile = false;
44
+ }
45
+ send(event) {
46
+ // eslint-disable-next-line no-param-reassign
47
+ event = Object.assign(Object.assign({}, event), this.defaultProps);
48
+ this.events.push(event);
49
+ if (this.events.length >= this.eventsPerFlush || event.category === "error") {
50
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
51
+ this.flush();
52
+ }
53
+ }
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
+ }
66
+ }
67
+ async close() {
68
+ await this.flush();
69
+ }
70
+ }
71
+ exports.BaseFileLogger = BaseFileLogger;
72
+ //# sourceMappingURL=baseFileLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"baseFileLogger.js","sourceRoot":"","sources":["../../src/logger/baseFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAIzB;;GAEG;AACH,MAAsB,cAAc;IAOhC;;;;OAIG;IACF,YACsB,QAAgB,EAChB,iBAAyB,EAAE,EAC3B,YAA8C;QAF9C,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAa;QAC3B,iBAAY,GAAZ,YAAY,CAAkC;QAZrE,0CAA0C;QAChC,WAAM,GAAU,EAAE,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;IAW/B,CAAC;IAEE,IAAI,CAAC,KAA0B;QAClC,6CAA6C;QAC7C,KAAK,mCAAQ,KAAK,GAAK,IAAI,CAAC,YAAY,CAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YACzE,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;SAChB;IACL,CAAC;IAES,KAAK,CAAC,KAAK;QACjB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YACxB,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7E,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBACvB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC;aAC1D;iBAAM;gBACH,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;aACpD;YACD,IAAI,CAAC,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;;GAGG;AACH,MAAM,WAAW,WAAY,SAAQ,oBAAoB;IACrD;;OAEG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,oBAAY,YAAY;IACpB,IAAI,IAAA;IACJ,GAAG,IAAA;CACN;AAGD;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAC9B,iFAAiF;IACjF,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IAE/C,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.OutputFormat = void 0;
8
+ /**
9
+ * Desired output format for the telemetry
10
+ */
11
+ var OutputFormat;
12
+ (function (OutputFormat) {
13
+ OutputFormat[OutputFormat["JSON"] = 0] = "JSON";
14
+ OutputFormat[OutputFormat["CSV"] = 1] = "CSV";
15
+ })(OutputFormat = exports.OutputFormat || (exports.OutputFormat = {}));
16
+ /* eslint-enable tsdoc/syntax */
17
+ //# sourceMappingURL=fileLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fileLogger.js","sourceRoot":"","sources":["../../src/logger/fileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAeH;;GAEG;AACH,IAAY,YAGX;AAHD,WAAY,YAAY;IACpB,+CAAI,CAAA;IACJ,6CAAG,CAAA;AACP,CAAC,EAHW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAGvB;AAoBD,gCAAgC","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\";\n\n/**\n * Contract for logger that writes telemetry to a file\n * @internal\n */\nexport interface IFileLogger extends ITelemetryBaseLogger {\n /**\n * This method acts as a \"dispose\" and should be explicitly called at the end of execution\n */\n close(): Promise<void>;\n}\n\n/**\n * Desired output format for the telemetry\n */\nexport enum OutputFormat {\n JSON,\n CSV,\n}\n\n/* eslint-disable tsdoc/syntax */\n/**\n * Options to provide upon creation of IFileLogger\n * @internal\n */\nexport interface ITelemetryOptions {\n /** Desired output format used to create a specific IFileLogger implementation */\n outputFormat?: OutputFormat;\n\n /**\n * Properties that should be added to every telemetry event\n * Example: { \"prop1\": \"value1\", \"prop2\": 10.0 }\n */\n defaultProps?: Record<string, string | number>;\n\n /** Number of telemetry events per flush to telemetry file */\n eventsPerFlush?: number;\n}\n/* eslint-enable tsdoc/syntax */\n"]}
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { BaseFileLogger } from "./baseFileLogger";
6
+ /**
7
+ * FileLogger that writes events into a defined CSV file
8
+ * @internal
9
+ */
10
+ export declare class JSONFileLogger extends BaseFileLogger {
11
+ constructor(filePath: string, eventsPerFlush?: number, defaultProps?: Record<string, string | number>);
12
+ close(): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=jsonFileLogger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/jsonFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,cAAc;gBAE1C,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW,EAC3B,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;IAMrC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAItC"}
@@ -0,0 +1,44 @@
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.JSONFileLogger = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const baseFileLogger_1 = require("./baseFileLogger");
29
+ /**
30
+ * FileLogger that writes events into a defined CSV file
31
+ * @internal
32
+ */
33
+ class JSONFileLogger extends baseFileLogger_1.BaseFileLogger {
34
+ constructor(filePath, eventsPerFlush = 50, defaultProps) {
35
+ super(filePath, eventsPerFlush, defaultProps);
36
+ fs.appendFileSync(this.filePath, "[");
37
+ }
38
+ async close() {
39
+ await super.close();
40
+ fs.appendFileSync(this.filePath, "]");
41
+ }
42
+ }
43
+ exports.JSONFileLogger = JSONFileLogger;
44
+ //# sourceMappingURL=jsonFileLogger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jsonFileLogger.js","sourceRoot":"","sources":["../../src/logger/jsonFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qDAAkD;AAElD;;;GAGG;AACH,MAAa,cAAe,SAAQ,+BAAc;IAC9C,YACI,QAAgB,EAChB,iBAAyB,EAAE,EAC3B,YAA8C;QAE9C,KAAK,CAAC,QAAQ,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;QAC9C,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAEM,KAAK,CAAC,KAAK;QACd,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;CACJ;AAdD,wCAcC","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 { BaseFileLogger } from \"./baseFileLogger\";\n\n/**\n * FileLogger that writes events into a defined CSV file\n * @internal\n */\nexport class JSONFileLogger extends BaseFileLogger {\n constructor(\n filePath: string,\n eventsPerFlush: number = 50,\n defaultProps?: Record<string, string | number>,\n ) {\n super(filePath, eventsPerFlush, defaultProps);\n fs.appendFileSync(this.filePath, \"[\");\n }\n\n public async close(): Promise<void> {\n await super.close();\n fs.appendFileSync(this.filePath, \"]\");\n }\n}\n"]}
@@ -0,0 +1,36 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
+ import { IFileLogger, ITelemetryOptions } from "./fileLogger";
7
+ /**
8
+ * Create a ITelemetryLogger wrapped around provided IFileLogger
9
+ * ! It is expected that all events be sent through the returned "logger" value
10
+ * ! The "fileLogger" value should have its "close()" method called at the end of execution
11
+ * Note: if an output format is not supplied, default is JSON
12
+ * @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called
13
+ */
14
+ export declare function createLogger(filePath: string, options?: ITelemetryOptions): {
15
+ logger: ITelemetryLogger;
16
+ fileLogger: IFileLogger;
17
+ };
18
+ /**
19
+ * Validate the telemetryFile command line argument
20
+ * @param telemetryFile - path where telemetry will be written
21
+ */
22
+ export declare function getTelemetryFileValidationError(telemetryFile: string): string | undefined;
23
+ /**
24
+ * Validate the provided output format and default properties
25
+ * @param format - desired output format of the telemetry
26
+ * @param props - default properties to be added to every telemetry entry
27
+ * @internal
28
+ */
29
+ export declare function validateAndParseTelemetryOptions(format?: string, props?: (string | number)[]): {
30
+ success: false;
31
+ error: string;
32
+ } | {
33
+ success: true;
34
+ telemetryOptions: ITelemetryOptions;
35
+ };
36
+ //# sourceMappingURL=loggerUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loggerUtils.d.ts","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAgB,MAAM,cAAc,CAAC;AAG5E;;;;;;GAMG;AACF,wBAAgB,YAAY,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,iBAAiB,GAC5B;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,UAAU,EAAE,WAAW,CAAC;CAAE,CASxD;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQzF;AAED;;;;;GAKG;AACH,wBAAgB,gCAAgC,CAC5C,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAC5B;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,iBAAiB,CAAC;CAAE,CAwB9F"}
@@ -0,0 +1,90 @@
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.validateAndParseTelemetryOptions = exports.getTelemetryFileValidationError = exports.createLogger = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
29
+ const csvFileLogger_1 = require("./csvFileLogger");
30
+ const fileLogger_1 = require("./fileLogger");
31
+ const jsonFileLogger_1 = require("./jsonFileLogger");
32
+ /**
33
+ * Create a ITelemetryLogger wrapped around provided IFileLogger
34
+ * ! It is expected that all events be sent through the returned "logger" value
35
+ * ! The "fileLogger" value should have its "close()" method called at the end of execution
36
+ * Note: if an output format is not supplied, default is JSON
37
+ * @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called
38
+ */
39
+ function createLogger(filePath, options) {
40
+ const fileLogger = (options === null || options === void 0 ? void 0 : options.outputFormat) === fileLogger_1.OutputFormat.CSV
41
+ ? new csvFileLogger_1.CSVFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps)
42
+ : new jsonFileLogger_1.JSONFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps);
43
+ const logger = telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
44
+ return { logger, fileLogger };
45
+ }
46
+ exports.createLogger = createLogger;
47
+ /**
48
+ * Validate the telemetryFile command line argument
49
+ * @param telemetryFile - path where telemetry will be written
50
+ */
51
+ function getTelemetryFileValidationError(telemetryFile) {
52
+ if (!telemetryFile) {
53
+ return "Telemetry file argument is missing.";
54
+ }
55
+ else if (fs.existsSync(telemetryFile)) {
56
+ return `Telemetry file already exists [${telemetryFile}].`;
57
+ }
58
+ return undefined;
59
+ }
60
+ exports.getTelemetryFileValidationError = getTelemetryFileValidationError;
61
+ /**
62
+ * Validate the provided output format and default properties
63
+ * @param format - desired output format of the telemetry
64
+ * @param props - default properties to be added to every telemetry entry
65
+ * @internal
66
+ */
67
+ function validateAndParseTelemetryOptions(format, props) {
68
+ let outputFormat;
69
+ const defaultProps = {};
70
+ if (format) {
71
+ outputFormat = fileLogger_1.OutputFormat[format];
72
+ if (outputFormat === undefined) {
73
+ return { success: false, error: `Invalid telemetry format [${format}]` };
74
+ }
75
+ }
76
+ if (props && props.length > 0) {
77
+ if (props.length % 2 !== 0) {
78
+ return { success: false, error: `Invalid number of telemetry properties to add [${props.length}]` };
79
+ }
80
+ for (let i = 0; i < props.length; i += 2) {
81
+ if (typeof props[i] === "number") {
82
+ return { success: false, error: `Property name cannot be number at index [${i}] -> [${props[i]}]` };
83
+ }
84
+ defaultProps[props[i]] = props[i + 1];
85
+ }
86
+ }
87
+ return { success: true, telemetryOptions: { outputFormat, defaultProps } };
88
+ }
89
+ exports.validateAndParseTelemetryOptions = validateAndParseTelemetryOptions;
90
+ //# sourceMappingURL=loggerUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loggerUtils.js","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,qEAA8D;AAC9D,mDAAgD;AAChD,6CAA4E;AAC5E,qDAAkD;AAElD;;;;;;GAMG;AACF,SAAgB,YAAY,CACzB,QAAgB,EAChB,OAA2B;IAE3B,MAAM,UAAU,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,yBAAY,CAAC,GAAG;QACzD,CAAC,CAAC,IAAI,6BAAa,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;QAC7E,CAAC,CAAC,IAAI,+BAAc,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC,CAAC;IAEnF,MAAM,MAAM,GAAG,6BAAW,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,EAClE,EAAE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAE/C,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAClC,CAAC;AAZA,oCAYA;AAED;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,aAAqB;IACjE,IAAI,CAAC,aAAa,EAAE;QAChB,OAAO,qCAAqC,CAAC;KAChD;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;QACrC,OAAO,kCAAkC,aAAa,IAAI,CAAC;KAC9D;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AARD,0EAQC;AAED;;;;;GAKG;AACH,SAAgB,gCAAgC,CAC5C,MAAe,EACf,KAA2B;IAE3B,IAAI,YAAsC,CAAC;IAC3C,MAAM,YAAY,GAAoC,EAAE,CAAC;IAEzD,IAAI,MAAM,EAAE;QACR,YAAY,GAAG,yBAAY,CAAC,MAAM,CAAC,CAAC;QACpC,IAAI,YAAY,KAAK,SAAS,EAAE;YAC5B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,6BAA6B,MAAM,GAAG,EAAE,CAAC;SAC5E;KACJ;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;QAC3B,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;YACxB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,kDAAkD,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;SACvG;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACtC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBAC9B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,4CAA4C,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;aACvG;YACD,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACzC;KACJ;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,EAAE,CAAC;AAC/E,CAAC;AA3BD,4EA2BC","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 { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { CSVFileLogger } from \"./csvFileLogger\";\nimport { IFileLogger, ITelemetryOptions, OutputFormat } from \"./fileLogger\";\nimport { JSONFileLogger } from \"./jsonFileLogger\";\n\n/**\n * Create a ITelemetryLogger wrapped around provided IFileLogger\n * ! It is expected that all events be sent through the returned \"logger\" value\n * ! The \"fileLogger\" value should have its \"close()\" method called at the end of execution\n * Note: if an output format is not supplied, default is JSON\n * @returns - both the IFileLogger implementation and ITelemetryLogger wrapper to be called\n */\n export function createLogger(\n filePath: string,\n options?: ITelemetryOptions,\n): { logger: ITelemetryLogger; fileLogger: IFileLogger; } {\n const fileLogger = options?.outputFormat === OutputFormat.CSV\n ? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)\n : new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);\n\n const logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\",\n { all: { Event_Time: () => Date.now() } });\n\n return { logger, fileLogger };\n}\n\n/**\n * Validate the telemetryFile command line argument\n * @param telemetryFile - path where telemetry will be written\n */\nexport function getTelemetryFileValidationError(telemetryFile: string): string | undefined {\n if (!telemetryFile) {\n return \"Telemetry file argument is missing.\";\n } else if (fs.existsSync(telemetryFile)) {\n return `Telemetry file already exists [${telemetryFile}].`;\n }\n\n return undefined;\n}\n\n/**\n * Validate the provided output format and default properties\n * @param format - desired output format of the telemetry\n * @param props - default properties to be added to every telemetry entry\n * @internal\n */\nexport function validateAndParseTelemetryOptions(\n format?: string,\n props?: (string | number)[],\n): { success: false; error: string; } | { success: true; telemetryOptions: ITelemetryOptions; } {\n let outputFormat: OutputFormat | undefined;\n const defaultProps: Record<string, string | number> = {};\n\n if (format) {\n outputFormat = OutputFormat[format];\n if (outputFormat === undefined) {\n return { success: false, error: `Invalid telemetry format [${format}]` };\n }\n }\n\n if (props && props.length > 0) {\n if (props.length % 2 !== 0) {\n return { success: false, error: `Invalid number of telemetry properties to add [${props.length}]` };\n }\n for (let i = 0; i < props.length; i += 2) {\n if (typeof props[i] === \"number\") {\n return { success: false, error: `Property name cannot be number at index [${i}] -> [${props[i]}]` };\n }\n defaultProps[props[i]] = props[i + 1];\n }\n }\n\n return { success: true, telemetryOptions: { outputFormat, defaultProps } };\n}\n"]}
@@ -0,0 +1,9 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
+ */
7
+ export declare const pkgName = "@fluidframework/fluid-runner";
8
+ export declare const pkgVersion = "1.2.0";
9
+ //# sourceMappingURL=packageVersion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,UAAU,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ *
6
+ * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.pkgVersion = exports.pkgName = void 0;
10
+ exports.pkgName = "@fluidframework/fluid-runner";
11
+ exports.pkgVersion = "1.2.0";
12
+ //# sourceMappingURL=packageVersion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/fluid-runner\";\nexport const pkgVersion = \"1.2.0\";\n"]}
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IExportFileResponse } from "./exportFile";
6
+ import { ITelemetryOptions } from "./logger/fileLogger";
7
+ /**
8
+ * Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file
9
+ * @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)
10
+ */
11
+ export declare function parseBundleAndExportFile(codeLoader: string, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: ITelemetryOptions): Promise<IExportFileResponse>;
12
+ //# sourceMappingURL=parseBundleAndExportFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBundleAndExportFile.d.ts","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAA6B,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAG9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC1C,UAAU,EAAE,MAAM,EAClB,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,CAkD9B"}