@fluidframework/fluid-runner 2.0.0-internal.1.0.0.82628

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 (79) hide show
  1. package/.eslintrc.js +18 -0
  2. package/LICENSE +21 -0
  3. package/README.md +16 -0
  4. package/bin/fluidRunner +2 -0
  5. package/dist/codeLoaderBundle.d.ts +44 -0
  6. package/dist/codeLoaderBundle.d.ts.map +1 -0
  7. package/dist/codeLoaderBundle.js +17 -0
  8. package/dist/codeLoaderBundle.js.map +1 -0
  9. package/dist/exportFile.d.ts +20 -0
  10. package/dist/exportFile.d.ts.map +1 -0
  11. package/dist/exportFile.js +84 -0
  12. package/dist/exportFile.js.map +1 -0
  13. package/dist/fakeUrlResolver.d.ts +14 -0
  14. package/dist/fakeUrlResolver.d.ts.map +1 -0
  15. package/dist/fakeUrlResolver.js +42 -0
  16. package/dist/fakeUrlResolver.js.map +1 -0
  17. package/dist/fluidRunner.d.ts +6 -0
  18. package/dist/fluidRunner.d.ts.map +1 -0
  19. package/dist/fluidRunner.js +88 -0
  20. package/dist/fluidRunner.js.map +1 -0
  21. package/dist/getArgsValidationError.d.ts +6 -0
  22. package/dist/getArgsValidationError.d.ts.map +1 -0
  23. package/dist/getArgsValidationError.js +54 -0
  24. package/dist/getArgsValidationError.js.map +1 -0
  25. package/dist/index.d.ts +7 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +19 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/logger/FileLogger.d.ts +23 -0
  30. package/dist/logger/FileLogger.d.ts.map +1 -0
  31. package/dist/logger/FileLogger.js +58 -0
  32. package/dist/logger/FileLogger.js.map +1 -0
  33. package/dist/packageVersion.d.ts +9 -0
  34. package/dist/packageVersion.d.ts.map +1 -0
  35. package/dist/packageVersion.js +12 -0
  36. package/dist/packageVersion.js.map +1 -0
  37. package/lib/codeLoaderBundle.d.ts +44 -0
  38. package/lib/codeLoaderBundle.d.ts.map +1 -0
  39. package/lib/codeLoaderBundle.js +13 -0
  40. package/lib/codeLoaderBundle.js.map +1 -0
  41. package/lib/exportFile.d.ts +20 -0
  42. package/lib/exportFile.d.ts.map +1 -0
  43. package/lib/exportFile.js +57 -0
  44. package/lib/exportFile.js.map +1 -0
  45. package/lib/fakeUrlResolver.d.ts +14 -0
  46. package/lib/fakeUrlResolver.d.ts.map +1 -0
  47. package/lib/fakeUrlResolver.js +38 -0
  48. package/lib/fakeUrlResolver.js.map +1 -0
  49. package/lib/fluidRunner.d.ts +6 -0
  50. package/lib/fluidRunner.d.ts.map +1 -0
  51. package/lib/fluidRunner.js +67 -0
  52. package/lib/fluidRunner.js.map +1 -0
  53. package/lib/getArgsValidationError.d.ts +6 -0
  54. package/lib/getArgsValidationError.d.ts.map +1 -0
  55. package/lib/getArgsValidationError.js +31 -0
  56. package/lib/getArgsValidationError.js.map +1 -0
  57. package/lib/index.d.ts +7 -0
  58. package/lib/index.d.ts.map +1 -0
  59. package/lib/index.js +7 -0
  60. package/lib/index.js.map +1 -0
  61. package/lib/logger/FileLogger.d.ts +23 -0
  62. package/lib/logger/FileLogger.d.ts.map +1 -0
  63. package/lib/logger/FileLogger.js +35 -0
  64. package/lib/logger/FileLogger.js.map +1 -0
  65. package/lib/packageVersion.d.ts +9 -0
  66. package/lib/packageVersion.d.ts.map +1 -0
  67. package/lib/packageVersion.js +9 -0
  68. package/lib/packageVersion.js.map +1 -0
  69. package/package.json +86 -0
  70. package/src/codeLoaderBundle.ts +52 -0
  71. package/src/exportFile.ts +94 -0
  72. package/src/fakeUrlResolver.ts +49 -0
  73. package/src/fluidRunner.ts +83 -0
  74. package/src/getArgsValidationError.ts +36 -0
  75. package/src/index.ts +7 -0
  76. package/src/logger/FileLogger.ts +44 -0
  77. package/src/packageVersion.ts +9 -0
  78. package/tsconfig.esnext.json +7 -0
  79. package/tsconfig.json +14 -0
package/.eslintrc.js ADDED
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ module.exports = {
7
+ "extends": [
8
+ require.resolve("@fluidframework/eslint-config-fluid")
9
+ ],
10
+ "parserOptions": {
11
+ "project": ["./tsconfig.json", "./src/test/tsconfig.json"]
12
+ },
13
+ "rules": {
14
+ "@typescript-eslint/no-non-null-assertion": "off",
15
+ "@typescript-eslint/no-use-before-define": "off",
16
+ "@typescript-eslint/strict-boolean-expressions": "off",
17
+ }
18
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation and contributors. All rights reserved.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # @fluidframework/fluid-runner
2
+ This package contains utility for running various functionality inside a Fluid Framework environment.
3
+
4
+ ## Export File
5
+ Allows some execution to be made on a container given a provided ODSP snapshot.
6
+
7
+ ### Sample command
8
+ `node fluidRunner exportFile --codeLoader=compiledBundle.js --inputFile=inputFileName.fluid --outputFolder=outputFolderName --scenario=test --telemetryFile=telemetryFile.txt`
9
+
10
+ ### Code Loader bundle format
11
+ The Code Loader bundle should provide defined exports required for this functionality.
12
+ For more details on what exports are needed, see [codeLoaderBundle.ts](./src/codeLoaderBundle.ts).
13
+
14
+ ### Input file format
15
+ The input file is expected to be an ODSP snapshot.
16
+ For some examples, see the files in the [localOdspSnapshots folder](./src/test/localOdspSnapshots).
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("../dist/fluidRunner.js");
@@ -0,0 +1,44 @@
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
+ import { ICodeDetailsLoader, IContainer } from "@fluidframework/container-definitions";
7
+ import { FluidObject } from "@fluidframework/core-interfaces";
8
+ /**
9
+ * Contract that defines the necessary exports for the bundle provided at runtime
10
+ * For an example, see "src/test/sampleCodeLoader.ts"
11
+ */
12
+ export interface ICodeLoaderBundle {
13
+ /**
14
+ * Fluid export of all the required objects and functions
15
+ */
16
+ fluidExport: Promise<IFluidFileConverter>;
17
+ }
18
+ /**
19
+ * Instance that holds all the details for Fluid file conversion
20
+ */
21
+ export interface IFluidFileConverter {
22
+ /**
23
+ * Code loader details to provide at Loader creation
24
+ */
25
+ codeLoader: ICodeDetailsLoader;
26
+ /**
27
+ * Scope object to provide at Loader creation
28
+ */
29
+ scope?: FluidObject;
30
+ /**
31
+ * Execute code and return the results
32
+ * @param container - container created by this application
33
+ * @param scenario - scenario this execution is related to
34
+ * @param logger - passed through logger object
35
+ * @returns - object containing file names as property keys and file content as values
36
+ */
37
+ execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, string>>;
38
+ }
39
+ /**
40
+ * Type cast to ensure necessary methods are present in the provided bundle
41
+ * @param bundle - bundle provided to this application
42
+ */
43
+ export declare function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle;
44
+ //# sourceMappingURL=codeLoaderBundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeLoaderBundle.d.ts","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAE9D;;;GAGG;AACF,MAAM,WAAW,iBAAiB;IAC/B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,UAAU,EAAE,kBAAkB,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;;;;;OAMG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACnH;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,iBAAiB,CAG3E"}
@@ -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.isCodeLoaderBundle = void 0;
8
+ /**
9
+ * Type cast to ensure necessary methods are present in the provided bundle
10
+ * @param bundle - bundle provided to this application
11
+ */
12
+ function isCodeLoaderBundle(bundle) {
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
14
+ return (bundle === null || bundle === void 0 ? void 0 : bundle.fluidExport) && typeof bundle.fluidExport === "object";
15
+ }
16
+ exports.isCodeLoaderBundle = isCodeLoaderBundle;
17
+ //# sourceMappingURL=codeLoaderBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAyCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC1C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACzE,CAAC;AAHD,gDAGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract that defines the necessary exports for the bundle provided at runtime\n * For an example, see \"src/test/sampleCodeLoader.ts\"\n */\n export interface ICodeLoaderBundle {\n /**\n * Fluid export of all the required objects and functions\n */\n fluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n /**\n * Code loader details to provide at Loader creation\n */\n codeLoader: ICodeDetailsLoader;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Execute code and return the results\n * @param container - container created by this application\n * @param scenario - scenario this execution is related to\n * @param logger - passed through logger object\n * @returns - object containing file names as property keys and file content as values\n */\n execute(container: IContainer, scenario: string, logger: ITelemetryBaseLogger): Promise<Record<string, string>>;\n}\n\n/**\n * Type cast to ensure necessary methods are present in the provided bundle\n * @param bundle - bundle provided to this application\n */\nexport function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n"]}
@@ -0,0 +1,20 @@
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 { IFluidFileConverter } from "./codeLoaderBundle";
7
+ export declare type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
8
+ interface IExportFileResponseSuccess {
9
+ success: true;
10
+ }
11
+ interface IExportFileResponseFailure {
12
+ success: false;
13
+ eventName: string;
14
+ errorMessage: string;
15
+ error?: any;
16
+ }
17
+ export declare function exportFile(codeLoader: string, inputFile: string, outputFolder: string, scenario: string, logger: ITelemetryLogger): Promise<IExportFileResponse>;
18
+ export declare function createContainerAndExecute(localOdspSnapshot: string, fluidFileConverter: IFluidFileConverter, scenario: string, logger: ITelemetryLogger): Promise<Record<string, string>>;
19
+ export {};
20
+ //# sourceMappingURL=exportFile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EAAE,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAG7E,oBAAY,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F,UAAU,0BAA0B;IAChC,OAAO,EAAE,IAAI,CAAC;CACjB;AAED,UAAU,0BAA0B;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACf;AAID,wBAAsB,UAAU,CAC5B,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAoC9B;AAED,wBAAsB,yBAAyB,CAC3C,iBAAiB,EAAE,MAAM,EACzB,kBAAkB,EAAE,mBAAmB,EACvC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,gBAAgB,GACzB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAajC"}
@@ -0,0 +1,84 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.createContainerAndExecute = exports.exportFile = void 0;
30
+ const fs = __importStar(require("fs"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const container_definitions_1 = require("@fluidframework/container-definitions");
33
+ const container_loader_1 = require("@fluidframework/container-loader");
34
+ const odsp_driver_1 = require("@fluidframework/odsp-driver");
35
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
36
+ const getArgsValidationError_1 = require("./getArgsValidationError");
37
+ const codeLoaderBundle_1 = require("./codeLoaderBundle");
38
+ const fakeUrlResolver_1 = require("./fakeUrlResolver");
39
+ const clientArgsValidationError = "Client_ArgsValidationError";
40
+ async function exportFile(codeLoader, inputFile, outputFolder, scenario, logger) {
41
+ try {
42
+ return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
43
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
44
+ const codeLoaderBundle = require(codeLoader);
45
+ if (!(0, codeLoaderBundle_1.isCodeLoaderBundle)(codeLoaderBundle)) {
46
+ const eventName = clientArgsValidationError;
47
+ const message = "Code loader bundle is not of type CodeLoaderBundle";
48
+ return { success: false, eventName, errorMessage: message };
49
+ }
50
+ const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFolder, scenario);
51
+ if (argsValidationError) {
52
+ const eventName = clientArgsValidationError;
53
+ return { success: false, eventName, errorMessage: argsValidationError };
54
+ }
55
+ // TODO: read file stream
56
+ const inputFileContent = fs.readFileSync(inputFile, { encoding: "utf-8" });
57
+ const results = await createContainerAndExecute(inputFileContent, await codeLoaderBundle.fluidExport, scenario, logger);
58
+ // eslint-disable-next-line guard-for-in, no-restricted-syntax
59
+ for (const key in results) {
60
+ fs.appendFileSync(path_1.default.join(outputFolder, key), results[key]);
61
+ }
62
+ return { success: true };
63
+ });
64
+ }
65
+ catch (error) {
66
+ const eventName = "Client_UnexpectedError";
67
+ return { success: false, eventName, errorMessage: "Unexpected error", error };
68
+ }
69
+ }
70
+ exports.exportFile = exportFile;
71
+ async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, scenario, logger) {
72
+ const loader = new container_loader_1.Loader({
73
+ urlResolver: new fakeUrlResolver_1.FakeUrlResolver(),
74
+ documentServiceFactory: (0, odsp_driver_1.createLocalOdspDocumentServiceFactory)(localOdspSnapshot),
75
+ codeLoader: fluidFileConverter.codeLoader,
76
+ scope: fluidFileConverter.scope,
77
+ });
78
+ const container = await loader.resolve({ url: "/fakeUrl/", headers: {
79
+ [container_definitions_1.LoaderHeader.loadMode]: { opsBeforeReturn: "cached" }
80
+ } });
81
+ return telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, scenario, logger));
82
+ }
83
+ exports.createContainerAndExecute = createContainerAndExecute;
84
+ //# sourceMappingURL=exportFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"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","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport path from \"path\";\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\nimport { IFluidFileConverter, isCodeLoaderBundle } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\n\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\ninterface IExportFileResponseSuccess {\n success: true;\n}\n\ninterface IExportFileResponseFailure {\n success: false;\n eventName: string;\n errorMessage: string;\n error?: any;\n}\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\nexport async function exportFile(\n codeLoader: string,\n inputFile: string,\n outputFolder: string,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<IExportFileResponse> {\n try {\n return await PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires\n const codeLoaderBundle = require(codeLoader);\n if (!isCodeLoaderBundle(codeLoaderBundle)) {\n const eventName = clientArgsValidationError;\n const message = \"Code loader bundle is not of type CodeLoaderBundle\";\n return { success: false, eventName, errorMessage: message };\n }\n\n const argsValidationError = getArgsValidationError(inputFile, outputFolder, scenario);\n if (argsValidationError) {\n const eventName = clientArgsValidationError;\n return { success: false, eventName, errorMessage: argsValidationError };\n }\n\n // TODO: read file stream\n const inputFileContent = fs.readFileSync(inputFile, { encoding: \"utf-8\" });\n\n const results = await createContainerAndExecute(\n inputFileContent,\n await codeLoaderBundle.fluidExport,\n scenario,\n logger,\n );\n // eslint-disable-next-line guard-for-in, no-restricted-syntax\n for (const key in results) {\n fs.appendFileSync(path.join(outputFolder, key), results[key]);\n }\n return { success: true };\n });\n } catch (error) {\n const eventName = \"Client_UnexpectedError\";\n return { success: false, eventName, errorMessage: \"Unexpected error\", error };\n }\n}\n\nexport async function createContainerAndExecute(\n localOdspSnapshot: string,\n fluidFileConverter: IFluidFileConverter,\n scenario: string,\n logger: ITelemetryLogger,\n): Promise<Record<string, string>> {\n const loader = new Loader({\n urlResolver: new FakeUrlResolver(),\n documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n codeLoader: fluidFileConverter.codeLoader,\n scope: fluidFileConverter.scope,\n });\n\n const container = await loader.resolve({ url: \"/fakeUrl/\", headers: {\n [LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" } } });\n\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () =>\n fluidFileConverter.execute(container, scenario, logger));\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IRequest } from "@fluidframework/core-interfaces";
6
+ import { IContainerPackageInfo, IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
7
+ /**
8
+ * Fake URL resolver that returns hard coded values on every request
9
+ */
10
+ export declare class FakeUrlResolver implements IUrlResolver {
11
+ resolve(_request: IRequest): Promise<IResolvedUrl | undefined>;
12
+ getAbsoluteUrl(_resolvedUrl: IResolvedUrl, _relativeUrl: string, _packageInfoSource?: IContainerPackageInfo): Promise<string>;
13
+ }
14
+ //# sourceMappingURL=fakeUrlResolver.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,42 @@
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.FakeUrlResolver = void 0;
8
+ const fakeId = "FakeUrlResolver";
9
+ const fakeUrl = "/FakeUrlResolver/";
10
+ /**
11
+ * Fake URL resolver that returns hard coded values on every request
12
+ */
13
+ class FakeUrlResolver {
14
+ async resolve(_request) {
15
+ const fakeOdspResolvedUrl = {
16
+ type: "fluid",
17
+ odspResolvedUrl: true,
18
+ id: fakeId,
19
+ siteUrl: fakeUrl,
20
+ driveId: fakeId,
21
+ itemId: fakeId,
22
+ url: fakeUrl,
23
+ hashedDocumentId: fakeId,
24
+ endpoints: {
25
+ snapshotStorageUrl: fakeUrl,
26
+ attachmentPOSTStorageUrl: fakeUrl,
27
+ attachmentGETStorageUrl: fakeUrl,
28
+ deltaStorageUrl: fakeUrl,
29
+ },
30
+ tokens: {},
31
+ fileName: fakeId,
32
+ summarizer: false,
33
+ fileVersion: fakeId,
34
+ };
35
+ return fakeOdspResolvedUrl;
36
+ }
37
+ async getAbsoluteUrl(_resolvedUrl, _relativeUrl, _packageInfoSource) {
38
+ return "";
39
+ }
40
+ }
41
+ exports.FakeUrlResolver = FakeUrlResolver;
42
+ //# sourceMappingURL=fakeUrlResolver.js.map
@@ -0,0 +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"]}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=fluidRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluidRunner.d.ts","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,88 @@
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
+ const fs = __importStar(require("fs"));
27
+ const yargs = __importStar(require("yargs"));
28
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
29
+ const exportFile_1 = require("./exportFile");
30
+ // eslint-disable-next-line import/no-internal-modules
31
+ const FileLogger_1 = require("./logger/FileLogger");
32
+ function fluidRunner() {
33
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
34
+ yargs
35
+ .strict()
36
+ .version(false)
37
+ .command("exportFile", "Generate an output for a local snapshot",
38
+ // eslint-disable-next-line @typescript-eslint/no-shadow
39
+ (yargs) => yargs
40
+ .option("codeLoader", {
41
+ describe: "Name of the code loader bundle",
42
+ type: "string",
43
+ demandOption: true,
44
+ })
45
+ .option("inputFile", {
46
+ describe: "Name of the file containing local ODSP snapshot",
47
+ type: "string",
48
+ demandOption: true,
49
+ })
50
+ .option("outputFolder", {
51
+ describe: "Name of the output file",
52
+ type: "string",
53
+ demandOption: true,
54
+ })
55
+ .option("scenario", {
56
+ describe: "Name of scenario to invoke",
57
+ type: "string",
58
+ demandOption: true,
59
+ })
60
+ .option("telemetryFile", {
61
+ describe: "Config and session data for telemetry",
62
+ type: "string",
63
+ demandOption: true,
64
+ }),
65
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
66
+ async (argv) => {
67
+ if (fs.existsSync(argv.telemetryFile)) {
68
+ console.error(`Telemetry file already exists [${argv.telemetryFile}]`);
69
+ process.exit(1);
70
+ }
71
+ const fileLogger = new FileLogger_1.FileLogger(argv.telemetryFile);
72
+ const logger = telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", { all: { Event_Time: () => Date.now() } });
73
+ const result = await (0, exportFile_1.exportFile)(argv.codeLoader, argv.inputFile, argv.outputFolder, argv.scenario, logger);
74
+ if (!result.success) {
75
+ console.error(`${result.eventName}: ${result.errorMessage}`);
76
+ logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);
77
+ await fileLogger.flush();
78
+ process.exit(1);
79
+ }
80
+ else {
81
+ await fileLogger.flush();
82
+ }
83
+ })
84
+ .help()
85
+ .demandCommand().argv;
86
+ }
87
+ fluidRunner();
88
+ //# sourceMappingURL=fluidRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,6CAA+B;AAC/B,qEAA8D;AAC9D,6CAA0C;AAC1C,sDAAsD;AACtD,oDAAiD;AAEjD,SAAS,WAAW;IAChB,oEAAoE;IACpE,KAAK;SACA,MAAM,EAAE;SACR,OAAO,CAAC,KAAK,CAAC;SACd,OAAO,CACJ,YAAY,EACZ,yCAAyC;IACzC,wDAAwD;IACxD,CAAC,KAAK,EAAE,EAAE,CACN,KAAK;SACA,MAAM,CAAC,YAAY,EAAE;QAClB,QAAQ,EAAE,gCAAgC;QAC1C,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,WAAW,EAAE;QACjB,QAAQ,EAAE,iDAAiD;QAC3D,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,cAAc,EAAE;QACpB,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,UAAU,EAAE;QAChB,QAAQ,EAAE,4BAA4B;QACtC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;SACD,MAAM,CAAC,eAAe,EAAE;QACrB,QAAQ,EAAE,uCAAuC;QACjD,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,IAAI;KACrB,CAAC;IACV,kEAAkE;IAClE,KAAK,EAAE,IAAI,EAAE,EAAE;QACX,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE;YACnC,OAAO,CAAC,KAAK,CAAC,kCAAkC,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;YACvE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;QAED,MAAM,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAEtD,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;QAE/C,MAAM,MAAM,GAAG,MAAM,IAAA,uBAAU,EAC3B,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,QAAQ,EACb,MAAM,CACT,CAAC;QAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;YAC7D,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YACnG,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;YACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SACnB;aAAM;YACH,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;SAC5B;IACL,CAAC,CACJ;SACA,IAAI,EAAE;SACN,aAAa,EAAE,CAAC,IAAI,CAAC;AAC9B,CAAC;AAED,WAAW,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport * as yargs from \"yargs\";\nimport { ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { exportFile } from \"./exportFile\";\n// eslint-disable-next-line import/no-internal-modules\nimport { FileLogger } from \"./logger/FileLogger\";\n\nfunction fluidRunner() {\n // eslint-disable-next-line @typescript-eslint/no-unused-expressions\n yargs\n .strict()\n .version(false)\n .command(\n \"exportFile\",\n \"Generate an output for a local snapshot\",\n // eslint-disable-next-line @typescript-eslint/no-shadow\n (yargs) =>\n yargs\n .option(\"codeLoader\", {\n describe: \"Name of the code loader bundle\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"inputFile\", {\n describe: \"Name of the file containing local ODSP snapshot\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"outputFolder\", {\n describe: \"Name of the output file\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"scenario\", {\n describe: \"Name of scenario to invoke\",\n type: \"string\",\n demandOption: true,\n })\n .option(\"telemetryFile\", {\n describe: \"Config and session data for telemetry\",\n type: \"string\",\n demandOption: true,\n }),\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (argv) => {\n if (fs.existsSync(argv.telemetryFile)) {\n console.error(`Telemetry file already exists [${argv.telemetryFile}]`);\n process.exit(1);\n }\n\n const fileLogger = new FileLogger(argv.telemetryFile);\n\n const logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\",\n { all: { Event_Time: () => Date.now() } });\n\n const result = await exportFile(\n argv.codeLoader,\n argv.inputFile,\n argv.outputFolder,\n argv.scenario,\n logger,\n );\n\n if (!result.success) {\n console.error(`${result.eventName}: ${result.errorMessage}`);\n logger.sendErrorEvent({ eventName: result.eventName, message: result.errorMessage }, result.error);\n await fileLogger.flush();\n process.exit(1);\n } else {\n await fileLogger.flush();\n }\n },\n )\n .help()\n .demandCommand().argv;\n}\n\nfluidRunner();\n"]}
@@ -0,0 +1,6 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export declare function getArgsValidationError(inputFile: string, outputFolder: string, scenario: string): string | undefined;
6
+ //# sourceMappingURL=getArgsValidationError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getArgsValidationError.d.ts","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,GACjB,MAAM,GAAG,SAAS,CAwBpB"}
@@ -0,0 +1,54 @@
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.getArgsValidationError = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ function getArgsValidationError(inputFile, outputFolder, scenario) {
29
+ // Validate input file
30
+ if (!inputFile) {
31
+ // TODO: Do not log file name. It can be customer content
32
+ return "Input file name is missing.";
33
+ }
34
+ else if (!fs.existsSync(inputFile)) {
35
+ return "Input file does not exist.";
36
+ }
37
+ // Validate output file
38
+ if (!outputFolder) {
39
+ return "Output folder name is missing.";
40
+ }
41
+ else if (!fs.existsSync(outputFolder)) {
42
+ return "Output folder does not exist.";
43
+ }
44
+ else if (fs.existsSync(`${outputFolder}/index.html`)) {
45
+ return "Output file already exists.";
46
+ }
47
+ // Validate scenario name
48
+ if (!scenario) {
49
+ return "Scenario name is missing.";
50
+ }
51
+ return undefined;
52
+ }
53
+ exports.getArgsValidationError = getArgsValidationError;
54
+ //# sourceMappingURL=getArgsValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,SAAgB,sBAAsB,CAClC,SAAiB,EACjB,YAAoB,EACpB,QAAgB;IAEhB,sBAAsB;IACtB,IAAI,CAAC,SAAS,EAAE;QACZ,yDAAyD;QACzD,OAAO,6BAA6B,CAAC;KACxC;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;QAClC,OAAO,4BAA4B,CAAC;KACvC;IAED,uBAAuB;IACvB,IAAI,CAAC,YAAY,EAAE;QACf,OAAO,gCAAgC,CAAC;KAC3C;SAAM,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE;QACrC,OAAO,+BAA+B,CAAC;KAC1C;SAAM,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,YAAY,aAAa,CAAC,EAAE;QACpD,OAAO,6BAA6B,CAAC;KACxC;IAED,yBAAyB;IACzB,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,2BAA2B,CAAC;KACtC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AA5BD,wDA4BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\n\nexport function getArgsValidationError(\n inputFile: string,\n outputFolder: string,\n scenario: string,\n): string | undefined {\n // Validate input file\n if (!inputFile) {\n // TODO: Do not log file name. It can be customer content\n return \"Input file name is missing.\";\n } else if (!fs.existsSync(inputFile)) {\n return \"Input file does not exist.\";\n }\n\n // Validate output file\n if (!outputFolder) {\n return \"Output folder name is missing.\";\n } else if (!fs.existsSync(outputFolder)) {\n return \"Output folder does not exist.\";\n } else if (fs.existsSync(`${outputFolder}/index.html`)) {\n return \"Output file already exists.\";\n }\n\n // Validate scenario name\n if (!scenario) {\n return \"Scenario name is missing.\";\n }\n\n return undefined;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export * from "./codeLoaderBundle";
6
+ export * from "./exportFile";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
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
+ __exportStar(require("./codeLoaderBundle"), exports);
18
+ __exportStar(require("./exportFile"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,qDAAmC;AACnC,+CAA6B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./codeLoaderBundle\";\nexport * from \"./exportFile\";\n"]}
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/common-definitions";
6
+ /**
7
+ * Logger that writes events into a defined file
8
+ */
9
+ export declare class FileLogger implements ITelemetryBaseLogger {
10
+ private readonly filePath;
11
+ private readonly eventsPerFlush;
12
+ supportsTags?: true | undefined;
13
+ /** Hold events in memory until flushed */
14
+ private events;
15
+ /**
16
+ * @param filePath - file path to write logs to
17
+ * @param eventsPerFlush - number of events per flush
18
+ */
19
+ constructor(filePath: string, eventsPerFlush?: number);
20
+ flush(): Promise<void>;
21
+ send(event: ITelemetryBaseEvent): void;
22
+ }
23
+ //# 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;AAGH,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE/F;;GAEG;AACH,qBAAa,UAAW,YAAW,oBAAoB;IAW/C,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,cAAc;IAX5B,YAAY,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAEvC,0CAA0C;IAC1C,OAAO,CAAC,MAAM,CAAgB;IAE9B;;;OAGG;gBAEkB,QAAQ,EAAE,MAAM,EAChB,cAAc,GAAE,MAAW;IAGnC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAO5B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;CAUhD"}