@fluidframework/fluid-runner 2.11.0 → 2.12.0
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.
- package/CHANGELOG.md +4 -0
- package/dist/exportFile.d.ts.map +1 -1
- package/dist/exportFile.js +9 -6
- package/dist/exportFile.js.map +1 -1
- package/dist/logger/csvFileLogger.d.ts +5 -1
- package/dist/logger/csvFileLogger.d.ts.map +1 -1
- package/dist/logger/csvFileLogger.js +13 -3
- package/dist/logger/csvFileLogger.js.map +1 -1
- package/lib/exportFile.d.ts.map +1 -1
- package/lib/exportFile.js +10 -7
- package/lib/exportFile.js.map +1 -1
- package/lib/logger/csvFileLogger.d.ts +5 -1
- package/lib/logger/csvFileLogger.d.ts.map +1 -1
- package/lib/logger/csvFileLogger.js +13 -3
- package/lib/logger/csvFileLogger.js.map +1 -1
- package/package.json +13 -13
- package/src/exportFile.ts +14 -8
- package/src/logger/csvFileLogger.ts +14 -5
package/CHANGELOG.md
CHANGED
package/dist/exportFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ;AAID;;;GAGG;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;;;;GAIG;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,CA6CjB"}
|
package/dist/exportFile.js
CHANGED
|
@@ -82,17 +82,20 @@ async function createContainerAndExecute(localOdspSnapshot, fluidFileConverter,
|
|
|
82
82
|
throw new Error("Network fetch is not allowed");
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
const
|
|
85
|
+
const loaderProps = {
|
|
86
86
|
urlResolver: new fakeUrlResolver_js_1.FakeUrlResolver(),
|
|
87
87
|
documentServiceFactory: (0, internal_3.createLocalOdspDocumentServiceFactory)(localOdspSnapshot),
|
|
88
88
|
codeLoader: await fluidFileConverter.getCodeLoader(logger),
|
|
89
89
|
scope: await fluidFileConverter.getScope?.(logger),
|
|
90
90
|
logger,
|
|
91
|
-
}
|
|
92
|
-
const container = await
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
};
|
|
92
|
+
const container = await (0, internal_2.loadExistingContainer)({
|
|
93
|
+
...loaderProps,
|
|
94
|
+
request: {
|
|
95
|
+
url: "/fakeUrl/",
|
|
96
|
+
headers: {
|
|
97
|
+
[internal_1.LoaderHeader.loadMode]: { opsBeforeReturn: "cached" },
|
|
98
|
+
},
|
|
96
99
|
},
|
|
97
100
|
});
|
|
98
101
|
return internal_4.PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
package/dist/exportFile.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,6EAA8E;AAC9E,
|
|
1
|
+
{"version":3,"file":"exportFile.js","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAEzB,6EAA8E;AAC9E,wEAGmD;AACnD,mEAA6F;AAC7F,uEAGkD;AAGlD,6DAAuD;AAGvD,4DAAwF;AACxF,yCAA4F;AA4B5F,MAAM,yBAAyB,GAAG,4BAA4B,CAAC;AAE/D;;;GAGG;AACI,KAAK,UAAU,UAAU,CAC/B,kBAAuC,EACvC,SAAiB,EACjB,UAAkB,EAClB,aAAqB,EACrB,OAAgB,EAChB,gBAAoC,EACpC,OAAgB,EAChB,mBAA6B;IAE7B,MAAM,iBAAiB,GAAG,IAAA,gDAA+B,EAAC,aAAa,CAAC,CAAC;IACzE,IAAI,iBAAiB,EAAE,CAAC;QACvB,MAAM,SAAS,GAAG,yBAAyB,CAAC;QAC5C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC;IACvE,CAAC;IACD,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,IAAA,6BAAY,EAAC,aAAa,EAAE,gBAAgB,CAAC,CAAC;IAE7E,IAAI,CAAC;QACJ,OAA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EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QACnC,CAAC,EAAE,OAAO,CAAC,CAAC;IACb,CAAC;SAAM,CAAC;QACP,OAAO,EAAE,EAAE,CAAC;IACb,CAAC;AACF,CAAC;AApDD,8DAoDC","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\nimport { LoaderHeader } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IFluidFileConverter } from \"./codeLoaderBundle.js\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver.js\";\n/* eslint-disable import/no-internal-modules */\nimport { ITelemetryOptions } from \"./logger/fileLogger.js\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils.js\";\nimport { getArgsValidationError, getSnapshotFileContent, timeoutPromise } from \"./utils.js\";\n/* eslint-enable import/no-internal-modules */\n\n/**\n * @legacy\n * @alpha\n */\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IExportFileResponseSuccess {\n\tsuccess: true;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface 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 * @internal\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 * @internal\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 loaderProps: ILoaderProps = {\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 loadExistingContainer({\n\t\t\t...loaderProps,\n\t\t\trequest: {\n\t\t\t\turl: \"/fakeUrl/\",\n\t\t\t\theaders: {\n\t\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t\t},\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"]}
|
|
@@ -9,7 +9,11 @@ import { BaseFileLogger } from "./baseFileLogger.js";
|
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
export declare class CSVFileLogger extends BaseFileLogger {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Store the column names to write as the CSV header.
|
|
14
|
+
*
|
|
15
|
+
* Order of this set is used for the oder of columns.
|
|
16
|
+
*/
|
|
13
17
|
private readonly columns;
|
|
14
18
|
protected flush(): Promise<void>;
|
|
15
19
|
send(event: ITelemetryBaseEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAChD
|
|
1
|
+
{"version":3,"file":"csvFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAChD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;cAE7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAShC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAanC"}
|
|
@@ -29,7 +29,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.CSVFileLogger = void 0;
|
|
31
31
|
const fs = __importStar(require("fs"));
|
|
32
|
-
const
|
|
32
|
+
const plainjs_1 = require("@json2csv/plainjs");
|
|
33
33
|
const baseFileLogger_js_1 = require("./baseFileLogger.js");
|
|
34
34
|
/**
|
|
35
35
|
* FileLogger that writes events into a defined CSV file
|
|
@@ -38,7 +38,11 @@ const baseFileLogger_js_1 = require("./baseFileLogger.js");
|
|
|
38
38
|
class CSVFileLogger extends baseFileLogger_js_1.BaseFileLogger {
|
|
39
39
|
constructor() {
|
|
40
40
|
super(...arguments);
|
|
41
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* Store the column names to write as the CSV header.
|
|
43
|
+
*
|
|
44
|
+
* Order of this set is used for the oder of columns.
|
|
45
|
+
*/
|
|
42
46
|
this.columns = new Set();
|
|
43
47
|
}
|
|
44
48
|
async flush() {
|
|
@@ -47,6 +51,7 @@ class CSVFileLogger extends baseFileLogger_js_1.BaseFileLogger {
|
|
|
47
51
|
send(event) {
|
|
48
52
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
49
53
|
for (const prop in event) {
|
|
54
|
+
// Include "prop" as a column, moving it to the end of the column set if already included.
|
|
50
55
|
this.columns.add(prop);
|
|
51
56
|
}
|
|
52
57
|
super.send(event);
|
|
@@ -55,9 +60,14 @@ class CSVFileLogger extends baseFileLogger_js_1.BaseFileLogger {
|
|
|
55
60
|
await super.close();
|
|
56
61
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
57
62
|
for (const field in this.defaultProps) {
|
|
63
|
+
// Include "field" as a column, moving it to the end of the column set if already included.
|
|
58
64
|
this.columns.add(field);
|
|
59
65
|
}
|
|
60
|
-
|
|
66
|
+
const parser = new plainjs_1.Parser({
|
|
67
|
+
// Orders columns based on order of the set, which puts most recently seen fields from send at the end.
|
|
68
|
+
fields: Array.from(this.columns),
|
|
69
|
+
});
|
|
70
|
+
fs.writeFileSync(this.filePath, parser.parse(this.events));
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
exports.CSVFileLogger = CSVFileLogger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvFileLogger.js","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAGzB
|
|
1
|
+
{"version":3,"file":"csvFileLogger.js","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AAGzB,+CAA2C;AAE3C,2DAAqD;AAErD;;;GAGG;AACH,MAAa,aAAc,SAAQ,kCAAc;IAAjD;;QACC;;;;WAIG;QACc,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IA4B9C,CAAC;IA1BU,KAAK,CAAC,KAAK;QACpB,yFAAyF;IAC1F,CAAC;IAEM,IAAI,CAAC,KAA0B;QACrC,8DAA8D;QAC9D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,0FAA0F;YAC1F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,KAAK;QACjB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,8DAA8D;QAC9D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,2FAA2F;YAC3F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC;YACzB,uGAAuG;YACvG,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;CACD;AAlCD,sCAkCC","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\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { Parser } from \"@json2csv/plainjs\";\n\nimport { BaseFileLogger } from \"./baseFileLogger.js\";\n\n/**\n * FileLogger that writes events into a defined CSV file\n * @internal\n */\nexport class CSVFileLogger extends BaseFileLogger {\n\t/**\n\t * Store the column names to write as the CSV header.\n\t *\n\t * Order of this set is used for the oder of columns.\n\t */\n\tprivate readonly columns = new Set<string>();\n\n\tprotected async flush(): Promise<void> {\n\t\t// No flushing is performed since we need all log entries to determine set of CSV columns\n\t}\n\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const prop in event) {\n\t\t\t// Include \"prop\" as a column, moving it to the end of the column set if already included.\n\t\t\tthis.columns.add(prop);\n\t\t}\n\t\tsuper.send(event);\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tawait super.close();\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const field in this.defaultProps) {\n\t\t\t// Include \"field\" as a column, moving it to the end of the column set if already included.\n\t\t\tthis.columns.add(field);\n\t\t}\n\t\tconst parser = new Parser({\n\t\t\t// Orders columns based on order of the set, which puts most recently seen fields from send at the end.\n\t\t\tfields: Array.from(this.columns),\n\t\t});\n\t\tfs.writeFileSync(this.filePath, parser.parse(this.events));\n\t}\n}\n"]}
|
package/lib/exportFile.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"exportFile.d.ts","sourceRoot":"","sources":["../src/exportFile.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACN,mBAAmB,EAEnB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,0BAA0B,GAAG,0BAA0B,CAAC;AAE1F;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,KAAK,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,GAAG,CAAC;CACZ;AAID;;;GAGG;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;;;;GAIG;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,CA6CjB"}
|
package/lib/exportFile.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import * as fs from "fs";
|
|
6
6
|
import { LoaderHeader } from "@fluidframework/container-definitions/internal";
|
|
7
|
-
import {
|
|
7
|
+
import { loadExistingContainer, } from "@fluidframework/container-loader/internal";
|
|
8
8
|
import { createLocalOdspDocumentServiceFactory } from "@fluidframework/odsp-driver/internal";
|
|
9
9
|
import { PerformanceEvent, } from "@fluidframework/telemetry-utils/internal";
|
|
10
10
|
import { FakeUrlResolver } from "./fakeUrlResolver.js";
|
|
@@ -55,17 +55,20 @@ export async function createContainerAndExecute(localOdspSnapshot, fluidFileConv
|
|
|
55
55
|
throw new Error("Network fetch is not allowed");
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
const
|
|
58
|
+
const loaderProps = {
|
|
59
59
|
urlResolver: new FakeUrlResolver(),
|
|
60
60
|
documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
|
|
61
61
|
codeLoader: await fluidFileConverter.getCodeLoader(logger),
|
|
62
62
|
scope: await fluidFileConverter.getScope?.(logger),
|
|
63
63
|
logger,
|
|
64
|
-
}
|
|
65
|
-
const container = await
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
};
|
|
65
|
+
const container = await loadExistingContainer({
|
|
66
|
+
...loaderProps,
|
|
67
|
+
request: {
|
|
68
|
+
url: "/fakeUrl/",
|
|
69
|
+
headers: {
|
|
70
|
+
[LoaderHeader.loadMode]: { opsBeforeReturn: "cached" },
|
|
71
|
+
},
|
|
69
72
|
},
|
|
70
73
|
});
|
|
71
74
|
return PerformanceEvent.timedExecAsync(logger, { eventName: "ExportFile" }, async () => {
|
package/lib/exportFile.js.map
CHANGED
|
@@ -1 +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,gDAAgD,CAAC;AAC9E,OAAO,
|
|
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,gDAAgD,CAAC;AAC9E,OAAO,EACN,qBAAqB,GAErB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,qCAAqC,EAAE,MAAM,sCAAsC,CAAC;AAC7F,OAAO,EAEN,gBAAgB,GAChB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAGvD,OAAO,EAA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AAC,QAAQ,CAAC,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE;iBACtD;aACD;SACD,CAAC,CAAC;QAEH,OAAO,gBAAgB,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,IAAI,EAAE;YACtF,IAAI,CAAC;gBACJ,OAAO,MAAM,kBAAkB,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC7D,CAAC;oBAAS,CAAC;gBACV,SAAS,CAAC,OAAO,EAAE,CAAC;YACrB,CAAC;QACF,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,kDAAkD;IAClD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,cAAc,CAAS,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;IACb,CAAC;SAAM,CAAC;QACP,OAAO,EAAE,EAAE,CAAC;IACb,CAAC;AACF,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\nimport { LoaderHeader } from \"@fluidframework/container-definitions/internal\";\nimport {\n\tloadExistingContainer,\n\ttype ILoaderProps,\n} from \"@fluidframework/container-loader/internal\";\nimport { createLocalOdspDocumentServiceFactory } from \"@fluidframework/odsp-driver/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IFluidFileConverter } from \"./codeLoaderBundle.js\";\nimport { FakeUrlResolver } from \"./fakeUrlResolver.js\";\n/* eslint-disable import/no-internal-modules */\nimport { ITelemetryOptions } from \"./logger/fileLogger.js\";\nimport { createLogger, getTelemetryFileValidationError } from \"./logger/loggerUtils.js\";\nimport { getArgsValidationError, getSnapshotFileContent, timeoutPromise } from \"./utils.js\";\n/* eslint-enable import/no-internal-modules */\n\n/**\n * @legacy\n * @alpha\n */\nexport type IExportFileResponse = IExportFileResponseSuccess | IExportFileResponseFailure;\n\n/**\n * @legacy\n * @alpha\n */\nexport interface IExportFileResponseSuccess {\n\tsuccess: true;\n}\n\n/**\n * @legacy\n * @alpha\n */\nexport interface 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 * @internal\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 * @internal\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 loaderProps: ILoaderProps = {\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 loadExistingContainer({\n\t\t\t...loaderProps,\n\t\t\trequest: {\n\t\t\t\turl: \"/fakeUrl/\",\n\t\t\t\theaders: {\n\t\t\t\t\t[LoaderHeader.loadMode]: { opsBeforeReturn: \"cached\" },\n\t\t\t\t},\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"]}
|
|
@@ -9,7 +9,11 @@ import { BaseFileLogger } from "./baseFileLogger.js";
|
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
11
|
export declare class CSVFileLogger extends BaseFileLogger {
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Store the column names to write as the CSV header.
|
|
14
|
+
*
|
|
15
|
+
* Order of this set is used for the oder of columns.
|
|
16
|
+
*/
|
|
13
17
|
private readonly columns;
|
|
14
18
|
protected flush(): Promise<void>;
|
|
15
19
|
send(event: ITelemetryBaseEvent): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAChD
|
|
1
|
+
{"version":3,"file":"csvFileLogger.d.ts","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,qBAAa,aAAc,SAAQ,cAAc;IAChD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;cAE7B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B,IAAI,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI;IAShC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAanC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import * as fs from "fs";
|
|
6
|
-
import {
|
|
6
|
+
import { Parser } from "@json2csv/plainjs";
|
|
7
7
|
import { BaseFileLogger } from "./baseFileLogger.js";
|
|
8
8
|
/**
|
|
9
9
|
* FileLogger that writes events into a defined CSV file
|
|
@@ -12,7 +12,11 @@ import { BaseFileLogger } from "./baseFileLogger.js";
|
|
|
12
12
|
export class CSVFileLogger extends BaseFileLogger {
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Store the column names to write as the CSV header.
|
|
17
|
+
*
|
|
18
|
+
* Order of this set is used for the oder of columns.
|
|
19
|
+
*/
|
|
16
20
|
this.columns = new Set();
|
|
17
21
|
}
|
|
18
22
|
async flush() {
|
|
@@ -21,6 +25,7 @@ export class CSVFileLogger extends BaseFileLogger {
|
|
|
21
25
|
send(event) {
|
|
22
26
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
23
27
|
for (const prop in event) {
|
|
28
|
+
// Include "prop" as a column, moving it to the end of the column set if already included.
|
|
24
29
|
this.columns.add(prop);
|
|
25
30
|
}
|
|
26
31
|
super.send(event);
|
|
@@ -29,9 +34,14 @@ export class CSVFileLogger extends BaseFileLogger {
|
|
|
29
34
|
await super.close();
|
|
30
35
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
31
36
|
for (const field in this.defaultProps) {
|
|
37
|
+
// Include "field" as a column, moving it to the end of the column set if already included.
|
|
32
38
|
this.columns.add(field);
|
|
33
39
|
}
|
|
34
|
-
|
|
40
|
+
const parser = new Parser({
|
|
41
|
+
// Orders columns based on order of the set, which puts most recently seen fields from send at the end.
|
|
42
|
+
fields: Array.from(this.columns),
|
|
43
|
+
});
|
|
44
|
+
fs.writeFileSync(this.filePath, parser.parse(this.events));
|
|
35
45
|
}
|
|
36
46
|
}
|
|
37
47
|
//# sourceMappingURL=csvFileLogger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"csvFileLogger.js","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"csvFileLogger.js","sourceRoot":"","sources":["../../src/logger/csvFileLogger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,cAAc;IAAjD;;QACC;;;;WAIG;QACc,YAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IA4B9C,CAAC;IA1BU,KAAK,CAAC,KAAK;QACpB,yFAAyF;IAC1F,CAAC;IAEM,IAAI,CAAC,KAA0B;QACrC,8DAA8D;QAC9D,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YAC1B,0FAA0F;YAC1F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACxB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IAEM,KAAK,CAAC,KAAK;QACjB,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACpB,8DAA8D;QAC9D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,2FAA2F;YAC3F,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;YACzB,uGAAuG;YACvG,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC;QACH,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5D,CAAC;CACD","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\nimport { ITelemetryBaseEvent } from \"@fluidframework/core-interfaces\";\nimport { Parser } from \"@json2csv/plainjs\";\n\nimport { BaseFileLogger } from \"./baseFileLogger.js\";\n\n/**\n * FileLogger that writes events into a defined CSV file\n * @internal\n */\nexport class CSVFileLogger extends BaseFileLogger {\n\t/**\n\t * Store the column names to write as the CSV header.\n\t *\n\t * Order of this set is used for the oder of columns.\n\t */\n\tprivate readonly columns = new Set<string>();\n\n\tprotected async flush(): Promise<void> {\n\t\t// No flushing is performed since we need all log entries to determine set of CSV columns\n\t}\n\n\tpublic send(event: ITelemetryBaseEvent): void {\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const prop in event) {\n\t\t\t// Include \"prop\" as a column, moving it to the end of the column set if already included.\n\t\t\tthis.columns.add(prop);\n\t\t}\n\t\tsuper.send(event);\n\t}\n\n\tpublic async close(): Promise<void> {\n\t\tawait super.close();\n\t\t// eslint-disable-next-line guard-for-in, no-restricted-syntax\n\t\tfor (const field in this.defaultProps) {\n\t\t\t// Include \"field\" as a column, moving it to the end of the column set if already included.\n\t\t\tthis.columns.add(field);\n\t\t}\n\t\tconst parser = new Parser({\n\t\t\t// Orders columns based on order of the set, which puts most recently seen fields from send at the end.\n\t\t\tfields: Array.from(this.columns),\n\t\t});\n\t\tfs.writeFileSync(this.filePath, parser.parse(this.events));\n\t}\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/fluid-runner",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "Utility for running various functionality inside a Fluid Framework environment",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -71,26 +71,26 @@
|
|
|
71
71
|
"temp-directory": "nyc/.nyc_output"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@fluidframework/aqueduct": "~2.
|
|
75
|
-
"@fluidframework/container-definitions": "~2.
|
|
76
|
-
"@fluidframework/container-loader": "~2.
|
|
77
|
-
"@fluidframework/core-interfaces": "~2.
|
|
78
|
-
"@fluidframework/driver-definitions": "~2.
|
|
79
|
-
"@fluidframework/odsp-driver": "~2.
|
|
80
|
-
"@fluidframework/odsp-driver-definitions": "~2.
|
|
81
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
82
|
-
"json2csv": "^
|
|
74
|
+
"@fluidframework/aqueduct": "~2.12.0",
|
|
75
|
+
"@fluidframework/container-definitions": "~2.12.0",
|
|
76
|
+
"@fluidframework/container-loader": "~2.12.0",
|
|
77
|
+
"@fluidframework/core-interfaces": "~2.12.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.12.0",
|
|
79
|
+
"@fluidframework/odsp-driver": "~2.12.0",
|
|
80
|
+
"@fluidframework/odsp-driver-definitions": "~2.12.0",
|
|
81
|
+
"@fluidframework/telemetry-utils": "~2.12.0",
|
|
82
|
+
"@json2csv/plainjs": "^7.0.6",
|
|
83
83
|
"yargs": "17.7.2"
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
|
-
"@arethetypeswrong/cli": "^0.
|
|
86
|
+
"@arethetypeswrong/cli": "^0.17.1",
|
|
87
87
|
"@biomejs/biome": "~1.9.3",
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
88
|
+
"@fluid-internal/mocha-test-setup": "~2.12.0",
|
|
89
89
|
"@fluid-tools/build-cli": "^0.51.0",
|
|
90
90
|
"@fluidframework/build-common": "^2.0.3",
|
|
91
91
|
"@fluidframework/build-tools": "^0.51.0",
|
|
92
92
|
"@fluidframework/eslint-config-fluid": "^5.6.0",
|
|
93
|
-
"@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.
|
|
93
|
+
"@fluidframework/fluid-runner-previous": "npm:@fluidframework/fluid-runner@2.11.0",
|
|
94
94
|
"@microsoft/api-extractor": "7.47.8",
|
|
95
95
|
"@types/mocha": "^9.1.1",
|
|
96
96
|
"@types/node": "^18.19.0",
|
package/src/exportFile.ts
CHANGED
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
|
|
8
8
|
import { LoaderHeader } from "@fluidframework/container-definitions/internal";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
loadExistingContainer,
|
|
11
|
+
type ILoaderProps,
|
|
12
|
+
} from "@fluidframework/container-loader/internal";
|
|
10
13
|
import { createLocalOdspDocumentServiceFactory } from "@fluidframework/odsp-driver/internal";
|
|
11
14
|
import {
|
|
12
15
|
ITelemetryLoggerExt,
|
|
@@ -125,18 +128,21 @@ export async function createContainerAndExecute(
|
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
130
|
|
|
128
|
-
const
|
|
131
|
+
const loaderProps: ILoaderProps = {
|
|
129
132
|
urlResolver: new FakeUrlResolver(),
|
|
130
133
|
documentServiceFactory: createLocalOdspDocumentServiceFactory(localOdspSnapshot),
|
|
131
134
|
codeLoader: await fluidFileConverter.getCodeLoader(logger),
|
|
132
135
|
scope: await fluidFileConverter.getScope?.(logger),
|
|
133
136
|
logger,
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const container = await
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
const container = await loadExistingContainer({
|
|
140
|
+
...loaderProps,
|
|
141
|
+
request: {
|
|
142
|
+
url: "/fakeUrl/",
|
|
143
|
+
headers: {
|
|
144
|
+
[LoaderHeader.loadMode]: { opsBeforeReturn: "cached" },
|
|
145
|
+
},
|
|
140
146
|
},
|
|
141
147
|
});
|
|
142
148
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import * as fs from "fs";
|
|
7
7
|
|
|
8
8
|
import { ITelemetryBaseEvent } from "@fluidframework/core-interfaces";
|
|
9
|
-
import {
|
|
9
|
+
import { Parser } from "@json2csv/plainjs";
|
|
10
10
|
|
|
11
11
|
import { BaseFileLogger } from "./baseFileLogger.js";
|
|
12
12
|
|
|
@@ -15,8 +15,12 @@ import { BaseFileLogger } from "./baseFileLogger.js";
|
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
17
|
export class CSVFileLogger extends BaseFileLogger {
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Store the column names to write as the CSV header.
|
|
20
|
+
*
|
|
21
|
+
* Order of this set is used for the oder of columns.
|
|
22
|
+
*/
|
|
23
|
+
private readonly columns = new Set<string>();
|
|
20
24
|
|
|
21
25
|
protected async flush(): Promise<void> {
|
|
22
26
|
// No flushing is performed since we need all log entries to determine set of CSV columns
|
|
@@ -25,6 +29,7 @@ export class CSVFileLogger extends BaseFileLogger {
|
|
|
25
29
|
public send(event: ITelemetryBaseEvent): void {
|
|
26
30
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
27
31
|
for (const prop in event) {
|
|
32
|
+
// Include "prop" as a column, moving it to the end of the column set if already included.
|
|
28
33
|
this.columns.add(prop);
|
|
29
34
|
}
|
|
30
35
|
super.send(event);
|
|
@@ -34,9 +39,13 @@ export class CSVFileLogger extends BaseFileLogger {
|
|
|
34
39
|
await super.close();
|
|
35
40
|
// eslint-disable-next-line guard-for-in, no-restricted-syntax
|
|
36
41
|
for (const field in this.defaultProps) {
|
|
42
|
+
// Include "field" as a column, moving it to the end of the column set if already included.
|
|
37
43
|
this.columns.add(field);
|
|
38
44
|
}
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
const parser = new Parser({
|
|
46
|
+
// Orders columns based on order of the set, which puts most recently seen fields from send at the end.
|
|
47
|
+
fields: Array.from(this.columns),
|
|
48
|
+
});
|
|
49
|
+
fs.writeFileSync(this.filePath, parser.parse(this.events));
|
|
41
50
|
}
|
|
42
51
|
}
|