@fluidframework/local-driver 2.74.0-368706 → 2.74.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/localDeltaStorageService.js.map +1 -1
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/localDocumentDeltaConnection.js.map +1 -1
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localLayerCompatState.js +1 -1
- package/dist/localLayerCompatState.js.map +1 -1
- package/dist/localSessionStorageDb.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/eslint.config.mts +29 -0
- package/lib/localDeltaStorageService.js.map +1 -1
- package/lib/localDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/localDocumentDeltaConnection.js.map +1 -1
- package/lib/localDocumentService.d.ts.map +1 -1
- package/lib/localDocumentService.js.map +1 -1
- package/lib/localDocumentServiceFactory.d.ts.map +1 -1
- package/lib/localDocumentServiceFactory.js.map +1 -1
- package/lib/localDocumentStorageService.js.map +1 -1
- package/lib/localLayerCompatState.js +1 -1
- package/lib/localLayerCompatState.js.map +1 -1
- package/lib/localSessionStorageDb.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +14 -13
- package/src/localDeltaStorageService.ts +1 -1
- package/src/localDocumentDeltaConnection.ts +2 -2
- package/src/localDocumentService.ts +1 -1
- package/src/localDocumentServiceFactory.ts +7 -2
- package/src/localDocumentStorageService.ts +2 -2
- package/src/localLayerCompatState.ts +1 -1
- package/src/localSessionStorageDb.ts +3 -3
- package/src/packageVersion.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAOH,oEAA2E;AAG3E;;;GAGG;AACH,MAAa,wBAAwB;IACpC,YACkB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IAChD,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,IAAA,6BAAkB,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC9C,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,CAAC;QACvC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD;AA9BD,4DA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\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<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number) {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["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;AA9BD,4DA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\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<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCA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C","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string) {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t) {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,mEAA+E;AAE/E,0EAIqD;AAGrD,uEAA6E;AAG7E,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;GAGG;A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GAAG,EAClB,OAAsB,wBAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD;AArFD,oEAqFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string): void {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t): void {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAKlF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mCAAmC,CAAC;AAGjF;;;GAGG;AACH,qBAAa,oBACZ,SAAQ,iBAAiB,CAAC,sBAAsB,CAChD,YAAW,gBAAgB;aASV,WAAW,EAAE,YAAY;IACzC,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,2BAA2B;aAC5B,QAAQ,EAAE,wBAAwB;IAClD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IAfzB;;;;;OAKG;gBAEc,WAAW,EAAE,YAAY,EACxB,0BAA0B,EAAE,2BAA2B,EACvD,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,2BAA2B,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,GAAG,CAAC,QAAQ,EAAE,uBAAuB,CAAC,CAAC;QAExE,kFAAkF;QAClF,uBAAuB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC7C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;CACD;AA7FD,oDA6FC;AAED;;;;;;;GAOG;AACH,SAAgB,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC,EACvC,MAA6B;IAE7B,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,EACpB,MAAM,CACN,CAAC;AACH,CAAC;AAtBD,gEAsBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\n\nimport { LocalDeltaStorageService } from \"./localDeltaStorageService.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { LocalDocumentStorageService } from \"./localDocumentStorageService.js\";\n\n/**\n * Basic implementation of a document service for local use.\n * @internal\n */\nexport class LocalDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t * @param tokenProvider - token provider\n\t * @param tenantId - ID of tenant\n\t * @param documentId - ID of document\n\t */\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly documentId: string,\n\t\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\t\tpublic readonly policies: IDocumentServicePolicies = { supportGetSnapshotApi: true },\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(): void {}\n\n\t/**\n\t * Creates and returns a document storage service for local use.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn new LocalDocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tnew GitManager(\n\t\t\t\tnew TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),\n\t\t\t),\n\t\t\t{\n\t\t\t\tmaximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n\t\t\t},\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\tthis.resolvedUrl,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta storage service for local use.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStorage();\n\t\t}\n\t\treturn new LocalDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tthis.localDeltaConnectionServer.databaseManager,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta stream for local use.\n\t * @param client - client data\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.policies.storageOnly === true) {\n\t\t\tthrow new Error(\"can't connect to delta stream in storage-only mode\");\n\t\t}\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStream(client);\n\t\t}\n\t\tconst ordererToken = await this.tokenProvider.fetchOrdererToken(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t);\n\t\tconst documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tordererToken.jwt,\n\t\t\tclient,\n\t\t\tthis.localDeltaConnectionServer.webSocketServer,\n\t\t\tundefined,\n\t\t\tthis.logger,\n\t\t);\n\t\tconst clientId = documentDeltaConnection.clientId;\n\n\t\t// Add this document service for the clientId in the document service factory.\n\t\tthis.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n\t\t// Add a listener to remove this document service when the client is disconnected.\n\t\tdocumentDeltaConnection.on(\"disconnect\", () => {\n\t\t\tthis.documentDeltaConnectionsMap.delete(clientId);\n\t\t});\n\n\t\treturn documentDeltaConnection;\n\t}\n}\n\n/**\n * Creates and returns a document service for local use.\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider with a single token\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n * @internal\n */\nexport function createLocalDocumentService(\n\tresolvedUrl: IResolvedUrl,\n\tlocalDeltaConnectionServer: ILocalDeltaConnectionServer,\n\ttokenProvider: ITokenProvider,\n\ttenantId: string,\n\tdocumentId: string,\n\tdocumentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\tpolicies?: IDocumentServicePolicies,\n\tinnerDocumentService?: IDocumentService,\n\tlogger?: ITelemetryBaseLogger,\n): IDocumentService {\n\treturn new LocalDocumentService(\n\t\tresolvedUrl,\n\t\tlocalDeltaConnectionServer,\n\t\ttokenProvider,\n\t\ttenantId,\n\t\tdocumentId,\n\t\tdocumentDeltaConnectionsMap,\n\t\tpolicies,\n\t\tinnerDocumentService,\n\t\tlogger,\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAOlF;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IASzE,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IATvC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CACjC;IAEX;;OAEG;gBAEe,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,CAAC,sCAA0B,EACnC,oBAAoB,CAAC,8BAAkB;IAGzD;;;;;;OAMG;IACH,SAAgB,mBAAmB,CAAC,EAAE,OAAO,CAAqC;IAErE,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAU5B;;;;OAIG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,E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S,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD;AA7GD,kEA6GC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver/internal\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { createLocalDocumentService } from \"./localDocumentService.js\";\nimport { localDriverCompatDetailsForLoader } from \"./localLayerCompatState.js\";\n\n/**\n * Implementation of document service factory for local use.\n * @legacy @beta\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n\t// A map of clientId to LocalDocumentService.\n\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =\n\t\tnew Map();\n\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t */\n\tconstructor(\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly policies?: IDocumentServicePolicies,\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\t/**\n\t * The compatibility details of the Local Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = localDriverCompatDetailsForLoader;\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tif (createNewSummary !== undefined) {\n\t\t\tawait createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);\n\t\t}\n\t\treturn this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n\t}\n\n\t/**\n\t * Creates and returns a document service for testing using the given resolved\n\t * URL for the tenant ID, document ID, and token.\n\t * @param resolvedUrl - resolved URL of document\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname ? parsedUrl.pathname.split(\"/\") : [];\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst fluidResolvedUrl = resolvedUrl;\n\t\tconst jwtToken = fluidResolvedUrl.tokens.jwt;\n\t\tif (!jwtToken) {\n\t\t\tthrow new Error(`Token was not provided.`);\n\t\t}\n\n\t\tconst tokenProvider = new DefaultTokenProvider(jwtToken);\n\n\t\treturn createLocalDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\ttokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.documentDeltaConnectionsMap,\n\t\t\tthis.policies,\n\t\t\tthis.innerDocumentService,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to disconnect the client.\n\t * @param clientId - The ID of the client to be disconnected.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(clientId: string, disconnectReason: string): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.disconnectClient(disconnectReason);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to nack the client.\n\t * @param clientId - The ID of the client to be Nack'd.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tclientId: string,\n\t\tcode?: number,\n\t\ttype?: NackErrorType,\n\t\tmessage?: any,\n\t): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.nackClient(code, type, message);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAKsC;AACtC,kEAA6D;AAa7D,iEAAsE;AAEtE,mFAIgD;AAEhD,qEAA0D;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAa,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY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AAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AA3SD,kEA2SC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAKsC;AACtC,kEAA6D;AAa7D,iEAAsE;AAEtE,mFAIgD;AAEhD,qEAA0D;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAa,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QACxC,+BAA0B,GAA1B,0BAA0B,CAA8B;QACxD,gBAAW,GAAX,WAAW,CAAe;QAV5C,uFAAuF;QACvF,2BAA2B;QACR,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAU5D,IAAI,CAAC,wBAAwB,GAAG,IAAI,iDAAwB,CAC3D,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CACvC,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,SAAwB,EAAE,KAAa;QAC/D,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC/B,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI;YAC/B,EAAE,E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C,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YACnD,0CAA0C;YAC1C,oEAAoE;YACpE,OAAO,OAAO,CAAC,CAAC,CAAE,CAAC,EAAE,CAAC;QACvB,CAAC;QACD,OAAO,IAAI,CAAC,wBAAwB,CAAC,gBAAgB,CACpD,OAAO,EACP,OAAO,CAAC,SAAS,IAAI,EAAE,EACvB,SAAS,CACT,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,OAAO;aACjB,UAAU,CAAC,IAAA,iCAAkB,EAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;aAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AA3SD,kEA2SC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<void> {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined): void {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localLayerCompatState.js","sourceRoot":"","sources":["../src/localLayerCompatState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2DAAiD;AAEjD;;;GAGG;AACU,QAAA,iCAAiC,GAAwB;IACrE;;OAEG;IACH,UAAU,EAAV,8BAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Local Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const localDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Local Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Local Driver layer.\n\t */\n\tgeneration:
|
|
1
|
+
{"version":3,"file":"localLayerCompatState.js","sourceRoot":"","sources":["../src/localLayerCompatState.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH,2DAAiD;AAEjD;;;GAGG;AACU,QAAA,iCAAiC,GAAwB;IACrE;;OAEG;IACH,UAAU,EAAV,8BAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Local Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const localDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Local Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Local Driver layer.\n\t */\n\tgeneration: 3,\n\t/**\n\t * The features supported by the Local Driver layer across the Driver / Loader boundary.\n\t */\n\tsupportedFeatures: new Set<string>(),\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QAC3D,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,QAA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IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAa,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QAC3D,MAAM,IAAI,KAA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AC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAa,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string): any {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b): number {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]): void {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\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/local-driver";
|
|
8
|
-
export declare const pkgVersion = "2.74.0
|
|
8
|
+
export declare const pkgVersion = "2.74.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
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/local-driver";
|
|
11
|
-
exports.pkgVersion = "2.74.0
|
|
11
|
+
exports.pkgVersion = "2.74.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,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,QAAQ,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/local-driver\";\nexport const pkgVersion = \"2.74.0\";\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/**
|
|
3
|
+
* GENERATED FILE - DO NOT EDIT DIRECTLY.
|
|
4
|
+
* To regenerate: pnpm tsx scripts/generate-flat-eslint-configs.ts --typescript
|
|
5
|
+
*/
|
|
6
|
+
import type { Linter } from "eslint";
|
|
7
|
+
import { minimalDeprecated } from "../../../common/build/eslint-config-fluid/flat.mts";
|
|
8
|
+
|
|
9
|
+
const config: Linter.Config[] = [
|
|
10
|
+
...minimalDeprecated,
|
|
11
|
+
{
|
|
12
|
+
rules: {
|
|
13
|
+
"@typescript-eslint/strict-boolean-expressions": "off",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
files: ["*.spec.ts", "src/test/**"],
|
|
18
|
+
rules: {
|
|
19
|
+
"import-x/no-nodejs-modules": [
|
|
20
|
+
"error",
|
|
21
|
+
{
|
|
22
|
+
"allow": ["assert"],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
export default config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IAChD,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC9C,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,CAAC;QACvC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\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<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number) {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAG3E;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACpC,YACkB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IAChD,CAAC;IAEG,aAAa,CACnB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEpB,OAAO,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC9C,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC/D,KAAK,CAAC,0BAA0B,CAAC,GAAG,EAAE,CAAC;QACvC,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,oBAAoB;QAEtE,kFAAkF;QAClF,iBAAiB;QACjB,KAAK,CAAC,0BAA0B,CAAC,CAAC,GAAG,GAAG,EAAE,IAAI,MAAM,CAAC,gBAAgB,CAAC;QAEtE,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QACxF,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,0BAA0B,EAAE,CAAC,EAAE,CAAC,CAAC;QAChF,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAC1D,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaStorageService,\n\tIStream,\n\tISequencedDocumentMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils/internal\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n * @internal\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly databaseManager: IDatabaseManager,\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<ISequencedDocumentMessage[]> {\n\t\treturn streamFromMessages(this.getCore(from, to));\n\t}\n\n\tprivate async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {\n\t\tconst query = { documentId: this.id, tenantId: this.tenantId };\n\t\tquery[\"operation.sequenceNumber\"] = {};\n\t\tquery[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n\t\t// This looks like a bug. It used to work without setting $lt key. Now it does not\n\t\t// Need follow up\n\t\tquery[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n\t\tconst allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n\t\tconst dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n\t\tconst messages = dbDeltas.map((delta) => delta.operation);\n\t\treturn messages;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAEN,gBAAgB,EAChB,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;WACiB,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,EACjB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAI7E;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EAEN,gBAAgB,EAChB,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;;GAGG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;WACiB,MAAM,CACzB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,EACjB,MAAM,CAAC,EAAE,oBAAoB,GAC3B,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,oBAAoB;IAI7E;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAIvD;;;;;OAKG;IACI,UAAU,CAChB,IAAI,oBAAc,EAClB,IAAI,2BAA+C,EACnD,OAAO,EAAE,GAAG,GACV,IAAI;CAYP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentDeltaConnection.js","s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AAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAChB,OAAe,GAAG,EAClB,OAAsB,aAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string) {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t) {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,OAAO,EAGN,aAAa,GACb,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,uBAAuB;IACxE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,QAAgB,EAChB,EAAU,EACV,KAAa,EACb,MAAe,EACf,eAAiC,EACjC,SAAS,GAAG,KAAK,EACjB,MAA6B;QAE7B,MAAM,MAAM,GAAI,eAAwC,CAAC,gBAAgB,EAAE,CAAC;QAE5E,4GAA4G;QAC5G,0EAA0E;QAC1E,MAAM,kBAAkB,GAAG,MAA2B,CAAC;QAEvD,MAAM,eAAe,GAAG,IAAI,4BAA4B,CAAC,kBAAkB,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;QAEzF,MAAM,cAAc,GAAa;YAChC,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK,EAAE,8DAA8D;YACrE,QAAQ,EAAE,oBAAoB;SAC9B,CAAC;QACF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IACxB,CAAC;IAED,YAAY,MAAc,EAAE,UAAkB,EAAE,MAA6B;QAC5E,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACzC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IAClD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAChB,OAAe,GAAG,EAClB,OAAsB,aAAa,CAAC,eAAe,EACnD,OAAY;QAEZ,MAAM,WAAW,GAAG;YACnB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACR,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACP;SACD,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAC7C,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\nimport { createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport type { Socket } from \"socket.io-client\";\n\nconst testProtocolVersions = [\"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\n\n/**\n * Represents a connection to a stream of delta updates\n * @internal\n */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n\t/**\n\t * Create a LocalDocumentDeltaConnection\n\t * Handle initial messages, contents or signals if they were in queue\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param id - document ID\n\t * @param token - authorization token for storage service\n\t * @param client - information about the client\n\t * @param webSocketServer - web socket server to create connection\n\t */\n\tpublic static async create(\n\t\ttenantId: string,\n\t\tid: string,\n\t\ttoken: string,\n\t\tclient: IClient,\n\t\twebSocketServer: IWebSocketServer,\n\t\ttimeoutMs = 60000,\n\t\tlogger?: ITelemetryBaseLogger,\n\t): Promise<LocalDocumentDeltaConnection> {\n\t\tconst socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n\t\t// Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n\t\t// but should be fine because this delta connection is for local use only.\n\t\tconst socketWithListener = socket as unknown as Socket;\n\n\t\tconst deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id, logger);\n\n\t\tconst connectMessage: IConnect = {\n\t\t\tclient,\n\t\t\tid,\n\t\t\tmode: client.mode,\n\t\t\ttenantId,\n\t\t\ttoken, // Token is going to indicate tenant level information, etc...\n\t\t\tversions: testProtocolVersions,\n\t\t};\n\t\tawait deltaConnection.initialize(connectMessage, timeoutMs);\n\t\treturn deltaConnection;\n\t}\n\n\tconstructor(socket: Socket, documentId: string, logger?: ITelemetryBaseLogger) {\n\t\tsuper(socket, documentId, createChildLogger({ logger }));\n\t}\n\n\t/**\n\t * Submits a new delta operation to the server\n\t */\n\tpublic submit(messages: IDocumentMessage[]): void {\n\t\t// We use a promise resolve to force a turn break given message processing is sync\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tPromise.resolve().then(() => {\n\t\t\tthis.emitMessages(\"submitOp\", [messages]);\n\t\t});\n\t}\n\n\t/**\n\t * Send a \"disconnect\" message on the socket.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(disconnectReason: string): void {\n\t\tthis.socket.emit(\"disconnect\", disconnectReason);\n\t}\n\n\t/**\n\t * * Sends a \"nack\" message on the socket.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tcode: number = 400,\n\t\ttype: NackErrorType = NackErrorType.ThrottlingError,\n\t\tmessage: any,\n\t): void {\n\t\tconst nackMessage = {\n\t\t\toperation: undefined,\n\t\t\tsequenceNumber: -1,\n\t\t\tcontent: {\n\t\t\t\tcode,\n\t\t\t\ttype,\n\t\t\t\tmessage,\n\t\t\t},\n\t\t};\n\t\tthis.socket.emit(\"nack\", \"\", [nackMessage]);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAA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ExE,kFAAkF;QAClF,uBAAuB,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,EAAE;YAC7C,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;CACD;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC,EACvC,MAA6B;IAE7B,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,EACpB,MAAM,CACN,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServiceEvents,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\n\nimport { LocalDeltaStorageService } from \"./localDeltaStorageService.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { LocalDocumentStorageService } from \"./localDocumentStorageService.js\";\n\n/**\n * Basic implementation of a document service for local use.\n * @internal\n */\nexport class LocalDocumentService\n\textends TypedEventEmitter<IDocumentServiceEvents>\n\timplements IDocumentService\n{\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t * @param tokenProvider - token provider\n\t * @param tenantId - ID of tenant\n\t * @param documentId - ID of document\n\t */\n\tconstructor(\n\t\tpublic readonly resolvedUrl: IResolvedUrl,\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly documentId: string,\n\t\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\t\tpublic readonly policies: IDocumentServicePolicies = { supportGetSnapshotApi: true },\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t\tprivate readonly logger?: ITelemetryBaseLogger,\n\t) {\n\t\tsuper();\n\t}\n\n\tpublic dispose(): void {}\n\n\t/**\n\t * Creates and returns a document storage service for local use.\n\t */\n\tpublic async connectToStorage(): Promise<IDocumentStorageService> {\n\t\treturn new LocalDocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tnew GitManager(\n\t\t\t\tnew TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase),\n\t\t\t),\n\t\t\t{\n\t\t\t\tmaximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n\t\t\t},\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\tthis.resolvedUrl,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta storage service for local use.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStorage();\n\t\t}\n\t\treturn new LocalDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tthis.localDeltaConnectionServer.databaseManager,\n\t\t);\n\t}\n\n\t/**\n\t * Creates and returns a delta stream for local use.\n\t * @param client - client data\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tif (this.policies.storageOnly === true) {\n\t\t\tthrow new Error(\"can't connect to delta stream in storage-only mode\");\n\t\t}\n\t\tif (this.innerDocumentService) {\n\t\t\treturn this.innerDocumentService.connectToDeltaStream(client);\n\t\t}\n\t\tconst ordererToken = await this.tokenProvider.fetchOrdererToken(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t);\n\t\tconst documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tordererToken.jwt,\n\t\t\tclient,\n\t\t\tthis.localDeltaConnectionServer.webSocketServer,\n\t\t\tundefined,\n\t\t\tthis.logger,\n\t\t);\n\t\tconst clientId = documentDeltaConnection.clientId;\n\n\t\t// Add this document service for the clientId in the document service factory.\n\t\tthis.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n\t\t// Add a listener to remove this document service when the client is disconnected.\n\t\tdocumentDeltaConnection.on(\"disconnect\", () => {\n\t\t\tthis.documentDeltaConnectionsMap.delete(clientId);\n\t\t});\n\n\t\treturn documentDeltaConnection;\n\t}\n}\n\n/**\n * Creates and returns a document service for local use.\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider with a single token\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n * @internal\n */\nexport function createLocalDocumentService(\n\tresolvedUrl: IResolvedUrl,\n\tlocalDeltaConnectionServer: ILocalDeltaConnectionServer,\n\ttokenProvider: ITokenProvider,\n\ttenantId: string,\n\tdocumentId: string,\n\tdocumentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n\tpolicies?: IDocumentServicePolicies,\n\tinnerDocumentService?: IDocumentService,\n\tlogger?: ITelemetryBaseLogger,\n): IDocumentService {\n\treturn new LocalDocumentService(\n\t\tresolvedUrl,\n\t\tlocalDeltaConnectionServer,\n\t\ttokenProvider,\n\t\ttenantId,\n\t\tdocumentId,\n\t\tdocumentDeltaConnectionsMap,\n\t\tpolicies,\n\t\tinnerDocumentService,\n\t\tlogger,\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EACN,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACZ,aAAa,EACb,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAOlF;;;GAGG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IASzE,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IATvC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CACjC;IAEX;;OAEG;gBAEe,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,CAAC,sCAA0B,EACnC,oBAAoB,CAAC,8BAAkB;IAGzD;;;;;;OAMG;IACH,SAAgB,mBAAmB,CAAC,EAAE,OAAO,CAAqC;IAErE,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAU5B;;;;OAIG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA8B5B;;;;OAIG;IACI,gBAAgB,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C;IAC5D,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAChB,QAAgB,EAChB,IAAa,EACb,IAAoB,EACpB,OAAa;QAEb,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;QACvD,CAAC;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\tNackErrorType,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver/internal\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection.js\";\nimport { createLocalDocumentService } from \"./localDocumentService.js\";\nimport { localDriverCompatDetailsForLoader } from \"./localLayerCompatState.js\";\n\n/**\n * Implementation of document service factory for local use.\n * @legacy @beta\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n\t// A map of clientId to LocalDocumentService.\n\tprivate readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> =\n\t\tnew Map();\n\n\t/**\n\t * @param localDeltaConnectionServer - delta connection server for ops\n\t */\n\tconstructor(\n\t\tprivate readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n\t\tprivate readonly policies?: IDocumentServicePolicies,\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\t/**\n\t * The compatibility details of the Local Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = localDriverCompatDetailsForLoader;\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tif (createNewSummary !== undefined) {\n\t\t\tawait createDocument(this.localDeltaConnectionServer, resolvedUrl, createNewSummary);\n\t\t}\n\t\treturn this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n\t}\n\n\t/**\n\t * Creates and returns a document service for testing using the given resolved\n\t * URL for the tenant ID, document ID, and token.\n\t * @param resolvedUrl - resolved URL of document\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname ? parsedUrl.pathname.split(\"/\") : [];\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst fluidResolvedUrl = resolvedUrl;\n\t\tconst jwtToken = fluidResolvedUrl.tokens.jwt;\n\t\tif (!jwtToken) {\n\t\t\tthrow new Error(`Token was not provided.`);\n\t\t}\n\n\t\tconst tokenProvider = new DefaultTokenProvider(jwtToken);\n\n\t\treturn createLocalDocumentService(\n\t\t\tresolvedUrl,\n\t\t\tthis.localDeltaConnectionServer,\n\t\t\ttokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.documentDeltaConnectionsMap,\n\t\t\tthis.policies,\n\t\t\tthis.innerDocumentService,\n\t\t\tlogger,\n\t\t);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to disconnect the client.\n\t * @param clientId - The ID of the client to be disconnected.\n\t * @param disconnectReason - The reason of the disconnection.\n\t */\n\tpublic disconnectClient(clientId: string, disconnectReason: string): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.disconnectClient(disconnectReason);\n\t}\n\n\t/**\n\t * Gets the document delta connection for the clientId and asks it to nack the client.\n\t * @param clientId - The ID of the client to be Nack'd.\n\t * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n\t * @param type - Type of the Nack.\n\t * @param message - A message about the nack for debugging/logging/telemetry purposes.\n\t */\n\tpublic nackClient(\n\t\tclientId: string,\n\t\tcode?: number,\n\t\ttype?: NackErrorType,\n\t\tmessage?: any,\n\t): void {\n\t\tconst documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n\t\tif (documentDeltaConnection === undefined) {\n\t\t\tthrow new Error(`No client with the id: ${clientId}`);\n\t\t}\n\t\tdocumentDeltaConnection.nackClient(code, type, message);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC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,CAAC;QACD,OAAO,IAAI,CAAC,wBAAwB,CAAC,gBAAgB,CACpD,OAAO,EACP,OAAO,CAAC,SAAS,IAAI,EAAE,EACvB,SAAS,CACT,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAqB;QAC5C,MAAM,cAAc,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,OAAO;aACjB,UAAU,CAAC,kBAAkB,CAAC,cAAc,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;aAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAa7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAGN,wBAAwB,GACxB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QACxC,+BAA0B,GAA1B,0BAA0B,CAA8B;QACxD,gBAAW,GAAX,WAAW,CAAe;QAV5C,uFAAuF;QACvF,2BAA2B;QACR,kBAAa,GAAG,IAAI,GAAG,EA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C,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<void> {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined): void {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"localLayerCompatState.js","sourceRoot":"","sources":["../src/localLayerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAwB;IACrE;;OAEG;IACH,UAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Local Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const localDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Local Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Local Driver layer.\n\t */\n\tgeneration:
|
|
1
|
+
{"version":3,"file":"localLayerCompatState.js","sourceRoot":"","sources":["../src/localLayerCompatState.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAwB;IACrE;;OAEG;IACH,UAAU;IACV;;OAEG;IACH,UAAU,EAAE,CAAC;IACb;;OAEG;IACH,iBAAiB,EAAE,IAAI,GAAG,EAAU;CACpC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { type ILayerCompatDetails } from \"@fluid-internal/client-utils\";\n\nimport { pkgVersion } from \"./packageVersion.js\";\n\n/**\n * Local Driver's compatibility details that is exposed to the Loader layer.\n * @internal\n */\nexport const localDriverCompatDetailsForLoader: ILayerCompatDetails = {\n\t/**\n\t * The package version of the Local Driver layer.\n\t */\n\tpkgVersion,\n\t/**\n\t * The current generation of the Local Driver layer.\n\t */\n\tgeneration: 3,\n\t/**\n\t * The features supported by the Local Driver layer across the Driver / Loader boundary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,CAAC,EAAE,CAAC;wBAC7B,aAAa,GAAG,IAAI,CAAC;wBACrB,MAAM;oBACP,CAAC;gBACF,CAAC;gBAED,IAAI,CAAC,aAAa,EAAE,CAAC;oBACpB,OAAO,KAAK,CAAC;gBACd,CAAC;YACF,CAAC;QACF,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,YAAY;IAAhD;;QACkB,gBAAW,GAAG,IAAI,GAAG,EAA8C,CAAC;IAgBtF,CAAC;IAfO,KAAK,CAAC,KAAK,KAAmB,CAAC;IAC/B,UAAU,CAAI,IAAY;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAtB,mBAAc,GAAd,cAAc,CAAQ;IAAG,CAAC;IAEhD,SAAS,CAAC,QAAa,EAAE,OAAa;QAC5C,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,MAAW,EAAE,GAAQ,EAAE,QAAa;QAC3D,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,CAAC;IACM,KAAK,CAAC,aAAa,CAAC,KAAU,EAAE,KAAQ;QAC9C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH;;;OAGG;IACI,KAAK,CAAC,IAAI,CAAC,KAAU,EAAE,IAAS;QACtC,iDAAiD;QACjD,SAAS,aAAa,CAAC,WAAW,EAAE,GAAW;YAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5B,IAAI,KAAK,GAAG,WAAW,CAAC;YACxB,IAAI,CAAC,OAAO,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ent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string): any {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b): number {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]): void {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
|
package/lib/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/local-driver";
|
|
8
|
-
export declare const pkgVersion = "2.74.0
|
|
8
|
+
export declare const pkgVersion = "2.74.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,WAAW,CAAC"}
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,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/local-driver\";\nexport const pkgVersion = \"2.74.0\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/local-driver",
|
|
3
|
-
"version": "2.74.0
|
|
3
|
+
"version": "2.74.0",
|
|
4
4
|
"description": "Fluid local driver",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -71,30 +71,30 @@
|
|
|
71
71
|
"temp-directory": "nyc/.nyc_output"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@fluid-internal/client-utils": "2.74.0
|
|
75
|
-
"@fluidframework/core-interfaces": "2.74.0
|
|
76
|
-
"@fluidframework/core-utils": "2.74.0
|
|
77
|
-
"@fluidframework/driver-base": "2.74.0
|
|
78
|
-
"@fluidframework/driver-definitions": "2.74.0
|
|
79
|
-
"@fluidframework/driver-utils": "2.74.0
|
|
74
|
+
"@fluid-internal/client-utils": "~2.74.0",
|
|
75
|
+
"@fluidframework/core-interfaces": "~2.74.0",
|
|
76
|
+
"@fluidframework/core-utils": "~2.74.0",
|
|
77
|
+
"@fluidframework/driver-base": "~2.74.0",
|
|
78
|
+
"@fluidframework/driver-definitions": "~2.74.0",
|
|
79
|
+
"@fluidframework/driver-utils": "~2.74.0",
|
|
80
80
|
"@fluidframework/protocol-base": "^7.0.0",
|
|
81
|
-
"@fluidframework/routerlicious-driver": "2.74.0
|
|
81
|
+
"@fluidframework/routerlicious-driver": "~2.74.0",
|
|
82
82
|
"@fluidframework/server-local-server": "^7.0.0",
|
|
83
83
|
"@fluidframework/server-services-client": "^7.0.0",
|
|
84
84
|
"@fluidframework/server-services-core": "^7.0.0",
|
|
85
85
|
"@fluidframework/server-test-utils": "^7.0.0",
|
|
86
|
-
"@fluidframework/telemetry-utils": "2.74.0
|
|
86
|
+
"@fluidframework/telemetry-utils": "~2.74.0",
|
|
87
87
|
"jsrsasign": "^11.0.0",
|
|
88
88
|
"uuid": "^11.1.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@arethetypeswrong/cli": "^0.17.1",
|
|
92
92
|
"@biomejs/biome": "~1.9.3",
|
|
93
|
-
"@fluid-internal/mocha-test-setup": "2.74.0
|
|
94
|
-
"@fluid-tools/build-cli": "^0.
|
|
93
|
+
"@fluid-internal/mocha-test-setup": "~2.74.0",
|
|
94
|
+
"@fluid-tools/build-cli": "^0.61.0",
|
|
95
95
|
"@fluidframework/build-common": "^2.0.3",
|
|
96
|
-
"@fluidframework/build-tools": "^0.
|
|
97
|
-
"@fluidframework/eslint-config-fluid": "2.74.0
|
|
96
|
+
"@fluidframework/build-tools": "^0.61.0",
|
|
97
|
+
"@fluidframework/eslint-config-fluid": "~2.74.0",
|
|
98
98
|
"@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.73.0",
|
|
99
99
|
"@microsoft/api-extractor": "7.52.11",
|
|
100
100
|
"@types/jsrsasign": "^10.5.12",
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"copyfiles": "^2.4.1",
|
|
106
106
|
"cross-env": "^7.0.3",
|
|
107
107
|
"eslint": "~8.57.1",
|
|
108
|
+
"jiti": "^2.6.1",
|
|
108
109
|
"mocha": "^10.8.2",
|
|
109
110
|
"mocha-multi-reporters": "^1.5.1",
|
|
110
111
|
"rimraf": "^4.4.0",
|
|
@@ -31,7 +31,7 @@ export class LocalDeltaStorageService implements IDocumentDeltaStorageService {
|
|
|
31
31
|
return streamFromMessages(this.getCore(from, to));
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
private async getCore(from: number, to?: number) {
|
|
34
|
+
private async getCore(from: number, to?: number): Promise<ISequencedDocumentMessage[]> {
|
|
35
35
|
const query = { documentId: this.id, tenantId: this.tenantId };
|
|
36
36
|
query["operation.sequenceNumber"] = {};
|
|
37
37
|
query["operation.sequenceNumber"].$gt = from - 1; // from is inclusive
|
|
@@ -81,7 +81,7 @@ export class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
81
81
|
* Send a "disconnect" message on the socket.
|
|
82
82
|
* @param disconnectReason - The reason of the disconnection.
|
|
83
83
|
*/
|
|
84
|
-
public disconnectClient(disconnectReason: string) {
|
|
84
|
+
public disconnectClient(disconnectReason: string): void {
|
|
85
85
|
this.socket.emit("disconnect", disconnectReason);
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -95,7 +95,7 @@ export class LocalDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
95
95
|
code: number = 400,
|
|
96
96
|
type: NackErrorType = NackErrorType.ThrottlingError,
|
|
97
97
|
message: any,
|
|
98
|
-
) {
|
|
98
|
+
): void {
|
|
99
99
|
const nackMessage = {
|
|
100
100
|
operation: undefined,
|
|
101
101
|
sequenceNumber: -1,
|
|
@@ -106,7 +106,7 @@ export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
|
|
|
106
106
|
* @param clientId - The ID of the client to be disconnected.
|
|
107
107
|
* @param disconnectReason - The reason of the disconnection.
|
|
108
108
|
*/
|
|
109
|
-
public disconnectClient(clientId: string, disconnectReason: string) {
|
|
109
|
+
public disconnectClient(clientId: string, disconnectReason: string): void {
|
|
110
110
|
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
111
111
|
if (documentDeltaConnection === undefined) {
|
|
112
112
|
throw new Error(`No client with the id: ${clientId}`);
|
|
@@ -121,7 +121,12 @@ export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
|
|
|
121
121
|
* @param type - Type of the Nack.
|
|
122
122
|
* @param message - A message about the nack for debugging/logging/telemetry purposes.
|
|
123
123
|
*/
|
|
124
|
-
public nackClient(
|
|
124
|
+
public nackClient(
|
|
125
|
+
clientId: string,
|
|
126
|
+
code?: number,
|
|
127
|
+
type?: NackErrorType,
|
|
128
|
+
message?: any,
|
|
129
|
+
): void {
|
|
125
130
|
const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
|
|
126
131
|
if (documentDeltaConnection === undefined) {
|
|
127
132
|
throw new Error(`No client with the id: ${clientId}`);
|
|
@@ -145,7 +145,7 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
|
|
|
145
145
|
tree: ISnapshotTreeEx,
|
|
146
146
|
loadingGroupIds: Set<string>,
|
|
147
147
|
blobContents: Map<string, ArrayBuffer>,
|
|
148
|
-
) {
|
|
148
|
+
): Promise<void> {
|
|
149
149
|
const groupId = await this.readGroupId(tree);
|
|
150
150
|
if (groupId === undefined || loadingGroupIds.has(groupId)) {
|
|
151
151
|
for (const id of Object.values(tree.blobs)) {
|
|
@@ -264,7 +264,7 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
|
|
|
264
264
|
);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
private stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {
|
|
267
|
+
private stripTree(tree: ISnapshotTreeEx, groupId: string | undefined): void {
|
|
268
268
|
tree.blobs = {};
|
|
269
269
|
tree.groupId = groupId;
|
|
270
270
|
tree.trees = {};
|
|
@@ -19,7 +19,7 @@ export const localDriverCompatDetailsForLoader: ILayerCompatDetails = {
|
|
|
19
19
|
/**
|
|
20
20
|
* The current generation of the Local Driver layer.
|
|
21
21
|
*/
|
|
22
|
-
generation:
|
|
22
|
+
generation: 3,
|
|
23
23
|
/**
|
|
24
24
|
* The features supported by the Local Driver layer across the Driver / Loader boundary.
|
|
25
25
|
*/
|
|
@@ -41,7 +41,7 @@ class LocalSessionStorageCollection<T> implements ICollection<T> {
|
|
|
41
41
|
*/
|
|
42
42
|
public async find(query: any, sort: any): Promise<any[]> {
|
|
43
43
|
// split the keys and get the corresponding value
|
|
44
|
-
function getValueByKey(propertyBag, key: string) {
|
|
44
|
+
function getValueByKey(propertyBag, key: string): any {
|
|
45
45
|
const keys = key.split(".");
|
|
46
46
|
let value = propertyBag;
|
|
47
47
|
keys.forEach((splitKey) => {
|
|
@@ -78,7 +78,7 @@ class LocalSessionStorageCollection<T> implements ICollection<T> {
|
|
|
78
78
|
|
|
79
79
|
if (sort && Object.keys(sort).length === 1) {
|
|
80
80
|
// eslint-disable-next-line no-inner-declarations
|
|
81
|
-
function compare(a, b) {
|
|
81
|
+
function compare(a, b): number {
|
|
82
82
|
// Non null asserting here because of the length check above
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
84
|
const sortKey = Object.keys(sort)[0]!;
|
|
@@ -238,7 +238,7 @@ class LocalSessionStorageCollection<T> implements ICollection<T> {
|
|
|
238
238
|
*
|
|
239
239
|
* @param values - data to insert to the database
|
|
240
240
|
*/
|
|
241
|
-
private insertInternal(...values: any[]) {
|
|
241
|
+
private insertInternal(...values: any[]): void {
|
|
242
242
|
for (const value of values) {
|
|
243
243
|
if (value) {
|
|
244
244
|
if (!value._id) {
|
package/src/packageVersion.ts
CHANGED