@fluidframework/fluid-runner 2.0.0-dev.5.3.2.178189 → 2.0.0-dev.6.4.0.191258

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 (63) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +5 -3
  3. package/dist/codeLoaderBundle.js +2 -2
  4. package/dist/codeLoaderBundle.js.map +1 -1
  5. package/dist/exportFile.js +1 -2
  6. package/dist/exportFile.js.map +1 -1
  7. package/dist/logger/baseFileLogger.js +1 -1
  8. package/dist/logger/baseFileLogger.js.map +1 -1
  9. package/dist/logger/loggerUtils.d.ts +11 -5
  10. package/dist/logger/loggerUtils.d.ts.map +1 -1
  11. package/dist/logger/loggerUtils.js +20 -10
  12. package/dist/logger/loggerUtils.js.map +1 -1
  13. package/package.json +21 -25
  14. package/src/logger/loggerUtils.ts +18 -8
  15. package/lib/codeLoaderBundle.d.ts +0 -44
  16. package/lib/codeLoaderBundle.d.ts.map +0 -1
  17. package/lib/codeLoaderBundle.js +0 -20
  18. package/lib/codeLoaderBundle.js.map +0 -1
  19. package/lib/exportFile.d.ts +0 -28
  20. package/lib/exportFile.d.ts.map +0 -1
  21. package/lib/exportFile.js +0 -91
  22. package/lib/exportFile.js.map +0 -1
  23. package/lib/fakeUrlResolver.d.ts +0 -15
  24. package/lib/fakeUrlResolver.d.ts.map +0 -1
  25. package/lib/fakeUrlResolver.js +0 -39
  26. package/lib/fakeUrlResolver.js.map +0 -1
  27. package/lib/fluidRunner.d.ts +0 -10
  28. package/lib/fluidRunner.d.ts.map +0 -1
  29. package/lib/fluidRunner.js +0 -98
  30. package/lib/fluidRunner.js.map +0 -1
  31. package/lib/index.d.ts +0 -12
  32. package/lib/index.d.ts.map +0 -1
  33. package/lib/index.js +0 -12
  34. package/lib/index.js.map +0 -1
  35. package/lib/logger/baseFileLogger.d.ts +0 -28
  36. package/lib/logger/baseFileLogger.d.ts.map +0 -1
  37. package/lib/logger/baseFileLogger.js +0 -49
  38. package/lib/logger/baseFileLogger.js.map +0 -1
  39. package/lib/logger/csvFileLogger.d.ts +0 -18
  40. package/lib/logger/csvFileLogger.d.ts.map +0 -1
  41. package/lib/logger/csvFileLogger.js +0 -37
  42. package/lib/logger/csvFileLogger.js.map +0 -1
  43. package/lib/logger/fileLogger.d.ts +0 -37
  44. package/lib/logger/fileLogger.d.ts.map +0 -1
  45. package/lib/logger/fileLogger.js +0 -14
  46. package/lib/logger/fileLogger.js.map +0 -1
  47. package/lib/logger/jsonFileLogger.d.ts +0 -14
  48. package/lib/logger/jsonFileLogger.d.ts.map +0 -1
  49. package/lib/logger/jsonFileLogger.js +0 -21
  50. package/lib/logger/jsonFileLogger.js.map +0 -1
  51. package/lib/logger/loggerUtils.d.ts +0 -35
  52. package/lib/logger/loggerUtils.d.ts.map +0 -1
  53. package/lib/logger/loggerUtils.js +0 -78
  54. package/lib/logger/loggerUtils.js.map +0 -1
  55. package/lib/parseBundleAndExportFile.d.ts +0 -12
  56. package/lib/parseBundleAndExportFile.d.ts.map +0 -1
  57. package/lib/parseBundleAndExportFile.js +0 -60
  58. package/lib/parseBundleAndExportFile.js.map +0 -1
  59. package/lib/utils.d.ts +0 -32
  60. package/lib/utils.d.ts.map +0 -1
  61. package/lib/utils.js +0 -75
  62. package/lib/utils.js.map +0 -1
  63. package/tsconfig.esnext.json +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,52 @@
1
1
  # @fluidframework/fluid-runner
2
2
 
3
+ ## 2.0.0-internal.6.3.0
4
+
5
+ Dependency updates only.
6
+
7
+ ## 2.0.0-internal.6.2.0
8
+
9
+ ### Minor Changes
10
+
11
+ - Remove use of @fluidframework/common-definitions ([#16638](https://github.com/microsoft/FluidFramework/issues/16638)) [a8c81509c9](https://github.com/microsoft/FluidFramework/commits/a8c81509c9bf09cfb2092ebcf7265205f9eb6dbf)
12
+
13
+ The **@fluidframework/common-definitions** package is being deprecated, so the following interfaces and types are now
14
+ imported from the **@fluidframework/core-interfaces** package:
15
+
16
+ - interface IDisposable
17
+ - interface IErrorEvent
18
+ - interface IErrorEvent
19
+ - interface IEvent
20
+ - interface IEventProvider
21
+ - interface ILoggingError
22
+ - interface ITaggedTelemetryPropertyType
23
+ - interface ITelemetryBaseEvent
24
+ - interface ITelemetryBaseLogger
25
+ - interface ITelemetryErrorEvent
26
+ - interface ITelemetryGenericEvent
27
+ - interface ITelemetryLogger
28
+ - interface ITelemetryPerformanceEvent
29
+ - interface ITelemetryProperties
30
+ - type ExtendEventProvider
31
+ - type IEventThisPlaceHolder
32
+ - type IEventTransformer
33
+ - type ReplaceIEventThisPlaceHolder
34
+ - type ReplaceIEventThisPlaceHolder
35
+ - type TelemetryEventCategory
36
+ - type TelemetryEventPropertyType
37
+
38
+ ## 2.0.0-internal.6.1.0
39
+
40
+ Dependency updates only.
41
+
42
+ ## 2.0.0-internal.6.0.0
43
+
44
+ Dependency updates only.
45
+
46
+ ## 2.0.0-internal.5.4.0
47
+
48
+ Dependency updates only.
49
+
3
50
  ## 2.0.0-internal.5.3.0
4
51
 
5
52
  Dependency updates only.
package/README.md CHANGED
@@ -24,10 +24,12 @@ For more details on what exports are needed, see [codeLoaderBundle.ts](./src/cod
24
24
  You may notice the command line argument `codeLoader` is optional. If you choose not to provide a value for `codeLoader`, you must extend this library
25
25
  and provide a [`IFluidFileConverter`](./src/codeLoaderBundle.ts) implementation to the [`fluidRunner(...)`](./src/fluidRunner.ts) method.
26
26
 
27
- ```
27
+ ```typescript
28
28
  import { fluidRunner } from "@fluidframework/fluid-runner";
29
29
 
30
- fluidRunner({ /* IFluidFileConverter implementation here */ });
30
+ fluidRunner({
31
+ /* IFluidFileConverter implementation here */
32
+ });
31
33
  ```
32
34
 
33
35
  > **Note**: Only one of `codeLoader` or `fluidRunner(...)` argument is allowed. If both or none are provided, an error will be thrown at the start of execution.
@@ -72,7 +74,7 @@ Example of invalid usages:
72
74
 
73
75
  The code around `exportFile` can be consumed in multiple different layers. It is not necessary to run all this code fully as is, and the following are some interesting code bits involved in this workflow:
74
76
 
75
- - [`createLogger(...)`](./src/logger/fileLogger.ts)
77
+ - [`createLogger(...)`](./src/logger/loggerUtils.ts)
76
78
  - Creates and wraps an `IFileLogger` and adds some useful telemetry data to every entry
77
79
  - [`createContainerAndExecute(...)`](./src/exportFile.ts)
78
80
  - This is the core logic for running some action based on a local ODSP snapshot
@@ -11,12 +11,12 @@ exports.isFluidFileConverter = exports.isCodeLoaderBundle = void 0;
11
11
  */
12
12
  function isCodeLoaderBundle(bundle) {
13
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";
14
+ return bundle?.fluidExport && typeof bundle.fluidExport === "object";
15
15
  }
16
16
  exports.isCodeLoaderBundle = isCodeLoaderBundle;
17
17
  function isFluidFileConverter(obj) {
18
18
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
19
- return ((obj === null || obj === void 0 ? void 0 : obj.getCodeLoader) &&
19
+ return (obj?.getCodeLoader &&
20
20
  typeof obj.getCodeLoader === "function" &&
21
21
  obj.execute &&
22
22
  typeof obj.execute === "function");
@@ -1 +1 @@
1
- {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC7C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACtE,CAAC;AAHD,gDAGC;AAED,SAAgB,oBAAoB,CAAC,GAAQ;IAC5C,+DAA+D;IAC/D,OAAO,CACN,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa;QAClB,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;QACvC,GAAG,CAAC,OAAO;QACX,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CACjC,CAAC;AACH,CAAC;AARD,oDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { ITelemetryBaseLogger, 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\t/**\n\t * Fluid export of all the required objects and functions\n\t */\n\tfluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n\t/**\n\t * Get code loader details to provide at Loader creation\n\t * @param logger - created logger object to pass to code loader\n\t */\n\tgetCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n\t/**\n\t * Get scope object to provide at Loader creation\n\t * @param logger - created logger object to pass to scope object\n\t */\n\tgetScope?(logger: ITelemetryBaseLogger): Promise<FluidObject>;\n\n\t/**\n\t * Executes code on container and returns the result\n\t * @param container - container created by this application\n\t * @param options - additional options\n\t */\n\texecute(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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn (\n\t\tobj?.getCodeLoader &&\n\t\ttypeof obj.getCodeLoader === \"function\" &&\n\t\tobj.execute &&\n\t\ttypeof obj.execute === \"function\"\n\t);\n}\n"]}
1
+ {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAwCH;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAW;IAC7C,+DAA+D;IAC/D,OAAO,MAAM,EAAE,WAAW,IAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACtE,CAAC;AAHD,gDAGC;AAED,SAAgB,oBAAoB,CAAC,GAAQ;IAC5C,+DAA+D;IAC/D,OAAO,CACN,GAAG,EAAE,aAAa;QAClB,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;QACvC,GAAG,CAAC,OAAO;QACX,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CACjC,CAAC;AACH,CAAC;AARD,oDAQC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { ITelemetryBaseLogger, 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\t/**\n\t * Fluid export of all the required objects and functions\n\t */\n\tfluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n\t/**\n\t * Get code loader details to provide at Loader creation\n\t * @param logger - created logger object to pass to code loader\n\t */\n\tgetCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n\t/**\n\t * Get scope object to provide at Loader creation\n\t * @param logger - created logger object to pass to scope object\n\t */\n\tgetScope?(logger: ITelemetryBaseLogger): Promise<FluidObject>;\n\n\t/**\n\t * Executes code on container and returns the result\n\t * @param container - container created by this application\n\t * @param options - additional options\n\t */\n\texecute(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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn (\n\t\tobj?.getCodeLoader &&\n\t\ttypeof obj.getCodeLoader === \"function\" &&\n\t\tobj.execute &&\n\t\ttypeof obj.execute === \"function\"\n\t);\n}\n"]}
@@ -71,7 +71,6 @@ exports.exportFile = exportFile;
71
71
  */
72
72
  async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter, logger, options, timeout, disableNetworkFetch = false) {
73
73
  const fn = async () => {
74
- var _a;
75
74
  if (disableNetworkFetch) {
76
75
  global.fetch = async () => {
77
76
  throw new Error("Network fetch is not allowed");
@@ -81,7 +80,7 @@ async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter,
81
80
  urlResolver: new fakeUrlResolver_1.FakeUrlResolver(),
82
81
  documentServiceFactory: (0, odsp_driver_1.createLocalOdspDocumentServiceFactory)(localOdspSnapshot),
83
82
  codeLoader: await fluidFileConverter.getCodeLoader(logger),
84
- scope: await ((_a = fluidFileConverter.getScope) === null || _a === void 0 ? void 0 : _a.call(fluidFileConverter, logger)),
83
+ scope: await fluidFileConverter.getScope?.(logger),
85
84
  logger,
86
85
  });
87
86
  const container = await loader.resolve({
@@ -1 +1 @@
1
- {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAwF;AACxF,iFAAqE;AACrE,uEAA0D;AAC1D,6DAAoF;AAEpF,uDAAoD;AACpD,mCAAyF;AAGzF,sDAAqF;AAgBrF,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;GAEG;AACI,K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AkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aAC5D;oBAAS;gBACT,SAAS,CAAC,OAAO,EAAE,CAAC;aACpB;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,kDAAkD;IAClD,IAAI,OAAO,KAAK,SAAS,EAAE;QAC1B,OAAO,IAAA,sBAAc,EAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,EAAE,EAAE;iBACF,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC/B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC,EAAE,OAAO,CAAC,CAAC;KACZ;SAAM;QACN,OAAO,EAAE,EAAE,CAAC;KACZ;AACF,CAAC;AAjDD,8DAiDC","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 { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\nimport { getSnapshotFileContent, timeoutPromise, getArgsValidationError } 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\tsuccess: true;\n}\n\ninterface IExportFileResponseFailure {\n\tsuccess: false;\n\teventName: string;\n\terrorMessage: string;\n\terror?: 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\tfluidFileConverter: IFluidFileConverter,\n\tinputFile: string,\n\toutputFile: string,\n\ttelemetryFile: string,\n\toptions?: string,\n\ttelemetryOptions?: ITelemetryOptions,\n\ttimeout?: number,\n\tdisableNetworkFetch?: boolean,\n): Promise<IExportFileResponse> {\n\tconst telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n\tif (telemetryArgError) {\n\t\tconst eventName = clientArgsValidationError;\n\t\treturn { success: false, eventName, errorMessage: telemetryArgError };\n\t}\n\tconst { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);\n\n\ttry {\n\t\treturn await PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"ExportFile\" },\n\t\t\tasync () => {\n\t\t\t\tconst argsValidationError = getArgsValidationError(inputFile, outputFile, timeout);\n\t\t\t\tif (argsValidationError) {\n\t\t\t\t\tconst eventName = clientArgsValidationError;\n\t\t\t\t\tlogger.sendErrorEvent({ eventName, message: argsValidationError });\n\t\t\t\t\treturn { success: false, eventName, errorMessage: argsValidationError };\n\t\t\t\t}\n\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputFile,\n\t\t\t\t\tawait createContainerAndExecute(\n\t\t\t\t\t\tgetSnapshotFileContent(inputFile),\n\t\t\t\t\t\tfluidFileConverter,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tdisableNetworkFetch,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn { success: true };\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tconst eventName = \"Client_UnexpectedError\";\n\t\tlogger.sendErrorEvent({ eventName }, error);\n\t\treturn { success: false, eventName, errorMessage: \"Unexpected error\", error };\n\t} finally {\n\t\tawait fileLogger.close();\n\t}\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\tlocalOdspSnapshot: string | Uint8Array,\n\tfluidFileConverter: IFluidFileConverter,\n\tlogger: ITelemetryLoggerExt,\n\toptions?: string,\n\ttimeout?: number,\n\tdisableNetworkFetch: boolean = false,\n): Promise<string> {\n\tconst fn = async () => {\n\t\tif (disableNetworkFetch) {\n\t\t\tglobal.fetch = async () => {\n\t\t\t\tthrow new Error(\"Network fetch is not allowed\");\n\t\t\t};\n\t\t}\n\n\t\tconst loader = new Loader({\n\t\t\turlResolver: new FakeUrlResolver(),\n\t\t\tdocumentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n\t\t\tcodeLoader: await fluidFileConverter.getCodeLoader(logger),\n\t\t\tscope: await fluidFileConverter.getScope?.(logger),\n\t\t\tlogger,\n\t\t});\n\n\t\tconst container = await loader.resolve({\n\t\t\turl: \"/fakeUrl/\",\n\t\t\theaders: {\n\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t},\n\t\t});\n\n\t\treturn PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n\t\t\ttry {\n\t\t\t\treturn await fluidFileConverter.execute(container, options);\n\t\t\t} finally {\n\t\t\t\tcontainer.dispose();\n\t\t\t}\n\t\t});\n\t};\n\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (timeout !== undefined) {\n\t\treturn timeoutPromise<string>((resolve, reject) => {\n\t\t\tfn()\n\t\t\t\t.then((value) => resolve(value))\n\t\t\t\t.catch((error) => reject(error));\n\t\t}, timeout);\n\t} else {\n\t\treturn fn();\n\t}\n}\n"]}
1
+ {"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAwF;AACxF,iFAAqE;AACrE,uEAA0D;AAC1D,6DAAoF;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AS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACtF,IAAI;gBACH,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aAC5D;oBAAS;gBACT,SAAS,CAAC,OAAO,EAAE,CAAC;aACpB;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,kDAAkD;IAClD,IAAI,OAAO,KAAK,SAAS,EAAE;QAC1B,OAAO,IAAA,sBAAc,EAAS,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,EAAE,EAAE;iBACF,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;iBAC/B,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC,EAAE,OAAO,CAAC,CAAC;KACZ;SAAM;QACN,OAAO,EAAE,EAAE,CAAC;KACZ;AACF,CAAC;AAjDD,8DAiDC","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 { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { LoaderHeader } from \"@fluidframework/container-definitions\";\nimport { Loader } from \"@fluidframework/container-loader\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver\";\nimport { IFluidFileConverter } from \"./codeLoaderBundle\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver\";\nimport { getSnapshotFileContent, timeoutPromise, getArgsValidationError } 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\tsuccess: true;\n}\n\ninterface IExportFileResponseFailure {\n\tsuccess: false;\n\teventName: string;\n\terrorMessage: string;\n\terror?: 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\tfluidFileConverter: IFluidFileConverter,\n\tinputFile: string,\n\toutputFile: string,\n\ttelemetryFile: string,\n\toptions?: string,\n\ttelemetryOptions?: ITelemetryOptions,\n\ttimeout?: number,\n\tdisableNetworkFetch?: boolean,\n): Promise<IExportFileResponse> {\n\tconst telemetryArgError = getTelemetryFileValidationError(telemetryFile);\n\tif (telemetryArgError) {\n\t\tconst eventName = clientArgsValidationError;\n\t\treturn { success: false, eventName, errorMessage: telemetryArgError };\n\t}\n\tconst { fileLogger, logger } = createLogger(telemetryFile, telemetryOptions);\n\n\ttry {\n\t\treturn await PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{ eventName: \"ExportFile\" },\n\t\t\tasync () => {\n\t\t\t\tconst argsValidationError = getArgsValidationError(inputFile, outputFile, timeout);\n\t\t\t\tif (argsValidationError) {\n\t\t\t\t\tconst eventName = clientArgsValidationError;\n\t\t\t\t\tlogger.sendErrorEvent({ eventName, message: argsValidationError });\n\t\t\t\t\treturn { success: false, eventName, errorMessage: argsValidationError };\n\t\t\t\t}\n\n\t\t\t\tfs.writeFileSync(\n\t\t\t\t\toutputFile,\n\t\t\t\t\tawait createContainerAndExecute(\n\t\t\t\t\t\tgetSnapshotFileContent(inputFile),\n\t\t\t\t\t\tfluidFileConverter,\n\t\t\t\t\t\tlogger,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttimeout,\n\t\t\t\t\t\tdisableNetworkFetch,\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\treturn { success: true };\n\t\t\t},\n\t\t);\n\t} catch (error) {\n\t\tconst eventName = \"Client_UnexpectedError\";\n\t\tlogger.sendErrorEvent({ eventName }, error);\n\t\treturn { success: false, eventName, errorMessage: \"Unexpected error\", error };\n\t} finally {\n\t\tawait fileLogger.close();\n\t}\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\tlocalOdspSnapshot: string | Uint8Array,\n\tfluidFileConverter: IFluidFileConverter,\n\tlogger: ITelemetryLoggerExt,\n\toptions?: string,\n\ttimeout?: number,\n\tdisableNetworkFetch: boolean = false,\n): Promise<string> {\n\tconst fn = async () => {\n\t\tif (disableNetworkFetch) {\n\t\t\tglobal.fetch = async () => {\n\t\t\t\tthrow new Error(\"Network fetch is not allowed\");\n\t\t\t};\n\t\t}\n\n\t\tconst loader = new Loader({\n\t\t\turlResolver: new FakeUrlResolver(),\n\t\t\tdocumentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),\n\t\t\tcodeLoader: await fluidFileConverter.getCodeLoader(logger),\n\t\t\tscope: await fluidFileConverter.getScope?.(logger),\n\t\t\tlogger,\n\t\t});\n\n\t\tconst container = await loader.resolve({\n\t\t\turl: \"/fakeUrl/\",\n\t\t\theaders: {\n\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t},\n\t\t});\n\n\t\treturn PerformanceEvent.timedExecAsync(logger, { eventName: \"ExportFile\" }, async () => {\n\t\t\ttry {\n\t\t\t\treturn await fluidFileConverter.execute(container, options);\n\t\t\t} finally {\n\t\t\t\tcontainer.dispose();\n\t\t\t}\n\t\t});\n\t};\n\n\t// eslint-disable-next-line unicorn/prefer-ternary\n\tif (timeout !== undefined) {\n\t\treturn timeoutPromise<string>((resolve, reject) => {\n\t\t\tfn()\n\t\t\t\t.then((value) => resolve(value))\n\t\t\t\t.catch((error) => reject(error));\n\t\t}, timeout);\n\t} else {\n\t\treturn fn();\n\t}\n}\n"]}
@@ -44,7 +44,7 @@ class BaseFileLogger {
44
44
  }
45
45
  send(event) {
46
46
  // eslint-disable-next-line no-param-reassign
47
- event = Object.assign(Object.assign({}, event), this.defaultProps);
47
+ event = { ...event, ...this.defaultProps };
48
48
  this.events.push(event);
49
49
  if (this.events.length >= this.eventsPerFlush || event.category === "error") {
50
50
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
@@ -1 +1 @@
1
- {"version":3,"file":"baseFileLogger.js","sourceRoot":"","sources":["../../src/logger/baseFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAIzB;;GAEG;AACH,MAAsB,cAAc;IAOnC;;;;OAIG;IACH,YACoB,QAAgB,EAChB,iBAAyB,EAAE,EAC3B,YAA8C;QAF9C,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAa;QAC3B,iBAAY,GAAZ,YAAY,CAAkC;QAZlE,0CAA0C;QAChC,WAAM,GAAU,EAAE,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;IAWhC,CAAC;IAEG,IAAI,CAAC,KAA0B;QACrC,6CAA6C;QAC7C,KAAK,mCAAQ,KAAK,GAAK,IAAI,CAAC,YAAY,CAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC5E,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;SACb;IACF,CAAC;IAES,KAAK,CAAC,KAAK;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7E,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBAC1B,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC;aACvD;iBAAM;gBACN,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAC7B;IACF,CAAC;IAEM,KAAK,CAAC,KAAK;QACjB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACD;AA7CD,wCA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { IFileLogger } from \"./fileLogger\";\n\n/**\n * @internal\n */\nexport abstract class BaseFileLogger implements IFileLogger {\n\tpublic supportsTags?: true | undefined;\n\n\t/** Hold events in memory until flushed */\n\tprotected events: any[] = [];\n\tprotected hasWrittenToFile = false;\n\n\t/**\n\t * @param filePath - file path to write logs to\n\t * @param eventsPerFlush - number of events per flush\n\t * @param defaultProps - default properties to add to every telemetry event\n\t */\n\tpublic constructor(\n\t\tprotected readonly filePath: string,\n\t\tprotected readonly eventsPerFlush: number = 50,\n\t\tprotected readonly defaultProps?: Record<string, string | number>,\n\t) {}\n\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tevent = { ...event, ...this.defaultProps };\n\t\tthis.events.push(event);\n\n\t\tif (this.events.length >= this.eventsPerFlush || event.category === \"error\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tthis.flush();\n\t\t}\n\t}\n\n\tprotected async flush(): Promise<void> {\n\t\tif (this.events.length > 0) {\n\t\t\tconst contentToWrite = this.events.map((it) => JSON.stringify(it)).join(\",\");\n\t\t\tif (this.hasWrittenToFile) {\n\t\t\t\tfs.appendFileSync(this.filePath, `,${contentToWrite}`);\n\t\t\t} else {\n\t\t\t\tfs.appendFileSync(this.filePath, contentToWrite);\n\t\t\t}\n\t\t\tthis.events = [];\n\t\t\tthis.hasWrittenToFile = true;\n\t\t}\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tawait this.flush();\n\t}\n}\n"]}
1
+ {"version":3,"file":"baseFileLogger.js","sourceRoot":"","sources":["../../src/logger/baseFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAIzB;;GAEG;AACH,MAAsB,cAAc;IAOnC;;;;OAIG;IACH,YACoB,QAAgB,EAChB,iBAAyB,EAAE,EAC3B,YAA8C;QAF9C,aAAQ,GAAR,QAAQ,CAAQ;QAChB,mBAAc,GAAd,cAAc,CAAa;QAC3B,iBAAY,GAAZ,YAAY,CAAkC;QAZlE,0CAA0C;QAChC,WAAM,GAAU,EAAE,CAAC;QACnB,qBAAgB,GAAG,KAAK,CAAC;IAWhC,CAAC;IAEG,IAAI,CAAC,KAA0B;QACrC,6CAA6C;QAC7C,KAAK,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAExB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,cAAc,IAAI,KAAK,CAAC,QAAQ,KAAK,OAAO,EAAE;YAC5E,mEAAmE;YACnE,IAAI,CAAC,KAAK,EAAE,CAAC;SACb;IACF,CAAC;IAES,KAAK,CAAC,KAAK;QACpB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE;YAC3B,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7E,IAAI,IAAI,CAAC,gBAAgB,EAAE;gBAC1B,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,cAAc,EAAE,CAAC,CAAC;aACvD;iBAAM;gBACN,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;aACjD;YACD,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;SAC7B;IACF,CAAC;IAEM,KAAK,CAAC,KAAK;QACjB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;CACD;AA7CD,wCA6CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as fs from \"fs\";\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { IFileLogger } from \"./fileLogger\";\n\n/**\n * @internal\n */\nexport abstract class BaseFileLogger implements IFileLogger {\n\tpublic supportsTags?: true | undefined;\n\n\t/** Hold events in memory until flushed */\n\tprotected events: any[] = [];\n\tprotected hasWrittenToFile = false;\n\n\t/**\n\t * @param filePath - file path to write logs to\n\t * @param eventsPerFlush - number of events per flush\n\t * @param defaultProps - default properties to add to every telemetry event\n\t */\n\tpublic constructor(\n\t\tprotected readonly filePath: string,\n\t\tprotected readonly eventsPerFlush: number = 50,\n\t\tprotected readonly defaultProps?: Record<string, string | number>,\n\t) {}\n\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tevent = { ...event, ...this.defaultProps };\n\t\tthis.events.push(event);\n\n\t\tif (this.events.length >= this.eventsPerFlush || event.category === \"error\") {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\tthis.flush();\n\t\t}\n\t}\n\n\tprotected async flush(): Promise<void> {\n\t\tif (this.events.length > 0) {\n\t\t\tconst contentToWrite = this.events.map((it) => JSON.stringify(it)).join(\",\");\n\t\t\tif (this.hasWrittenToFile) {\n\t\t\t\tfs.appendFileSync(this.filePath, `,${contentToWrite}`);\n\t\t\t} else {\n\t\t\t\tfs.appendFileSync(this.filePath, contentToWrite);\n\t\t\t}\n\t\t\tthis.events = [];\n\t\t\tthis.hasWrittenToFile = true;\n\t\t}\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tawait this.flush();\n\t}\n}\n"]}
@@ -5,11 +5,17 @@
5
5
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
6
6
  import { IFileLogger, ITelemetryOptions } from "./fileLogger";
7
7
  /**
8
- * Create a ITelemetryLoggerExt wrapped around provided IFileLogger
9
- * ! It is expected that all events be sent through the returned "logger" value
10
- * ! The "fileLogger" value should have its "close()" method called at the end of execution
11
- * Note: if an output format is not supplied, default is JSON
12
- * @returns - both the IFileLogger implementation and ITelemetryLoggerExt wrapper to be called
8
+ * Create an {@link @fluidframework/telemetry-utils#ITelemetryLoggerExt} wrapped around provided {@link IFileLogger}.
9
+ *
10
+ * @remarks
11
+ *
12
+ * It is expected that all events be sent through the returned "logger" value.
13
+ *
14
+ * The "fileLogger" value should have its "close()" method called at the end of execution.
15
+ *
16
+ * Note: if an output format is not supplied, default is JSON.
17
+ *
18
+ * @returns Both the `IFileLogger` implementation and `ITelemetryLoggerExt` wrapper to be called.
13
19
  */
14
20
  export declare function createLogger(filePath: string, options?: ITelemetryOptions): {
15
21
  logger: ITelemetryLoggerExt;
@@ -1 +1 @@
1
- {"version":3,"file":"loggerUtils.d.ts","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAe,MAAM,iCAAiC,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAgB,MAAM,cAAc,CAAC;AAG5E;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC3B,QAAQ,E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AAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,iBAAiB,CAAA;CAAE,CAqC5F"}
@@ -30,18 +30,28 @@ const csvFileLogger_1 = require("./csvFileLogger");
30
30
  const fileLogger_1 = require("./fileLogger");
31
31
  const jsonFileLogger_1 = require("./jsonFileLogger");
32
32
  /**
33
- * Create a ITelemetryLoggerExt wrapped around provided IFileLogger
34
- * ! It is expected that all events be sent through the returned "logger" value
35
- * ! The "fileLogger" value should have its "close()" method called at the end of execution
36
- * Note: if an output format is not supplied, default is JSON
37
- * @returns - both the IFileLogger implementation and ITelemetryLoggerExt wrapper to be called
33
+ * Create an {@link @fluidframework/telemetry-utils#ITelemetryLoggerExt} wrapped around provided {@link IFileLogger}.
34
+ *
35
+ * @remarks
36
+ *
37
+ * It is expected that all events be sent through the returned "logger" value.
38
+ *
39
+ * The "fileLogger" value should have its "close()" method called at the end of execution.
40
+ *
41
+ * Note: if an output format is not supplied, default is JSON.
42
+ *
43
+ * @returns Both the `IFileLogger` implementation and `ITelemetryLoggerExt` wrapper to be called.
38
44
  */
39
45
  function createLogger(filePath, options) {
40
- const fileLogger = (options === null || options === void 0 ? void 0 : options.outputFormat) === fileLogger_1.OutputFormat.CSV
41
- ? new csvFileLogger_1.CSVFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps)
42
- : new jsonFileLogger_1.JSONFileLogger(filePath, options === null || options === void 0 ? void 0 : options.eventsPerFlush, options === null || options === void 0 ? void 0 : options.defaultProps);
43
- const logger = telemetry_utils_1.ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", {
44
- all: { Event_Time: () => Date.now() },
46
+ const fileLogger = options?.outputFormat === fileLogger_1.OutputFormat.CSV
47
+ ? new csvFileLogger_1.CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)
48
+ : new jsonFileLogger_1.JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);
49
+ const logger = (0, telemetry_utils_1.createChildLogger)({
50
+ logger: fileLogger,
51
+ namespace: "LocalSnapshotRunnerApp",
52
+ properties: {
53
+ all: { Event_Time: () => Date.now() },
54
+ },
45
55
  });
46
56
  return { logger, fileLogger };
47
57
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loggerUtils.js","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAmF;AACnF,mDAAgD;AAChD,6CAA4E;AAC5E,qDAAkD;AAElD;;;;;;GAMG;AACH,SAAgB,YAAY,CAC3B,QAAgB,EAChB,OAA2B;IAE3B,MAAM,UAAU,GACf,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,MAAK,yBAAY,CAAC,GAAG;QACzC,CAAC,CAAC,IAAI,6BAAa,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC;QAC7E,CAAC,CAAC,IAAI,+BAAc,CAAC,QAAQ,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,YAAY,CAAC,CAAC;IAEjF,MAAM,MAAM,GAAG,6BAAW,CAAC,MAAM,CAAC,UAAU,EAAE,wBAAwB,EAAE;QACvE,GAAG,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE;KACrC,CAAC,CAAC;IAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;AAC/B,CAAC;AAdD,oCAcC;AAED;;;GAGG;AACH,SAAgB,+BAA+B,CAAC,aAAqB;IACpE,IAAI,CAAC,aAAa,EAAE;QACnB,OAAO,qCAAqC,CAAC;KAC7C;SAAM,IAAI,EA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AAC;KACF;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC;AAC5F,CAAC;AAzCD,4EAyCC","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 { ITelemetryLoggerExt, ChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { CSVFileLogger } from \"./csvFileLogger\";\nimport { IFileLogger, ITelemetryOptions, OutputFormat } from \"./fileLogger\";\nimport { JSONFileLogger } from \"./jsonFileLogger\";\n\n/**\n * Create a ITelemetryLoggerExt wrapped around provided IFileLogger\n * ! It is expected that all events be sent through the returned \"logger\" value\n * ! The \"fileLogger\" value should have its \"close()\" method called at the end of execution\n * Note: if an output format is not supplied, default is JSON\n * @returns - both the IFileLogger implementation and ITelemetryLoggerExt wrapper to be called\n */\nexport function createLogger(\n\tfilePath: string,\n\toptions?: ITelemetryOptions,\n): { logger: ITelemetryLoggerExt; fileLogger: IFileLogger } {\n\tconst fileLogger =\n\t\toptions?.outputFormat === OutputFormat.CSV\n\t\t\t? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)\n\t\t\t: new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);\n\n\tconst logger = ChildLogger.create(fileLogger, \"LocalSnapshotRunnerApp\", {\n\t\tall: { Event_Time: () => Date.now() },\n\t});\n\n\treturn { logger, fileLogger };\n}\n\n/**\n * Validate the telemetryFile command line argument\n * @param telemetryFile - path where telemetry will be written\n */\nexport function getTelemetryFileValidationError(telemetryFile: string): string | undefined {\n\tif (!telemetryFile) {\n\t\treturn \"Telemetry file argument is missing.\";\n\t} else if (fs.existsSync(telemetryFile)) {\n\t\treturn `Telemetry file already exists [${telemetryFile}].`;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validate the provided output format and default properties\n * @param format - desired output format of the telemetry\n * @param props - default properties to be added to every telemetry entry\n */\nexport function validateAndParseTelemetryOptions(\n\tformat?: string,\n\tprops?: (string | number)[],\n\teventsPerFlush?: number,\n): { success: false; error: string } | { success: true; telemetryOptions: ITelemetryOptions } {\n\tlet outputFormat: OutputFormat | undefined;\n\tconst defaultProps: Record<string, string | number> = {};\n\n\tif (format) {\n\t\toutputFormat = OutputFormat[format];\n\t\tif (outputFormat === undefined) {\n\t\t\treturn { success: false, error: `Invalid telemetry format [${format}]` };\n\t\t}\n\t}\n\n\tif (props && props.length > 0) {\n\t\tif (props.length % 2 !== 0) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `Invalid number of telemetry properties to add [${props.length}]`,\n\t\t\t};\n\t\t}\n\t\tfor (let i = 0; i < props.length; i += 2) {\n\t\t\tif (typeof props[i] === \"number\") {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Property name cannot be number at index [${i}] -> [${props[i]}]`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefaultProps[props[i]] = props[i + 1];\n\t\t}\n\t}\n\n\tif (eventsPerFlush !== undefined && isNaN(eventsPerFlush)) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: \"Invalid eventsPerFlush\",\n\t\t};\n\t}\n\n\treturn { success: true, telemetryOptions: { outputFormat, defaultProps, eventsPerFlush } };\n}\n"]}
1
+ {"version":3,"file":"loggerUtils.js","sourceRoot":"","sources":["../../src/logger/loggerUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,qEAAyF;AACzF,mDAAgD;AAChD,6CAA4E;AAC5E,qDAAkD;AAElD;;;;;;;;;;;;GAYG;AACH,SAAgB,YAAY,CAC3B,QAAgB,EAChB,OAA2B;IAE3B,MAAM,UAAU,GACf,OAAO,EAAE,YAAY,KAAK,yBAAY,CAAC,GAAG;QACzC,CAAC,CAAC,IAAI,6BAAa,CAAC,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,KAAK,EAAE,kDAAkD,KAAK,CAAC,MAAM,GAAG;aACxE,CAAC;SACF;QACD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;YACzC,IAAI,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,EAAE;gBACjC,OAAO;oBACN,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,4CAA4C,CAAC,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG;iBACxE,CAAC;aACF;YACD,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;SACtC;KACD;IAED,IAAI,cAAc,KAAK,SAAS,IAAI,KAAK,CAAC,cAAc,CAAC,EAAE;QAC1D,OAAO;YACN,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,wBAAwB;SAC/B,CAAC;KACF;IAED,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,gBAAgB,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,EAAE,CAAC;AAC5F,CAAC;AAzCD,4EAyCC","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 { ITelemetryLoggerExt, createChildLogger } from \"@fluidframework/telemetry-utils\";\nimport { CSVFileLogger } from \"./csvFileLogger\";\nimport { IFileLogger, ITelemetryOptions, OutputFormat } from \"./fileLogger\";\nimport { JSONFileLogger } from \"./jsonFileLogger\";\n\n/**\n * Create an {@link @fluidframework/telemetry-utils#ITelemetryLoggerExt} wrapped around provided {@link IFileLogger}.\n *\n * @remarks\n *\n * It is expected that all events be sent through the returned \"logger\" value.\n *\n * The \"fileLogger\" value should have its \"close()\" method called at the end of execution.\n *\n * Note: if an output format is not supplied, default is JSON.\n *\n * @returns Both the `IFileLogger` implementation and `ITelemetryLoggerExt` wrapper to be called.\n */\nexport function createLogger(\n\tfilePath: string,\n\toptions?: ITelemetryOptions,\n): { logger: ITelemetryLoggerExt; fileLogger: IFileLogger } {\n\tconst fileLogger =\n\t\toptions?.outputFormat === OutputFormat.CSV\n\t\t\t? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)\n\t\t\t: new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);\n\n\tconst logger = createChildLogger({\n\t\tlogger: fileLogger,\n\t\tnamespace: \"LocalSnapshotRunnerApp\",\n\t\tproperties: {\n\t\t\tall: { Event_Time: () => Date.now() },\n\t\t},\n\t});\n\n\treturn { logger, fileLogger };\n}\n\n/**\n * Validate the telemetryFile command line argument\n * @param telemetryFile - path where telemetry will be written\n */\nexport function getTelemetryFileValidationError(telemetryFile: string): string | undefined {\n\tif (!telemetryFile) {\n\t\treturn \"Telemetry file argument is missing.\";\n\t} else if (fs.existsSync(telemetryFile)) {\n\t\treturn `Telemetry file already exists [${telemetryFile}].`;\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Validate the provided output format and default properties\n * @param format - desired output format of the telemetry\n * @param props - default properties to be added to every telemetry entry\n */\nexport function validateAndParseTelemetryOptions(\n\tformat?: string,\n\tprops?: (string | number)[],\n\teventsPerFlush?: number,\n): { success: false; error: string } | { success: true; telemetryOptions: ITelemetryOptions } {\n\tlet outputFormat: OutputFormat | undefined;\n\tconst defaultProps: Record<string, string | number> = {};\n\n\tif (format) {\n\t\toutputFormat = OutputFormat[format];\n\t\tif (outputFormat === undefined) {\n\t\t\treturn { success: false, error: `Invalid telemetry format [${format}]` };\n\t\t}\n\t}\n\n\tif (props && props.length > 0) {\n\t\tif (props.length % 2 !== 0) {\n\t\t\treturn {\n\t\t\t\tsuccess: false,\n\t\t\t\terror: `Invalid number of telemetry properties to add [${props.length}]`,\n\t\t\t};\n\t\t}\n\t\tfor (let i = 0; i < props.length; i += 2) {\n\t\t\tif (typeof props[i] === \"number\") {\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: `Property name cannot be number at index [${i}] -> [${props[i]}]`,\n\t\t\t\t};\n\t\t\t}\n\t\t\tdefaultProps[props[i]] = props[i + 1];\n\t\t}\n\t}\n\n\tif (eventsPerFlush !== undefined && isNaN(eventsPerFlush)) {\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: \"Invalid eventsPerFlush\",\n\t\t};\n\t}\n\n\treturn { success: true, telemetryOptions: { outputFormat, defaultProps, eventsPerFlush } };\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/fluid-runner",
3
- "version": "2.0.0-dev.5.3.2.178189",
3
+ "version": "2.0.0-dev.6.4.0.191258",
4
4
  "description": "Utility for running various functionality inside a Fluid Framework environment",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -15,7 +15,7 @@
15
15
  "bin": {
16
16
  "fluid-runner": "bin/fluid-runner"
17
17
  },
18
- "nyc": {
18
+ "c8": {
19
19
  "all": true,
20
20
  "cache-dir": "nyc/.cache",
21
21
  "exclude": [
@@ -36,36 +36,34 @@
36
36
  "temp-directory": "nyc/.nyc_output"
37
37
  },
38
38
  "dependencies": {
39
- "@fluidframework/aqueduct": "2.0.0-dev.5.3.2.178189",
40
- "@fluidframework/common-definitions": "^0.20.1",
41
- "@fluidframework/container-definitions": "2.0.0-dev.5.3.2.178189",
42
- "@fluidframework/container-loader": "2.0.0-dev.5.3.2.178189",
43
- "@fluidframework/core-interfaces": "2.0.0-dev.5.3.2.178189",
44
- "@fluidframework/driver-definitions": "2.0.0-dev.5.3.2.178189",
45
- "@fluidframework/odsp-driver": "2.0.0-dev.5.3.2.178189",
46
- "@fluidframework/odsp-driver-definitions": "2.0.0-dev.5.3.2.178189",
47
- "@fluidframework/telemetry-utils": "2.0.0-dev.5.3.2.178189",
39
+ "@fluidframework/aqueduct": "2.0.0-dev.6.4.0.191258",
40
+ "@fluidframework/container-definitions": "2.0.0-dev.6.4.0.191258",
41
+ "@fluidframework/container-loader": "2.0.0-dev.6.4.0.191258",
42
+ "@fluidframework/core-interfaces": "2.0.0-dev.6.4.0.191258",
43
+ "@fluidframework/driver-definitions": "2.0.0-dev.6.4.0.191258",
44
+ "@fluidframework/odsp-driver": "2.0.0-dev.6.4.0.191258",
45
+ "@fluidframework/odsp-driver-definitions": "2.0.0-dev.6.4.0.191258",
46
+ "@fluidframework/telemetry-utils": "2.0.0-dev.6.4.0.191258",
48
47
  "json2csv": "^5.0.7",
49
48
  "yargs": "13.2.2"
50
49
  },
51
50
  "devDependencies": {
52
- "@fluid-tools/build-cli": "^0.21.0",
53
- "@fluidframework/build-common": "^1.2.0",
54
- "@fluidframework/build-tools": "^0.21.0",
55
- "@fluidframework/eslint-config-fluid": "^2.0.0",
56
- "@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.0.0-internal.5.2.0",
57
- "@fluidframework/mocha-test-setup": "2.0.0-dev.5.3.2.178189",
51
+ "@fluid-tools/build-cli": "^0.22.0",
52
+ "@fluidframework/build-common": "^2.0.0",
53
+ "@fluidframework/build-tools": "^0.22.0",
54
+ "@fluidframework/eslint-config-fluid": "^2.1.0",
55
+ "@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.0.0-internal.6.3.0",
56
+ "@fluidframework/mocha-test-setup": "2.0.0-dev.6.4.0.191258",
58
57
  "@types/mocha": "^9.1.1",
59
- "@types/node": "^14.18.38",
58
+ "@types/node": "^16.18.38",
60
59
  "@types/yargs": "^13",
61
- "concurrently": "^7.6.0",
60
+ "c8": "^7.7.1",
62
61
  "cross-env": "^7.0.3",
63
62
  "eslint": "~8.6.0",
64
63
  "mocha": "^10.2.0",
65
64
  "mocha-json-output-reporter": "^2.0.1",
66
65
  "mocha-multi-reporters": "^1.5.1",
67
66
  "moment": "^2.21.0",
68
- "nyc": "^15.1.0",
69
67
  "prettier": "~2.6.2",
70
68
  "rimraf": "^4.4.0",
71
69
  "typescript": "~4.5.5"
@@ -77,9 +75,8 @@
77
75
  "build": "fluid-build . --task build",
78
76
  "build:commonjs": "fluid-build . --task commonjs",
79
77
  "build:compile": "fluid-build . --task compile",
80
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
81
78
  "build:test": "tsc --project ./src/test/tsconfig.json",
82
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
79
+ "clean": "rimraf --glob 'dist' 'lib' '*.tsbuildinfo' '*.build.log' 'nyc'",
83
80
  "eslint": "eslint --format stylish src",
84
81
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
85
82
  "format": "npm run prettier:fix",
@@ -88,9 +85,8 @@
88
85
  "prettier": "prettier --check . --ignore-path ../../../.prettierignore",
89
86
  "prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
90
87
  "test": "npm run test:mocha",
91
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
92
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
93
- "test:mocha:multireport": "cross-env FLUID_TEST_MULTIREPORT=1 npm run test:mocha",
88
+ "test:coverage": "c8 npm test",
89
+ "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
94
90
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
95
91
  "tsc": "tsc",
96
92
  "typetests:gen": "fluid-type-test-generator",
@@ -4,17 +4,23 @@
4
4
  */
5
5
 
6
6
  import * as fs from "fs";
7
- import { ITelemetryLoggerExt, ChildLogger } from "@fluidframework/telemetry-utils";
7
+ import { ITelemetryLoggerExt, createChildLogger } from "@fluidframework/telemetry-utils";
8
8
  import { CSVFileLogger } from "./csvFileLogger";
9
9
  import { IFileLogger, ITelemetryOptions, OutputFormat } from "./fileLogger";
10
10
  import { JSONFileLogger } from "./jsonFileLogger";
11
11
 
12
12
  /**
13
- * Create a ITelemetryLoggerExt wrapped around provided IFileLogger
14
- * ! It is expected that all events be sent through the returned "logger" value
15
- * ! The "fileLogger" value should have its "close()" method called at the end of execution
16
- * Note: if an output format is not supplied, default is JSON
17
- * @returns - both the IFileLogger implementation and ITelemetryLoggerExt wrapper to be called
13
+ * Create an {@link @fluidframework/telemetry-utils#ITelemetryLoggerExt} wrapped around provided {@link IFileLogger}.
14
+ *
15
+ * @remarks
16
+ *
17
+ * It is expected that all events be sent through the returned "logger" value.
18
+ *
19
+ * The "fileLogger" value should have its "close()" method called at the end of execution.
20
+ *
21
+ * Note: if an output format is not supplied, default is JSON.
22
+ *
23
+ * @returns Both the `IFileLogger` implementation and `ITelemetryLoggerExt` wrapper to be called.
18
24
  */
19
25
  export function createLogger(
20
26
  filePath: string,
@@ -25,8 +31,12 @@ export function createLogger(
25
31
  ? new CSVFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps)
26
32
  : new JSONFileLogger(filePath, options?.eventsPerFlush, options?.defaultProps);
27
33
 
28
- const logger = ChildLogger.create(fileLogger, "LocalSnapshotRunnerApp", {
29
- all: { Event_Time: () => Date.now() },
34
+ const logger = createChildLogger({
35
+ logger: fileLogger,
36
+ namespace: "LocalSnapshotRunnerApp",
37
+ properties: {
38
+ all: { Event_Time: () => Date.now() },
39
+ },
30
40
  });
31
41
 
32
42
  return { logger, fileLogger };
@@ -1,44 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ICodeDetailsLoader, IContainer } from "@fluidframework/container-definitions";
6
- import { ITelemetryBaseLogger, FluidObject } from "@fluidframework/core-interfaces";
7
- /**
8
- * Contract that defines the necessary exports for the bundle provided at runtime
9
- * For an example, see "src/test/sampleCodeLoaders/sampleCodeLoader.ts"
10
- */
11
- export interface ICodeLoaderBundle {
12
- /**
13
- * Fluid export of all the required objects and functions
14
- */
15
- fluidExport: Promise<IFluidFileConverter>;
16
- }
17
- /**
18
- * Instance that holds all the details for Fluid file conversion
19
- */
20
- export interface IFluidFileConverter {
21
- /**
22
- * Get code loader details to provide at Loader creation
23
- * @param logger - created logger object to pass to code loader
24
- */
25
- getCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;
26
- /**
27
- * Get scope object to provide at Loader creation
28
- * @param logger - created logger object to pass to scope object
29
- */
30
- getScope?(logger: ITelemetryBaseLogger): Promise<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
@@ -1 +0,0 @@
1
- {"version":3,"file":"codeLoaderBundle.d.ts","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAEpF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,aAAa,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAEzE;;;OAGG;IACH,QAAQ,CAAC,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAE9D;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClE;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,CAQzE"}
@@ -1,20 +0,0 @@
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) &&
16
- typeof obj.getCodeLoader === "function" &&
17
- obj.execute &&
18
- typeof obj.execute === "function");
19
- }
20
- //# sourceMappingURL=codeLoaderBundle.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"codeLoaderBundle.js","sourceRoot":"","sources":["../src/codeLoaderBundle.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAwCH;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAW;IAC7C,+DAA+D;IAC/D,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,KAAI,OAAO,MAAM,CAAC,WAAW,KAAK,QAAQ,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,GAAQ;IAC5C,+DAA+D;IAC/D,OAAO,CACN,CAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,aAAa;QAClB,OAAO,GAAG,CAAC,aAAa,KAAK,UAAU;QACvC,GAAG,CAAC,OAAO;QACX,OAAO,GAAG,CAAC,OAAO,KAAK,UAAU,CACjC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ICodeDetailsLoader, IContainer } from \"@fluidframework/container-definitions\";\nimport { ITelemetryBaseLogger, 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\t/**\n\t * Fluid export of all the required objects and functions\n\t */\n\tfluidExport: Promise<IFluidFileConverter>;\n}\n\n/**\n * Instance that holds all the details for Fluid file conversion\n */\nexport interface IFluidFileConverter {\n\t/**\n\t * Get code loader details to provide at Loader creation\n\t * @param logger - created logger object to pass to code loader\n\t */\n\tgetCodeLoader(logger: ITelemetryBaseLogger): Promise<ICodeDetailsLoader>;\n\n\t/**\n\t * Get scope object to provide at Loader creation\n\t * @param logger - created logger object to pass to scope object\n\t */\n\tgetScope?(logger: ITelemetryBaseLogger): Promise<FluidObject>;\n\n\t/**\n\t * Executes code on container and returns the result\n\t * @param container - container created by this application\n\t * @param options - additional options\n\t */\n\texecute(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\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn bundle?.fluidExport && typeof bundle.fluidExport === \"object\";\n}\n\nexport function isFluidFileConverter(obj: any): obj is IFluidFileConverter {\n\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\treturn (\n\t\tobj?.getCodeLoader &&\n\t\ttypeof obj.getCodeLoader === \"function\" &&\n\t\tobj.execute &&\n\t\ttypeof obj.execute === \"function\"\n\t);\n}\n"]}
@@ -1,28 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
- import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
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, timeout?: number, disableNetworkFetch?: boolean): 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: ITelemetryLoggerExt, options?: string, timeout?: number, disableNetworkFetch?: boolean): Promise<string>;
27
- export {};
28
- //# sourceMappingURL=exportFile.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,iCAAiC,CAAC;AAIxF,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;IACnC,OAAO,EAAE,IAAI,CAAC;CACd;AAED,UAAU,0BAA0B;IACnC,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ;AAID;;GAEG;AACH,wBAAsB,UAAU,CAC/B,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,EACpC,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,OAAO,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CA0C9B;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAC9C,iBAAiB,EAAE,MAAM,GAAG,UAAU,EACtC,kBAAkB,EAAE,mBAAmB,EACvC,MAAM,EAAE,mBAAmB,EAC3B,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,mBAAmB,GAAE,OAAe,GAClC,OAAO,CAAC,MAAM,CAAC,CA0CjB"}