@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,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
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.parseBundleAndExportFile = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
29
+ const codeLoaderBundle_1 = require("./codeLoaderBundle");
30
+ const exportFile_1 = require("./exportFile");
31
+ const getArgsValidationError_1 = require("./getArgsValidationError");
32
+ const loggerUtils_1 = require("./logger/loggerUtils");
33
+ /* eslint-enable import/no-internal-modules */
34
+ const utils_1 = require("./utils");
35
+ const clientArgsValidationError = "Client_ArgsValidationError";
36
+ /**
37
+ * Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file
38
+ * @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)
39
+ */
40
+ async function parseBundleAndExportFile(codeLoader, inputFile, outputFile, telemetryFile, options, telemetryOptions) {
41
+ const telemetryArgError = (0, loggerUtils_1.getTelemetryFileValidationError)(telemetryFile);
42
+ if (telemetryArgError) {
43
+ const eventName = clientArgsValidationError;
44
+ return { success: false, eventName, errorMessage: telemetryArgError };
45
+ }
46
+ const { fileLogger, logger } = (0, loggerUtils_1.createLogger)(telemetryFile, telemetryOptions);
47
+ try {
48
+ return await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, { eventName: "ParseBundleAndExportFile" }, async () => {
49
+ // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
50
+ const codeLoaderBundle = require(codeLoader);
51
+ if (!(0, codeLoaderBundle_1.isCodeLoaderBundle)(codeLoaderBundle)) {
52
+ const eventName = clientArgsValidationError;
53
+ const errorMessage = "Code loader bundle is not of type ICodeLoaderBundle";
54
+ logger.sendErrorEvent({ eventName, message: errorMessage });
55
+ return { success: false, eventName, errorMessage };
56
+ }
57
+ const fluidExport = await codeLoaderBundle.fluidExport;
58
+ if (!(0, codeLoaderBundle_1.isFluidFileConverter)(fluidExport)) {
59
+ const eventName = clientArgsValidationError;
60
+ const errorMessage = "Fluid export from CodeLoaderBundle is not of type IFluidFileConverter";
61
+ logger.sendErrorEvent({ eventName, message: errorMessage });
62
+ return { success: false, eventName, errorMessage };
63
+ }
64
+ const argsValidationError = (0, getArgsValidationError_1.getArgsValidationError)(inputFile, outputFile);
65
+ if (argsValidationError) {
66
+ const eventName = clientArgsValidationError;
67
+ logger.sendErrorEvent({ eventName, message: argsValidationError });
68
+ return { success: false, eventName, errorMessage: argsValidationError };
69
+ }
70
+ fs.writeFileSync(outputFile, await (0, exportFile_1.createContainerAndExecute)((0, utils_1.getSnapshotFileContent)(inputFile), fluidExport, logger, options));
71
+ return { success: true };
72
+ });
73
+ }
74
+ catch (error) {
75
+ const eventName = "Client_UnexpectedError";
76
+ logger.sendErrorEvent({ eventName }, error);
77
+ return { success: false, eventName, errorMessage: "Unexpected error", error };
78
+ }
79
+ finally {
80
+ await fileLogger.close();
81
+ }
82
+ }
83
+ exports.parseBundleAndExportFile = parseBundleAndExportFile;
84
+ //# sourceMappingURL=parseBundleAndExportFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseBundleAndExportFile.js","sourceRoot":"","sources":["../src/parseBundleAndExportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAmE;AACnE,yDAA8E;AAC9E,6CAA8E;AAC9E,qEAAkE;AAGlE,sDAAqF;AACrF,8CAA8C;AAC9C,mCAAiD;AAEjD,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;;GAGG;AACI,KAAK,UAAU,wBAAwB,CAC1C,UAAkB,EAClB,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,E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,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,MAAM,IAAA,sCAAyB,EACxD,IAAA,8BAAsB,EAAC,SAAS,CAAC,EACjC,WAAW,EACX,MAAM,EACN,OAAO,CACV,CAAC,CAAC;YAEH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QAC7B,CAAC,CAAC,CAAC;KACN;IAAC,OAAO,KAAK,EAAE;QACZ,MAAM,SAAS,GAAG,wBAAwB,CAAC;QAC3C,MAAM,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC;KACjF;YAAS;QACN,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;KAC5B;AACL,CAAC;AAzDD,4DAyDC","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 { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { isCodeLoaderBundle, isFluidFileConverter } from \"./codeLoaderBundle\";\nimport { createContainerAndExecute, IExportFileResponse } from \"./exportFile\";\nimport { getArgsValidationError } from \"./getArgsValidationError\";\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 */\nimport { getSnapshotFileContent } from \"./utils\";\n\nconst clientArgsValidationError = \"Client_ArgsValidationError\";\n\n/**\n * Parse a provided JS bundle, execute code on Container based on ODSP snapshot, and write result to file\n * @param codeLoader - path to provided JS bundle that implements ICodeLoaderBundle (see codeLoaderBundle.ts)\n */\nexport async function parseBundleAndExportFile(\n codeLoader: string,\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: \"ParseBundleAndExportFile\" }, 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 errorMessage = \"Code loader bundle is not of type ICodeLoaderBundle\";\n logger.sendErrorEvent({ eventName, message: errorMessage });\n return { success: false, eventName, errorMessage };\n }\n\n const fluidExport = await codeLoaderBundle.fluidExport;\n if (!isFluidFileConverter(fluidExport)) {\n const eventName = clientArgsValidationError;\n const errorMessage = \"Fluid export from CodeLoaderBundle is not of type IFluidFileConverter\";\n logger.sendErrorEvent({ eventName, message: errorMessage });\n return { success: false, eventName, errorMessage };\n }\n\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 fluidExport,\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"]}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /// <reference types="node" />
6
+ import { IFluidFileConverter } from "./codeLoaderBundle";
7
+ /**
8
+ * Is the given snapshot in JSON format
9
+ * @param content - snapshot file content
10
+ * @internal
11
+ */
12
+ export declare function isJsonSnapshot(content: Buffer): boolean;
13
+ /**
14
+ * Get the ODSP snapshot file content
15
+ * Works on both JSON and binary snapshot formats
16
+ * @param filePath - path to the ODSP snapshot file
17
+ */
18
+ export declare function getSnapshotFileContent(filePath: string): string | Buffer;
19
+ /**
20
+ * Validate provided command line arguments
21
+ * @internal
22
+ */
23
+ export declare function validateCommandLineArgs(codeLoader?: string, fluidFileConverter?: IFluidFileConverter): string | undefined;
24
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAGH,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAIxE;AAED;;;GAGG;AACF,wBAAgB,uBAAuB,CACpC,UAAU,CAAC,EAAE,MAAM,EACnB,kBAAkB,CAAC,EAAE,mBAAmB,GACzC,MAAM,GAAG,SAAS,CASpB"}
package/dist/utils.js ADDED
@@ -0,0 +1,63 @@
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.validateCommandLineArgs = exports.getSnapshotFileContent = exports.isJsonSnapshot = void 0;
27
+ const fs = __importStar(require("fs"));
28
+ /**
29
+ * Is the given snapshot in JSON format
30
+ * @param content - snapshot file content
31
+ * @internal
32
+ */
33
+ function isJsonSnapshot(content) {
34
+ return content.toString(undefined, 0, 1) === "{";
35
+ }
36
+ exports.isJsonSnapshot = isJsonSnapshot;
37
+ /**
38
+ * Get the ODSP snapshot file content
39
+ * Works on both JSON and binary snapshot formats
40
+ * @param filePath - path to the ODSP snapshot file
41
+ */
42
+ function getSnapshotFileContent(filePath) {
43
+ // TODO: read file stream
44
+ const content = fs.readFileSync(filePath);
45
+ return isJsonSnapshot(content) ? content.toString() : content;
46
+ }
47
+ exports.getSnapshotFileContent = getSnapshotFileContent;
48
+ /**
49
+ * Validate provided command line arguments
50
+ * @internal
51
+ */
52
+ function validateCommandLineArgs(codeLoader, fluidFileConverter) {
53
+ if (codeLoader && fluidFileConverter !== undefined) {
54
+ return "\"codeLoader\" and \"fluidFileConverter\" cannot both be provided. See README for details.";
55
+ }
56
+ if (!codeLoader && fluidFileConverter === undefined) {
57
+ // eslint-disable-next-line max-len
58
+ return "\"codeLoader\" must be provided if there is no explicit \"fluidFileConverter\". See README for details.";
59
+ }
60
+ return undefined;
61
+ }
62
+ exports.validateCommandLineArgs = validateCommandLineArgs;
63
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAGzB;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAe;IAC1C,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC;AACrD,CAAC;AAFD,wCAEC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,QAAgB;IACnD,yBAAyB;IACzB,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;AAClE,CAAC;AAJD,wDAIC;AAED;;;GAGG;AACF,SAAgB,uBAAuB,CACpC,UAAmB,EACnB,kBAAwC;IAExC,IAAI,UAAU,IAAI,kBAAkB,KAAK,SAAS,EAAE;QAChD,OAAO,4FAA4F,CAAC;KACvG;IACD,IAAI,CAAC,UAAU,IAAI,kBAAkB,KAAK,SAAS,EAAE;QACjD,mCAAmC;QACnC,OAAO,yGAAyG,CAAC;KACpH;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAZA,0DAYA","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 { IFluidFileConverter } from \"./codeLoaderBundle\";\n\n/**\n * Is the given snapshot in JSON format\n * @param content - snapshot file content\n * @internal\n */\nexport function isJsonSnapshot(content: Buffer): boolean {\n return content.toString(undefined, 0, 1) === \"{\";\n}\n\n/**\n * Get the ODSP snapshot file content\n * Works on both JSON and binary snapshot formats\n * @param filePath - path to the ODSP snapshot file\n */\nexport function getSnapshotFileContent(filePath: string): string | Buffer {\n // TODO: read file stream\n const content = fs.readFileSync(filePath);\n return isJsonSnapshot(content) ? content.toString() : content;\n}\n\n/**\n * Validate provided command line arguments\n * @internal\n */\n export function validateCommandLineArgs(\n codeLoader?: string,\n fluidFileConverter?: IFluidFileConverter,\n): string | undefined {\n if (codeLoader && fluidFileConverter !== undefined) {\n return \"\\\"codeLoader\\\" and \\\"fluidFileConverter\\\" cannot both be provided. See README for details.\";\n }\n if (!codeLoader && fluidFileConverter === undefined) {\n // eslint-disable-next-line max-len\n return \"\\\"codeLoader\\\" must be provided if there is no explicit \\\"fluidFileConverter\\\". See README for details.\";\n }\n return undefined;\n}\n"]}
@@ -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/sampleCodeLoaders/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
+ * Get code loader details to provide at Loader creation
24
+ * @param logger - created logger object to pass to code loader
25
+ */
26
+ getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
27
+ /**
28
+ * Scope object to provide at Loader creation
29
+ */
30
+ scope?: FluidObject;
31
+ /**
32
+ * Executes code on container and returns the result
33
+ * @param container - container created by this application
34
+ * @param options - additional options
35
+ */
36
+ execute(container: IContainer, options?: string): Promise<string>;
37
+ }
38
+ /**
39
+ * Type cast to ensure necessary methods are present in the provided bundle
40
+ * @param bundle - bundle provided to this application
41
+ */
42
+ export declare function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle;
43
+ export declare function isFluidFileConverter(obj: any): obj is IFluidFileConverter;
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;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzE;;OAEG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IAEpB;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACrE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,IAAI,iBAAiB,CAG3E;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,mBAAmB,CAIzE"}
@@ -0,0 +1,18 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Type cast to ensure necessary methods are present in the provided bundle
7
+ * @param bundle - bundle provided to this application
8
+ */
9
+ export function isCodeLoaderBundle(bundle) {
10
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
11
+ return (bundle === null || bundle === void 0 ? void 0 : bundle.fluidExport) && typeof bundle.fluidExport === "object";
12
+ }
13
+ export function isFluidFileConverter(obj) {
14
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
15
+ return (obj === null || obj === void 0 ? void 0 : obj.getCodeLoader) && typeof obj.getCodeLoader === "function"
16
+ && obj.execute && typeof obj.execute === "function";
17
+ }
18
+ //# sourceMappingURL=codeLoaderBundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwCH;;;GAGG;AACH,MAAM,UAAU,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;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IACzC,+DAA+D;IAC/D,OAAO,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa,KAAI,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;WAC7D,GAAG,CAAC,OAAO,IAAI,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CAAC;AAC5D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { FluidObject } from \"@fluidframework/core-interfaces\";\n\n/**\n * Contract that defines the necessary exports for the bundle provided at runtime\n * For an example, see \"src/test/sampleCodeLoaders/sampleCodeLoader.ts\"\n */\nexport interface ICodeLoaderBundle {\n /**\n * Fluid export of all the required objects and functions\n */\n fluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n /**\n * Get code loader details to provide at Loader creation\n * @param logger - created logger object to pass to code loader\n */\n getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n /**\n * Scope object to provide at Loader creation\n */\n scope?: FluidObject;\n\n /**\n * Executes code on container and returns the result\n * @param container - container created by this application\n * @param options - additional options\n */\n execute(container: IContainer, options?: string): Promise<string>;\n}\n\n/**\n * Type cast to ensure necessary methods are present in the provided bundle\n * @param bundle - bundle provided to this application\n */\nexport function isCodeLoaderBundle(bundle: any): bundle is ICodeLoaderBundle {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return obj?.getCodeLoader && typeof obj.getCodeLoader === \"function\"\n && obj.execute && typeof obj.execute === \"function\";\n}\n"]}
@@ -0,0 +1,28 @@
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
+ import { ITelemetryOptions } from "./logger/fileLogger";
8
+ export declare type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;
9
+ interface IExportFileResponseSuccess {
10
+ success: true;
11
+ }
12
+ interface IExportFileResponseFailure {
13
+ success: false;
14
+ eventName: string;
15
+ errorMessage: string;
16
+ error?: any;
17
+ }
18
+ /**
19
+ * Execute code on Container based on ODSP snapshot and write result to file
20
+ */
21
+ export declare function exportFile(fluidFileConverter: IFluidFileConverter, inputFile: string, outputFile: string, telemetryFile: string, options?: string, telemetryOptions?: ITelemetryOptions): Promise<IExportFileResponse>;
22
+ /**
23
+ * Create the container based on an ODSP snapshot and execute code on it
24
+ * @returns result of execution
25
+ */
26
+ export declare function createContainerAndExecute(localOdspSnapshot: string | Uint8Array, fluidFileConverter: IFluidFileConverter, logger: ITelemetryLogger, options?: string): Promise<string>;
27
+ export {};
28
+ //# sourceMappingURL=exportFile.d.ts.map
@@ -0,0 +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;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"}
@@ -0,0 +1,63 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import * as fs from "fs";
6
+ import { LoaderHeader } from "@fluidframework/container-definitions";
7
+ import { Loader } from "@fluidframework/container-loader";
8
+ import { createLocalOdspDocumentServiceFactory } from "@fluidframework/odsp-driver";
9
+ import { PerformanceEvent } from "@fluidframework/telemetry-utils";
10
+ import { getArgsValidationError } from "./getArgsValidationError";
11
+ import { FakeUrlResolver } from "./fakeUrlResolver";
12
+ import { getSnapshotFileContent } from "./utils";
13
+ import { createLogger, getTelemetryFileValidationError } from "./logger/loggerUtils";
14
+ const clientArgsValidationError = "Client_ArgsValidationError";
15
+ /**
16
+ * Execute code on Container based on ODSP snapshot and write result to file
17
+ */
18
+ export async function exportFile(fluidFileConverter, inputFile, outputFile, telemetryFile, options, telemetryOptions) {
19
+ const telemetryArgError = getTelemetryFileValidationError(telemetryFile);
20
+ if (telemetryArgError) {
21
+ const eventName = clientArgsValidationError;
22
+ return { success: false, eventName, errorMessage: telemetryArgError };
23
+ }
24
+ const { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);
25
+ try {
26
+ return await PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
27
+ const argsValidationError = getArgsValidationError(inputFile, outputFile);
28
+ if (argsValidationError) {
29
+ const eventName = clientArgsValidationError;
30
+ logger.sendErrorEvent({ eventName, message: argsValidationError });
31
+ return { success: false, eventName, errorMessage: argsValidationError };
32
+ }
33
+ fs.writeFileSync(outputFile, await createContainerAndExecute(getSnapshotFileContent(inputFile), fluidFileConverter, logger, options));
34
+ return { success: true };
35
+ });
36
+ }
37
+ catch (error) {
38
+ const eventName = "Client_UnexpectedError";
39
+ logger.sendErrorEvent({ eventName }, error);
40
+ return { success: false, eventName, errorMessage: "Unexpected error", error };
41
+ }
42
+ finally {
43
+ await fileLogger.close();
44
+ }
45
+ }
46
+ /**
47
+ * Create the container based on an ODSP snapshot and execute code on it
48
+ * @returns result of execution
49
+ */
50
+ export async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options) {
51
+ const loader = new Loader({
52
+ urlResolver: new FakeUrlResolver(),
53
+ documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
54
+ codeLoader: await fluidFileConverter.getCodeLoader(logger),
55
+ scope: fluidFileConverter.scope,
56
+ logger,
57
+ });
58
+ const container = await loader.resolve({ url: "/fakeUrl/", headers: {
59
+ [LoaderHeader.loadMode]: { opsBeforeReturn: "cached" }
60
+ } });
61
+ return PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => fluidFileConverter.execute(container, options));
62
+ }
63
+ //# sourceMappingURL=exportFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,+BAA+B,EAAE,MAAM,sBAAsB,CAAC;AAgBrF,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC5B,kBAAuC,EACvC,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB,EAChB,gBAAoC;IAEpC,MAAM,iBAAiB,GAAG,+BAA+B,CAAC,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,YAAY,CAAC,aAAa,EAAE,gB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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,YAAY,CAAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;SAAE,EAAE,CAAC,CAAC;IAEhE,OAAO,gBAAgB,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","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"]}
@@ -0,0 +1,15 @@
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
+ * @internal
10
+ */
11
+ export declare class FakeUrlResolver implements IUrlResolver {
12
+ resolve(_request: IRequest): Promise<IResolvedUrl | undefined>;
13
+ getAbsoluteUrl(_resolvedUrl: IResolvedUrl, _relativeUrl: string, _packageInfoSource?: IContainerPackageInfo): Promise<string>;
14
+ }
15
+ //# 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;;;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"}
@@ -0,0 +1,39 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ const fakeId = "FakeUrlResolver";
6
+ const fakeUrl = "/FakeUrlResolver/";
7
+ /**
8
+ * Fake URL resolver that returns hard coded values on every request
9
+ * @internal
10
+ */
11
+ export class FakeUrlResolver {
12
+ async resolve(_request) {
13
+ const fakeOdspResolvedUrl = {
14
+ type: "fluid",
15
+ odspResolvedUrl: true,
16
+ id: fakeId,
17
+ siteUrl: fakeUrl,
18
+ driveId: fakeId,
19
+ itemId: fakeId,
20
+ url: fakeUrl,
21
+ hashedDocumentId: fakeId,
22
+ endpoints: {
23
+ snapshotStorageUrl: fakeUrl,
24
+ attachmentPOSTStorageUrl: fakeUrl,
25
+ attachmentGETStorageUrl: fakeUrl,
26
+ deltaStorageUrl: fakeUrl,
27
+ },
28
+ tokens: {},
29
+ fileName: fakeId,
30
+ summarizer: false,
31
+ fileVersion: fakeId,
32
+ };
33
+ return fakeOdspResolvedUrl;
34
+ }
35
+ async getAbsoluteUrl(_resolvedUrl, _relativeUrl, _packageInfoSource) {
36
+ return "";
37
+ }
38
+ }
39
+ //# 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;;;GAGG;AACH,MAAM,OAAO,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","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"]}
@@ -0,0 +1,10 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IFluidFileConverter } from "./codeLoaderBundle";
6
+ /**
7
+ * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
8
+ */
9
+ export declare function fluidRunner(fluidFileConverter?: IFluidFileConverter): void;
10
+ //# sourceMappingURL=fluidRunner.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,83 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /* eslint-disable max-len */
6
+ import * as yargs from "yargs";
7
+ import { exportFile } from "./exportFile";
8
+ import { parseBundleAndExportFile } from "./parseBundleAndExportFile";
9
+ // eslint-disable-next-line import/no-internal-modules
10
+ import { validateAndParseTelemetryOptions } from "./logger/loggerUtils";
11
+ import { validateCommandLineArgs } from "./utils";
12
+ /**
13
+ * @param fluidFileConverter - needs to be provided if "codeLoaderBundle" is not and vice versa
14
+ */
15
+ export function fluidRunner(fluidFileConverter) {
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
17
+ yargs
18
+ .strict()
19
+ .version(false)
20
+ .command("exportFile", "Generate an output for a local ODSP snapshot",
21
+ // eslint-disable-next-line @typescript-eslint/no-shadow
22
+ (yargs) => yargs
23
+ .option("codeLoader", {
24
+ describe: "Path to code loader bundle. Required if this application is being called without modification.\nSee \"README.md\" for more details.",
25
+ type: "string",
26
+ demandOption: false,
27
+ })
28
+ .option("inputFile", {
29
+ describe: "Path to local ODSP snapshot",
30
+ type: "string",
31
+ demandOption: true,
32
+ })
33
+ .option("outputFile", {
34
+ describe: "Path of output file (cannot already exist).\nExecution result will be written here",
35
+ type: "string",
36
+ demandOption: true,
37
+ })
38
+ .option("telemetryFile", {
39
+ describe: "Path of telemetry file for config and session data (cannot already exist)",
40
+ type: "string",
41
+ demandOption: true,
42
+ })
43
+ .option("options", {
44
+ describe: "Additional options passed to container on execution",
45
+ type: "string",
46
+ demandOption: false,
47
+ })
48
+ .option("telemetryFormat", {
49
+ describe: "Output format for telemetry. Current options are: [\"JSON\", \"CSV\"]",
50
+ type: "string",
51
+ demandOption: false,
52
+ default: "JSON",
53
+ })
54
+ .option("telemetryProp", {
55
+ describe: "Property to add to every telemetry entry. Formatted like \"--telemetryProp prop1 value1 --telemetryProp prop2 \\\"value 2\\\"\".",
56
+ type: "array",
57
+ demandOption: false,
58
+ }),
59
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
60
+ async (argv) => {
61
+ const argsError = validateCommandLineArgs(argv.codeLoader, fluidFileConverter);
62
+ if (argsError) {
63
+ console.error(argsError);
64
+ process.exit(1);
65
+ }
66
+ const telemetryOptionsResult = validateAndParseTelemetryOptions(argv.telemetryFormat, argv.telemetryProp);
67
+ if (!telemetryOptionsResult.success) {
68
+ console.error(telemetryOptionsResult.error);
69
+ process.exit(1);
70
+ }
71
+ const result = await (argv.codeLoader
72
+ ? parseBundleAndExportFile(argv.codeLoader, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions) : exportFile(fluidFileConverter, argv.inputFile, argv.outputFile, argv.telemetryFile, argv.options, telemetryOptionsResult.telemetryOptions));
73
+ if (!result.success) {
74
+ console.error(`${result.eventName}: ${result.errorMessage}`);
75
+ process.exit(1);
76
+ }
77
+ })
78
+ .help()
79
+ .demandCommand().argv;
80
+ }
81
+ fluidRunner();
82
+ /* eslint-enable max-len */
83
+ //# sourceMappingURL=fluidRunner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fluidRunner.js","sourceRoot":"","sources":["../src/fluidRunner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,4BAA4B;AAC5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,wBAAwB,EAAE,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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"]}
@@ -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, outputFile: 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,UAAU,EAAE,MAAM,GACnB,MAAM,GAAG,SAAS,CAgBpB"}
@@ -0,0 +1,23 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import * as fs from "fs";
6
+ export function getArgsValidationError(inputFile, outputFile) {
7
+ // Validate input file
8
+ if (!inputFile) {
9
+ return "Input file name argument is missing.";
10
+ }
11
+ else if (!fs.existsSync(inputFile)) {
12
+ return "Input file does not exist.";
13
+ }
14
+ // Validate output file
15
+ if (!outputFile) {
16
+ return "Output file argument is missing.";
17
+ }
18
+ else if (fs.existsSync(outputFile)) {
19
+ return `Output file already exists [${outputFile}].`;
20
+ }
21
+ return undefined;
22
+ }
23
+ //# sourceMappingURL=getArgsValidationError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getArgsValidationError.js","sourceRoot":"","sources":["../src/getArgsValidationError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,MAAM,UAAU,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","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/lib/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ export { ICodeLoaderBundle, IFluidFileConverter } from "./codeLoaderBundle";
6
+ export * from "./exportFile";
7
+ export { fluidRunner } from "./fluidRunner";
8
+ export { OutputFormat } from "./logger/fileLogger";
9
+ export { createLogger, getTelemetryFileValidationError } from "./logger/loggerUtils";
10
+ export * from "./parseBundleAndExportFile";
11
+ export { getSnapshotFileContent } from "./utils";
12
+ //# sourceMappingURL=index.d.ts.map