@fluidframework/file-driver 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.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/.eslintrc.js +6 -9
- package/README.md +1 -1
- package/api-extractor.json +2 -2
- package/dist/fileDeltaStorageService.d.ts.map +1 -1
- package/dist/fileDeltaStorageService.js.map +1 -1
- package/dist/fileDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/fileDocumentDeltaConnection.js +6 -3
- package/dist/fileDocumentDeltaConnection.js.map +1 -1
- package/dist/fileDocumentService.d.ts.map +1 -1
- package/dist/fileDocumentService.js.map +1 -1
- package/dist/fileDocumentServiceFactory.d.ts.map +1 -1
- package/dist/fileDocumentServiceFactory.js.map +1 -1
- package/dist/fileDocumentStorageService.d.ts.map +1 -1
- package/dist/fileDocumentStorageService.js +4 -2
- package/dist/fileDocumentStorageService.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/package.json +33 -32
- package/prettier.config.cjs +1 -1
- package/src/fileDeltaStorageService.ts +53 -50
- package/src/fileDocumentDeltaConnection.ts +186 -171
- package/src/fileDocumentService.ts +26 -27
- package/src/fileDocumentServiceFactory.ts +33 -33
- package/src/fileDocumentStorageService.ts +190 -178
- package/src/packageVersion.ts +1 -1
- package/tsconfig.json +9 -14
package/.eslintrc.js
CHANGED
|
@@ -4,12 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
"import/no-nodejs-modules": ["error", { "allow": ["fs"] }],
|
|
14
|
-
}
|
|
15
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
rules: {
|
|
9
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
10
|
+
"import/no-nodejs-modules": ["error", { allow: ["fs"] }],
|
|
11
|
+
},
|
|
12
|
+
};
|
package/README.md
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
# @fluidframework/file-driver
|
|
2
2
|
|
|
3
|
-
This is an implementation of a driver which provides a DocumentService which uses local filesystem to get data for different endpoints like Document Storage, Delta Storage and Delta stream. It also provides implementation of Document Storage, Delta Storage and Delta stream. It also has a replay service which provides user the capability to replays ops accordingly.
|
|
3
|
+
This is an implementation of a driver which provides a DocumentService which uses local filesystem to get data for different endpoints like Document Storage, Delta Storage and Delta stream. It also provides implementation of Document Storage, Delta Storage and Delta stream. It also has a replay service which provides user the capability to replays ops accordingly.
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "@fluidframework/build-common/api-extractor-common-report.json"
|
|
4
4
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D;;GAEG;AACH,qBAAa,uBAAwB,YAAW,4BAA4B;
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAE3F,OAAO,KAAK,GAAG,MAAM,sCAAsC,CAAC;AAE5D;;GAEG;AACH,qBAAa,uBAAwB,YAAW,4BAA4B;IAI/D,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAkC;IAC3D,OAAO,CAAC,OAAO,CAAuC;gBAEzB,IAAI,EAAE,MAAM;IAkBlC,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE,CAAC;IAI3C,IAAW,GAAG,IAAI,SAAS,QAAQ,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,CAEnE;IAED;;;;;OAKG;IACI,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,GAAG,CAAC,yBAAyB,EAAE;CAmBlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDeltaStorageService.js","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AACpB,+DAAsD;AAEtD,+DAAkE;AAGlE;;GAEG;AACH,MAAa,uBAAuB;
|
|
1
|
+
{"version":3,"file":"fileDeltaStorageService.js","sourceRoot":"","sources":["../src/fileDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,4CAAoB;AACpB,+DAAsD;AAEtD,+DAAkE;AAGlE;;GAEG;AACH,MAAa,uBAAuB;IAInC,YAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAFjC,YAAO,GAAoC,EAAE,CAAC;QAGrD,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,OAAO,GAAG,CAAC,CAAC;QAChB,iDAAiD;QACjD,OAAO,IAAI,EAAE;YACZ,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,aAAa,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,EAA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C,OAAO,CAAC;SACpB;QACD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACrD,IAAA,qBAAM,EACL,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,cAAc,KAAK,QAAQ,GAAG,CAAC,EAC/C,KAAK,CAAC,kEAAkE,CACxE,CAAC;QACF,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;CACD;AA5DD,0DA4DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IDocumentDeltaStorageService, IStream } from \"@fluidframework/driver-definitions\";\nimport { emptyMessageStream } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\n\n/**\n * Provides access to the underlying delta storage on the local file storage for file driver.\n */\nexport class FileDeltaStorageService implements IDocumentDeltaStorageService {\n\tprivate readonly messages: api.ISequencedDocumentMessage[];\n\tprivate lastOps: api.ISequencedDocumentMessage[] = [];\n\n\tconstructor(private readonly path: string) {\n\t\tthis.messages = [];\n\t\tlet counter = 0;\n\t\t// eslint-disable-next-line no-constant-condition\n\t\twhile (true) {\n\t\t\tconst filename = `${this.path}//messages${counter === 0 ? \"\" : counter}.json`;\n\t\t\tif (!fs.existsSync(filename)) {\n\t\t\t\tif (counter === 0) {\n\t\t\t\t\tthrow new Error(`file ${filename} not found`);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tconst data = fs.readFileSync(filename);\n\t\t\tthis.messages = this.messages.concat(JSON.parse(data.toString(\"utf-8\")));\n\t\t\tcounter++;\n\t\t}\n\t}\n\n\tpublic fetchMessages(\n\t\tfrom: number,\n\t\tto: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t): IStream<api.ISequencedDocumentMessage[]> {\n\t\treturn emptyMessageStream;\n\t}\n\n\tpublic get ops(): readonly Readonly<api.ISequencedDocumentMessage>[] {\n\t\treturn this.messages;\n\t}\n\n\t/**\n\t * Retrieve ops within the exclusive sequence number range.\n\t *\n\t * @param from - First op to be fetched.\n\t * @param to - Last op to be fetched. This is exclusive.\n\t */\n\tpublic getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[] {\n\t\tconst readFrom = Math.max(from, 0); // Inclusive\n\t\tconst readTo = Math.min(to, this.messages.length); // Exclusive\n\n\t\tif (readFrom >= this.messages.length || readTo <= 0 || readFrom >= readTo) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// Optimizations for multiple readers (replay tool)\n\t\tif (this.lastOps.length > 0 && this.lastOps[0].sequenceNumber === readFrom + 1) {\n\t\t\treturn this.lastOps;\n\t\t}\n\t\tthis.lastOps = this.messages.slice(readFrom, readTo);\n\t\tassert(\n\t\t\tthis.lastOps[0].sequenceNumber === readFrom + 1,\n\t\t\t0x091 /* \"Retrieved ops' first sequence number has unexpected value!\" */,\n\t\t);\n\t\treturn this.lastOps;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EACN,wBAAwB,EACxB,8BAA8B,EAC9B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,cAAc,EACd,oBAAoB,EACpB,UAAU,EACV,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,cAAc,EACd,Y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AW,cAAc,IAAI,aAAa,EAAE,CAE3C;IAED,IAAW,oBAAoB,IAAI,oBAAoB,CAEtD;IAEM,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAM5C,YAAY,CAAC,OAAO,EAAE,GAAG;IAEtC,OAAO,CAAC,SAAS,CAAS;IAC1B,IAAW,QAAQ,YAElB;IACM,OAAO;CAGd"}
|
|
@@ -150,10 +150,13 @@ class ReplayFileDeltaConnection extends common_utils_1.TypedEventEmitter {
|
|
|
150
150
|
// and thus can never move to sending ops.
|
|
151
151
|
throw new Error("ReplayFileDeltaConnection.submit() can't be called");
|
|
152
152
|
}
|
|
153
|
-
async submitSignal(message) {
|
|
153
|
+
async submitSignal(message) { }
|
|
154
|
+
get disposed() {
|
|
155
|
+
return this._disposed;
|
|
156
|
+
}
|
|
157
|
+
dispose() {
|
|
158
|
+
this._disposed = true;
|
|
154
159
|
}
|
|
155
|
-
get disposed() { return this._disposed; }
|
|
156
|
-
dispose() { this._disposed = true; }
|
|
157
160
|
}
|
|
158
161
|
exports.ReplayFileDeltaConnection = ReplayFileDeltaConnection;
|
|
159
162
|
//# sourceMappingURL=fileDocumentDeltaConnection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,+EAU8C;AAC9C,+DAAiE;AAGjE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,qFAAqF;AACrF,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAiB;IACzB,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,gCAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAA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OAAO,KAAK,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC;CAC9C;AA/FD,8DA+FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport { IDocumentDeltaConnection, IDocumentDeltaConnectionEvents } from \"@fluidframework/driver-definitions\";\nimport {\n ConnectionMode,\n IClientConfiguration,\n IConnected,\n IDocumentMessage,\n ISequencedDocumentMessage,\n ISignalClient,\n ISignalMessage,\n ITokenClaims,\n ScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\n\nconst MaxBatchDeltas = 2000;\n\n// Since the replay service never actually sends messages the size below is arbitrary\nconst ReplayMaxMessageSize = 16 * 1024;\n\nconst fileProtocolVersion = \"^0.1.0\";\n\nconst replayDocumentId = \"replayDocId\";\n\nconst Claims: ITokenClaims = {\n documentId: replayDocumentId,\n scopes: [ScopeType.DocRead],\n tenantId: \"\",\n user: {\n id: \"\",\n },\n iat: Math.round(new Date().getTime() / 1000),\n exp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n ver: \"1.0\",\n};\n\n/**\n * Replay service used to play ops using the delta connection.\n */\nexport class Replayer {\n private currentReplayOp = 0;\n\n constructor(\n private readonly deltaConnection: ReplayFileDeltaConnection,\n private readonly documentStorageService: FileDeltaStorageService) {\n }\n\n public get currentReplayedOp() {\n return this.currentReplayOp;\n }\n\n public set currentReplayedOp(op: number) {\n this.currentReplayOp = op;\n }\n\n public get ops(): readonly Readonly<ISequencedDocumentMessage>[] {\n return this.documentStorageService.ops;\n }\n\n /**\n * Replay the ops upto a certain number.\n * @param replayTo - The last op number to be replayed.\n */\n public replay(replayTo: number) {\n let totalReplayedOps = 0;\n let done: boolean;\n do {\n const fetchToBatch = this.currentReplayOp + MaxBatchDeltas;\n const fetchTo = Math.min(fetchToBatch, replayTo);\n\n const fetchedOps = this.documentStorageService.getFromWebSocket(this.currentReplayOp, fetchTo);\n\n if (fetchedOps.length <= 0) {\n break;\n } else {\n this.emit(fetchedOps);\n totalReplayedOps += fetchedOps.length;\n this.currentReplayOp += fetchedOps.length;\n done = this.isDoneFetch(replayTo);\n }\n } while (!done);\n return totalReplayedOps;\n }\n\n private isDoneFetch(replayTo: number) {\n if (replayTo >= 0) {\n return this.currentReplayOp >= replayTo;\n }\n return false;\n }\n\n private emit(ops: ISequencedDocumentMessage[]) {\n // Note: do not clone messages here!\n // If Replay Tool fails due to one container patching message in-place,\n // then same thing can happen in shipping product due to\n // socket reuse in ODSP between main and summarizer containers.\n this.deltaConnection.emit(\"op\", replayDocumentId, ops);\n }\n}\n\nexport class ReplayFileDeltaConnection\n extends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n implements IDocumentDeltaConnection, IDisposable {\n /**\n * Mimic the delta connection to replay ops on it.\n *\n * @param documentDeltaStorageService - The delta storage service to get ops from.\n * @returns Document delta connection.\n */\n public static async create(\n documentDeltaStorageService: FileDeltaStorageService): Promise<ReplayFileDeltaConnection> {\n const mode: ConnectionMode = \"read\";\n const connection = {\n claims: Claims,\n clientId: \"PseudoClientId\",\n existing: true,\n initialMessages: [],\n initialSignals: [],\n initialClients: [],\n maxMessageSize: ReplayMaxMessageSize,\n mode,\n serviceConfiguration: {\n blockSize: 64436,\n maxMessageSize: ReplayMaxMessageSize,\n },\n supportedVersions: [fileProtocolVersion],\n user: null,\n version: fileProtocolVersion,\n };\n const deltaConnection = new ReplayFileDeltaConnection(connection, documentDeltaStorageService);\n return deltaConnection;\n }\n\n public readonly maxMessageSize = ReplayMaxMessageSize;\n private readonly replayer: Replayer;\n\n public constructor(public details: IConnected, documentDeltaStorageService: FileDeltaStorageService) {\n super();\n this.replayer = new Replayer(\n this,\n documentDeltaStorageService);\n }\n\n public getReplayer() {\n return this.replayer;\n }\n\n public get clientId(): string {\n return this.details.clientId;\n }\n\n public get mode(): ConnectionMode {\n return this.details.mode;\n }\n\n public get claims(): ITokenClaims {\n return this.details.claims;\n }\n\n public get existing(): boolean {\n return this.details.existing;\n }\n\n public get version(): string {\n return this.details.version;\n }\n\n public get initialMessages(): ISequencedDocumentMessage[] {\n return this.details.initialMessages;\n }\n\n public get initialSignals(): ISignalMessage[] {\n return this.details.initialSignals;\n }\n\n public get initialClients(): ISignalClient[] {\n return this.details.initialClients;\n }\n\n public get serviceConfiguration(): IClientConfiguration {\n return this.details.serviceConfiguration;\n }\n\n public submit(documentMessages: IDocumentMessage[]): void {\n // ReplayFileDeltaConnection.submit() can't be called - client never sees its own join on,\n // and thus can never move to sending ops.\n throw new Error(\"ReplayFileDeltaConnection.submit() can't be called\");\n }\n\n public async submitSignal(message: any) {\n }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n public dispose() { this._disposed = true; }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fileDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/fileDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,+EAU8C;AAC9C,+DAAiE;AAGjE,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,qFAAqF;AACrF,MAAM,oBAAoB,GAAG,EAAE,GAAG,IAAI,CAAC;AAEvC,MAAM,mBAAmB,GAAG,QAAQ,CAAC;AAErC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAiB;IAC5B,UAAU,EAAE,gBAAgB;IAC5B,MAAM,EAAE,CAAC,gCAAS,CAAC,OAAO,CAAC;IAC3B,QAAQ,EAAE,EAAE;IACZ,IAAI,EAAE;QACL,EAAE,EAAE,EAAE;KACN;IACD,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC;IAC5C,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,C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OAAO,eAAe,CAAC;IACxB,CAAC;IAaM,WAAW;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAW,IAAI;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAW,MAAM;QAChB,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC9B,CAAC;IAED,IAAW,OAAO;QACjB,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,IAAW,eAAe;QACzB,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;IACrC,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACpC,CAAC;IAED,IAAW,cAAc;QACxB,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC;IACpC,CAAC;IAED,IAAW,oBAAoB;QAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC;IAC1C,CAAC;IAEM,MAAM,CAAC,gBAAoC;QACjD,0FAA0F;QAC1F,0CAA0C;QAC1C,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,OAAY,IAAG,CAAC;IAG1C,IAAW,QAAQ;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACvB,CAAC;IACM,OAAO;QACb,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACvB,CAAC;CACD;AAxGD,8DAwGC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/common-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaConnectionEvents,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tConnectionMode,\n\tIClientConfiguration,\n\tIConnected,\n\tIDocumentMessage,\n\tISequencedDocumentMessage,\n\tISignalClient,\n\tISignalMessage,\n\tITokenClaims,\n\tScopeType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\n\nconst MaxBatchDeltas = 2000;\n\n// Since the replay service never actually sends messages the size below is arbitrary\nconst ReplayMaxMessageSize = 16 * 1024;\n\nconst fileProtocolVersion = \"^0.1.0\";\n\nconst replayDocumentId = \"replayDocId\";\n\nconst Claims: ITokenClaims = {\n\tdocumentId: replayDocumentId,\n\tscopes: [ScopeType.DocRead],\n\ttenantId: \"\",\n\tuser: {\n\t\tid: \"\",\n\t},\n\tiat: Math.round(new Date().getTime() / 1000),\n\texp: Math.round(new Date().getTime() / 1000) + 60 * 60, // 1 hour expiration\n\tver: \"1.0\",\n};\n\n/**\n * Replay service used to play ops using the delta connection.\n */\nexport class Replayer {\n\tprivate currentReplayOp = 0;\n\n\tconstructor(\n\t\tprivate readonly deltaConnection: ReplayFileDeltaConnection,\n\t\tprivate readonly documentStorageService: FileDeltaStorageService,\n\t) {}\n\n\tpublic get currentReplayedOp() {\n\t\treturn this.currentReplayOp;\n\t}\n\n\tpublic set currentReplayedOp(op: number) {\n\t\tthis.currentReplayOp = op;\n\t}\n\n\tpublic get ops(): readonly Readonly<ISequencedDocumentMessage>[] {\n\t\treturn this.documentStorageService.ops;\n\t}\n\n\t/**\n\t * Replay the ops upto a certain number.\n\t * @param replayTo - The last op number to be replayed.\n\t */\n\tpublic replay(replayTo: number) {\n\t\tlet totalReplayedOps = 0;\n\t\tlet done: boolean;\n\t\tdo {\n\t\t\tconst fetchToBatch = this.currentReplayOp + MaxBatchDeltas;\n\t\t\tconst fetchTo = Math.min(fetchToBatch, replayTo);\n\n\t\t\tconst fetchedOps = this.documentStorageService.getFromWebSocket(\n\t\t\t\tthis.currentReplayOp,\n\t\t\t\tfetchTo,\n\t\t\t);\n\n\t\t\tif (fetchedOps.length <= 0) {\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tthis.emit(fetchedOps);\n\t\t\t\ttotalReplayedOps += fetchedOps.length;\n\t\t\t\tthis.currentReplayOp += fetchedOps.length;\n\t\t\t\tdone = this.isDoneFetch(replayTo);\n\t\t\t}\n\t\t} while (!done);\n\t\treturn totalReplayedOps;\n\t}\n\n\tprivate isDoneFetch(replayTo: number) {\n\t\tif (replayTo >= 0) {\n\t\t\treturn this.currentReplayOp >= replayTo;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate emit(ops: ISequencedDocumentMessage[]) {\n\t\t// Note: do not clone messages here!\n\t\t// If Replay Tool fails due to one container patching message in-place,\n\t\t// then same thing can happen in shipping product due to\n\t\t// socket reuse in ODSP between main and summarizer containers.\n\t\tthis.deltaConnection.emit(\"op\", replayDocumentId, ops);\n\t}\n}\n\nexport class ReplayFileDeltaConnection\n\textends TypedEventEmitter<IDocumentDeltaConnectionEvents>\n\timplements IDocumentDeltaConnection, IDisposable\n{\n\t/**\n\t * Mimic the delta connection to replay ops on it.\n\t *\n\t * @param documentDeltaStorageService - The delta storage service to get ops from.\n\t * @returns Document delta connection.\n\t */\n\tpublic static async create(\n\t\tdocumentDeltaStorageService: FileDeltaStorageService,\n\t): Promise<ReplayFileDeltaConnection> {\n\t\tconst mode: ConnectionMode = \"read\";\n\t\tconst connection = {\n\t\t\tclaims: Claims,\n\t\t\tclientId: \"PseudoClientId\",\n\t\t\texisting: true,\n\t\t\tinitialMessages: [],\n\t\t\tinitialSignals: [],\n\t\t\tinitialClients: [],\n\t\t\tmaxMessageSize: ReplayMaxMessageSize,\n\t\t\tmode,\n\t\t\tserviceConfiguration: {\n\t\t\t\tblockSize: 64436,\n\t\t\t\tmaxMessageSize: ReplayMaxMessageSize,\n\t\t\t},\n\t\t\tsupportedVersions: [fileProtocolVersion],\n\t\t\tuser: null,\n\t\t\tversion: fileProtocolVersion,\n\t\t};\n\t\tconst deltaConnection = new ReplayFileDeltaConnection(\n\t\t\tconnection,\n\t\t\tdocumentDeltaStorageService,\n\t\t);\n\t\treturn deltaConnection;\n\t}\n\n\tpublic readonly maxMessageSize = ReplayMaxMessageSize;\n\tprivate readonly replayer: Replayer;\n\n\tpublic constructor(\n\t\tpublic details: IConnected,\n\t\tdocumentDeltaStorageService: FileDeltaStorageService,\n\t) {\n\t\tsuper();\n\t\tthis.replayer = new Replayer(this, documentDeltaStorageService);\n\t}\n\n\tpublic getReplayer() {\n\t\treturn this.replayer;\n\t}\n\n\tpublic get clientId(): string {\n\t\treturn this.details.clientId;\n\t}\n\n\tpublic get mode(): ConnectionMode {\n\t\treturn this.details.mode;\n\t}\n\n\tpublic get claims(): ITokenClaims {\n\t\treturn this.details.claims;\n\t}\n\n\tpublic get existing(): boolean {\n\t\treturn this.details.existing;\n\t}\n\n\tpublic get version(): string {\n\t\treturn this.details.version;\n\t}\n\n\tpublic get initialMessages(): ISequencedDocumentMessage[] {\n\t\treturn this.details.initialMessages;\n\t}\n\n\tpublic get initialSignals(): ISignalMessage[] {\n\t\treturn this.details.initialSignals;\n\t}\n\n\tpublic get initialClients(): ISignalClient[] {\n\t\treturn this.details.initialClients;\n\t}\n\n\tpublic get serviceConfiguration(): IClientConfiguration {\n\t\treturn this.details.serviceConfiguration;\n\t}\n\n\tpublic submit(documentMessages: IDocumentMessage[]): void {\n\t\t// ReplayFileDeltaConnection.submit() can't be called - client never sees its own join on,\n\t\t// and thus can never move to sending ops.\n\t\tthrow new Error(\"ReplayFileDeltaConnection.submit() can't be called\");\n\t}\n\n\tpublic async submitSignal(message: any) {}\n\n\tprivate _disposed = false;\n\tpublic get disposed() {\n\t\treturn this._disposed;\n\t}\n\tpublic dispose() {\n\t\tthis._disposed = true;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentService.d.ts","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AAEH,qBAAa,mBAAoB,YAAW,GAAG,CAAC,gBAAgB;
|
|
1
|
+
{"version":3,"file":"fileDocumentService.d.ts","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;;GAGG;AAEH,qBAAa,mBAAoB,YAAW,GAAG,CAAC,gBAAgB;IAE9D,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,OAAO,EAAE,GAAG,CAAC,uBAAuB,EACpC,YAAY,EAAE,uBAAuB,EACrC,eAAe,EAAE,GAAG,CAAC,wBAAwB;IAGxD,OAAO;IAGd,IAAW,WAAW,IAAI,GAAG,CAAC,YAAY,CAEzC;IAEY,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IAIxD,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;IAI/E;;;;;;OAMG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;CAGzF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentService.js","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AACH,4CAA4C;AAC5C,MAAa,mBAAmB;
|
|
1
|
+
{"version":3,"file":"fileDocumentService.js","sourceRoot":"","sources":["../src/fileDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAMH;;;GAGG;AACH,4CAA4C;AAC5C,MAAa,mBAAmB;IAC/B,YACkB,OAAoC,EACpC,YAAqC,EACrC,eAA6C;QAF7C,YAAO,GAAP,OAAO,CAA6B;QACpC,iBAAY,GAAZ,YAAY,CAAyB;QACrC,oBAAe,GAAf,eAAe,CAA8B;IAC5D,CAAC;IAEG,OAAO,KAAI,CAAC;IAEnB,8EAA8E;IAC9E,IAAW,WAAW;QACrB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,gBAAgB;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC;IACrB,CAAC;IAEM,KAAK,CAAC,qBAAqB;QACjC,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,oBAAoB,CAAC,MAAe;QAChD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC7B,CAAC;CACD;AAhCD,kDAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\n\n/**\n * The DocumentService manages the different endpoints for connecting to\n * underlying storage for file document service.\n */\n// eslint-disable-next-line import/namespace\nexport class FileDocumentService implements api.IDocumentService {\n\tconstructor(\n\t\tprivate readonly storage: api.IDocumentStorageService,\n\t\tprivate readonly deltaStorage: FileDeltaStorageService,\n\t\tprivate readonly deltaConnection: api.IDocumentDeltaConnection,\n\t) {}\n\n\tpublic dispose() {}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic get resolvedUrl(): api.IResolvedUrl {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n\n\tpublic async connectToStorage(): Promise<api.IDocumentStorageService> {\n\t\treturn this.storage;\n\t}\n\n\tpublic async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n\t\treturn this.deltaStorage;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint of provided documentService to get ops and then replaying\n\t * them so as to mimic a delta stream endpoint.\n\t *\n\t * @param client - Client that connects to socket.\n\t * @returns returns the delta stream service.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n\t\treturn this.deltaConnection;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"fileDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,wBAAwB,EACxB,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAGpE;;;GAGG;AACH,qBAAa,0BAA2B,YAAW,uBAAuB;IAGxE,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,eAAe;IAJjC,SAAgB,YAAY,iBAAiB;gBAE3B,OAAO,EAAE,uBAAuB,EAChC,YAAY,EAAE,uBAAuB,EACrC,eAAe,EAAE,wBAAwB;IAG3D;;;;;OAKG;IACU,qBAAqB,CACjC,OAAO,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAKf,eAAe,CAC3B,gBAAgB,EAAE,YAAY,EAC9B,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;CAG5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentServiceFactory.js","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,+DAA4D;AAE5D;;;GAGG;AACH,MAAa,0BAA0B;
|
|
1
|
+
{"version":3,"file":"fileDocumentServiceFactory.js","sourceRoot":"","sources":["../src/fileDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,+DAA4D;AAE5D;;;GAGG;AACH,MAAa,0BAA0B;IAEtC,YACkB,OAAgC,EAChC,YAAqC,EACrC,eAAyC;QAFzC,YAAO,GAAP,OAAO,CAAyB;QAChC,iBAAY,GAAZ,YAAY,CAAyB;QACrC,oBAAe,GAAf,eAAe,CAA0B;QAJ3C,iBAAY,GAAG,aAAa,CAAC;IAK1C,CAAC;IAEJ;;;;;OAKG;IACI,KAAK,CAAC,qBAAqB,CACjC,OAAqB,EACrB,MAA6B,EAC7B,kBAA4B;QAE5B,OAAO,IAAI,yCAAmB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACvF,CAAC;IAED,8EAA8E;IACvE,KAAK,CAAC,eAAe,CAC3B,gBAA8B,EAC9B,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;QAE5B,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACpC,CAAC;CACD;AA/BD,gEA+BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { FileDeltaStorageService } from \"./fileDeltaStorageService\";\nimport { FileDocumentService } from \"./fileDocumentService\";\n\n/**\n * Factory for creating the file document service. Use this if you want to\n * use the local file storage as underlying storage.\n */\nexport class FileDocumentServiceFactory implements IDocumentServiceFactory {\n\tpublic readonly protocolName = \"fluid-file:\";\n\tconstructor(\n\t\tprivate readonly storage: IDocumentStorageService,\n\t\tprivate readonly deltaStorage: FileDeltaStorageService,\n\t\tprivate readonly deltaConnection: IDocumentDeltaConnection,\n\t) {}\n\n\t/**\n\t * Creates the file document service if the path exists.\n\t *\n\t * @param fileURL - Path of directory containing ops/snapshots.\n\t * @returns file document service.\n\t */\n\tpublic async createDocumentService(\n\t\tfileURL: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn new FileDocumentService(this.storage, this.deltaStorage, this.deltaConnection);\n\t}\n\n\t// TODO: Issue-2109 Implement detach container api or put appropriate comment.\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tthrow new Error(\"Not implemented\");\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts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,SAAQ,uBAAuB;IACtE,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACjD,KAAK,IAAI,IAAI,CAAC;CACd;AAED,oBAAY,iBAAiB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,uBAAuB,CAAC;AAChF,eAAO,MAAM,8BAA8B;kBADG,GAAG,EAAE;;;;;oCAcd,aAAa,GAAG,IAAI;sBAI5B,MAAM,GAAG,QAAQ,eAAe,CAAC;+BAQxB,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;6DAiBpC,QAAQ,IAAI,aAAa,GAAG,IAAI,CAAC;0CAQ7E,IAAI,YAAY,WAChB,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,IAAI,aAAa,GAAG,QAAQ,IAAI,KAAK,CAAC;;;;;;;;SA8B3E,CAAC;AAcH,eAAO,MAAM,kCAAkC;kBA/GD,GAAG,EAAE;;;;;oCAcd,aAAa,GAAG,IAAI;sBAI5B,MAAM,GAAG,QAAQ,eAAe,CAAC;+BAQxB,MAAM,GAAG,IAAI,SAAS,MAAM,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC;6DAiBpC,QAAQ,IAAI,aAAa,GAAG,IAAI,CAAC;0CAQ7E,IAAI,YAAY,WAChB,eAAe,GACtB,QAAQ,MAAM,CAAC;gCAcmB,IAAI,aAAa,GAAG,QAAQ,IAAI,KAAK,CAAC;;;;;;;;2BA4CqB,CAAC"}
|
|
@@ -95,10 +95,12 @@ class FluidFetchReader extends replay_driver_1.ReadDocumentStorageServiceBase {
|
|
|
95
95
|
}
|
|
96
96
|
else if (this.versionName !== undefined) {
|
|
97
97
|
(0, common_utils_1.assert)(!!this.docTree, 0x094 /* "Missing snapshot tree!" */);
|
|
98
|
-
return [
|
|
98
|
+
return [
|
|
99
|
+
{
|
|
99
100
|
id: versionId,
|
|
100
101
|
treeId: FileStorageVersionTreeId,
|
|
101
|
-
}
|
|
102
|
+
},
|
|
103
|
+
];
|
|
102
104
|
}
|
|
103
105
|
throw new Error(`Unknown version: ${versionId}`);
|
|
104
106
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAAsE;AAEtE,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,8CAA8B;IAGhE,YAA6B,IAAY,EAAmB,WAAoB;QAC5E,KAAK,EAAE,CAAC;QADiB,SAAI,GAAJ,IAAI,CAAQ;QAAmB,gBAAW,GAAX,WAAW,CAAS;QAFtE,YAAO,GAA6B,IAAI,CAAC;IAInD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,OAAsB;QAC/C,IAAA,qBAAM,EAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,IAAA,qBAAM,EAAC,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,wBAAwB,EAC1D,KAAK,CAAC,wDAAwD,CAAC,CAAC;QAEpE,IAAI,QAAgB,CAAC;QACrB,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,EAAE,KAAK,QAAQ,EAAE;YACrC,IAAI,IAAI,CAAC,OAAO,EAAE;gBACd,OAAO,IAAI,CAAC,OAAO,CAAC;aACvB;YACD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS,EAAE;gBAChC,OAAO,IAAI,CAAC;aACf;YACD,Q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AS,CAAC,IAAI,EAAE;YAClC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACjC;KACJ;IACD,IAAA,qBAAM,EAAC,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EAC5C,KAAK,CAAC,+DAA+D,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC,EAAE,CAAC;AACnB,CAAC;AACY,QAAA,kCAAkC,GAAG,IAAA,sCAA8B,EAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { assert, bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\nexport const FileStorageDocumentName = \"FileStorageDocId\"; // Some unique document name\n\n// Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.\nconst FileStorageVersionTreeId = \"FileStorageTreeId\";\n\n/**\n * Document storage service for the file driver.\n */\nexport class FluidFetchReader extends ReadDocumentStorageServiceBase implements IDocumentStorageService {\n protected docTree: api.ISnapshotTree | null = null;\n\n constructor(private readonly path: string, private readonly versionName?: string) {\n super();\n }\n\n /**\n * Read the file and returns the snapshot tree.\n * @param version - The version contains the path of the file which contains the snapshot tree.\n */\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n assert(version !== null, 0x092 /* \"version input for reading snapshot tree is null!\" */);\n assert(!version || version.treeId === FileStorageVersionTreeId,\n 0x093 /* \"invalid version input for reading snapshot tree!\" */);\n\n let filename: string;\n let rootTree = false;\n if (!version || version.id === \"latest\") {\n if (this.docTree) {\n return this.docTree;\n }\n if (this.versionName === undefined) {\n return null;\n }\n rootTree = true;\n filename = `${this.path}/${this.versionName}/tree.json`;\n } else {\n filename = `${this.path}/${this.versionName}/${version.id}.json`;\n }\n\n if (!fs.existsSync(filename)) {\n throw new Error(`Can't find file ${filename}`);\n }\n const data = fs.readFileSync(filename);\n const tree = JSON.parse(data.toString(\"utf-8\"));\n if (rootTree) {\n this.docTree = tree;\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return tree;\n }\n\n /**\n * Gets the path of the snapshot tree to be read.\n * @param versionId - version ID.\n * @param count - Number of versions to be returned.\n */\n public async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n if (versionId === FileStorageDocumentName || versionId === null) {\n if (this.docTree || this.versionName !== undefined) {\n return [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n }\n // Started with ops - return empty set.\n return [];\n } else if (this.versionName !== undefined) {\n assert(!!this.docTree, 0x094 /* \"Missing snapshot tree!\" */);\n return [{\n id: versionId,\n treeId: FileStorageVersionTreeId,\n }];\n }\n throw new Error(`Unknown version: ${versionId}`);\n }\n\n public async readBlob(sha: string): Promise<ArrayBufferLike> {\n if (this.versionName !== undefined) {\n const fileName = `${this.path}/${this.versionName}/${sha}`;\n if (fs.existsSync(fileName)) {\n const data = fs.readFileSync(fileName);\n return data;\n }\n }\n throw new Error(`Can't find blob ${sha}`);\n }\n}\n\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n onSnapshotHandler(snapshot: IFileSnapshot): void;\n reset(): void;\n}\n\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\nexport const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(Base: TBase) =>\n class extends Base implements ISnapshotWriterStorage {\n // Note: if variable name has same name as in base class, it overrides it!\n public blobsWriter = new Map<string, ArrayBufferLike>();\n public latestWriterTree?: api.ISnapshotTree;\n public docId?: string;\n\n public reset() {\n this.blobsWriter = new Map<string, ArrayBufferLike>();\n this.latestWriterTree = undefined;\n this.docId = undefined;\n }\n\n public onSnapshotHandler(snapshot: IFileSnapshot): void {\n throw new Error(\"onSnapshotHandler is not setup! Please provide your handler!\");\n }\n\n public async readBlob(sha: string): Promise<ArrayBufferLike> {\n const blob = this.blobsWriter.get(sha);\n if (blob !== undefined) {\n return blob;\n }\n return super.readBlob(sha);\n }\n\n public async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n // If we already saved document, that means we are getting here because of snapshot generation.\n // Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for\n // each unchanged data store.\n // If we want to change that, we would need to capture docId on first call and return this.latestWriterTree\n // when latest is requested.\n if (this.latestWriterTree && (this.docId === versionId || versionId === null)) {\n return [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n }\n\n if (this.docId === undefined && versionId !== null) {\n this.docId = versionId;\n }\n\n return super.getVersions(versionId, count);\n }\n\n public async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n if (this.latestWriterTree && (!version || version.id === \"latest\")) {\n return this.latestWriterTree;\n }\n return super.getSnapshotTree(version);\n }\n\n public async uploadSummaryWithContext(summary: api.ISummaryTree, context: ISummaryContext): Promise<string> {\n const tree = convertSummaryTreeToSnapshotITree(summary);\n\n // Remove tree IDs for easier comparison of snapshots\n delete tree.id;\n removeNullTreeIds(tree);\n\n this.latestWriterTree = buildSnapshotTree(tree.entries, this.blobsWriter);\n\n const fileSnapshot: IFileSnapshot = { tree, commits: {} };\n this.onSnapshotHandler(fileSnapshot);\n return \"testHandleId\";\n }\n\n public async buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree> {\n const tree: api.ITree = { entries: [] };\n\n for (const subTreeId of Object.keys(snapshotTree.trees)) {\n const subTree = await this.buildTree(snapshotTree.trees[subTreeId]);\n tree.entries.push({\n mode: api.FileMode.Directory,\n path: subTreeId,\n type: api.TreeEntry.Tree,\n value: subTree,\n });\n }\n\n for (const blobName of Object.keys(snapshotTree.blobs)) {\n const buffer = await this.readBlob(snapshotTree.blobs[blobName]);\n const contents = bufferToString(buffer, \"utf8\");\n const blob: api.IBlob = {\n contents,\n encoding: \"utf-8\",\n };\n tree.entries.push({\n mode: api.FileMode.File,\n path: blobName,\n type: api.TreeEntry.Blob,\n value: blob,\n });\n }\n\n return tree;\n }\n };\n\nfunction removeNullTreeIds(tree: api.ITree) {\n for (const node of tree.entries) {\n if (node.type === api.TreeEntry.Tree) {\n removeNullTreeIds(node.value);\n }\n }\n assert(tree.id === undefined || tree.id === null,\n 0x096 /* \"Trying to remove valid tree IDs in removeNullTreeIds()!\" */);\n delete tree.id;\n}\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
|
1
|
+
{"version":3,"file":"fileDocumentStorageService.js","sourceRoot":"","sources":["../src/fileDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4CAAoB;AACpB,+DAAsE;AAEtE,+DAAoG;AACpG,0EAA4D;AAC5D,iEAA8F;AAE9F,iDAAiD;AACjD,gFAAgF;AACnE,QAAA,uBAAuB,GAAG,kBAAkB,CAAC,CAAC,4BAA4B;AAEvF,8FAA8F;AAC9F,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAErD;;GAEG;AACH,MAAa,gBACZ,SAAQ,8CAA8B;IAKtC,YAA6B,IAAY,EAAmB,WAAoB;QAC/E,KAAK,EAAE,CAAC;QADoB,SAAI,GAAJ,IAAI,CAAQ;QAAmB,gBAAW,GAAX,WAAW,CAAS;QAFtE,YAAO,GAA6B,IAAI,CAAC;IAInD,CAAC;IAED;;;OAGG;IACI,KAAK,CAAC,eAAe,CAAC,OAAsB;QAClD,IAAA,qBAAM,EAAC,OAAO,KAAK,IAAI,EAAE,KAAK,CAAC,wDAAwD,CAAC,CAAC;QACzF,IAAA,qBAAM,EACL,CAAC,OAAO,IAAI,OAAO,C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CAAC,IAAI;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,GAAG,CAAC,SAAS,CAAC,IAAI;gBACxB,KAAK,EAAE,IAAI;aACX,CAAC,CAAC;SACH;QAED,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAC;AAhGU,QAAA,8BAA8B,kCAgGxC;AAEH,SAAS,iBAAiB,CAAC,IAAe;IACzC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,OAAO,EAAE;QAChC,IAAI,IAAI,CAAC,IAAI,KAAK,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE;YACrC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SAC9B;KACD;IACD,IAAA,qBAAM,EACL,IAAI,CAAC,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,EACzC,KAAK,CAAC,+DAA+D,CACrE,CAAC;IACF,OAAO,IAAI,CAAC,EAAE,CAAC;AAChB,CAAC;AACY,QAAA,kCAAkC,GAAG,IAAA,sCAA8B,EAAC,gBAAgB,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport fs from \"fs\";\nimport { assert, bufferToString } from \"@fluidframework/common-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { buildSnapshotTree, convertSummaryTreeToSnapshotITree } from \"@fluidframework/driver-utils\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { IFileSnapshot, ReadDocumentStorageServiceBase } from \"@fluidframework/replay-driver\";\n\n// This ID is used by replay tool as Document Id.\n// We leverage it to figure out when container is asking for root document tree.\nexport const FileStorageDocumentName = \"FileStorageDocId\"; // Some unique document name\n\n// Tree ID use to communicate between getVersions() & getSnapshotTree() that IVersion is ours.\nconst FileStorageVersionTreeId = \"FileStorageTreeId\";\n\n/**\n * Document storage service for the file driver.\n */\nexport class FluidFetchReader\n\textends ReadDocumentStorageServiceBase\n\timplements IDocumentStorageService\n{\n\tprotected docTree: api.ISnapshotTree | null = null;\n\n\tconstructor(private readonly path: string, private readonly versionName?: string) {\n\t\tsuper();\n\t}\n\n\t/**\n\t * Read the file and returns the snapshot tree.\n\t * @param version - The version contains the path of the file which contains the snapshot tree.\n\t */\n\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\tassert(version !== null, 0x092 /* \"version input for reading snapshot tree is null!\" */);\n\t\tassert(\n\t\t\t!version || version.treeId === FileStorageVersionTreeId,\n\t\t\t0x093 /* \"invalid version input for reading snapshot tree!\" */,\n\t\t);\n\n\t\tlet filename: string;\n\t\tlet rootTree = false;\n\t\tif (!version || version.id === \"latest\") {\n\t\t\tif (this.docTree) {\n\t\t\t\treturn this.docTree;\n\t\t\t}\n\t\t\tif (this.versionName === undefined) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\trootTree = true;\n\t\t\tfilename = `${this.path}/${this.versionName}/tree.json`;\n\t\t} else {\n\t\t\tfilename = `${this.path}/${this.versionName}/${version.id}.json`;\n\t\t}\n\n\t\tif (!fs.existsSync(filename)) {\n\t\t\tthrow new Error(`Can't find file ${filename}`);\n\t\t}\n\t\tconst data = fs.readFileSync(filename);\n\t\tconst tree = JSON.parse(data.toString(\"utf-8\"));\n\t\tif (rootTree) {\n\t\t\tthis.docTree = tree;\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn tree;\n\t}\n\n\t/**\n\t * Gets the path of the snapshot tree to be read.\n\t * @param versionId - version ID.\n\t * @param count - Number of versions to be returned.\n\t */\n\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\tif (versionId === FileStorageDocumentName || versionId === null) {\n\t\t\tif (this.docTree || this.versionName !== undefined) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\t\t\t// Started with ops - return empty set.\n\t\t\treturn [];\n\t\t} else if (this.versionName !== undefined) {\n\t\t\tassert(!!this.docTree, 0x094 /* \"Missing snapshot tree!\" */);\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: versionId,\n\t\t\t\t\ttreeId: FileStorageVersionTreeId,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\t\tthrow new Error(`Unknown version: ${versionId}`);\n\t}\n\n\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\tif (this.versionName !== undefined) {\n\t\t\tconst fileName = `${this.path}/${this.versionName}/${sha}`;\n\t\t\tif (fs.existsSync(fileName)) {\n\t\t\t\tconst data = fs.readFileSync(fileName);\n\t\t\t\treturn data;\n\t\t\t}\n\t\t}\n\t\tthrow new Error(`Can't find blob ${sha}`);\n\t}\n}\n\nexport interface ISnapshotWriterStorage extends IDocumentStorageService {\n\tonSnapshotHandler(snapshot: IFileSnapshot): void;\n\treset(): void;\n}\n\nexport type ReaderConstructor = new (...args: any[]) => IDocumentStorageService;\nexport const FileSnapshotWriterClassFactory = <TBase extends ReaderConstructor>(Base: TBase) =>\n\tclass extends Base implements ISnapshotWriterStorage {\n\t\t// Note: if variable name has same name as in base class, it overrides it!\n\t\tpublic blobsWriter = new Map<string, ArrayBufferLike>();\n\t\tpublic latestWriterTree?: api.ISnapshotTree;\n\t\tpublic docId?: string;\n\n\t\tpublic reset() {\n\t\t\tthis.blobsWriter = new Map<string, ArrayBufferLike>();\n\t\t\tthis.latestWriterTree = undefined;\n\t\t\tthis.docId = undefined;\n\t\t}\n\n\t\tpublic onSnapshotHandler(snapshot: IFileSnapshot): void {\n\t\t\tthrow new Error(\"onSnapshotHandler is not setup! Please provide your handler!\");\n\t\t}\n\n\t\tpublic async readBlob(sha: string): Promise<ArrayBufferLike> {\n\t\t\tconst blob = this.blobsWriter.get(sha);\n\t\t\tif (blob !== undefined) {\n\t\t\t\treturn blob;\n\t\t\t}\n\t\t\treturn super.readBlob(sha);\n\t\t}\n\n\t\tpublic async getVersions(versionId: string | null, count: number): Promise<api.IVersion[]> {\n\t\t\t// If we already saved document, that means we are getting here because of snapshot generation.\n\t\t\t// Not returning tree ensures that ContainerRuntime.snapshot() would regenerate subtrees for\n\t\t\t// each unchanged data store.\n\t\t\t// If we want to change that, we would need to capture docId on first call and return this.latestWriterTree\n\t\t\t// when latest is requested.\n\t\t\tif (this.latestWriterTree && (this.docId === versionId || versionId === null)) {\n\t\t\t\treturn [{ id: \"latest\", treeId: FileStorageVersionTreeId }];\n\t\t\t}\n\n\t\t\tif (this.docId === undefined && versionId !== null) {\n\t\t\t\tthis.docId = versionId;\n\t\t\t}\n\n\t\t\treturn super.getVersions(versionId, count);\n\t\t}\n\n\t\tpublic async getSnapshotTree(version?: api.IVersion): Promise<api.ISnapshotTree | null> {\n\t\t\tif (this.latestWriterTree && (!version || version.id === \"latest\")) {\n\t\t\t\treturn this.latestWriterTree;\n\t\t\t}\n\t\t\treturn super.getSnapshotTree(version);\n\t\t}\n\n\t\tpublic async uploadSummaryWithContext(\n\t\t\tsummary: api.ISummaryTree,\n\t\t\tcontext: ISummaryContext,\n\t\t): Promise<string> {\n\t\t\tconst tree = convertSummaryTreeToSnapshotITree(summary);\n\n\t\t\t// Remove tree IDs for easier comparison of snapshots\n\t\t\tdelete tree.id;\n\t\t\tremoveNullTreeIds(tree);\n\n\t\t\tthis.latestWriterTree = buildSnapshotTree(tree.entries, this.blobsWriter);\n\n\t\t\tconst fileSnapshot: IFileSnapshot = { tree, commits: {} };\n\t\t\tthis.onSnapshotHandler(fileSnapshot);\n\t\t\treturn \"testHandleId\";\n\t\t}\n\n\t\tpublic async buildTree(snapshotTree: api.ISnapshotTree): Promise<api.ITree> {\n\t\t\tconst tree: api.ITree = { entries: [] };\n\n\t\t\tfor (const subTreeId of Object.keys(snapshotTree.trees)) {\n\t\t\t\tconst subTree = await this.buildTree(snapshotTree.trees[subTreeId]);\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.Directory,\n\t\t\t\t\tpath: subTreeId,\n\t\t\t\t\ttype: api.TreeEntry.Tree,\n\t\t\t\t\tvalue: subTree,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const blobName of Object.keys(snapshotTree.blobs)) {\n\t\t\t\tconst buffer = await this.readBlob(snapshotTree.blobs[blobName]);\n\t\t\t\tconst contents = bufferToString(buffer, \"utf8\");\n\t\t\t\tconst blob: api.IBlob = {\n\t\t\t\t\tcontents,\n\t\t\t\t\tencoding: \"utf-8\",\n\t\t\t\t};\n\t\t\t\ttree.entries.push({\n\t\t\t\t\tmode: api.FileMode.File,\n\t\t\t\t\tpath: blobName,\n\t\t\t\t\ttype: api.TreeEntry.Blob,\n\t\t\t\t\tvalue: blob,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn tree;\n\t\t}\n\t};\n\nfunction removeNullTreeIds(tree: api.ITree) {\n\tfor (const node of tree.entries) {\n\t\tif (node.type === api.TreeEntry.Tree) {\n\t\t\tremoveNullTreeIds(node.value);\n\t\t}\n\t}\n\tassert(\n\t\ttree.id === undefined || tree.id === null,\n\t\t0x096 /* \"Trying to remove valid tree IDs in removeNullTreeIds()!\" */,\n\t);\n\tdelete tree.id;\n}\nexport const FluidFetchReaderFileSnapshotWriter = FileSnapshotWriterClassFactory(FluidFetchReader);\n"]}
|
package/dist/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/file-driver";
|
|
8
|
-
export declare const pkgVersion = "2.0.0-internal.3.0
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.3.2.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/file-driver";
|
|
11
|
-
exports.pkgVersion = "2.0.0-internal.3.0
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.3.2.0";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/file-driver\";\nexport const pkgVersion = \"2.0.0-internal.3.0
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/file-driver\";\nexport const pkgVersion = \"2.0.0-internal.3.2.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/file-driver",
|
|
3
|
-
"version": "2.0.0-internal.3.0
|
|
3
|
+
"version": "2.0.0-internal.3.2.0",
|
|
4
4
|
"description": "A driver that reads/write from/to local file storage.",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -14,40 +14,20 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"module": "lib/index.js",
|
|
16
16
|
"types": "dist/index.d.ts",
|
|
17
|
-
"scripts": {
|
|
18
|
-
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
19
|
-
"build:compile": "concurrently npm:typetests:gen npm:tsc",
|
|
20
|
-
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
21
|
-
"build:full": "npm run build",
|
|
22
|
-
"build:full:compile": "npm run build:compile",
|
|
23
|
-
"build:genver": "gen-version",
|
|
24
|
-
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
25
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
26
|
-
"eslint": "eslint --format stylish src",
|
|
27
|
-
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
28
|
-
"format": "npm run prettier:fix",
|
|
29
|
-
"lint": "npm run eslint",
|
|
30
|
-
"lint:fix": "npm run eslint:fix",
|
|
31
|
-
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
32
|
-
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
33
|
-
"tsc": "tsc",
|
|
34
|
-
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
35
|
-
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
36
|
-
},
|
|
37
17
|
"dependencies": {
|
|
38
18
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
39
|
-
"@fluidframework/common-utils": "^1.
|
|
40
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.3.0
|
|
41
|
-
"@fluidframework/driver-utils": ">=2.0.0-internal.3.0
|
|
19
|
+
"@fluidframework/common-utils": "^1.1.1",
|
|
20
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
21
|
+
"@fluidframework/driver-utils": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0",
|
|
42
22
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
43
|
-
"@fluidframework/replay-driver": ">=2.0.0-internal.3.0
|
|
23
|
+
"@fluidframework/replay-driver": ">=2.0.0-internal.3.2.0 <2.0.0-internal.4.0.0"
|
|
44
24
|
},
|
|
45
25
|
"devDependencies": {
|
|
46
|
-
"@fluid-tools/build-cli": "^0.
|
|
26
|
+
"@fluid-tools/build-cli": "^0.10.0",
|
|
47
27
|
"@fluidframework/build-common": "^1.1.0",
|
|
48
|
-
"@fluidframework/build-tools": "^0.
|
|
28
|
+
"@fluidframework/build-tools": "^0.10.0",
|
|
49
29
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
50
|
-
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-internal.3.
|
|
30
|
+
"@fluidframework/file-driver-previous": "npm:@fluidframework/file-driver@2.0.0-internal.3.1.0",
|
|
51
31
|
"@microsoft/api-extractor": "^7.22.2",
|
|
52
32
|
"@rushstack/eslint-config": "^2.5.1",
|
|
53
33
|
"@types/node": "^14.18.36",
|
|
@@ -59,9 +39,30 @@
|
|
|
59
39
|
"typescript": "~4.5.5"
|
|
60
40
|
},
|
|
61
41
|
"typeValidation": {
|
|
62
|
-
"version": "2.0.0-internal.3.0
|
|
63
|
-
"previousVersionStyle": "
|
|
64
|
-
"baselineRange": "2.0.0-internal.3.0.0",
|
|
42
|
+
"version": "2.0.0-internal.3.2.0",
|
|
43
|
+
"previousVersionStyle": "~previousMinor",
|
|
44
|
+
"baselineRange": ">=2.0.0-internal.3.1.0 <2.0.0-internal.3.2.0",
|
|
45
|
+
"baselineVersion": "2.0.0-internal.3.1.0",
|
|
65
46
|
"broken": {}
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
|
|
50
|
+
"build:compile": "concurrently npm:typetests:gen npm:tsc",
|
|
51
|
+
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
52
|
+
"build:full": "npm run build",
|
|
53
|
+
"build:full:compile": "npm run build:compile",
|
|
54
|
+
"build:genver": "gen-version",
|
|
55
|
+
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
56
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
57
|
+
"eslint": "eslint --format stylish src",
|
|
58
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
59
|
+
"format": "npm run prettier:fix",
|
|
60
|
+
"lint": "npm run prettier && npm run eslint",
|
|
61
|
+
"lint:fix": "npm run prettier:fix && npm run eslint:fix",
|
|
62
|
+
"prettier": "prettier --check . --ignore-path ../../../.prettierignore",
|
|
63
|
+
"prettier:fix": "prettier --write . --ignore-path ../../../.prettierignore",
|
|
64
|
+
"tsc": "tsc",
|
|
65
|
+
"typetests:gen": "flub generate typetests --generate --dir .",
|
|
66
|
+
"typetests:prepare": "flub generate typetests --prepare --dir . --pin"
|
|
66
67
|
}
|
|
67
|
-
}
|
|
68
|
+
}
|
package/prettier.config.cjs
CHANGED
|
@@ -13,60 +13,63 @@ import * as api from "@fluidframework/protocol-definitions";
|
|
|
13
13
|
* Provides access to the underlying delta storage on the local file storage for file driver.
|
|
14
14
|
*/
|
|
15
15
|
export class FileDeltaStorageService implements IDocumentDeltaStorageService {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
private readonly messages: api.ISequencedDocumentMessage[];
|
|
17
|
+
private lastOps: api.ISequencedDocumentMessage[] = [];
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
constructor(private readonly path: string) {
|
|
20
|
+
this.messages = [];
|
|
21
|
+
let counter = 0;
|
|
22
|
+
// eslint-disable-next-line no-constant-condition
|
|
23
|
+
while (true) {
|
|
24
|
+
const filename = `${this.path}//messages${counter === 0 ? "" : counter}.json`;
|
|
25
|
+
if (!fs.existsSync(filename)) {
|
|
26
|
+
if (counter === 0) {
|
|
27
|
+
throw new Error(`file ${filename} not found`);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
const data = fs.readFileSync(filename);
|
|
32
|
+
this.messages = this.messages.concat(JSON.parse(data.toString("utf-8")));
|
|
33
|
+
counter++;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
public fetchMessages(
|
|
38
|
+
from: number,
|
|
39
|
+
to: number | undefined,
|
|
40
|
+
abortSignal?: AbortSignal,
|
|
41
|
+
cachedOnly?: boolean,
|
|
42
|
+
): IStream<api.ISequencedDocumentMessage[]> {
|
|
43
|
+
return emptyMessageStream;
|
|
44
|
+
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
public get ops(): readonly Readonly<api.ISequencedDocumentMessage>[] {
|
|
47
|
+
return this.messages;
|
|
48
|
+
}
|
|
48
49
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve ops within the exclusive sequence number range.
|
|
52
|
+
*
|
|
53
|
+
* @param from - First op to be fetched.
|
|
54
|
+
* @param to - Last op to be fetched. This is exclusive.
|
|
55
|
+
*/
|
|
56
|
+
public getFromWebSocket(from: number, to: number): api.ISequencedDocumentMessage[] {
|
|
57
|
+
const readFrom = Math.max(from, 0); // Inclusive
|
|
58
|
+
const readTo = Math.min(to, this.messages.length); // Exclusive
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
if (readFrom >= this.messages.length || readTo <= 0 || readFrom >= readTo) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
64
|
+
// Optimizations for multiple readers (replay tool)
|
|
65
|
+
if (this.lastOps.length > 0 && this.lastOps[0].sequenceNumber === readFrom + 1) {
|
|
66
|
+
return this.lastOps;
|
|
67
|
+
}
|
|
68
|
+
this.lastOps = this.messages.slice(readFrom, readTo);
|
|
69
|
+
assert(
|
|
70
|
+
this.lastOps[0].sequenceNumber === readFrom + 1,
|
|
71
|
+
0x091 /* "Retrieved ops' first sequence number has unexpected value!" */,
|
|
72
|
+
);
|
|
73
|
+
return this.lastOps;
|
|
74
|
+
}
|
|
72
75
|
}
|