@fluidframework/local-driver 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.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.
Files changed (36) hide show
  1. package/.eslintrc.js +19 -22
  2. package/.mocharc.js +2 -2
  3. package/dist/auth.d.ts.map +1 -1
  4. package/dist/auth.js +2 -2
  5. package/dist/auth.js.map +1 -1
  6. package/dist/localDeltaStorageService.d.ts.map +1 -1
  7. package/dist/localDeltaStorageService.js.map +1 -1
  8. package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
  9. package/dist/localDocumentDeltaConnection.js.map +1 -1
  10. package/dist/localDocumentService.d.ts.map +1 -1
  11. package/dist/localDocumentService.js.map +1 -1
  12. package/dist/localDocumentServiceFactory.d.ts.map +1 -1
  13. package/dist/localDocumentServiceFactory.js +3 -2
  14. package/dist/localDocumentServiceFactory.js.map +1 -1
  15. package/dist/localDocumentStorageService.d.ts.map +1 -1
  16. package/dist/localDocumentStorageService.js +4 -3
  17. package/dist/localDocumentStorageService.js.map +1 -1
  18. package/dist/localResolver.d.ts.map +1 -1
  19. package/dist/localResolver.js.map +1 -1
  20. package/dist/localSessionStorageDb.d.ts.map +1 -1
  21. package/dist/localSessionStorageDb.js.map +1 -1
  22. package/dist/packageVersion.d.ts +1 -1
  23. package/dist/packageVersion.js +1 -1
  24. package/dist/packageVersion.js.map +1 -1
  25. package/package.json +104 -103
  26. package/prettier.config.cjs +1 -1
  27. package/src/auth.ts +35 -29
  28. package/src/localDeltaStorageService.ts +26 -29
  29. package/src/localDocumentDeltaConnection.ts +89 -85
  30. package/src/localDocumentService.ts +106 -98
  31. package/src/localDocumentServiceFactory.ts +126 -117
  32. package/src/localDocumentStorageService.ts +17 -10
  33. package/src/localResolver.ts +55 -55
  34. package/src/localSessionStorageDb.ts +267 -261
  35. package/src/packageVersion.ts +1 -1
  36. package/tsconfig.json +9 -13
package/.eslintrc.js CHANGED
@@ -4,27 +4,24 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
8
- parserOptions: {
9
- project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
- },
11
- rules: {
12
- "@typescript-eslint/strict-boolean-expressions": "off",
7
+ extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
8
+ parserOptions: {
9
+ project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
+ },
11
+ rules: {
12
+ "@typescript-eslint/strict-boolean-expressions": "off",
13
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"] }],
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
- ],
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"] }],
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": ["error", { allow: ["assert", "url", "events"] }],
24
+ },
25
+ },
26
+ ],
30
27
  };
package/.mocharc.js CHANGED
@@ -3,9 +3,9 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- 'use strict';
6
+ "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require('@fluidframework/mocha-test-setup/mocharc-common');
8
+ const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAKtF;;;GAGG;AACH,wBAAgB,aAAa,CACzB,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GAAG,MAAM,CAqB/B;AAED,wBAAgB,YAAY,IAAI,KAAK,CAOpC"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAKtF;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GACjB,MAAM,CA0BR;AAED,wBAAgB,YAAY,IAAI,KAAK,CAOpC"}
package/dist/auth.js CHANGED
@@ -13,12 +13,12 @@ const server_services_client_1 = require("@fluidframework/server-services-client
13
13
  * services-client since it cannot run in the browser without polyfills.
14
14
  */
15
15
  function generateToken(tenantId, documentId, key, scopes, user, lifetime = 60 * 60, ver = "1.0") {
16
- let userClaim = (user) ? user : generateUser();
16
+ let userClaim = user ? user : generateUser();
17
17
  if (userClaim.id === "" || userClaim.id === undefined) {
18
18
  userClaim = generateUser();
19
19
  }
20
20
  // Current time in seconds
21
- const now = Math.round((new Date()).getTime() / 1000);
21
+ const now = Math.round(new Date().getTime() / 1000);
22
22
  const claims = {
23
23
  documentId,
24
24
  scopes,
package/dist/auth.js.map CHANGED
@@ -1 +1 @@
1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;IAEF,OAAO,UAAU,CAAC;AACtB,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims, IUser, ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\nimport { getRandomName } from \"@fluidframework/server-services-client\";\n\n/**\n * Generates a JWT token to authorize against. We do not use the implementation in\n * services-client since it cannot run in the browser without polyfills.\n */\nexport function generateToken(\n tenantId: string,\n documentId: string,\n key: string,\n scopes: ScopeType[],\n user?: IUser,\n lifetime: number = 60 * 60,\n ver: string = \"1.0\"): string {\n let userClaim = (user) ? user : generateUser();\n if (userClaim.id === \"\" || userClaim.id === undefined) {\n userClaim = generateUser();\n }\n\n // Current time in seconds\n const now = Math.round((new Date()).getTime() / 1000);\n\n const claims: ITokenClaims = {\n documentId,\n scopes,\n tenantId,\n user: userClaim,\n iat: now,\n exp: now + lifetime,\n ver,\n };\n\n const utf8Key = { utf8: key };\n return jsrsasign.jws.JWS.sign(null, JSON.stringify({ alg: \"HS256\", typ: \"JWT\" }), claims, utf8Key);\n}\n\nexport function generateUser(): IUser {\n const randomUser = {\n id: uuid(),\n name: getRandomName(\" \", true),\n };\n\n return randomUser;\n}\n"]}
1
+ {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,yCAA8C;AAC9C,+BAAkC;AAClC,mFAAuE;AAEvE;;;GAGG;AACH,SAAgB,aAAa,CAC5B,QAAgB,EAChB,UAAkB,EAClB,GAAW,EACX,MAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC7C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE;QACtD,SAAS,GAAG,YAAY,EAAE,CAAC;KAC3B;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAiB;QAC5B,UAAU;QACV,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;KACH,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,gBAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAC5B,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAlCD,sCAkCC;AAED,SAAgB,YAAY;IAC3B,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,IAAA,SAAI,GAAE;QACV,IAAI,EAAE,IAAA,sCAAa,EAAC,GAAG,EAAE,IAAI,CAAC;KAC9B,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC;AAPD,oCAOC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims, IUser, ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\nimport { getRandomName } from \"@fluidframework/server-services-client\";\n\n/**\n * Generates a JWT token to authorize against. We do not use the implementation in\n * services-client since it cannot run in the browser without polyfills.\n */\nexport function generateToken(\n\ttenantId: string,\n\tdocumentId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ? user : generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(new Date().getTime() / 1000);\n\n\tconst claims: ITokenClaims = {\n\t\tdocumentId,\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t};\n\n\tconst utf8Key = { utf8: key };\n\treturn jsrsasign.jws.JWS.sign(\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\nexport function generateUser(): IUser {\n\tconst randomUser = {\n\t\tid: uuid(),\n\t\tname: getRandomName(\" \", true),\n\t};\n\n\treturn randomUser;\n}\n"]}
@@ -1 +1 @@
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
+ {"version":3,"file":"localDeltaStorageService.d.ts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAGxE;;GAEG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAE3E,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;IAG5C,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAIzB,OAAO;CAcrB"}
@@ -1 +1 @@
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"]}
1
+ {"version":3,"file":"localDeltaStorageService.js","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAKH,+DAAkE;AAElE;;GAEG;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,iCAAkB,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,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;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 { IDocumentDeltaStorageService, IStream } 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\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 +1 @@
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"}
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,EACN,OAAO,EAEP,gBAAgB,EAChB,aAAa,EACb,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;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,GACf,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,CAChB,IAAI,oBAAc,EAClB,IAAI,2BAA+C,EACnD,OAAO,EAAE,GAAG;CAab"}
@@ -1 +1 @@
1
- {"version":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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"]}
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;IACxE;;;;;;;;;OASG;IACI,MAAM,CAAC,KAAK,CAAC,MAAM,CACzB,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;YAChC,MAAM;YACN,EAAE;YACF,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,QAAQ;YACR,KAAK;YACL,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;QAC7C,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,qCAAmB,EAAE,CAAC,CAAC;IACtD,CAAC;IAES,UAAU,CAAC,IAAY,EAAE,QAA4B;QAC9D,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,QAA4B;QACzC,kFAAkF;QAClF,mEAAmE;QACnE,OAAO,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QACvC,CAAC,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,YAAY,CAAC,OAAY;QAC/B,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAC5C,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,oCAAa,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;AA/FD,oEA+FC","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\tIClient,\n\tIConnect,\n\tIDocumentMessage,\n\tNackErrorType,\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\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): 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);\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) {\n\t\tsuper(socket, documentId, new TelemetryNullLogger());\n\t}\n\n\tprotected submitCore(type: string, messages: IDocumentMessage[]) {\n\t\tthis.emitMessages(type, [messages]);\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.submitCore(\"submitOp\", messages);\n\t\t});\n\t}\n\n\t/**\n\t * Submits a new signal to the server\n\t */\n\tpublic submitSignal(message: any): void {\n\t\tthis.submitCore(\"submitSignal\", [message]);\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 +1 @@
1
- {"version":3,"file":"localDocumentService.d.ts","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,wBAAwB,EACxB,uBAAuB,EACvB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAGtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAA4B,4BAA4B,EAA+B,MAAM,GAAG,CAAC;AACxG;;GAEG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;aAQrC,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,CA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C,EAAE,gBAAgB,GACrC,gBAAgB,CAWlB"}
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentService.js","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAYH,mFAAoE;AACpE,yEAAkE;AAElE,wBAAwG;AACxG;;GAEG;AACH,MAAa,oBAAoB;IAC7B;;;;;OAKG;IACH,YACoB,WAAyB,EACxB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACvE,WAAqC,EAAE,EACtC,oBAAuC;QAPxC,gBAAW,GAAX,WAAW,CAAc;QACxB,+BAA0B,GAA1B,0BAA0B,CAA6B;QACvD,kBAAa,GAAb,aAAa,CAAgB;QAC7B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,eAAU,GAAV,UAAU,CAAQ;QAClB,gCAA2B,GAA3B,2BAA2B,CAA2C;QACvE,aAAQ,GAAR,QAAQ,CAA+B;QACtC,yBAAoB,GAApB,oBAAoB,CAAmB;IACxD,CAAC;IAEE,OAAO,KAAK,CAAC;IAEpB;;OAEG;IACI,KAAK,CAAC,gBAAgB;QACzB,OAAO,IAAI,8BAA2B,CAClC,IAAI,CAAC,UAAU,EACf,IAAI,mCAAU,CAAC,IAAI,iCAAa,CAAC,IAAI,CAAC,0BAA0B,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,EAC7F;YACI,WAAW,EAAE,IAAI;YACjB,sBAAsB,EAAE,SAAW,EAAE,yFAAyF;SACjI,CACJ,CAAC;IACN,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,qBAAqB;QAC9B,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC3B,OAAO,IAAI,CAAC,oBAAoB,CAAC,qBAAqB,EAAE,CAAC;SAC5D;QACD,OAAO,IAAI,2BAAwB,CAC/B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAAC,CAAC;IAC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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 {\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 {\n minBlobSize: 2048, // Test blob aggregation\n maximumCacheDurationMs: 432_000_000, // 5 days in ms. Not actually enforced but shouldn't matter for any local driver scenario\n },\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
+ {"version":3,"file":"localDocumentService.js","sourceRoot":"","sources":["../src/localDocumentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;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oDAAoD,CAAC,CAAC;SACtE;QACD,IAAI,IAAI,CAAC,oBAAoB,EAAE;YAC9B,OAAO,IAAI,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;SAC9D;QACD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,iBAAiB,CAC9D,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,UAAU,CACf,CAAC;QACF,MAAM,uBAAuB,GAAG,MAAM,+BAA4B,CAAC,MAAM,CACxE,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,UAAU,EACf,YAAY,CAAC,GAAG,EAChB,MAAM,EACN,IAAI,CAAC,0BAA0B,CAAC,eAAe,CAC/C,CAAC;QACF,MAAM,QAAQ,GAAG,uBAAuB,CAAC,QAAQ,CAAC;QAElD,8EAA8E;QAC9E,IAAI,CAAC,2BAA2B,CAAC,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;AApFD,oDAoFC;AAED;;;;;;GAMG;AACH,SAAgB,0BAA0B,CACzC,WAAyB,EACzB,0BAAuD,EACvD,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,2BAAsE,EACtE,QAAmC,EACnC,oBAAuC;IAEvC,OAAO,IAAI,oBAAoB,CAC9B,WAAW,EACX,0BAA0B,EAC1B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,2BAA2B,EAC3B,QAAQ,EACR,oBAAoB,CACpB,CAAC;AACH,CAAC;AApBD,gEAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentDeltaStorageService,\n\tIDocumentService,\n\tIDocumentServicePolicies,\n\tIDocumentStorageService,\n\tIResolvedUrl,\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 {\n\tLocalDeltaStorageService,\n\tLocalDocumentDeltaConnection,\n\tLocalDocumentStorageService,\n} from \".\";\n/**\n * Basic implementation of a document service for local use.\n */\nexport class LocalDocumentService implements IDocumentService {\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 = {},\n\t\tprivate readonly innerDocumentService?: IDocumentService,\n\t) {}\n\n\tpublic dispose() {}\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\tminBlobSize: 2048, // Test blob aggregation\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);\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);\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 */\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): 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);\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,MAAM,oCAAoC,CAAC;AAE1E,OAAO,EAAE,2BAA2B,EAA8B,MAAM,qCAAqC,CAAC;AAM9G,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAKnF;;GAEG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IAUnE,OAAO,CAAC,QAAQ,CAAC,0BAA0B;IAC3C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAC1B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC;IAX1C,SAAgB,YAAY,iBAAiB;IAG7C,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAwD;IAEpG;;OAEG;gBAEkB,0BAA0B,EAAE,2BAA2B,EACvD,QAAQ,CAAC,sCAA0B,EACnC,oBAAoB,CAAC,8BAAkB;IAE/C,eAAe,CACxB,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;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EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAuC5B;;;;OAIG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IA+B5B;;;;OAIG;IACI,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM;IAQlE;;;;;;OAMG;IACI,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,GAAG;CAOtF"}
@@ -38,7 +38,8 @@ class LocalDocumentServiceFactory {
38
38
  if (!this.localDeltaConnectionServer) {
39
39
  throw new Error("Provide the localDeltaConnectionServer!!");
40
40
  }
41
- const documentStorage = this.localDeltaConnectionServer.documentStorage;
41
+ const documentStorage = this.localDeltaConnectionServer
42
+ .documentStorage;
42
43
  const protocolSummary = createNewSummary.tree[".protocol"];
43
44
  const appSummary = createNewSummary.tree[".app"];
44
45
  if (!(protocolSummary && appSummary)) {
@@ -47,7 +48,7 @@ class LocalDocumentServiceFactory {
47
48
  const documentAttributes = (0, driver_utils_1.getDocAttributesFromProtocolSummary)(protocolSummary);
48
49
  const quorumValues = (0, driver_utils_1.getQuorumValuesFromProtocolSummary)(protocolSummary);
49
50
  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 : "", (_d = resolvedUrl.endpoints.deltaStorageUrl) !== null && _d !== void 0 ? _d : "", quorumValues, false);
51
+ 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 /* enableDiscovery */);
51
52
  return this.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
52
53
  }
53
54
  /**
@@ -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,SAAS,EAAE;YAChC,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;SAClF;QACD,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;QACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,O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C,QAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,OAAa;QAClF,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACzD;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACJ;AAzHD,kEAyHC","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 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"]}
1
+ {"version":3,"file":"localDocumentServiceFactory.js","sourceRoot":"","sources":["../src/localDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAQ5B,+EAA4E;AAK5E,+DAIsC;AAEtC,mFAAqE;AAErE,iEAAoE;AAEpE;;GAEG;AACH,MAAa,2BAA2B;IAOvC;;OAEG;IACH,YACkB,0BAAuD,EACvD,QAAmC,EACnC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,yBAAyB,CAAC,CAAC;SAC3C;QAED,MAAM,aAAa,GAAG,IAAI,2CAAoB,CAAC,QAAQ,CAAC,CAAC;QAEzD,OAAO,IAAA,iDAA0B,EAChC,WAAW,EACX,IAAI,CAAC,0BAA0B,EAC/B,aAAa,EACb,QAAQ,EACR,UAAU,EACV,IAAI,CAAC,2BAA2B,EAChC,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,oBAAoB,CACzB,CAAC;IACH,CAAC;IAED;;;;OAIG;IACI,gBAAgB,CAAC,QAAgB,EAAE,gBAAwB;QACjE,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACtD;QACD,uBAAuB,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAC5D,CAAC;IAED;;;;;;OAMG;IACI,UAAU,CAAC,QAAgB,EAAE,IAAa,EAAE,IAAoB,EAAE,OAAa;QACrF,MAAM,uBAAuB,GAAG,IAAI,CAAC,2BAA2B,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC/E,IAAI,uBAAuB,KAAK,SAAS,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,EAAE,CAAC,CAAC;SACtD;QACD,uBAAuB,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACzD,CAAC;CACD;AA/HD,kEA+HC","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\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { DefaultTokenProvider } from \"@fluidframework/routerlicious-driver\";\nimport {\n\tILocalDeltaConnectionServer,\n\tLocalDeltaConnectionServer,\n} from \"@fluidframework/server-local-server\";\nimport {\n\tensureFluidResolvedUrl,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\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\tpublic readonly protocolName = \"fluid-test:\";\n\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\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\tensureFluidResolvedUrl(resolvedUrl);\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tconst pathName = new URL(resolvedUrl.url).pathname;\n\t\tconst pathArr = pathName.split(\"/\");\n\t\tconst tenantId = pathArr[pathArr.length - 2];\n\t\tconst id = pathArr[pathArr.length - 1];\n\t\tif (!this.localDeltaConnectionServer) {\n\t\t\tthrow new Error(\"Provide the localDeltaConnectionServer!!\");\n\t\t}\n\t\tconst documentStorage = (this.localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t\t.documentStorage;\n\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"] as ISummaryTree;\n\t\tconst appSummary = createNewSummary.tree[\".app\"] as ISummaryTree;\n\t\tif (!(protocolSummary && appSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\t\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\t\tawait documentStorage.createDocument(\n\t\t\ttenantId,\n\t\t\tid,\n\t\t\tappSummary,\n\t\t\tsequenceNumber,\n\t\t\tdocumentAttributes.term ?? 1,\n\t\t\tdefaultHash,\n\t\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\t\tquorumValues,\n\t\t\tfalse /* enableDiscovery */,\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\tensureFluidResolvedUrl(resolvedUrl);\n\n\t\tconst parsedUrl = parse(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.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);\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) {\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(clientId: string, code?: number, type?: NackErrorType, message?: any) {\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.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;AA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,eAAe,EACf,cAAc,EACd,YAAY,EACZ,QAAQ,EACR,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EACN,UAAU,EAGV,MAAM,wCAAwC,CAAC;AAEhD,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,EAAE,+BAA+B;IAS7C,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,CACpC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC;IAQL,UAAU,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAO/D,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;YAI7D,uBAAuB;CAWrC"}
@@ -55,15 +55,16 @@ class LocalDocumentStorageService {
55
55
  }
56
56
  async createBlob(file) {
57
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 }));
58
+ return this.manager
59
+ .createBlob((0, common_utils_1.Uint8ArrayToString)(uint8ArrayFile, "base64"), "base64")
60
+ .then((r) => ({ id: r.sha, url: r.url }));
59
61
  }
60
62
  async downloadSummary(handle) {
61
63
  throw new Error("NOT IMPLEMENTED!");
62
64
  }
63
65
  async getPreviousFullSnapshot(parentHandle) {
64
66
  return parentHandle
65
- ? this.getVersions(parentHandle, 1)
66
- .then(async (versions) => {
67
+ ? this.getVersions(parentHandle, 1).then(async (versions) => {
67
68
  // Clear the cache as the getSnapshotTree call will fill the cache.
68
69
  this.blobsShaCache.clear();
69
70
  return this.getSnapshotTree(versions[0]);
@@ -1 +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,QAAyC;QAFxC,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QAZ1D,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,CAAC,IAAI,CAAC,IAAI,CAAC,CACvC,CAAC;IACH,CAAC;IAdD,IAAW,aAAa;QACvB,OAAO,EAAE,CAAC;IACX,CAAC;IAcM,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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gB,CACpD,OAAO,EACP,MAAA,OAAO,CAAC,SAAS,mCAAI,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,CAAC,UAAU,CAC7B,IAAA,iCAAkB,EACjB,cAAc,EAAE,QAAQ,CAAC,EAC1B,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CAAC,YAAoB;QACzD,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;iBACjC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBACxB,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;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"]}
1
+ {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAAkF;AAalF,iEAA+D;AAC/D,mFAIgD;AAEhD,MAAa,2BAA2B;IAUvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC;QAFxC,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QAZ1D,uFAAuF;QACvF,2BAA2B;QACR,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAY5D,IAAI,CAAC,wBAAwB,GAAG,IAAI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AI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC,CAAC;YACJ,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AAxFD,kEAwFC","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 {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} 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(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): 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\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.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(\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 })\n\t\t\t: undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEH,YAAY,EACZ,YAAY,EAEf,MAAM,oCAAoC,CAAC;AAI5C,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQhF;AAED;;;GAGG;AACH,qBAAa,aAAc,YAAW,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;;IAIvC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBjD,cAAc,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAiBrF,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;CAG9D"}
1
+ {"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,YAAY,EACZ,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAI5C,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQhF;AAED;;;GAGG;AACH,qBAAa,aAAc,YAAW,YAAY;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;;IAIvC;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC;IAoBj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the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n IFluidResolvedUrl,\n IResolvedUrl,\n IUrlResolver,\n DriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport { ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { generateToken } from \"./auth\";\n\nexport function createLocalResolverCreateNewRequest(documentId: string): IRequest {\n const createNewRequest: IRequest = {\n url: `http://localhost:3000/${documentId}`,\n headers: {\n [DriverHeader.createNew]: true,\n },\n };\n return createNewRequest;\n}\n\n/**\n * Resolves URLs by providing fake URLs which succeed with the other\n * related local classes.\n */\nexport class LocalResolver implements IUrlResolver {\n private readonly tenantId = \"tenantId\";\n private readonly tokenKey = \"tokenKey\";\n\n constructor() { }\n\n /**\n * Resolves URL requests by providing fake URLs with an actually generated\n * token from constant test strings. The root of the URL is fake, but the\n * remaining relative URL can still be parsed.\n * @param request - request to handle\n */\n public async resolve(request: IRequest): Promise<IResolvedUrl> {\n const parsedUrl = new URL(request.url);\n const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;\n const documentId = fullPath.split(\"/\")[0];\n const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];\n const resolved: IFluidResolvedUrl = {\n endpoints: {\n deltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,\n ordererUrl: \"http://localhost:3000\",\n storageUrl: `http://localhost:3000/repos/${this.tenantId}`,\n },\n id: documentId,\n tokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },\n type: \"fluid\",\n url: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,\n };\n\n return resolved;\n }\n\n public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n let url = relativeUrl;\n if (url.startsWith(\"/\")) {\n url = url.substr(1);\n }\n const fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n const parsedUrl = parse(fluidResolvedUrl.url);\n if (parsedUrl.pathname === null) {\n throw new Error(\"Url should contain tenant and docId!!\");\n }\n const [, , documentId] = parsedUrl.pathname.split(\"/\");\n assert(!!documentId, 0x09a /* \"'documentId' must be a defined, non-zero length string.\" */);\n\n return `http://localhost:3000/${documentId}/${url}`;\n }\n\n public createCreateNewRequest(documentId: string): IRequest {\n return createLocalResolverCreateNewRequest(documentId);\n }\n}\n"]}
1
+ {"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAC5B,+DAAsD;AAEtD,2EAK4C;AAC5C,+EAAiE;AACjE,iCAAuC;AAEvC,SAAgB,mCAAmC,CAAC,UAAkB;IACrE,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,yBAAyB,UAAU,EAAE;QAC1C,OAAO,EAAE;YACR,CAAC,iCAAY,CAAC,SAAS,CAAC,EAAE,IAAI;SAC9B;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AARD,kFAQC;AAED;;;GAGG;AACH,MAAa,aAAa;IAIzB;QAHiB,aAAQ,GAAG,UAAU,CAAC;QACtB,aAAQ,GAAG,UAAU,CAAC;IAExB,CAAC;IAEhB;;;;;OAKG;IACI,KAAK,CAAC,OAAO,CAAC,OAAiB;QACrC,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;QACtE,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,CAAC,gCAAS,CAAC,OAAO,EAAE,gCAAS,CAAC,QAAQ,EAAE,gCAAS,CAAC,YAAY,CAAC,CAAC;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UAAU,CAAC,CAAC;IACxD,CAAC;CACD;AApDD,sCAoDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport { assert } from \"@fluidframework/common-utils\";\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tIFluidResolvedUrl,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tDriverHeader,\n} from \"@fluidframework/driver-definitions\";\nimport { ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { generateToken } from \"./auth\";\n\nexport function createLocalResolverCreateNewRequest(documentId: string): IRequest {\n\tconst createNewRequest: IRequest = {\n\t\turl: `http://localhost:3000/${documentId}`,\n\t\theaders: {\n\t\t\t[DriverHeader.createNew]: true,\n\t\t},\n\t};\n\treturn createNewRequest;\n}\n\n/**\n * Resolves URLs by providing fake URLs which succeed with the other\n * related local classes.\n */\nexport class LocalResolver implements IUrlResolver {\n\tprivate readonly tenantId = \"tenantId\";\n\tprivate readonly tokenKey = \"tokenKey\";\n\n\tconstructor() {}\n\n\t/**\n\t * Resolves URL requests by providing fake URLs with an actually generated\n\t * token from constant test strings. The root of the URL is fake, but the\n\t * remaining relative URL can still be parsed.\n\t * @param request - request to handle\n\t */\n\tpublic async resolve(request: IRequest): Promise<IResolvedUrl> {\n\t\tconst parsedUrl = new URL(request.url);\n\t\tconst fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;\n\t\tconst documentId = fullPath.split(\"/\")[0];\n\t\tconst scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];\n\t\tconst resolved: IFluidResolvedUrl = {\n\t\t\tendpoints: {\n\t\t\t\tdeltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,\n\t\t\t\tordererUrl: \"http://localhost:3000\",\n\t\t\t\tstorageUrl: `http://localhost:3000/repos/${this.tenantId}`,\n\t\t\t},\n\t\t\tid: documentId,\n\t\t\ttokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },\n\t\t\ttype: \"fluid\",\n\t\t\turl: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {\n\t\tlet url = relativeUrl;\n\t\tif (url.startsWith(\"/\")) {\n\t\t\turl = url.substr(1);\n\t\t}\n\t\tconst fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;\n\n\t\tconst parsedUrl = parse(fluidResolvedUrl.url);\n\t\tif (parsedUrl.pathname === null) {\n\t\t\tthrow new Error(\"Url should contain tenant and docId!!\");\n\t\t}\n\t\tconst [, , documentId] = parsedUrl.pathname.split(\"/\");\n\t\tassert(!!documentId, 0x09a /* \"'documentId' must be a defined, non-zero length string.\" */);\n\n\t\treturn `http://localhost:3000/${documentId}/${url}`;\n\t}\n\n\tpublic createCreateNewRequest(documentId: string): IRequest {\n\t\treturn createLocalResolverCreateNewRequest(documentId);\n\t}\n}\n"]}
@@ -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;AAuSnE;;GAEG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAC/D,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,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;AA6SnE;;GAEG;AACH,qBAAa,4BAA6B,YA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AAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACpC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAC;SACf;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED;;GAEG;AACH,MAAa,4BAA4B;IAAzC;QACoB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIpE,CAAC;IAHU,KAAK,CAAC,OAAO;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;CACJ;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\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 /**\n * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n */\n constructor(private readonly collectionName: string) { }\n\n public aggregate(pipeline: any, options?: any): any {\n throw new Error(\"Method Not Implemented\");\n }\n\n public async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n throw new Error(\"Method Not Implemented\");\n }\n public async distinct(key: any, query: any): Promise<any> {\n throw new Error(\"Method Not Implemented\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n */\n /*\n * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n * The hierarchical syntax allows finding nested key patterns.\n */\n public async find(query: any, sort: any): Promise<any[]> {\n // split the keys and get the corresponding value\n function getValueByKey(propertyBag, key: string) {\n const keys = key.split(\".\");\n let value = propertyBag;\n keys.forEach((splitKey) => {\n value = value[splitKey];\n });\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return value;\n }\n\n // getting keys of the query we are trying to find\n const queryKeys = Object.keys(query);\n let filteredCollection = this.getAllInternal();\n queryKeys.forEach((key) => {\n if (!query[key]) {\n return;\n }\n if (query[key].$gt > 0 || query[key].$lt > 0) {\n if (query[key].$gt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) > query[key].$gt);\n }\n if (query[key].$lt > 0) {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) < query[key].$lt);\n }\n } else {\n filteredCollection = filteredCollection.filter(\n (value) => getValueByKey(value, key) === query[key]);\n }\n });\n\n if (sort && Object.keys(sort).length === 1) {\n // eslint-disable-next-line no-inner-declarations\n function compare(a, b) {\n const sortKey = Object.keys(sort)[0];\n return sort[sortKey] === 1\n ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n : getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n }\n\n filteredCollection = filteredCollection.sort(compare);\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return filteredCollection;\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n */\n public async findAll(): Promise<any[]> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.getAllInternal();\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async findOne(query: any): Promise<any> {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return this.findOneInternal(query);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async update(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n throw new Error(\"Not found\");\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n */\n /*\n * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n */\n public async upsert(query: any, set: any, addToSet: any): Promise<void> {\n const value = this.findOneInternal(query);\n if (!value) {\n this.insertInternal(set);\n } else {\n for (const key of Object.keys(set)) {\n value[key] = set[key];\n }\n this.insertInternal(value);\n }\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n */\n /*\n * Value is expected to have a member \"_id\" which is a string used to search in the database.\n */\n public async insertOne(value: any): Promise<any> {\n const presentVal = this.findOneInternal(value);\n // Only raise error when the object is present and the value is not equal.\n if (presentVal) {\n if (JSON.stringify(presentVal) === JSON.stringify(value)) {\n return;\n }\n throw new Error(\"Existing Object!!\");\n }\n\n return this.insertInternal(value);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n */\n /*\n * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n */\n public async findOrCreate(query: any, value: any): Promise<{ value: any; existing: boolean; }> {\n const existing = this.findOneInternal(query);\n if (existing) {\n return { value: existing, existing: true };\n }\n this.insertInternal(value);\n return { value, existing: false };\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n */\n /*\n * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n */\n public async insertMany(values: any[], ordered: boolean): Promise<void> {\n this.insertInternal(...values);\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n */\n public async deleteOne(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n */\n public async deleteMany(query: any): Promise<any> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n */\n public async createIndex(index: any, unique: boolean): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n\n /**\n * Return all values in the database\n */\n private getAllInternal(): any[] {\n const values: string[] = [];\n for (let i = 0; i < sessionStorage.length; i++) {\n const key = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (key!.startsWith(this.collectionName)) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n values.push(JSON.parse(sessionStorage.getItem(key!)!));\n }\n }\n return values;\n }\n\n /**\n * Inserts values into the session storge.\n * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n *\n * @param values - data to insert to the database\n */\n private insertInternal(...values: any[]) {\n for (const value of values) {\n if (value) {\n if (!value._id) {\n value._id = uuid();\n }\n sessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n }\n }\n }\n\n /**\n * Finds the query in session storage and returns its value.\n * Returns null if query is not found.\n * Query is expected to have a member \"_id\" which is a unique id.\n *\n * @param query - what to find in the database\n */\n private findOneInternal(query: any): any {\n if (query._id) {\n const json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n if (json) {\n return JSON.parse(json);\n }\n } else {\n const queryKeys = Object.keys(query);\n for (let i = 0; i < sessionStorage.length; i++) {\n const ssKey = sessionStorage.key(i);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (!ssKey!.startsWith(this.collectionName)) {\n continue;\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n let foundMismatch = false;\n for (const qk of queryKeys) {\n if (value[qk] !== query[qk]) {\n foundMismatch = true;\n break;\n }\n }\n\n if (!foundMismatch) {\n return value;\n }\n }\n }\n return null;\n }\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n private readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n public async close(): Promise<void> { }\n public collection<T>(name: string): ICollection<T> {\n if (!this.collections.has(name)) {\n this.collections.set(name, new LocalSessionStorageCollection<T>(name));\n }\n return this.collections.get(name) as LocalSessionStorageCollection<T>;\n }\n\n public async dropCollection(name: string): Promise<boolean> {\n if (!this.collections.has(name)) {\n return true;\n }\n this.collections.delete(name);\n return true;\n }\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n public readonly testDatabase: IDb = new LocalSessionStorageDb();\n public async connect(): Promise<IDb> {\n return this.testDatabase;\n }\n}\n"]}
1
+ {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAAsC;AAGtC,+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,QAAQ,CAAC,GAAQ,EAAE,KAAU;QACzC,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC3C,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,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b,CAAC;CACD;AAED;;GAEG;AACH,MAAM,qBAAsB,SAAQ,qBAAY;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;YAChC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;SACvE;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;YAChC,OAAO,IAAI,CAAC;SACZ;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;GAEG;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 */\nimport { EventEmitter } from \"events\";\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\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\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(query: any, value: any): 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(\n\t\t\t\t\t`${this.collectionName}-${value._id}`,\n\t\t\t\t\tJSON.stringify(value),\n\t\t\t\t);\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 */\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"]}
@@ -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.0.0-internal.3.0.1";
8
+ export declare const pkgVersion = "2.0.0-internal.3.1.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -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.0.0-internal.3.0.1";
11
+ exports.pkgVersion = "2.0.0-internal.3.1.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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/local-driver\";\nexport const pkgVersion = \"2.0.0-internal.3.0.1\";\n"]}
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,sBAAsB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/local-driver\";\nexport const pkgVersion = \"2.0.0-internal.3.1.0\";\n"]}