@fluidframework/local-driver 2.0.0-internal.1.4.4 → 2.0.0-internal.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.eslintrc.js +23 -9
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -1
  6. package/dist/localDeltaStorageService.d.ts +3 -3
  7. package/dist/localDeltaStorageService.d.ts.map +1 -1
  8. package/dist/localDeltaStorageService.js.map +1 -1
  9. package/dist/localDocumentDeltaConnection.d.ts +2 -2
  10. package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
  11. package/dist/localDocumentDeltaConnection.js +2 -2
  12. package/dist/localDocumentDeltaConnection.js.map +1 -1
  13. package/dist/localDocumentService.d.ts +10 -10
  14. package/dist/localDocumentService.d.ts.map +1 -1
  15. package/dist/localDocumentService.js +1 -23
  16. package/dist/localDocumentService.js.map +1 -1
  17. package/dist/localDocumentServiceFactory.d.ts.map +1 -1
  18. package/dist/localDocumentServiceFactory.js +8 -8
  19. package/dist/localDocumentServiceFactory.js.map +1 -1
  20. package/dist/localDocumentStorageService.d.ts +24 -0
  21. package/dist/localDocumentStorageService.d.ts.map +1 -0
  22. package/dist/localDocumentStorageService.js +75 -0
  23. package/dist/localDocumentStorageService.js.map +1 -0
  24. package/dist/localSessionStorageDb.d.ts +0 -1
  25. package/dist/localSessionStorageDb.d.ts.map +1 -1
  26. package/dist/localSessionStorageDb.js +15 -13
  27. package/dist/localSessionStorageDb.js.map +1 -1
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/package.json +20 -16
  32. package/src/index.ts +1 -0
  33. package/src/localDeltaStorageService.ts +6 -3
  34. package/src/localDocumentDeltaConnection.ts +3 -3
  35. package/src/localDocumentService.ts +24 -23
  36. package/src/localDocumentServiceFactory.ts +7 -6
  37. package/src/localDocumentStorageService.ts +107 -0
  38. package/src/localSessionStorageDb.ts +11 -17
  39. package/src/packageVersion.ts +1 -1
package/.eslintrc.js CHANGED
@@ -4,13 +4,27 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- "extends": [
8
- require.resolve("@fluidframework/eslint-config-fluid")
9
- ],
10
- "parserOptions": {
11
- "project": ["./tsconfig.json", "./src/test/tsconfig.json"]
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid")],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
+ },
11
+ rules: {
12
+ "@typescript-eslint/strict-boolean-expressions": "off",
13
+
14
+ // This library is used in the browser, so we don't want dependencies on most node libraries.
15
+ "import/no-nodejs-modules": ["error", { allow: ["url", "events"] }],
12
16
  },
13
- "rules": {
14
- "@typescript-eslint/strict-boolean-expressions": "off"
15
- }
16
- }
17
+ overrides: [
18
+ {
19
+ // Rules only for test files
20
+ files: ["*.spec.ts", "src/test/**"],
21
+ rules: {
22
+ // Test files are run in node only so additional node libraries can be used.
23
+ "import/no-nodejs-modules": [
24
+ "error",
25
+ { allow: ["assert", "url", "events"] },
26
+ ],
27
+ },
28
+ },
29
+ ],
30
+ };
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from "./localDeltaStorageService";
6
6
  export * from "./localDocumentDeltaConnection";
7
7
  export * from "./localDocumentService";
8
8
  export * from "./localDocumentServiceFactory";
9
+ export * from "./localDocumentStorageService";
9
10
  export * from "./localResolver";
10
11
  export * from "./localSessionStorageDb";
11
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ __exportStar(require("./localDeltaStorageService"), exports);
18
18
  __exportStar(require("./localDocumentDeltaConnection"), exports);
19
19
  __exportStar(require("./localDocumentService"), exports);
20
20
  __exportStar(require("./localDocumentServiceFactory"), exports);
21
+ __exportStar(require("./localDocumentStorageService"), exports);
21
22
  __exportStar(require("./localResolver"), exports);
22
23
  __exportStar(require("./localSessionStorageDb"), exports);
23
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,gEAA8C;AAC9C,kDAAgC;AAChC,0DAAwC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./localDeltaStorageService\";\nexport * from \"./localDocumentDeltaConnection\";\nexport * from \"./localDocumentService\";\nexport * from \"./localDocumentServiceFactory\";\nexport * from \"./localResolver\";\nexport * from \"./localSessionStorageDb\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;AAEH,6DAA2C;AAC3C,iEAA+C;AAC/C,yDAAuC;AACvC,gEAA8C;AAC9C,gEAA8C;AAC9C,kDAAgC;AAChC,0DAAwC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport * from \"./localDeltaStorageService\";\nexport * from \"./localDocumentDeltaConnection\";\nexport * from \"./localDocumentService\";\nexport * from \"./localDocumentServiceFactory\";\nexport * from \"./localDocumentStorageService\";\nexport * from \"./localResolver\";\nexport * from \"./localSessionStorageDb\";\n"]}
@@ -2,18 +2,18 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import * as api from "@fluidframework/driver-definitions";
5
+ import { IDocumentDeltaStorageService, IStream } from "@fluidframework/driver-definitions";
6
6
  import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
7
7
  import { IDatabaseManager } from "@fluidframework/server-services-core";
8
8
  /**
9
9
  * Provides access to the underlying delta storage on the server for local driver.
10
10
  */
11
- export declare class LocalDeltaStorageService implements api.IDocumentDeltaStorageService {
11
+ export declare class LocalDeltaStorageService implements IDocumentDeltaStorageService {
12
12
  private readonly tenantId;
13
13
  private readonly id;
14
14
  private readonly databaseManager;
15
15
  constructor(tenantId: string, id: string, databaseManager: IDatabaseManager);
16
- fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): api.IStream<ISequencedDocumentMessage[]>;
16
+ fetchMessages(from: number, to: number | undefined, abortSignal?: AbortSignal, cachedOnly?: boolean): IStream<ISequencedDocumentMessage[]>;
17
17
  private getCore;
18
18
  }
19
19
  //# sourceMappingURL=localDeltaStorageService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,GAAG,CAAC,4BAA4B;IAEzE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG/C,aAAa,CAChB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GACrB,GAAG,CAAC,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAI7B,OAAO;CAcxB"}
1
+ {"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,4BAA4B,EAC5B,OAAO,EACV,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAErE,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG/C,aAAa,CAChB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GACrB,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAIzB,OAAO;CAcxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.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C;CACJ;AA9BD,4DA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n */\nexport class LocalDeltaStorageService implements api.IDocumentDeltaStorageService {\n constructor(\n private readonly tenantId: string,\n private readonly id: string,\n private readonly databaseManager: IDatabaseManager) {\n }\n\n public fetchMessages(\n from: number,\n to: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n ): api.IStream<ISequencedDocumentMessage[]> {\n return streamFromMessages(this.getCore(from, to));\n }\n\n private async getCore(from: number, to?: number) {\n const query = { documentId: this.id, tenantId: this.tenantId };\n query[\"operation.sequenceNumber\"] = {};\n query[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n // This looks like a bug. It used to work without setting $lt key. Now it does not\n // Need follow up\n query[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n const allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n const dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n const messages = dbDeltas.map((delta) => delta.operation);\n return messages;\n }\n}\n"]}
1
+ {"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAQH,+DAAkE;AAElE;;GAEG;AACH,MAAa,wBAAwB;IACjC,YACqB,QAAgB,EAChB,EAAU,EACV,eAAiC;QAFjC,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,oBAAe,GAAf,eAAe,CAAkB;IACtD,CAAC;IAEM,aAAa,CAChB,IAAY,EACZ,EAAsB,EACtB,WAAyB,EACzB,UAAoB;QAEhB,OAAO,IAAA,iCAAkB,EAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1D,CAAC;IAEO,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,EAAW;QAC3C,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,aAAF,EAAE,cAAF,EAAE,GAAI,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;IACpB,CAAC;CACJ;AA9BD,4DA8BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDocumentDeltaStorageService,\n IStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport { IDatabaseManager } from \"@fluidframework/server-services-core\";\nimport { streamFromMessages } from \"@fluidframework/driver-utils\";\n\n/**\n * Provides access to the underlying delta storage on the server for local driver.\n */\nexport class LocalDeltaStorageService implements IDocumentDeltaStorageService {\n constructor(\n private readonly tenantId: string,\n private readonly id: string,\n private readonly databaseManager: IDatabaseManager) {\n }\n\n public fetchMessages(\n from: number,\n to: number | undefined,\n abortSignal?: AbortSignal,\n cachedOnly?: boolean,\n ): IStream<ISequencedDocumentMessage[]> {\n return streamFromMessages(this.getCore(from, to));\n }\n\n private async getCore(from: number, to?: number) {\n const query = { documentId: this.id, tenantId: this.tenantId };\n query[\"operation.sequenceNumber\"] = {};\n query[\"operation.sequenceNumber\"].$gt = from - 1; // from is inclusive\n\n // This looks like a bug. It used to work without setting $lt key. Now it does not\n // Need follow up\n query[\"operation.sequenceNumber\"].$lt = to ?? Number.MAX_SAFE_INTEGER;\n\n const allDeltas = await this.databaseManager.getDeltaCollection(this.tenantId, this.id);\n const dbDeltas = await allDeltas.find(query, { \"operation.sequenceNumber\": 1 });\n const messages = dbDeltas.map((delta) => delta.operation);\n return messages;\n }\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import { DocumentDeltaConnection } from "@fluidframework/driver-base";
6
6
  import { IClient, IDocumentMessage, NackErrorType } from "@fluidframework/protocol-definitions";
7
- import * as core from "@fluidframework/server-services-core";
7
+ import { IWebSocketServer } from "@fluidframework/server-services-core";
8
8
  import type { Socket } from "socket.io-client";
9
9
  /**
10
10
  * Represents a connection to a stream of delta updates
@@ -20,7 +20,7 @@ export declare class LocalDocumentDeltaConnection extends DocumentDeltaConnectio
20
20
  * @param client - information about the client
21
21
  * @param webSocketServer - web socket server to create connection
22
22
  */
23
- static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: core.IWebSocketServer, timeoutMs?: number): Promise<LocalDocumentDeltaConnection>;
23
+ static create(tenantId: string, id: string, token: string, client: IClient, webSocketServer: IWebSocketServer, timeoutMs?: number): Promise<LocalDocumentDeltaConnection>;
24
24
  constructor(socket: Socket, documentId: string);
25
25
  protected submitCore(type: string, messages: IDocumentMessage[]): void;
26
26
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACH,OAAO,EAEP,gBAAgB,EAChB,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,KAAK,IAAI,MAAM,sCAAsC,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACrE;;;;;;;;;OASG;WACiB,MAAM,CACtB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,IAAI,CAAC,gBAAgB,EACtC,SAAS,SAAQ,GAClB,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI9C,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAI/D;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIvC;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAAC,IAAI,oBAAc,EAAE,IAAI,2BAA+C,EAAE,OAAO,EAAE,GAAG;CAY1G"}
1
+ {"version":3,"file":"localDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACH,OAAO,EAEP,gBAAgB,EAChB,aAAa,EAChB,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAI/C;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,uBAAuB;IACrE;;;;;;;;;OASG;WACiB,MAAM,CACtB,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,gBAAgB,EACjC,SAAS,SAAQ,GAClB,OAAO,CAAC,4BAA4B,CAAC;gBAqB5B,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;IAI9C,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE;IAI/D;;OAEG;IACI,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,IAAI;IAQjD;;OAEG;IACI,YAAY,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAIvC;;;OAGG;IACI,gBAAgB,CAAC,gBAAgB,EAAE,MAAM;IAIhD;;;;;OAKG;IACI,UAAU,CAAC,IAAI,oBAAc,EAAE,IAAI,2BAA+C,EAAE,OAAO,EAAE,GAAG;CAY1G"}
@@ -5,9 +5,9 @@
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.LocalDocumentDeltaConnection = void 0;
8
- const common_utils_1 = require("@fluidframework/common-utils");
9
8
  const driver_base_1 = require("@fluidframework/driver-base");
10
9
  const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
10
+ const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
11
11
  const testProtocolVersions = ["^0.3.0", "^0.2.0", "^0.1.0"];
12
12
  /**
13
13
  * Represents a connection to a stream of delta updates
@@ -41,7 +41,7 @@ class LocalDocumentDeltaConnection extends driver_base_1.DocumentDeltaConnection
41
41
  return deltaConnection;
42
42
  }
43
43
  constructor(socket, documentId) {
44
- super(socket, documentId, new common_utils_1.TelemetryNullLogger());
44
+ super(socket, documentId, new telemetry_utils_1.TelemetryNullLogger());
45
45
  }
46
46
  submitCore(type, messages) {
47
47
  this.emitMessages(type, [messages]);
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAmE;AACnE,6DAAsE;AACtE,+EAK8C;AAK9C,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAa,4BAA6B,SAAQ,qCAAuB;IACrE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACtB,QAAgB,EAChB,EAAU,EACV,KAAa,EACb,MAAe,EACf,eAAsC,EACtC,SAAS,GAAG,KAAK;QAEjB,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,CAAC,CAAC;QAEjF,MAAM,cAAc,GAAa;YAC7B,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK;YACL,QAAQ,EAAE,oBAAoB;SACjC,CAAC;QACF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,YAAY,MAAc,EAAE,UAAkB;QACxC,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,kCAAmB,EAAE,CAAC,CAAC;IAC3D,CAAC;IAES,UAAU,CAAC,IAAY,EAAE,QAA4B;QAC3D,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACtC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,OAAY;QAC5B,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,OAAe,GAAG,EAAE,OAAsB,oCAAa,CAAC,eAAe,EAAE,OAAY;QACnG,MAAM,WAAW,GAAG;YAChB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACL,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACV;SACJ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AA3FD,oEA2FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TelemetryNullLogger } from \"@fluidframework/common-utils\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport {\n IClient,\n IConnect,\n IDocumentMessage,\n NackErrorType,\n} from \"@fluidframework/protocol-definitions\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport * as core from \"@fluidframework/server-services-core\";\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 */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n /**\n * Create a LocalDocumentDeltaConnection\n * Handle initial messages, contents or signals if they were in queue\n *\n * @param tenantId - the ID of the tenant\n * @param id - document ID\n * @param token - authorization token for storage service\n * @param client - information about the client\n * @param webSocketServer - web socket server to create connection\n */\n public static async create(\n tenantId: string,\n id: string,\n token: string,\n client: IClient,\n webSocketServer: core.IWebSocketServer,\n timeoutMs = 60000,\n ): Promise<LocalDocumentDeltaConnection> {\n const socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n // Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n // but should be fine because this delta connection is for local use only.\n const socketWithListener = socket as unknown as Socket;\n\n const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id);\n\n const connectMessage: IConnect = {\n client,\n id,\n mode: client.mode,\n tenantId,\n token, // Token is going to indicate tenant level information, etc...\n versions: testProtocolVersions,\n };\n await deltaConnection.initialize(connectMessage, timeoutMs);\n return deltaConnection;\n }\n\n constructor(socket: Socket, documentId: string) {\n super(socket, documentId, new TelemetryNullLogger());\n }\n\n protected submitCore(type: string, messages: IDocumentMessage[]) {\n this.emitMessages(type, [messages]);\n }\n\n /**\n * Submits a new delta operation to the server\n */\n public submit(messages: IDocumentMessage[]): void {\n // We use a promise resolve to force a turn break given message processing is sync\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n this.submitCore(\"submitOp\", messages);\n });\n }\n\n /**\n * Submits a new signal to the server\n */\n public submitSignal(message: any): void {\n this.submitCore(\"submitSignal\", [message]);\n }\n\n /**\n * Send a \"disconnect\" message on the socket.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(disconnectReason: string) {\n this.socket.emit(\"disconnect\", disconnectReason);\n }\n\n /**\n * * Sends a \"nack\" message on the socket.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(code: number = 400, type: NackErrorType = NackErrorType.ThrottlingError, message: any) {\n const nackMessage = {\n operation: undefined,\n sequenceNumber: -1,\n content: {\n code,\n type,\n message,\n },\n };\n this.socket.emit(\"nack\", \"\", [nackMessage]);\n }\n}\n"]}
1
+ {"version":3,"file":"localDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/localDocumentDeltaConnection.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6DAAsE;AACtE,+EAK8C;AAC9C,qEAAsE;AAKtE,MAAM,oBAAoB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAE5D;;GAEG;AACH,MAAa,4BAA6B,SAAQ,qCAAuB;IACrE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACtB,QAAgB,EAChB,EAAU,EACV,KAAa,EACb,MAAe,EACf,eAAiC,EACjC,SAAS,GAAG,KAAK;QAEjB,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,CAAC,CAAC;QAEjF,MAAM,cAAc,GAAa;YAC7B,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK;YACL,QAAQ,EAAE,oBAAoB;SACjC,CAAC;QACF,MAAM,eAAe,CAAC,UAAU,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;QAC5D,OAAO,eAAe,CAAC;IAC3B,CAAC;IAED,YAAY,MAAc,EAAE,UAAkB;QACxC,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,qCAAmB,EAAE,CAAC,CAAC;IAC3D,CAAC;IAES,UAAU,CAAC,IAAY,EAAE,QAA4B;QAC3D,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACtC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YACxB,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;IACP,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,OAAY;QAC5B,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,gBAAgB,CAAC,gBAAwB;QAC5C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACI,UAAU,CAAC,OAAe,GAAG,EAAE,OAAsB,oCAAa,CAAC,eAAe,EAAE,OAAY;QACnG,MAAM,WAAW,GAAG;YAChB,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,CAAC,CAAC;YAClB,OAAO,EAAE;gBACL,IAAI;gBACJ,IAAI;gBACJ,OAAO;aACV;SACJ,CAAC;QACF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAChD,CAAC;CACJ;AA3FD,oEA2FC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport {\n IClient,\n IConnect,\n IDocumentMessage,\n NackErrorType,\n} from \"@fluidframework/protocol-definitions\";\nimport { TelemetryNullLogger } from \"@fluidframework/telemetry-utils\";\nimport { LocalWebSocketServer } from \"@fluidframework/server-local-server\";\nimport { IWebSocketServer } from \"@fluidframework/server-services-core\";\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 */\nexport class LocalDocumentDeltaConnection extends DocumentDeltaConnection {\n /**\n * Create a LocalDocumentDeltaConnection\n * Handle initial messages, contents or signals if they were in queue\n *\n * @param tenantId - the ID of the tenant\n * @param id - document ID\n * @param token - authorization token for storage service\n * @param client - information about the client\n * @param webSocketServer - web socket server to create connection\n */\n public static async create(\n tenantId: string,\n id: string,\n token: string,\n client: IClient,\n webSocketServer: IWebSocketServer,\n timeoutMs = 60000,\n ): Promise<LocalDocumentDeltaConnection> {\n const socket = (webSocketServer as LocalWebSocketServer).createConnection();\n\n // Cast LocalWebSocket to SocketIOClient.Socket which is the socket that the base class needs. This is hacky\n // but should be fine because this delta connection is for local use only.\n const socketWithListener = socket as unknown as Socket;\n\n const deltaConnection = new LocalDocumentDeltaConnection(socketWithListener, id);\n\n const connectMessage: IConnect = {\n client,\n id,\n mode: client.mode,\n tenantId,\n token, // Token is going to indicate tenant level information, etc...\n versions: testProtocolVersions,\n };\n await deltaConnection.initialize(connectMessage, timeoutMs);\n return deltaConnection;\n }\n\n constructor(socket: Socket, documentId: string) {\n super(socket, documentId, new TelemetryNullLogger());\n }\n\n protected submitCore(type: string, messages: IDocumentMessage[]) {\n this.emitMessages(type, [messages]);\n }\n\n /**\n * Submits a new delta operation to the server\n */\n public submit(messages: IDocumentMessage[]): void {\n // We use a promise resolve to force a turn break given message processing is sync\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n this.submitCore(\"submitOp\", messages);\n });\n }\n\n /**\n * Submits a new signal to the server\n */\n public submitSignal(message: any): void {\n this.submitCore(\"submitSignal\", [message]);\n }\n\n /**\n * Send a \"disconnect\" message on the socket.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(disconnectReason: string) {\n this.socket.emit(\"disconnect\", disconnectReason);\n }\n\n /**\n * * Sends a \"nack\" message on the socket.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(code: number = 400, type: NackErrorType = NackErrorType.ThrottlingError, message: any) {\n const nackMessage = {\n operation: undefined,\n sequenceNumber: -1,\n content: {\n code,\n type,\n message,\n },\n };\n this.socket.emit(\"nack\", \"\", [nackMessage]);\n }\n}\n"]}
@@ -2,22 +2,22 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import * as api from "@fluidframework/driver-definitions";
5
+ import { IDocumentDeltaConnection, IDocumentDeltaStorageService, IDocumentService, IDocumentServicePolicies, IDocumentStorageService, IResolvedUrl } from "@fluidframework/driver-definitions";
6
6
  import { IClient } from "@fluidframework/protocol-definitions";
7
- import * as socketStorage from "@fluidframework/routerlicious-driver";
7
+ import { ITokenProvider } from "@fluidframework/routerlicious-driver";
8
8
  import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
9
9
  import { LocalDocumentDeltaConnection } from ".";
10
10
  /**
11
11
  * Basic implementation of a document service for local use.
12
12
  */
13
- export declare class LocalDocumentService implements api.IDocumentService {
14
- readonly resolvedUrl: api.IResolvedUrl;
13
+ export declare class LocalDocumentService implements IDocumentService {
14
+ readonly resolvedUrl: IResolvedUrl;
15
15
  private readonly localDeltaConnectionServer;
16
16
  private readonly tokenProvider;
17
17
  private readonly tenantId;
18
18
  private readonly documentId;
19
19
  private readonly documentDeltaConnectionsMap;
20
- readonly policies: api.IDocumentServicePolicies;
20
+ readonly policies: IDocumentServicePolicies;
21
21
  private readonly innerDocumentService?;
22
22
  /**
23
23
  * @param localDeltaConnectionServer - delta connection server for ops
@@ -25,21 +25,21 @@ export declare class LocalDocumentService implements api.IDocumentService {
25
25
  * @param tenantId - ID of tenant
26
26
  * @param documentId - ID of document
27
27
  */
28
- constructor(resolvedUrl: api.IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: socketStorage.ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: api.IDocumentServicePolicies, innerDocumentService?: api.IDocumentService | undefined);
28
+ constructor(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService | undefined);
29
29
  dispose(): void;
30
30
  /**
31
31
  * Creates and returns a document storage service for local use.
32
32
  */
33
- connectToStorage(): Promise<api.IDocumentStorageService>;
33
+ connectToStorage(): Promise<IDocumentStorageService>;
34
34
  /**
35
35
  * Creates and returns a delta storage service for local use.
36
36
  */
37
- connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService>;
37
+ connectToDeltaStorage(): Promise<IDocumentDeltaStorageService>;
38
38
  /**
39
39
  * Creates and returns a delta stream for local use.
40
40
  * @param client - client data
41
41
  */
42
- connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection>;
42
+ connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection>;
43
43
  }
44
44
  /**
45
45
  * Creates and returns a document service for local use.
@@ -48,5 +48,5 @@ export declare class LocalDocumentService implements api.IDocumentService {
48
48
  * @param tenantId - ID of tenant
49
49
  * @param documentId - ID of document
50
50
  */
51
- export declare function createLocalDocumentService(resolvedUrl: api.IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: socketStorage.ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: api.IDocumentServicePolicies, innerDocumentService?: api.IDocumentService): api.IDocumentService;
51
+ export declare function createLocalDocumentService(resolvedUrl: IResolvedUrl, localDeltaConnectionServer: ILocalDeltaConnectionServer, tokenProvider: ITokenProvider, tenantId: string, documentId: string, documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>, policies?: IDocumentServicePolicies, innerDocumentService?: IDocumentService): IDocumentService;
52
52
  //# sourceMappingURL=localDocumentService.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,KAAK,aAAa,MAAM,sCAAsC,CAAC;AAGtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAElF,OAAO,EAA4B,4BAA4B,EAAE,MAAM,GAAG,CAAC;AAE3E;;GAEG;AACH,qBAAa,oBAAqB,YAAW,GAAG,CAAC,gBAAgB;aAQzC,WAAW,EAAE,GAAG,CAAC,YAAY;IAC7C,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,GAAG,CAAC,wBAAwB;IACtD,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAd1C;;;;;OAKG;gBAEiB,WAAW,EAAE,GAAG,CAAC,YAAY,EAC5B,0BAA0B,EAAE,2BAA2B,EACvD,aAAa,EAAE,aAAa,CAAC,cAAc,EAC3C,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,EACvE,QAAQ,GAAE,GAAG,CAAC,wBAA6B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Q,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;IAd1C;;;;;OAKG;gBAEiB,WAAW,EAAE,YAAY,EACxB,0BAA0B,EAAE,2BAA2B,EACvD,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,EACvE,QAAQ,GAAE,wBAA6B,EACtC,oBAAoB,CAAC,8BAAkB;IAGrD,OAAO;IAEd;;OAEG;IACU,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAQjE;;OAEG;IACU,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IAU3E;;;OAGG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;CA8BxF;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACtC,WAAW,EAAE,YAAY,EACzB,0BAA0B,EAAE,2BAA2B,EACvD,aAAa,EAAE,cAAc,EAC7B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,EACtE,QAAQ,CAAC,EAAE,wBAAwB,EACnC,oBAAoB,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAW7D"}
@@ -3,31 +3,10 @@
3
3
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
4
  * Licensed under the MIT License.
5
5
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
6
  Object.defineProperty(exports, "__esModule", { value: true });
26
7
  exports.createLocalDocumentService = exports.LocalDocumentService = void 0;
27
- const socketStorage = __importStar(require("@fluidframework/routerlicious-driver"));
28
8
  const server_services_client_1 = require("@fluidframework/server-services-client");
29
9
  const server_test_utils_1 = require("@fluidframework/server-test-utils");
30
- const common_utils_1 = require("@fluidframework/common-utils");
31
10
  const _1 = require(".");
32
11
  /**
33
12
  * Basic implementation of a document service for local use.
@@ -54,8 +33,7 @@ class LocalDocumentService {
54
33
  * Creates and returns a document storage service for local use.
55
34
  */
56
35
  async connectToStorage() {
57
- return new socketStorage.DocumentStorageService(this.documentId, new server_services_client_1.GitManager(new server_test_utils_1.TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)), new common_utils_1.TelemetryNullLogger(), { minBlobSize: 2048 }, // Test blob aggregation.
58
- undefined, undefined, undefined, new server_services_client_1.GitManager(new server_test_utils_1.TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)));
36
+ return new _1.LocalDocumentStorageService(this.documentId, new server_services_client_1.GitManager(new server_test_utils_1.TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)), { minBlobSize: 2048 });
59
37
  }
60
38
  /**
61
39
  * Creates and returns a delta storage service for local use.
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentService.js","sourceRoot":"","sources":["../src/localDocumentService.ts"],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BAAoB,CAC3B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,CACvB,CAAC;AACN,CAAC;AAnBD,gEAmBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport * as socketStorage from \"@fluidframework/routerlicious-driver\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { TelemetryNullLogger } from \"@fluidframework/common-utils\";\nimport { LocalDeltaStorageService, LocalDocumentDeltaConnection } from \".\";\n\n/**\n * Basic implementation of a document service for local use.\n */\nexport class LocalDocumentService implements api.IDocumentService {\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n */\n constructor(\n public readonly resolvedUrl: api.IResolvedUrl,\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly tokenProvider: socketStorage.ITokenProvider,\n private readonly tenantId: string,\n private readonly documentId: string,\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n public readonly policies: api.IDocumentServicePolicies = {},\n private readonly innerDocumentService?: api.IDocumentService,\n ) { }\n\n public dispose() { }\n\n /**\n * Creates and returns a document storage service for local use.\n */\n public async connectToStorage(): Promise<api.IDocumentStorageService> {\n return new socketStorage.DocumentStorageService(\n this.documentId,\n new GitManager(new TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)),\n new TelemetryNullLogger(),\n { minBlobSize: 2048 }, // Test blob aggregation.\n undefined,\n undefined,\n undefined,\n new GitManager(new TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)));\n }\n\n /**\n * Creates and returns a delta storage service for local use.\n */\n public async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n if (this.innerDocumentService) {\n return this.innerDocumentService.connectToDeltaStorage();\n }\n return new LocalDeltaStorageService(\n this.tenantId,\n this.documentId,\n this.localDeltaConnectionServer.databaseManager);\n }\n\n /**\n * Creates and returns a delta stream for local use.\n * @param client - client data\n */\n public async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n if (this.policies.storageOnly === true) {\n throw new Error(\"can't connect to delta stream in storage-only mode\");\n }\n if (this.innerDocumentService) {\n return this.innerDocumentService.connectToDeltaStream(client);\n }\n const ordererToken = await this.tokenProvider.fetchOrdererToken(\n this.tenantId,\n this.documentId,\n );\n const documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n this.tenantId,\n this.documentId,\n ordererToken.jwt,\n client,\n this.localDeltaConnectionServer.webSocketServer,\n );\n const clientId = documentDeltaConnection.clientId;\n\n // Add this document service for the clientId in the document service factory.\n this.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n // Add a listener to remove this document service when the client is disconnected.\n documentDeltaConnection.on(\"disconnect\", () => {\n this.documentDeltaConnectionsMap.delete(clientId);\n });\n\n return documentDeltaConnection;\n }\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 */\nexport function createLocalDocumentService(\n resolvedUrl: api.IResolvedUrl,\n localDeltaConnectionServer: ILocalDeltaConnectionServer,\n tokenProvider: socketStorage.ITokenProvider,\n tenantId: string,\n documentId: string,\n documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n policies?: api.IDocumentServicePolicies,\n innerDocumentService?: api.IDocumentService): api.IDocumentService {\n return new LocalDocumentService(\n resolvedUrl,\n localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n documentDeltaConnectionsMap,\n policies,\n innerDocumentService,\n );\n}\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and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n IDocumentDeltaConnection,\n IDocumentDeltaStorageService,\n IDocumentService,\n IDocumentServicePolicies,\n IDocumentStorageService,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport { ITokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { GitManager } from \"@fluidframework/server-services-client\";\nimport { TestHistorian } from \"@fluidframework/server-test-utils\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { LocalDeltaStorageService, LocalDocumentDeltaConnection, LocalDocumentStorageService } from \".\";\n/**\n * Basic implementation of a document service for local use.\n */\nexport class LocalDocumentService implements IDocumentService {\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n * @param tokenProvider - token provider\n * @param tenantId - ID of tenant\n * @param documentId - ID of document\n */\n constructor(\n public readonly resolvedUrl: IResolvedUrl,\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly tokenProvider: ITokenProvider,\n private readonly tenantId: string,\n private readonly documentId: string,\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n public readonly policies: IDocumentServicePolicies = {},\n private readonly innerDocumentService?: IDocumentService,\n ) { }\n\n public dispose() { }\n\n /**\n * Creates and returns a document storage service for local use.\n */\n public async connectToStorage(): Promise<IDocumentStorageService> {\n return new LocalDocumentStorageService(\n this.documentId,\n new GitManager(new TestHistorian(this.localDeltaConnectionServer.testDbFactory.testDatabase)),\n { minBlobSize: 2048 }, // Test blob aggregation.\n );\n }\n\n /**\n * Creates and returns a delta storage service for local use.\n */\n public async connectToDeltaStorage(): Promise<IDocumentDeltaStorageService> {\n if (this.innerDocumentService) {\n return this.innerDocumentService.connectToDeltaStorage();\n }\n return new LocalDeltaStorageService(\n this.tenantId,\n this.documentId,\n this.localDeltaConnectionServer.databaseManager);\n }\n\n /**\n * Creates and returns a delta stream for local use.\n * @param client - client data\n */\n public async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n if (this.policies.storageOnly === true) {\n throw new Error(\"can't connect to delta stream in storage-only mode\");\n }\n if (this.innerDocumentService) {\n return this.innerDocumentService.connectToDeltaStream(client);\n }\n const ordererToken = await this.tokenProvider.fetchOrdererToken(\n this.tenantId,\n this.documentId,\n );\n const documentDeltaConnection = await LocalDocumentDeltaConnection.create(\n this.tenantId,\n this.documentId,\n ordererToken.jwt,\n client,\n this.localDeltaConnectionServer.webSocketServer,\n );\n const clientId = documentDeltaConnection.clientId;\n\n // Add this document service for the clientId in the document service factory.\n this.documentDeltaConnectionsMap.set(clientId, documentDeltaConnection);\n\n // Add a listener to remove this document service when the client is disconnected.\n documentDeltaConnection.on(\"disconnect\", () => {\n this.documentDeltaConnectionsMap.delete(clientId);\n });\n\n return documentDeltaConnection;\n }\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 */\nexport function createLocalDocumentService(\n resolvedUrl: IResolvedUrl,\n localDeltaConnectionServer: ILocalDeltaConnectionServer,\n tokenProvider: ITokenProvider,\n tenantId: string,\n documentId: string,\n documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,\n policies?: IDocumentServicePolicies,\n innerDocumentService?: IDocumentService): IDocumentService {\n return new LocalDocumentService(\n resolvedUrl,\n localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n documentDeltaConnectionsMap,\n policies,\n innerDocumentService,\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,M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(createNewSummary, resolvedUrl, logger, clientIsSummarizer) {
29
- var _a, _b, _c;
29
+ var _a, _b, _c, _d;
30
30
  (0, driver_utils_1.ensureFluidResolvedUrl)(resolvedUrl);
31
31
  if (createNewSummary === undefined) {
32
32
  throw new Error("Empty file summary creation isn't supported in this driver.");
@@ -47,7 +47,7 @@ class LocalDocumentServiceFactory {
47
47
  const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
48
48
  const quorumValues = (0, driver_utils_1.getQuorumValuesFromProtocolSummary)(protocolSummary);
49
49
  const sequenceNumber = documentAttributes.sequenceNumber;
50
- await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1, server_services_client_1.defaultHash, (_b = resolvedUrl.endpoints.ordererUrl) !== null && _b !== void 0 ? _b : "", (_c = resolvedUrl.endpoints.storageUrl) !== null && _c !== void 0 ? _c : "", quorumValues, false);
50
+ await documentStorage.createDocument(tenantId, id, appSummary, sequenceNumber, (_a = documentAttributes.term) !== null && _a !== void 0 ? _a : 1, server_services_client_1.defaultHash, (_b = resolvedUrl.endpoints.ordererUrl) !== null && _b !== void 0 ? _b : "", (_c = resolvedUrl.endpoints.storageUrl) !== null && _c !== void 0 ? _c : "", (_d = resolvedUrl.endpoints.deltaStorageUrl) !== null && _d !== void 0 ? _d : "", quorumValues, false);
51
51
  return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
52
52
  }
53
53
  /**
@@ -76,11 +76,11 @@ class LocalDocumentServiceFactory {
76
76
  * @param disconnectReason - The reason of the disconnection.
77
77
  */
78
78
  disconnectClient(clientId, disconnectReason) {
79
- if (!this.documentDeltaConnectionsMap.has(clientId)) {
79
+ const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
80
+ if (documentDeltaConnection === undefined) {
80
81
  throw new Error(`No client with the id: ${clientId}`);
81
82
  }
82
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
83
- this.documentDeltaConnectionsMap.get(clientId).disconnectClient(disconnectReason);
83
+ documentDeltaConnection.disconnectClient(disconnectReason);
84
84
  }
85
85
  /**
86
86
  * Gets the document delta connection for the clientId and asks it to nack the client.
@@ -90,11 +90,11 @@ class LocalDocumentServiceFactory {
90
90
  * @param message - A message about the nack for debugging/logging/telemetry purposes.
91
91
  */
92
92
  nackClient(clientId, code, type, message) {
93
- if (!this.documentDeltaConnectionsMap.has(clientId)) {
93
+ const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);
94
+ if (documentDeltaConnection === undefined) {
94
95
  throw new Error(`No client with the id: ${clientId}`);
95
96
  }
96
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
97
- this.documentDeltaConnectionsMap.get(clientId).nackClient(code, type, message);
97
+ documentDeltaConnection.nackClient(code, type, message);
98
98
  }
99
99
  }
100
100
  exports.LocalDocumentServiceFactory = LocalDocumentServiceFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAQ5B,+EAA4E;AAE5E,+DAIsC;AAEtC,mFAAqE;AAErE,iEAAoE;AAEpE;;GAEG;AACH,MAAa,2BAA2B;IAMpC;;OAEG;IACH,YACqB,0BAAuD,EACvD,QAAmC,EACnC,oBAAuC;QAFvC,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,aAAQ,GAAR,QAAQ,CAA2B;QACnC,yBAAoB,GAApB,oBAAoB,CAAmB;QAX5C,iBAAY,GAAG,aAAa,CAAC;QAE7C,6CAA6C;QAC5B,gCAA2B,GAA8C,IAAI,GAAG,EAAE,CAAC;IAQpC,CAAC;IAE1D,KAAK,CAAC,eAAe,CACxB,gBAA0C,EAC1C,WAAyB,EACzB,MAA6B,EAC7B,kBAA4B;;QAE5B,IAAA,qCAAsB,EAAC,WAAW,CAAC,CAAC;QACpC,IAAI,gBAAgB,KAAK,SAA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,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACzD;QACD,oEAAoE;QACpE,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IACvF,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,OAAa;QAClF,IAAI,CAAC,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjD,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACzD;QACD,oEAAoE;QACpE,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAE,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;CACJ;AAxHD,kEAwHC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IDocumentServicePolicies,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer, LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n ensureFluidResolvedUrl,\n getDocAttributesFromProtocolSummary,\n getQuorumValuesFromProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree, NackErrorType } from \"@fluidframework/protocol-definitions\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nimport { createLocalDocumentService } from \"./localDocumentService\";\n\n/**\n * Implementation of document service factory for local use.\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-test:\";\n\n // A map of clientId to LocalDocumentService.\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> = new Map();\n\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n */\n constructor(\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly policies?: IDocumentServicePolicies,\n private readonly innerDocumentService?: IDocumentService) { }\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n if (createNewSummary === undefined) {\n throw new Error(\"Empty file summary creation isn't supported in this driver.\");\n }\n const pathName = new URL(resolvedUrl.url).pathname;\n const pathArr = pathName.split(\"/\");\n const tenantId = pathArr[pathArr.length - 2];\n const id = pathArr[pathArr.length - 1];\n if (!this.localDeltaConnectionServer) {\n throw new Error(\"Provide the localDeltaConnectionServer!!\");\n }\n const documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer).documentStorage;\n\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n if (!(protocolSummary && appSummary)) {\n throw new Error(\"Protocol and App Summary required in the full summary\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n const sequenceNumber = documentAttributes.sequenceNumber;\n await documentStorage.createDocument(\n tenantId,\n id,\n appSummary,\n sequenceNumber,\n documentAttributes.term ?? 1,\n defaultHash,\n resolvedUrl.endpoints.ordererUrl ?? \"\",\n resolvedUrl.endpoints.storageUrl ?? \"\",\n quorumValues,\n false, /* enableDiscovery */\n );\n return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n /**\n * Creates and returns a document service for testing using the given resolved\n * URL for the tenant ID, document ID, and token.\n * @param resolvedUrl - resolved URL of document\n */\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n\n const parsedUrl = parse(resolvedUrl.url);\n const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split(\"/\") : [];\n if (!documentId || !tenantId) {\n throw new Error(`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`);\n }\n\n const fluidResolvedUrl = resolvedUrl;\n const jwtToken = fluidResolvedUrl.tokens.jwt;\n if (!jwtToken) {\n throw new Error(`Token was not provided.`);\n }\n\n const tokenProvider = new DefaultTokenProvider(jwtToken);\n\n return createLocalDocumentService(\n resolvedUrl,\n this.localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n this.documentDeltaConnectionsMap,\n this.policies,\n this.innerDocumentService);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to disconnect the client.\n * @param clientId - The ID of the client to be disconnected.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(clientId: string, disconnectReason: string) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.disconnectClient(disconnectReason);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to nack the client.\n * @param clientId - The ID of the client to be Nack'd.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {\n if (!this.documentDeltaConnectionsMap.has(clientId)) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this.documentDeltaConnectionsMap.get(clientId)!.nackClient(code, type, message);\n }\n}\n"]}
1
+ {"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["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contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentService,\n IDocumentServiceFactory,\n IDocumentServicePolicies,\n IResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport { ILocalDeltaConnectionServer, LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n ensureFluidResolvedUrl,\n getDocAttributesFromProtocolSummary,\n getQuorumValuesFromProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree, NackErrorType } from \"@fluidframework/protocol-definitions\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\nimport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nimport { createLocalDocumentService } from \"./localDocumentService\";\n\n/**\n * Implementation of document service factory for local use.\n */\nexport class LocalDocumentServiceFactory implements IDocumentServiceFactory {\n public readonly protocolName = \"fluid-test:\";\n\n // A map of clientId to LocalDocumentService.\n private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection> = new Map();\n\n /**\n * @param localDeltaConnectionServer - delta connection server for ops\n */\n constructor(\n private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,\n private readonly policies?: IDocumentServicePolicies,\n private readonly innerDocumentService?: IDocumentService) { }\n\n public async createContainer(\n createNewSummary: ISummaryTree | undefined,\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n if (createNewSummary === undefined) {\n throw new Error(\"Empty file summary creation isn't supported in this driver.\");\n }\n const pathName = new URL(resolvedUrl.url).pathname;\n const pathArr = pathName.split(\"/\");\n const tenantId = pathArr[pathArr.length - 2];\n const id = pathArr[pathArr.length - 1];\n if (!this.localDeltaConnectionServer) {\n throw new Error(\"Provide the localDeltaConnectionServer!!\");\n }\n const documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer).documentStorage;\n\n const protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n const appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n if (!(protocolSummary && appSummary)) {\n throw new Error(\"Protocol and App Summary required in the full summary\");\n }\n const documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n const quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n const sequenceNumber = documentAttributes.sequenceNumber;\n await documentStorage.createDocument(\n tenantId,\n id,\n appSummary,\n sequenceNumber,\n documentAttributes.term ?? 1,\n defaultHash,\n resolvedUrl.endpoints.ordererUrl ?? \"\",\n resolvedUrl.endpoints.storageUrl ?? \"\",\n resolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n quorumValues,\n false, /* enableDiscovery */\n );\n return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n /**\n * Creates and returns a document service for testing using the given resolved\n * URL for the tenant ID, document ID, and token.\n * @param resolvedUrl - resolved URL of document\n */\n public async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n\n const parsedUrl = parse(resolvedUrl.url);\n const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split(\"/\") : [];\n if (!documentId || !tenantId) {\n throw new Error(`Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`);\n }\n\n const fluidResolvedUrl = resolvedUrl;\n const jwtToken = fluidResolvedUrl.tokens.jwt;\n if (!jwtToken) {\n throw new Error(`Token was not provided.`);\n }\n\n const tokenProvider = new DefaultTokenProvider(jwtToken);\n\n return createLocalDocumentService(\n resolvedUrl,\n this.localDeltaConnectionServer,\n tokenProvider,\n tenantId,\n documentId,\n this.documentDeltaConnectionsMap,\n this.policies,\n this.innerDocumentService);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to disconnect the client.\n * @param clientId - The ID of the client to be disconnected.\n * @param disconnectReason - The reason of the disconnection.\n */\n public disconnectClient(clientId: string, disconnectReason: string) {\n const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n if (documentDeltaConnection === undefined) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n documentDeltaConnection.disconnectClient(disconnectReason);\n }\n\n /**\n * Gets the document delta connection for the clientId and asks it to nack the client.\n * @param clientId - The ID of the client to be Nack'd.\n * @param code - An error code number that represents the error. It will be a valid HTTP error code.\n * @param type - Type of the Nack.\n * @param message - A message about the nack for debugging/logging/telemetry purposes.\n */\n public nackClient(clientId: string, code?: number, type?: NackErrorType, message?: any) {\n const documentDeltaConnection = this.documentDeltaConnectionsMap.get(clientId);\n if (documentDeltaConnection === undefined) {\n throw new Error(`No client with the id: ${clientId}`);\n }\n documentDeltaConnection.nackClient(code, type, message);\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ import { IDocumentStorageService, IDocumentStorageServicePolicies, ISummaryContext } from "@fluidframework/driver-definitions";
6
+ import { ICreateBlobResponse, ISnapshotTreeEx, ISummaryHandle, ISummaryTree, IVersion } from "@fluidframework/protocol-definitions";
7
+ import { GitManager } from "@fluidframework/server-services-client";
8
+ export declare class LocalDocumentStorageService implements IDocumentStorageService {
9
+ private readonly id;
10
+ private readonly manager;
11
+ readonly policies: IDocumentStorageServicePolicies;
12
+ protected readonly blobsShaCache: Map<string, string>;
13
+ private readonly summaryTreeUploadManager;
14
+ get repositoryUrl(): string;
15
+ constructor(id: string, manager: GitManager, policies?: IDocumentStorageServicePolicies);
16
+ getVersions(versionId: string | null, count: number): Promise<IVersion[]>;
17
+ getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null>;
18
+ readBlob(blobId: string): Promise<ArrayBufferLike>;
19
+ uploadSummaryWithContext(summary: ISummaryTree, context: ISummaryContext): Promise<string>;
20
+ createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse>;
21
+ downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree>;
22
+ private getPreviousFullSnapshot;
23
+ }
24
+ //# sourceMappingURL=localDocumentStorageService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,eAAe,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAmD,MAAM,wCAAwC,CAAC;AAErH,qBAAa,2BAA4B,YAAW,uBAAuB;IAWzE,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,QAAQ,EAAE,+BAA+B;IAV1D,SAAS,CAAC,QAAQ,CAAC,aAAa,sBAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAwB;IAEjE,IAAW,aAAa,IAAI,MAAM,CAEjC;gBAGiB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACpB,QAAQ,GAAE,+BAAoC;IASlD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUzE,eAAe,CAAC,OAAO,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAgBpE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAOlD,wBAAwB,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IAQ1F,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAQ/D,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;YAI7D,uBAAuB;CAUrC"}
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.LocalDocumentStorageService = void 0;
8
+ const common_utils_1 = require("@fluidframework/common-utils");
9
+ const protocol_base_1 = require("@fluidframework/protocol-base");
10
+ const server_services_client_1 = require("@fluidframework/server-services-client");
11
+ class LocalDocumentStorageService {
12
+ constructor(id, manager, policies = {}) {
13
+ this.id = id;
14
+ this.manager = manager;
15
+ this.policies = policies;
16
+ // The values of this cache is useless. We only need the keys. So we are always putting
17
+ // empty strings as values.
18
+ this.blobsShaCache = new Map();
19
+ this.summaryTreeUploadManager = new server_services_client_1.SummaryTreeUploadManager(manager, this.blobsShaCache, this.getPreviousFullSnapshot.bind(this));
20
+ }
21
+ get repositoryUrl() {
22
+ return "";
23
+ }
24
+ async getVersions(versionId, count) {
25
+ const id = versionId ? versionId : this.id;
26
+ const commits = await this.manager.getCommits(id, count);
27
+ return commits.map((commit) => ({
28
+ date: commit.commit.author.date,
29
+ id: commit.sha,
30
+ treeId: commit.commit.tree.sha,
31
+ }));
32
+ }
33
+ async getSnapshotTree(version) {
34
+ let requestVersion = version;
35
+ if (!requestVersion) {
36
+ const versions = await this.getVersions(this.id, 1);
37
+ if (versions.length === 0) {
38
+ return null;
39
+ }
40
+ requestVersion = versions[0];
41
+ }
42
+ const rawTree = await this.manager.getTree(requestVersion.treeId);
43
+ const tree = (0, protocol_base_1.buildHierarchy)(rawTree, this.blobsShaCache, true);
44
+ return tree;
45
+ }
46
+ async readBlob(blobId) {
47
+ const blob = await this.manager.getBlob(blobId);
48
+ this.blobsShaCache.set(blob.sha, "");
49
+ const bufferContent = (0, common_utils_1.stringToBuffer)(blob.content, blob.encoding);
50
+ return bufferContent;
51
+ }
52
+ async uploadSummaryWithContext(summary, context) {
53
+ var _a;
54
+ return this.summaryTreeUploadManager.writeSummaryTree(summary, (_a = context.ackHandle) !== null && _a !== void 0 ? _a : "", "channel");
55
+ }
56
+ async createBlob(file) {
57
+ const uint8ArrayFile = new Uint8Array(file);
58
+ return this.manager.createBlob((0, common_utils_1.Uint8ArrayToString)(uint8ArrayFile, "base64"), "base64").then((r) => ({ id: r.sha, url: r.url }));
59
+ }
60
+ async downloadSummary(handle) {
61
+ throw new Error("NOT IMPLEMENTED!");
62
+ }
63
+ async getPreviousFullSnapshot(parentHandle) {
64
+ return parentHandle
65
+ ? this.getVersions(parentHandle, 1)
66
+ .then(async (versions) => {
67
+ // Clear the cache as the getSnapshotTree call will fill the cache.
68
+ this.blobsShaCache.clear();
69
+ return this.getSnapshotTree(versions[0]);
70
+ })
71
+ : undefined;
72
+ }
73
+ }
74
+ exports.LocalDocumentStorageService = LocalDocumentStorageService;
75
+ //# sourceMappingURL=localDocumentStorageService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkF;AAalF,iEAA+D;AAC/D,mFAAqH;AAErH,MAAa,2BAA2B;IAUvC,YACkB,EAAU,EACV,OAAmB,EACpB,WAA4C,EAAE;QAF7C,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAsC;QAZ/D,uFAAuF;QACvF,2BAA2B;QACR,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAY5D,IAAI,CAAC,wBAAwB,GAAG,IAAI,iDAAwB,CAC3D,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,uBAAuB,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CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AArFD,kEAqFC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { stringToBuffer, Uint8ArrayToString } from \"@fluidframework/common-utils\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tISummaryContext,\n} from \"@fluidframework/driver-definitions\";\nimport {\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tISummaryHandle,\n\tISummaryTree,\n\tIVersion,\n} from \"@fluidframework/protocol-definitions\";\nimport { buildHierarchy } from \"@fluidframework/protocol-base\";\nimport { GitManager, ISummaryUploadManager, SummaryTreeUploadManager } from \"@fluidframework/server-services-client\";\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\tpublic get repositoryUrl(): string {\n\t\treturn \"\";\n\t}\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies = {},\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\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildHierarchy(rawTree, this.blobsShaCache, true);\n\t\treturn tree;\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(summary: ISummaryTree, context: ISummaryContext): Promise<string> {\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.createBlob(\n\t\t\tUint8ArrayToString(\n\t\t\t\tuint8ArrayFile, \"base64\"),\n\t\t\t\"base64\").then((r) => ({ id: r.sha, url: r.url }));\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(parentHandle: string): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1)\n\t\t\t\t.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"]}
@@ -5,7 +5,6 @@ import { ITestDbFactory } from "@fluidframework/server-test-utils";
5
5
  */
6
6
  export declare class LocalSessionStorageDbFactory implements ITestDbFactory {
7
7
  readonly testDatabase: IDb;
8
- constructor(namespace: string);
9
8
  connect(): Promise<IDb>;
10
9
  }
11
10
  //# sourceMappingURL=localSessionStorageDb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AA4SnE;;GAEG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAC/D,SAAgB,YAAY,EAAE,GAAG,CAAC;gBACtB,SAAS,EAAE,MAAM;IAGhB,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGvC"}
1
+ {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAKA,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAySnE;;GAEG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAC/D,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGvC"}