@fluidframework/local-driver 2.1.0-276985 → 2.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 (42) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +95 -2
  3. package/api-extractor/api-extractor.current.json +5 -0
  4. package/api-extractor/api-extractor.legacy.json +1 -1
  5. package/api-extractor.json +1 -1
  6. package/api-report/local-driver.legacy.public.api.md +9 -0
  7. package/dist/legacy.d.ts +1 -1
  8. package/dist/localCreateDocument.d.ts.map +1 -1
  9. package/dist/localCreateDocument.js +4 -0
  10. package/dist/localCreateDocument.js.map +1 -1
  11. package/dist/localDocumentStorageService.d.ts.map +1 -1
  12. package/dist/localDocumentStorageService.js +8 -0
  13. package/dist/localDocumentStorageService.js.map +1 -1
  14. package/dist/localResolver.d.ts.map +1 -1
  15. package/dist/localResolver.js +2 -0
  16. package/dist/localResolver.js.map +1 -1
  17. package/dist/localSessionStorageDb.d.ts.map +1 -1
  18. package/dist/localSessionStorageDb.js +2 -0
  19. package/dist/localSessionStorageDb.js.map +1 -1
  20. package/dist/public.d.ts +1 -1
  21. package/internal.d.ts +1 -1
  22. package/legacy.d.ts +1 -1
  23. package/lib/legacy.d.ts +1 -1
  24. package/lib/localCreateDocument.d.ts.map +1 -1
  25. package/lib/localCreateDocument.js +4 -0
  26. package/lib/localCreateDocument.js.map +1 -1
  27. package/lib/localDocumentStorageService.d.ts.map +1 -1
  28. package/lib/localDocumentStorageService.js +8 -0
  29. package/lib/localDocumentStorageService.js.map +1 -1
  30. package/lib/localResolver.d.ts.map +1 -1
  31. package/lib/localResolver.js +2 -0
  32. package/lib/localResolver.js.map +1 -1
  33. package/lib/localSessionStorageDb.d.ts.map +1 -1
  34. package/lib/localSessionStorageDb.js +2 -0
  35. package/lib/localSessionStorageDb.js.map +1 -1
  36. package/lib/public.d.ts +1 -1
  37. package/package.json +24 -22
  38. package/src/localCreateDocument.ts +6 -2
  39. package/src/localDocumentStorageService.ts +12 -4
  40. package/src/localResolver.ts +3 -1
  41. package/src/localSessionStorageDb.ts +3 -1
  42. package/tsconfig.json +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/local-driver
2
2
 
3
+ ## 2.1.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.0.0-rc.5.0.0
4
8
 
5
9
  ### Minor Changes
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # @fluidframework/local-driver
2
2
 
3
- <!-- AUTO-GENERATED-CONTENT:START (README_DEPENDENCY_GUIDELINES_SECTION:includeHeading=TRUE) -->
3
+ TODO: document this package
4
+
5
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_HEADER) -->
4
6
 
5
7
  <!-- prettier-ignore-start -->
6
8
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
@@ -13,15 +15,106 @@ library consumers should always prefer `^`.
13
15
 
14
16
  If using any of Fluid Framework's unstable APIs (for example, its `beta` APIs), we recommend using a more constrained version range, such as `~`.
15
17
 
18
+ ## Installation
19
+
20
+ To get started, install the package by running the following command:
21
+
22
+ ```bash
23
+ npm i @fluidframework/local-driver
24
+ ```
25
+
26
+ ## Importing from this package
27
+
28
+ This package leverages [package.json exports](https://nodejs.org/api/packages.html#exports) to separate its APIs by support level.
29
+ For more information on the related support guarantees, see [API Support Levels](https://fluidframework.com/docs/build/releases-and-apitags/#api-support-levels).
30
+
31
+ To access the `public` ([SemVer](https://semver.org/)) APIs, import via `@fluidframework/local-driver` like normal.
32
+
33
+ To access the `legacy` APIs, import via `@fluidframework/local-driver/legacy`.
34
+
35
+ ## API Documentation
36
+
37
+ API documentation for **@fluidframework/local-driver** is available at <https://fluidframework.com/docs/apis/local-driver>.
38
+
16
39
  <!-- prettier-ignore-end -->
17
40
 
18
41
  <!-- AUTO-GENERATED-CONTENT:END -->
19
42
 
20
- <!-- AUTO-GENERATED-CONTENT:START (README_TRADEMARK_SECTION:includeHeading=TRUE) -->
43
+ <!-- AUTO-GENERATED-CONTENT:START (LIBRARY_PACKAGE_README_FOOTER) -->
21
44
 
22
45
  <!-- prettier-ignore-start -->
23
46
  <!-- NOTE: This section is automatically generated using @fluid-tools/markdown-magic. Do not update these generated contents directly. -->
24
47
 
48
+ ## Minimum Client Requirements
49
+
50
+ These are the platform requirements for the current version of Fluid Framework Client Packages.
51
+ These requirements err on the side of being too strict since within a major version they can be relaxed over time, but not made stricter.
52
+ For Long Term Support (LTS) versions this can require supporting these platforms for several years.
53
+
54
+ It is likely that other configurations will work, but they are not supported: if they stop working, we do not consider that a bug.
55
+ If you would benefit from support for something not listed here, file an issue and the product team will evaluate your request.
56
+ When making such a request please include if the configuration already works (and thus the request is just that it becomes officially supported), or if changes are required to get it working.
57
+
58
+ ### Supported Runtimes
59
+
60
+ - NodeJs ^20.10.0 except that we will drop support for it [when NodeJs 20 loses its upstream support on 2026-04-30](https://github.com/nodejs/release#release-schedule), and will support a newer LTS version of NodeJS (22) at least 1 year before 20 is end-of-life. This same policy applies to NodeJS 22 when it is end of life (2027-04-30).
61
+ - Modern browsers supporting the es2022 standard library: in response to asks we can add explicit support for using babel to polyfill to target specific standards or runtimes (meaning we can avoid/remove use of things that don't polyfill robustly, but otherwise target modern standards).
62
+
63
+ ### Supported Tools
64
+
65
+ - TypeScript 5.4:
66
+ - All [`strict`](https://www.typescriptlang.org/tsconfig) options are supported.
67
+ - [`strictNullChecks`](https://www.typescriptlang.org/tsconfig) is required.
68
+ - [Configuration options deprecated in 5.0](https://github.com/microsoft/TypeScript/issues/51909) are not supported.
69
+ - `exactOptionalPropertyTypes` is currently not fully supported.
70
+ If used, narrowing members of Fluid Framework types types using `in`, `Reflect.has`, `Object.hasOwn` or `Object.prototype.hasOwnProperty` should be avoided as they may incorrectly exclude `undefined` from the possible values in some cases.
71
+ - [webpack](https://webpack.js.org/) 5
72
+ - We are not intending to be prescriptive about what bundler to use.
73
+ Other bundlers which can handle ES Modules should work, but webpack is the only one we actively test.
74
+
75
+ ### Module Resolution
76
+
77
+ [`Node16`, `NodeNext`, or `Bundler`](https://www.typescriptlang.org/tsconfig#moduleResolution) resolution should be used with TypeScript compilerOptions to follow the [Node.js v12+ ESM Resolution and Loading algorithm](https://nodejs.github.io/nodejs.dev/en/api/v20/esm/#resolution-and-loading-algorithm).
78
+ Node10 resolution is not supported as it does not support Fluid Framework's API structuring pattern that is used to distinguish stable APIs from those that are in development.
79
+
80
+ ### Module Formats
81
+
82
+ - ES Modules:
83
+ ES Modules are the preferred way to consume our client packages (including in NodeJs) and consuming our client packages from ES Modules is fully supported.
84
+ - CommonJs:
85
+ Consuming our client packages as CommonJs is supported only in NodeJS and only for the cases listed below.
86
+ This is done to accommodate some workflows without good ES Module support.
87
+ If you have a workflow you would like included in this list, file an issue.
88
+ Once this list of workflows motivating CommonJS support is empty, we may drop support for CommonJS one year after notice of the change is posted here.
89
+
90
+ - Testing with Jest (which lacks [stable ESM support](https://jestjs.io/docs/ecmascript-modules) due to [unstable APIs in NodeJs](https://github.com/nodejs/node/issues/37648))
91
+
92
+ ## Contribution Guidelines
93
+
94
+ There are many ways to [contribute](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md) to Fluid.
95
+
96
+ - Participate in Q&A in our [GitHub Discussions](https://github.com/microsoft/FluidFramework/discussions).
97
+ - [Submit bugs](https://github.com/microsoft/FluidFramework/issues) and help us verify fixes as they are checked in.
98
+ - Review the [source code changes](https://github.com/microsoft/FluidFramework/pulls).
99
+ - [Contribute bug fixes](https://github.com/microsoft/FluidFramework/blob/main/CONTRIBUTING.md).
100
+
101
+ Detailed instructions for working in the repo can be found in the [Wiki](https://github.com/microsoft/FluidFramework/wiki).
102
+
103
+ This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
104
+ For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
105
+
106
+ This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
107
+ Use of these trademarks or logos must follow Microsoft’s [Trademark & Brand Guidelines](https://www.microsoft.com/trademarks).
108
+ Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
109
+
110
+ ## Help
111
+
112
+ Not finding what you're looking for in this README? Check out [fluidframework.com](https://fluidframework.com/docs/).
113
+
114
+ Still not finding what you're looking for? Please [file an issue](https://github.com/microsoft/FluidFramework/wiki/Submitting-Bugs-and-Feature-Requests).
115
+
116
+ Thank you!
117
+
25
118
  ## Trademark
26
119
 
27
120
  This project may contain Microsoft trademarks or logos for Microsoft projects, products, or services.
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.current.json",
4
+ "mainEntryPointFilePath": "<projectFolder>/lib/public.d.ts"
5
+ }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-base.esm.legacy.json"
3
+ "extends": "<projectFolder>/../../../common/build/build-common/api-extractor-report.esm.legacy.json"
4
4
  }
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
- "extends": "../../../common/build/build-common/api-extractor-base.esm.current.json"
3
+ "extends": "../../../common/build/build-common/api-extractor-model.esm.json"
4
4
  }
@@ -0,0 +1,9 @@
1
+ ## Public API Report File for "@fluidframework/local-driver"
2
+
3
+ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
+
5
+ ```ts
6
+
7
+ // (No @packageDocumentation comment for this package)
8
+
9
+ ```
package/dist/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAS3E,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBA6BrB"}
1
+ {"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAS3E,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBAiCrB"}
@@ -10,7 +10,11 @@ const server_services_client_1 = require("@fluidframework/server-services-client
10
10
  async function createDocument(localDeltaConnectionServer, resolvedUrl, summary) {
11
11
  const pathName = new URL(resolvedUrl.url).pathname;
12
12
  const pathArr = pathName.split("/");
13
+ // TODO Why are we non null asserting here
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
13
15
  const tenantId = pathArr[pathArr.length - 2];
16
+ // TODO Why are we non null asserting here
17
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
18
  const id = pathArr[pathArr.length - 1];
15
19
  const documentStorage = localDeltaConnectionServer
16
20
  .documentStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../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C,0BAA0B,CAChC,CAAC;AACH,CAAC;AAhCD,wCAgCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\tconst tenantId = pathArr[pathArr.length - 2];\n\tconst id = pathArr[pathArr.length - 1];\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
1
+ {"version":3,"file":"localC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SAAS,CAAC,eAAe,IAAI,EAAE,EAC3C,YAAY,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,0BAA0B,CAChC,CAAC;AACH,CAAC;AApCD,wCAoCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst tenantId = pathArr[pathArr.length - 2]!;\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst id = pathArr[pathArr.length - 1]!;\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,QAAQ,EACR,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EACN,UAAU,EAGV,MAAM,wCAAwC,CAAC;AAKhD;;GAEG;AACH,qBAAa,2BAA4B,YAAW,uBAAuB;IAOzE,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,OAAO;aACR,QAAQ,EAAE,+BAA+B;IACzD,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAR9B,SAAS,CAAC,QAAQ,CAAC,aAAa,sBAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAwB;gBAG/C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACpB,QAAQ,EAAE,+BAA+B,EACxC,0BAA0B,CAAC,yCAA6B,EACxD,WAAW,CAAC,0BAAc;IAS/B,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAUzE,eAAe,CAAC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0B,CAAC;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC;IAR9B,SAAS,CAAC,QAAQ,CAAC,aAAa,sBAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAwB;gBAG/C,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,UAAU,EACpB,QAAQ,EAAE,+BAA+B,EACxC,0BAA0B,CAAC,yCAA6B,EACxD,WAAW,CAAC,0BAAc;IAS/B,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;IAmBpE,WAAW,CAAC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC;IAiD1F;;;;;;OAMG;YACW,uCAAuC;IAsBrD;;;;;;;;;;;;OAYG;YACW,2BAA2B;YA2D3B,oBAAoB;YAoBpB,eAAe;IAS7B,OAAO,CAAC,SAAS;YAMH,WAAW;IAaZ,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;IAoBL,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"}
@@ -42,6 +42,8 @@ class LocalDocumentStorageService {
42
42
  if (versions.length === 0) {
43
43
  return null;
44
44
  }
45
+ // Non null asserting here because of the length check above
46
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
47
  requestVersion = versions[0];
46
48
  }
47
49
  const rawTree = await this.manager.getTree(requestVersion.treeId);
@@ -56,11 +58,15 @@ class LocalDocumentStorageService {
56
58
  if (versions.length === 0) {
57
59
  throw new Error("No versions for the document!");
58
60
  }
61
+ // Non null asserting here because of the length check above
62
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
59
63
  versionId = versions[0].treeId;
60
64
  }
61
65
  const rawTree = await this.manager.getTree(versionId);
62
66
  const snapshotTree = (0, protocol_base_1.buildGitTreeHierarchy)(rawTree, this.blobsShaCache, true);
63
67
  const groupIds = new Set(snapshotFetchOptions?.loadingGroupIds ?? []);
68
+ // TODO Why are we non null asserting here
69
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
70
  const attributesBlobId = snapshotTree.trees[".protocol"].blobs.attributes;
65
71
  // Only populate contents for the blobs which are supposed to be returned.
66
72
  const blobContents = new Map();
@@ -201,6 +207,8 @@ class LocalDocumentStorageService {
201
207
  }
202
208
  await (0, localCreateDocument_js_1.createDocument)(this.localDeltaConnectionServer, this.resolvedUrl, summary);
203
209
  const version = await this.getVersions(this.id, 1);
210
+ // TODO Why are we non null asserting here
211
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
204
212
  return version[0].id;
205
213
  }
206
214
  return this.summaryTreeUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel");
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAKsC;AACtC,kEAA6D;AAa7D,iEAAsE;AAEtE,mFAIgD;AAEhD,qEAA0D;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAa,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,Q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;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AAnSD,kEAmSC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\tversionId = versions[0].treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"].blobs.attributes;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\treturn version[0].id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAKsC;AACtC,kEAA6D;AAa7D,iEAAsE;AAEtE,mFAIgD;AAEhD,qEAA0D;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAa,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;Q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c,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC;aAClE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD;AA3SD,kEA2SC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAEN,YAAY,EACZ,YAAY,EAEZ,MAAM,6CAA6C,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQhF;AAED;;;;;GAKG;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;IAoBjD,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC;IAkBX,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;CAG3D"}
1
+ {"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE3D,OAAO,EAEN,YAAY,EACZ,YAAY,EAEZ,MAAM,6CAA6C,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAQhF;AAED;;;;;GAKG;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;IAsBjD,cAAc,CAC1B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC;IAkBX,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ;CAG3D"}
@@ -42,6 +42,8 @@ class LocalResolver {
42
42
  async resolve(request) {
43
43
  const parsedUrl = new URL(request.url);
44
44
  const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
45
+ // TODO Why are we non null asserting here
46
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
45
47
  const documentId = fullPath.split("/")[0];
46
48
  const scopes = [internal_2.ScopeType.DocRead, internal_2.ScopeType.DocWrite, internal_2.ScopeType.SummaryWrite];
47
49
  const resolved = {
@@ -1 +1 @@
1
- {"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAC7D,0EAKqD;AAErD,uCAA0C;AAE1C;;;GAGG;AACH,SAAgB,mCAAmC,CAAC,UAAkB;IACrE,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,yBAAyB,UAAU,EAAE;QAC1C,OAAO,EAAE;YACR,CAAC,uBAAY,CAAC,SAAS,CAAC,EAAE,IAAI;SAC9B;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AARD,kFAQC;AAED;;;;;GAKG;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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AS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,IAAA,iBAAM,EACL,CAAC,CAAC,UAAU,EACZ,KAAK,CAAC,+DAA+D,CACrE,CAAC;QAEF,OAAO,yBAAyB,UAAU,IAAI,GAAG,EAAE,CAAC;IACrD,CAAC;IAEM,sBAAsB,CAAC,UAAkB;QAC/C,OAAO,mCAAmC,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACD;AAxDD,sCAwDC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tScopeType,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { generateToken } from \"./auth.js\";\n\n/**\n * @legacy\n * @alpha\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 * @legacy\n * @alpha\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: IResolvedUrl = {\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: `https://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): 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 parsedUrl = new URL(resolvedUrl.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(\n\t\t\t!!documentId,\n\t\t\t0x09a /* \"'documentId' must be a defined, non-zero length string.\" */,\n\t\t);\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
+ {"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,kEAA6D;AAC7D,0EAKqD;AAErD,uCAA0C;AAE1C;;;GAGG;AACH,SAAgB,mCAAmC,CAAC,UAAkB;IACrE,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,yBAAyB,UAAU,EAAE;QAC1C,OAAO,EAAE;YACR,CAAC,uBAAY,CAAC,SAAS,CAAC,EAAE,IAAI;SAC9B;KACD,CAAC;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I,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,CAAC,EAAE,AAAD,EAAG,UAAU,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,IAAA,iBAAM,EACL,CAAC,CAAC,UAAU,EACZ,KAAK,CAAC,+DAA+D,CACrE,CAAC;QAEF,OAAO,yBAAyB,UAAU,IAAI,GAAG,EAAE,CAAC;IACrD,CAAC;IAEM,sBAAsB,CAAC,UAAkB;QAC/C,OAAO,mCAAmC,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACD;AA1DD,sCA0DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tScopeType,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { generateToken } from \"./auth.js\";\n\n/**\n * @legacy\n * @alpha\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 * @legacy\n * @alpha\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\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst documentId = fullPath.split(\"/\")[0]!;\n\t\tconst scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];\n\t\tconst resolved: IResolvedUrl = {\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: `https://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): 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 parsedUrl = new URL(resolvedUrl.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(\n\t\t\t!!documentId,\n\t\t\t0x09a /* \"'documentId' must be a defined, non-zero length string.\" */,\n\t\t);\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":"AAAA;;;GAGG;AAGH,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAgTnE;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAClE,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGpC"}
1
+ {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAkTnE;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAClE,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGpC"}
@@ -70,6 +70,8 @@ class LocalSessionStorageCollection {
70
70
  if (sort && Object.keys(sort).length === 1) {
71
71
  // eslint-disable-next-line no-inner-declarations
72
72
  function compare(a, b) {
73
+ // Non null asserting here because of the length check above
74
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
73
75
  const sortKey = Object.keys(sort)[0];
74
76
  return sort[sortKey] === 1
75
77
  ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)
@@ -1 +1 @@
1
- {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;A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IAgBtF,CAAC;IAfO,KAAK,CAAC,KAAK,KAAmB,CAAC;IAC/B,UAAU,CAAI,IAAY;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAa,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\tconst sortKey = Object.keys(sort)[0];\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA4D;AAG5D,+BAAkC;AAElC;;;GAGG;AACH,MAAM,6BAA6B;IAClC;;OAEG;IACH,YAA6B,cAAsB;QAAt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AK,CAAC,KAAK,KAAmB,CAAC;IAC/B,UAAU,CAAI,IAAY;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAa,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD;AALD,oEAKC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
package/dist/public.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {}
package/internal.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/index.js";
package/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export * from "./lib/legacy.js";
package/lib/legacy.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAS3E,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBA6BrB"}
1
+ {"version":3,"file":"localCreateDocument.d.ts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAS3E,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBAiCrB"}
@@ -7,7 +7,11 @@ import { defaultHash } from "@fluidframework/server-services-client";
7
7
  export async function createDocument(localDeltaConnectionServer, resolvedUrl, summary) {
8
8
  const pathName = new URL(resolvedUrl.url).pathname;
9
9
  const pathArr = pathName.split("/");
10
+ // TODO Why are we non null asserting here
11
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
10
12
  const tenantId = pathArr[pathArr.length - 2];
13
+ // TODO Why are we non null asserting here
14
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
11
15
  const id = pathArr[pathArr.length - 1];
12
16
  const documentStorage = localDeltaConnectionServer
13
17
  .documentStorage;
@@ -1 +1 @@
1
- {"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,0BAA0B,EAC1B,WAAyB,EACzB,OAAqB;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7C,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvC,MAAM,eAAe,GAAI,0BAAyD;SAChF,eAAe,CAAC;IAClB,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,eAAe,CAAC,cAAc,CACnC,QAAQ,EACR,EAAE,EACF,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,EAC3C,YAAY,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,0BAA0B,CAChC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\tconst tenantId = pathArr[pathArr.length - 2];\n\tconst id = pathArr[pathArr.length - 1];\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
1
+ {"version":3,"file":"localCreateDocument.js","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,cAAc,CACnC,0BAA0B,EAC1B,WAAyB,EACzB,OAAqB;IAErB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;IACnD,MAAM,OAAO,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IAC9C,0CAA0C;IAC1C,oEAAoE;IACpE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IACxC,MAAM,eAAe,GAAI,0BAAyD;SAChF,eAAe,CAAC;IAClB,IAAI,CAAC,+BAA+B,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;IAC1E,CAAC;IACD,MAAM,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,MAAM,kBAAkB,GAAG,mCAAmC,CAAC,eAAe,CAAC,CAAC;IAChF,MAAM,YAAY,GAAG,kCAAkC,CAAC,eAAe,CAAC,CAAC;IACzE,MAAM,cAAc,GAAG,kBAAkB,CAAC,cAAc,CAAC;IACzD,MAAM,eAAe,CAAC,cAAc,CACnC,QAAQ,EACR,EAAE,EACF,UAAU,EACV,cAAc,EACd,WAAW,EACX,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,UAAU,IAAI,EAAE,EACtC,WAAW,CAAC,SAAS,CAAC,eAAe,IAAI,EAAE,EAC3C,YAAY,EACZ,KAAK,CAAC,qBAAqB,EAC3B,KAAK,CAAC,0BAA0B,CAChC,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport { defaultHash } from \"@fluidframework/server-services-client\";\n\nexport async function createDocument(\n\tlocalDeltaConnectionServer,\n\tresolvedUrl: IResolvedUrl,\n\tsummary: ISummaryTree,\n) {\n\tconst pathName = new URL(resolvedUrl.url).pathname;\n\tconst pathArr = pathName.split(\"/\");\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst tenantId = pathArr[pathArr.length - 2]!;\n\t// TODO Why are we non null asserting here\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\tconst id = pathArr[pathArr.length - 1]!;\n\tconst documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)\n\t\t.documentStorage;\n\tif (!isCombinedAppAndProtocolSummary(summary)) {\n\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t}\n\tconst protocolSummary = summary.tree[\".protocol\"];\n\tconst appSummary = summary.tree[\".app\"];\n\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\tconst sequenceNumber = documentAttributes.sequenceNumber;\n\tawait documentStorage.createDocument(\n\t\ttenantId,\n\t\tid,\n\t\tappSummary,\n\t\tsequenceNumber,\n\t\tdefaultHash,\n\t\tresolvedUrl.endpoints.ordererUrl ?? \"\",\n\t\tresolvedUrl.endpoints.storageUrl ?? \"\",\n\t\tresolvedUrl.endpoints.deltaStorageUrl ?? \"\",\n\t\tquorumValues,\n\t\tfalse /* enableDiscovery */,\n\t\tfalse /* isEphemeralContainer */,\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentStorageService.d.ts","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AASH,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EACN,uBAAuB,EACvB,+BAA+B,EAC/B,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,eAAe,EACf,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C;IAmBpE,WAAW,CAAC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,SAAS,CAAC;IAiD1F;;;;;;OAMG;YACW,uCAAuC;IAsBrD;;;;;;;;;;;;OAYG;YACW,2BAA2B;YA2D3B,oBAAoB;YAoBpB,eAAe;IAS7B,OAAO,CAAC,SAAS;YAMH,WAAW;IAaZ,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;IAoBL,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"}
@@ -39,6 +39,8 @@ export class LocalDocumentStorageService {
39
39
  if (versions.length === 0) {
40
40
  return null;
41
41
  }
42
+ // Non null asserting here because of the length check above
43
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
42
44
  requestVersion = versions[0];
43
45
  }
44
46
  const rawTree = await this.manager.getTree(requestVersion.treeId);
@@ -53,11 +55,15 @@ export class LocalDocumentStorageService {
53
55
  if (versions.length === 0) {
54
56
  throw new Error("No versions for the document!");
55
57
  }
58
+ // Non null asserting here because of the length check above
59
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
56
60
  versionId = versions[0].treeId;
57
61
  }
58
62
  const rawTree = await this.manager.getTree(versionId);
59
63
  const snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);
60
64
  const groupIds = new Set(snapshotFetchOptions?.loadingGroupIds ?? []);
65
+ // TODO Why are we non null asserting here
66
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
67
  const attributesBlobId = snapshotTree.trees[".protocol"].blobs.attributes;
62
68
  // Only populate contents for the blobs which are supposed to be returned.
63
69
  const blobContents = new Map();
@@ -198,6 +204,8 @@ export class LocalDocumentStorageService {
198
204
  }
199
205
  await createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);
200
206
  const version = await this.getVersions(this.id, 1);
207
+ // TODO Why are we non null asserting here
208
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
201
209
  return version[0].id;
202
210
  }
203
211
  return this.summaryTreeUploadManager.writeSummaryTree(summary, context.ackHandle ?? "", "channel");
@@ -1 +1 @@
1
- {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAa7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAGN,wBAAwB,GACxB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QACxC,+BAA0B,GAA1B,0BAA0B,CAA8B;QACxD,gBAAW,GAAX,WAAW,CAAe;QAV5C,uFAAuF;QACvF,2BAA2B;QACR,kBAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;QAU5D,IAAI,CAAC,wBAAwB,GAAG,IAAI,wBAAwB,CAC3D,OAAO,EACP,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC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AAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\trequestVersion = versions[0];\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\tversionId = versions[0].treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"].blobs.attributes;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\treturn version[0].id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localDocumentStorageService.js","sourceRoot":"","sources":["../src/localDocumentStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,SAAS,EACT,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAa7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAGN,wBAAwB,GACxB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,mBAAmB;AACzD;;GAEG;AACH,MAAM,OAAO,2BAA2B;IAMvC,YACkB,EAAU,EACV,OAAmB,EACpB,QAAyC,EACxC,0BAAwD,EACxD,WAA0B;QAJ1B,OAAE,GAAF,EAAE,CAAQ;QACV,YAAO,GAAP,OAAO,CAAY;QACpB,aAAQ,GAAR,QAAQ,CAAiC;QACxC,+BAA0B,GAA1B,0BAA0B,CAA8B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AAC,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,eAAe,CAAC,MAAsB;QAClD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACrC,CAAC;IAEO,KAAK,CAAC,uBAAuB,CACpC,YAAoB;QAEpB,OAAO,YAAY;YAClB,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;gBAC1D,mEAAmE;gBACnE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;gBAC3B,OAAO,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;YAC1C,CAAC,CAAC;YACH,CAAC,CAAC,SAAS,CAAC;IACd,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tIsoBuffer,\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryHandle, ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentStorageService,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\ttype ISnapshot,\n\ttype ISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tISnapshotTreeEx,\n\tIVersion,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { buildGitTreeHierarchy } from \"@fluidframework/protocol-base\";\nimport { ILocalDeltaConnectionServer } from \"@fluidframework/server-local-server\";\nimport {\n\tGitManager,\n\tISummaryUploadManager,\n\tSummaryTreeUploadManager,\n} from \"@fluidframework/server-services-client\";\n\nimport { createDocument } from \"./localCreateDocument.js\";\n\nconst minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP\n/**\n * @internal\n */\nexport class LocalDocumentStorageService implements IDocumentStorageService {\n\t// The values of this cache is useless. We only need the keys. So we are always putting\n\t// empty strings as values.\n\tprotected readonly blobsShaCache = new Map<string, string>();\n\tprivate readonly summaryTreeUploadManager: ISummaryUploadManager;\n\n\tconstructor(\n\t\tprivate readonly id: string,\n\t\tprivate readonly manager: GitManager,\n\t\tpublic readonly policies: IDocumentStorageServicePolicies,\n\t\tprivate readonly localDeltaConnectionServer?: ILocalDeltaConnectionServer,\n\t\tprivate readonly resolvedUrl?: IResolvedUrl,\n\t) {\n\t\tthis.summaryTreeUploadManager = new SummaryTreeUploadManager(\n\t\t\tmanager,\n\t\t\tthis.blobsShaCache,\n\t\t\tthis.getPreviousFullSnapshot.bind(this),\n\t\t);\n\t}\n\n\tpublic async getVersions(versionId: string | null, count: number): Promise<IVersion[]> {\n\t\tconst id = versionId ? versionId : this.id;\n\t\tconst commits = await this.manager.getCommits(id, count);\n\t\treturn commits.map((commit) => ({\n\t\t\tdate: commit.commit.author.date,\n\t\t\tid: commit.sha,\n\t\t\ttreeId: commit.commit.tree.sha,\n\t\t}));\n\t}\n\n\tpublic async getSnapshotTree(version?: IVersion): Promise<ISnapshotTreeEx | null> {\n\t\tlet requestVersion = version;\n\t\tif (!requestVersion) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\trequestVersion = versions[0]!;\n\t\t}\n\n\t\tconst rawTree = await this.manager.getTree(requestVersion.treeId);\n\t\tconst tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tawait this.populateGroupId(tree);\n\t\treturn tree;\n\t}\n\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\tlet versionId = snapshotFetchOptions?.versionId;\n\t\tif (!versionId) {\n\t\t\tconst versions = await this.getVersions(this.id, 1);\n\t\t\tif (versions.length === 0) {\n\t\t\t\tthrow new Error(\"No versions for the document!\");\n\t\t\t}\n\n\t\t\t// Non null asserting here because of the length check above\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tversionId = versions[0]!.treeId;\n\t\t}\n\t\tconst rawTree = await this.manager.getTree(versionId);\n\t\tconst snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);\n\t\tconst groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);\n\t\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst attributesBlobId = snapshotTree.trees[\".protocol\"]!.blobs.attributes!;\n\t\t// Only populate contents for the blobs which are supposed to be returned.\n\t\tconst blobContents = new Map<string, ArrayBuffer>();\n\t\tconst attributesBlobData = await this.readBlob(attributesBlobId);\n\t\tif (groupIds.has(\"\") || groupIds.size === 0) {\n\t\t\t// If the root is in the groupIds, we don't need to filter the tree.\n\t\t\t// We can just strip the of all groupIds as in collect the blobIds so that we can\n\t\t\t// return blob contents only for those ids.\n\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(snapshotTree, groupIds, blobContents);\n\t\t} else {\n\t\t\tconst hasFoundTree = await this.filterTreeByLoadingGroupIds(\n\t\t\t\tsnapshotTree,\n\t\t\t\tgroupIds,\n\t\t\t\tfalse,\n\t\t\t\tblobContents,\n\t\t\t);\n\t\t\tassert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);\n\t\t}\n\n\t\tconst attributesString = IsoBuffer.from(attributesBlobData).toString(\"utf-8\");\n\t\tconst attributes = JSON.parse(attributesString);\n\t\tconst sequenceNumber: number = attributes.sequenceNumber ?? 0;\n\t\treturn {\n\t\t\tsnapshotTree,\n\t\t\tblobContents,\n\t\t\tops: [],\n\t\t\tsnapshotFormatV: 1,\n\t\t\tsequenceNumber,\n\t\t\tlatestSequenceNumber: undefined,\n\t\t};\n\t}\n\n\t/**\n\t * Collect the blobIds to keep in the snapshot for ungrouped snapshot plus\n\t * any other loading groupId along with it.\n\t *\n\t * @param tree - The tree to evaluate for loading groupIds\n\t * @returns a tree that has trees with groupIds that are empty\n\t */\n\tprivate async collectBlobContentsForUngroupedSnapshot(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t) {\n\t\tconst groupId = await this.readGroupId(tree);\n\t\tif (groupId === undefined || loadingGroupIds.has(groupId)) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t\tawait Promise.all(\n\t\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\t\tawait this.collectBlobContentsForUngroupedSnapshot(\n\t\t\t\t\t\tchildTree,\n\t\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\t\tblobContents,\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Named differently as the algorithm is a little more involved.\n\t *\n\t * We want to strip the tree if it has a groupId that is not in the loadingGroupIds or if it doesn't have a descendent or ancestor\n\t * that has a groupId that is in the loadingGroupIds.\n\t *\n\t * We keep the tree in the opposite case.\n\t *\n\t * @param tree - the tree to strip of any data that is not in the loadingGroupIds\n\t * @param loadingGroupIds - the set of groupIds that are being loaded\n\t * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds\n\t * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds\n\t */\n\tprivate async filterTreeByLoadingGroupIds(\n\t\ttree: ISnapshotTreeEx,\n\t\tloadingGroupIds: Set<string>,\n\t\tancestorGroupIdInLoadingGroup: boolean,\n\t\tblobContents: Map<string, ArrayBuffer>,\n\t): Promise<boolean> {\n\t\tassert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);\n\t\tconst groupId = await this.readGroupId(tree);\n\n\t\t// Strip the tree if it has a groupId and it is not in the loadingGroupIds\n\t\t// This is an optimization here as we have other reasons to keep the tree.\n\t\tconst noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);\n\t\tif (noGroupIdInLoadingGroupIds) {\n\t\t\tthis.stripTree(tree, groupId);\n\t\t\treturn false;\n\t\t}\n\n\t\t// Keep tree if it has a groupId and it is in the loadingGroupIds\n\t\tconst groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);\n\n\t\t// Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId\n\t\tconst isChildOfAncestorWithGroupId =\n\t\t\tancestorGroupIdInLoadingGroup && groupId === undefined;\n\n\t\t// Collect blobsIds so that we can return blob contents only for these blobs.\n\t\tif (groupIdInLoadingGroupIds || isChildOfAncestorWithGroupId) {\n\t\t\tfor (const id of Object.values(tree.blobs)) {\n\t\t\t\tblobContents.set(id, await this.readBlob(id));\n\t\t\t}\n\t\t}\n\t\t// Keep tree if it has a child that has a groupId that is in loadingGroupIds\n\t\tconst descendants = await Promise.all<boolean>(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\treturn this.filterTreeByLoadingGroupIds(\n\t\t\t\t\tchildTree,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,\n\t\t\t\t\tblobContents,\n\t\t\t\t);\n\t\t\t}),\n\t\t);\n\t\tconst isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);\n\n\t\t// We don't want to return prematurely as we still may have children that we want to keep.\n\t\tif (\n\t\t\tgroupIdInLoadingGroupIds ||\n\t\t\tisChildOfAncestorWithGroupId ||\n\t\t\tisAncestorOfDescendantsWithGroupId\n\t\t) {\n\t\t\t// Keep this tree node\n\t\t\treturn true;\n\t\t}\n\n\t\t// This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds\n\t\tthis.stripTree(tree, groupId);\n\t\treturn false;\n\t}\n\n\t// Takes all the blobs of a tree and puts it into the blobContents\n\tprivate async populateBlobContents(\n\t\ttree: ISnapshotTreeEx,\n\t\tblobContents: Map<string, ArrayBufferLike>,\n\t\tblobIdsToKeep: Set<string>,\n\t): Promise<void> {\n\t\tawait Promise.all(\n\t\t\tObject.entries(tree.blobs).map(async ([path, blobId]) => {\n\t\t\t\tif (blobIdsToKeep.has(blobId)) {\n\t\t\t\t\tconst content = await this.readBlob(blobId);\n\t\t\t\t\tblobContents.set(blobId, content);\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateBlobContents(childTree, blobContents, blobIdsToKeep);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {\n\t\tawait this.readGroupId(tree);\n\t\tawait Promise.all(\n\t\t\tObject.values(tree.trees).map(async (childTree) => {\n\t\t\t\tawait this.populateGroupId(childTree);\n\t\t\t}),\n\t\t);\n\t}\n\n\tprivate stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {\n\t\ttree.blobs = {};\n\t\ttree.groupId = groupId;\n\t\ttree.trees = {};\n\t}\n\n\tprivate async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {\n\t\tconst groupIdBlobId = tree.blobs[\".groupId\"];\n\t\tif (groupIdBlobId !== undefined) {\n\t\t\tconst groupIdBuffer = await this.readBlob(groupIdBlobId);\n\t\t\tconst groupId = bufferToString(groupIdBuffer, \"utf8\");\n\t\t\ttree.groupId = groupId;\n\t\t\tdelete tree.blobs[\".groupId\"];\n\t\t\treturn groupId;\n\t\t}\n\n\t\treturn tree.groupId;\n\t}\n\n\tpublic async readBlob(blobId: string): Promise<ArrayBufferLike> {\n\t\tconst blob = await this.manager.getBlob(blobId);\n\t\tthis.blobsShaCache.set(blob.sha, \"\");\n\t\tconst bufferContent = stringToBuffer(blob.content, blob.encoding);\n\t\treturn bufferContent;\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tif (context.referenceSequenceNumber === 0) {\n\t\t\tif (this.localDeltaConnectionServer === undefined || this.resolvedUrl === undefined) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Insufficient constructor parameters. An ILocalDeltaConnectionServer and IResolvedUrl required\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tawait createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);\n\t\t\tconst version = await this.getVersions(this.id, 1);\n\t\t\t// TODO Why are we non null asserting here\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\treturn version[0]!.id;\n\t\t}\n\t\treturn this.summaryTreeUploadManager.writeSummaryTree(\n\t\t\tsummary,\n\t\t\tcontext.ackHandle ?? \"\",\n\t\t\t\"channel\",\n\t\t);\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tconst uint8ArrayFile = new Uint8Array(file);\n\t\treturn this.manager\n\t\t\t.createBlob(Uint8ArrayToString(uint8ArrayFile, \"base64\"), \"base64\")\n\t\t\t.then((r) => ({ id: r.sha, url: r.url, minTTLInSeconds }));\n\t}\n\n\tpublic async downloadSummary(handle: ISummaryHandle): Promise<ISummaryTree> {\n\t\tthrow new Error(\"NOT IMPLEMENTED!\");\n\t}\n\n\tprivate async getPreviousFullSnapshot(\n\t\tparentHandle: string,\n\t): Promise<ISnapshotTreeEx | null | undefined> {\n\t\treturn parentHandle\n\t\t\t? this.getVersions(parentHandle, 1).then(async (versions) => {\n\t\t\t\t\t// Clear the cache as the getSnapshotTree call will fill the cache.\n\t\t\t\t\tthis.blobsShaCache.clear();\n\t\t\t\t\treturn this.getSnapshotTree(versions[0]);\n\t\t\t\t})\n\t\t\t: undefined;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"localResolver.d.ts","sourceRoot":"","sources":["../src/localResol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AAU,EAAE,MAAM,GAAG,QAAQ;CAG3D"}
@@ -38,6 +38,8 @@ export class LocalResolver {
38
38
  async resolve(request) {
39
39
  const parsedUrl = new URL(request.url);
40
40
  const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
41
+ // TODO Why are we non null asserting here
42
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
41
43
  const documentId = fullPath.split("/")[0];
42
44
  const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];
43
45
  const resolved = {
@@ -1 +1 @@
1
- {"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,YAAY,EAGZ,SAAS,GACT,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,UAAkB;IACrE,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,yBAAyB,UAAU,EAAE;QAC1C,OAAO,EAAE;YACR,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;SAC9B;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,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,K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E,CAAC;QAEF,OAAO,yBAAyB,UAAU,IAAI,GAAG,EAAE,CAAC;IACrD,CAAC;IAEM,sBAAsB,CAAC,UAAkB;QAC/C,OAAO,mCAAmC,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tScopeType,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { generateToken } from \"./auth.js\";\n\n/**\n * @legacy\n * @alpha\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 * @legacy\n * @alpha\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: IResolvedUrl = {\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: `https://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): 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 parsedUrl = new URL(resolvedUrl.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(\n\t\t\t!!documentId,\n\t\t\t0x09a /* \"'documentId' must be a defined, non-zero length string.\" */,\n\t\t);\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
+ {"version":3,"file":"localResolver.js","sourceRoot":"","sources":["../src/localResolver.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EACN,YAAY,EAGZ,SAAS,GACT,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,mCAAmC,CAAC,UAAkB;IACrE,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,yBAAyB,UAAU,EAAE;QAC1C,OAAO,EAAE;YACR,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,IAAI;SAC9B;KACD,CAAC;IACF,OAAO,gBAAgB,CAA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AAE,CAAC;YACzB,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QACrB,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,SAAS,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;YACjC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,CAAC,EAAE,AAAD,EAAG,UAAU,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACvD,MAAM,CACL,CAAC,CAAC,UAAU,EACZ,KAAK,CAAC,+DAA+D,CACrE,CAAC;QAEF,OAAO,yBAAyB,UAAU,IAAI,GAAG,EAAE,CAAC;IACrD,CAAC;IAEM,sBAAsB,CAAC,UAAkB;QAC/C,OAAO,mCAAmC,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tDriverHeader,\n\tIResolvedUrl,\n\tIUrlResolver,\n\tScopeType,\n} from \"@fluidframework/driver-definitions/internal\";\n\nimport { generateToken } from \"./auth.js\";\n\n/**\n * @legacy\n * @alpha\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 * @legacy\n * @alpha\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\t// TODO Why are we non null asserting here\n\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\tconst documentId = fullPath.split(\"/\")[0]!;\n\t\tconst scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];\n\t\tconst resolved: IResolvedUrl = {\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: `https://localhost:3000/${this.tenantId}/${fullPath}`,\n\t\t};\n\n\t\treturn resolved;\n\t}\n\n\tpublic async getAbsoluteUrl(\n\t\tresolvedUrl: IResolvedUrl,\n\t\trelativeUrl: string,\n\t): 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 parsedUrl = new URL(resolvedUrl.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(\n\t\t\t!!documentId,\n\t\t\t0x09a /* \"'documentId' must be a defined, non-zero length string.\" */,\n\t\t);\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":"AAAA;;;GAGG;AAGH,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAgTnE;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAClE,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGpC"}
1
+ {"version":3,"file":"localSessionStorageDb.d.ts","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAe,GAAG,EAAE,MAAM,sCAAsC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAkTnE;;;GAGG;AACH,qBAAa,4BAA6B,YAAW,cAAc;IAClE,SAAgB,YAAY,EAAE,GAAG,CAA+B;IACnD,OAAO,IAAI,OAAO,CAAC,GAAG,CAAC;CAGpC"}
@@ -67,6 +67,8 @@ class LocalSessionStorageCollection {
67
67
  if (sort && Object.keys(sort).length === 1) {
68
68
  // eslint-disable-next-line no-inner-declarations
69
69
  function compare(a, b) {
70
+ // Non null asserting here because of the length check above
71
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
70
72
  const sortKey = Object.keys(sort)[0];
71
73
  return sort[sortKey] === 1
72
74
  ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)
@@ -1 +1 @@
1
- {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC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8C,CAAC;IAgBtF,CAAC;IAfO,KAAK,CAAC,KAAK,KAAmB,CAAC;IAC/B,UAAU,CAAI,IAAY;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\tconst sortKey = Object.keys(sort)[0];\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
1
+ {"version":3,"file":"localSessionStorageDb.js","sourceRoot":"","sources":["../src/localSessionStorageDb.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAG5D,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,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IAAhD;;QACkB,gBAAW,GAAG,IAAI,GAAG,EAA8C,CAAC;IAgBtF,CAAC;IAfO,KAAK,CAAC,KAAK,KAAmB,CAAC;IAC/B,UAAU,CAAI,IAAY;QAChC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,6BAA6B,CAAI,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAqC,CAAC;IACvE,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,IAAY;QACvC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACjC,OAAO,IAAI,CAAC;QACb,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACb,CAAC;CACD;AAED;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAAzC;QACiB,iBAAY,GAAQ,IAAI,qBAAqB,EAAE,CAAC;IAIjE,CAAC;IAHO,KAAK,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"@fluid-internal/client-utils\";\nimport { ICollection, IDb } from \"@fluidframework/server-services-core\";\nimport { ITestDbFactory } from \"@fluidframework/server-test-utils\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * A collection for local session storage, where data is stored in the browser\n * Functions include database operations such as queries, insertion and update.\n */\nclass LocalSessionStorageCollection<T> implements ICollection<T> {\n\t/**\n\t * @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.\n\t */\n\tconstructor(private readonly collectionName: string) {}\n\n\tpublic aggregate(pipeline: any, options?: any): any {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\n\tpublic async updateMany(filter: any, set: any, addToSet: any): Promise<void> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async distinct(key: any, query: any): Promise<any> {\n\t\tthrow new Error(\"Method Not Implemented\");\n\t}\n\tpublic async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.find}\n\t */\n\t/*\n\t * Each query key consists of several keys separated by '.' e.g: \"operation.sequenceNumber\".\n\t * The hierarchical syntax allows finding nested key patterns.\n\t */\n\tpublic async find(query: any, sort: any): Promise<any[]> {\n\t\t// split the keys and get the corresponding value\n\t\tfunction getValueByKey(propertyBag, key: string) {\n\t\t\tconst keys = key.split(\".\");\n\t\t\tlet value = propertyBag;\n\t\t\tkeys.forEach((splitKey) => {\n\t\t\t\tvalue = value[splitKey];\n\t\t\t});\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\t\treturn value;\n\t\t}\n\n\t\t// getting keys of the query we are trying to find\n\t\tconst queryKeys = Object.keys(query);\n\t\tlet filteredCollection = this.getAllInternal();\n\t\tqueryKeys.forEach((key) => {\n\t\t\tif (!query[key]) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (query[key].$gt > 0 || query[key].$lt > 0) {\n\t\t\t\tif (query[key].$gt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) > query[key].$gt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (query[key].$lt > 0) {\n\t\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t\t(value) => getValueByKey(value, key) < query[key].$lt,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfilteredCollection = filteredCollection.filter(\n\t\t\t\t\t(value) => getValueByKey(value, key) === query[key],\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (sort && Object.keys(sort).length === 1) {\n\t\t\t// eslint-disable-next-line no-inner-declarations\n\t\t\tfunction compare(a, b) {\n\t\t\t\t// Non null asserting here because of the length check above\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst sortKey = Object.keys(sort)[0]!;\n\t\t\t\treturn sort[sortKey] === 1\n\t\t\t\t\t? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)\n\t\t\t\t\t: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);\n\t\t\t}\n\n\t\t\tfilteredCollection = filteredCollection.sort(compare);\n\t\t}\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn filteredCollection;\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}\n\t */\n\tpublic async findAll(): Promise<any[]> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.getAllInternal();\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async findOne(query: any): Promise<any> {\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.findOneInternal(query);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.update}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async update(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthrow new Error(\"Not found\");\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}\n\t */\n\t/*\n\t * Query is expected to have a member \"_id\" which is a string used to find value in the database.\n\t */\n\tpublic async upsert(query: any, set: any, addToSet: any): Promise<void> {\n\t\tconst value = this.findOneInternal(query);\n\t\tif (!value) {\n\t\t\tthis.insertInternal(set);\n\t\t} else {\n\t\t\tfor (const key of Object.keys(set)) {\n\t\t\t\tvalue[key] = set[key];\n\t\t\t}\n\t\t\tthis.insertInternal(value);\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}\n\t */\n\t/*\n\t * Value is expected to have a member \"_id\" which is a string used to search in the database.\n\t */\n\tpublic async insertOne(value: any): Promise<any> {\n\t\tconst presentVal = this.findOneInternal(value);\n\t\t// Only raise error when the object is present and the value is not equal.\n\t\tif (presentVal) {\n\t\t\tif (JSON.stringify(presentVal) === JSON.stringify(value)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new Error(\"Existing Object!!\");\n\t\t}\n\n\t\treturn this.insertInternal(value);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}\n\t */\n\t/*\n\t * Value and query are expected to have a member \"_id\" which is a string used to search or insert in the database.\n\t */\n\tpublic async findOrCreate(\n\t\tquery: any,\n\t\tvalue: any,\n\t): Promise<{ value: any; existing: boolean }> {\n\t\tconst existing = this.findOneInternal(query);\n\t\tif (existing) {\n\t\t\treturn { value: existing, existing: true };\n\t\t}\n\t\tthis.insertInternal(value);\n\t\treturn { value, existing: false };\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}\n\t */\n\t/*\n\t * Each element in values is expected to have a member \"_id\" which is a string used to insert in the database.\n\t */\n\tpublic async insertMany(values: any[], ordered: boolean): Promise<void> {\n\t\tthis.insertInternal(...values);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}\n\t */\n\tpublic async deleteOne(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}\n\t */\n\tpublic async deleteMany(query: any): Promise<any> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}\n\t */\n\tpublic async createIndex(index: any, unique: boolean): Promise<void> {\n\t\tthrow new Error(\"Method not implemented.\");\n\t}\n\n\t/**\n\t * Return all values in the database\n\t */\n\tprivate getAllInternal(): any[] {\n\t\tconst values: string[] = [];\n\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\tconst key = sessionStorage.key(i);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\tif (key!.startsWith(this.collectionName)) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tvalues.push(JSON.parse(sessionStorage.getItem(key!)!));\n\t\t\t}\n\t\t}\n\t\treturn values;\n\t}\n\n\t/**\n\t * Inserts values into the session storge.\n\t * Values are expected to have a member \"_id\" which is a unique id, otherwise will be assigned one\n\t *\n\t * @param values - data to insert to the database\n\t */\n\tprivate insertInternal(...values: any[]) {\n\t\tfor (const value of values) {\n\t\t\tif (value) {\n\t\t\t\tif (!value._id) {\n\t\t\t\t\tvalue._id = uuid();\n\t\t\t\t}\n\t\t\t\tsessionStorage.setItem(`${this.collectionName}-${value._id}`, JSON.stringify(value));\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Finds the query in session storage and returns its value.\n\t * Returns null if query is not found.\n\t * Query is expected to have a member \"_id\" which is a unique id.\n\t *\n\t * @param query - what to find in the database\n\t */\n\tprivate findOneInternal(query: any): any {\n\t\tif (query._id) {\n\t\t\tconst json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);\n\t\t\tif (json) {\n\t\t\t\treturn JSON.parse(json);\n\t\t\t}\n\t\t} else {\n\t\t\tconst queryKeys = Object.keys(query);\n\t\t\tfor (let i = 0; i < sessionStorage.length; i++) {\n\t\t\t\tconst ssKey = sessionStorage.key(i);\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tif (!ssKey!.startsWith(this.collectionName)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst value = JSON.parse(sessionStorage.getItem(ssKey!)!);\n\t\t\t\tlet foundMismatch = false;\n\t\t\t\tfor (const qk of queryKeys) {\n\t\t\t\t\tif (value[qk] !== query[qk]) {\n\t\t\t\t\t\tfoundMismatch = true;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (!foundMismatch) {\n\t\t\t\t\treturn value;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}\n}\n\n/**\n * A database for testing that stores data in the browsers session storage\n */\nclass LocalSessionStorageDb extends EventEmitter implements IDb {\n\tprivate readonly collections = new Map<string, LocalSessionStorageCollection<any>>();\n\tpublic async close(): Promise<void> {}\n\tpublic collection<T>(name: string): ICollection<T> {\n\t\tif (!this.collections.has(name)) {\n\t\t\tthis.collections.set(name, new LocalSessionStorageCollection<T>(name));\n\t\t}\n\t\treturn this.collections.get(name) as LocalSessionStorageCollection<T>;\n\t}\n\n\tpublic async dropCollection(name: string): Promise<boolean> {\n\t\tif (!this.collections.has(name)) {\n\t\t\treturn true;\n\t\t}\n\t\tthis.collections.delete(name);\n\t\treturn true;\n\t}\n}\n\n/**\n * A database factory for testing that stores data in the browsers session storage\n * @internal\n */\nexport class LocalSessionStorageDbFactory implements ITestDbFactory {\n\tpublic readonly testDatabase: IDb = new LocalSessionStorageDb();\n\tpublic async connect(): Promise<IDb> {\n\t\treturn this.testDatabase;\n\t}\n}\n"]}
package/lib/public.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  /*
7
7
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
8
+ * Generated by "flub generate entrypoints" in @fluid-tools/build-cli.
9
9
  */
10
10
 
11
11
  export {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/local-driver",
3
- "version": "2.1.0-276985",
3
+ "version": "2.1.0",
4
4
  "description": "Fluid local driver",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -69,31 +69,31 @@
69
69
  "temp-directory": "nyc/.nyc_output"
70
70
  },
71
71
  "dependencies": {
72
- "@fluid-internal/client-utils": "2.1.0-276985",
73
- "@fluidframework/core-interfaces": "2.1.0-276985",
74
- "@fluidframework/core-utils": "2.1.0-276985",
75
- "@fluidframework/driver-base": "2.1.0-276985",
76
- "@fluidframework/driver-definitions": "2.1.0-276985",
77
- "@fluidframework/driver-utils": "2.1.0-276985",
72
+ "@fluid-internal/client-utils": "~2.1.0",
73
+ "@fluidframework/core-interfaces": "~2.1.0",
74
+ "@fluidframework/core-utils": "~2.1.0",
75
+ "@fluidframework/driver-base": "~2.1.0",
76
+ "@fluidframework/driver-definitions": "~2.1.0",
77
+ "@fluidframework/driver-utils": "~2.1.0",
78
78
  "@fluidframework/protocol-base": "^5.0.0",
79
- "@fluidframework/routerlicious-driver": "2.1.0-276985",
79
+ "@fluidframework/routerlicious-driver": "~2.1.0",
80
80
  "@fluidframework/server-local-server": "^5.0.0",
81
81
  "@fluidframework/server-services-client": "^5.0.0",
82
82
  "@fluidframework/server-services-core": "^5.0.0",
83
83
  "@fluidframework/server-test-utils": "^5.0.0",
84
- "@fluidframework/telemetry-utils": "2.1.0-276985",
84
+ "@fluidframework/telemetry-utils": "~2.1.0",
85
85
  "jsrsasign": "^11.0.0",
86
86
  "uuid": "^9.0.0"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@arethetypeswrong/cli": "^0.15.2",
90
- "@biomejs/biome": "^1.7.3",
91
- "@fluid-internal/mocha-test-setup": "2.1.0-276985",
92
- "@fluid-tools/build-cli": "^0.39.0",
90
+ "@biomejs/biome": "~1.8.3",
91
+ "@fluid-internal/mocha-test-setup": "~2.1.0",
92
+ "@fluid-tools/build-cli": "^0.41.0",
93
93
  "@fluidframework/build-common": "^2.0.3",
94
- "@fluidframework/build-tools": "^0.39.0",
94
+ "@fluidframework/build-tools": "^0.41.0",
95
95
  "@fluidframework/eslint-config-fluid": "^5.3.0",
96
- "@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.0.0-rc.5.0.0",
96
+ "@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.0.0",
97
97
  "@microsoft/api-extractor": "^7.45.1",
98
98
  "@types/jsrsasign": "^10.5.12",
99
99
  "@types/mocha": "^9.1.1",
@@ -121,17 +121,18 @@
121
121
  "api-extractor:commonjs": "flub generate entrypoints --outDir ./dist",
122
122
  "api-extractor:esnext": "flub generate entrypoints --outDir ./lib --node10TypeCompat",
123
123
  "build": "fluid-build . --task build",
124
+ "build:api-reports": "concurrently \"npm:build:api-reports:*\"",
125
+ "build:api-reports:current": "api-extractor run --local --config api-extractor/api-extractor.current.json",
126
+ "build:api-reports:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
124
127
  "build:commonjs": "fluid-build . --task commonjs",
125
128
  "build:compile": "fluid-build . --task compile",
126
- "build:docs": "concurrently \"npm:build:docs:*\"",
127
- "build:docs:current": "api-extractor run --local",
128
- "build:docs:legacy": "api-extractor run --local --config api-extractor/api-extractor.legacy.json",
129
+ "build:docs": "api-extractor run --local",
129
130
  "build:esnext": "tsc --project ./tsconfig.json",
130
131
  "build:test": "npm run build:test:esm && npm run build:test:cjs",
131
132
  "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
132
133
  "build:test:esm": "tsc --project ./src/test/tsconfig.json",
133
134
  "check:are-the-types-wrong": "attw --pack .",
134
- "check:biome": "biome check . --formatter-enabled=true",
135
+ "check:biome": "biome check .",
135
136
  "check:exports": "concurrently \"npm:check:exports:*\"",
136
137
  "check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
137
138
  "check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
@@ -140,14 +141,15 @@
140
141
  "check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
141
142
  "check:format": "npm run check:biome",
142
143
  "check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
143
- "ci:build:docs": "concurrently \"npm:ci:build:docs:*\"",
144
- "ci:build:docs:current": "api-extractor run",
145
- "ci:build:docs:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
144
+ "ci:build:api-reports": "concurrently \"npm:ci:build:api-reports:*\"",
145
+ "ci:build:api-reports:current": "api-extractor run --config api-extractor/api-extractor.current.json",
146
+ "ci:build:api-reports:legacy": "api-extractor run --config api-extractor/api-extractor.legacy.json",
147
+ "ci:build:docs": "api-extractor run",
146
148
  "clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
147
149
  "eslint": "eslint --format stylish src",
148
150
  "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
149
151
  "format": "npm run format:biome",
150
- "format:biome": "biome check . --formatter-enabled=true --apply",
152
+ "format:biome": "biome check . --write",
151
153
  "format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
152
154
  "lint": "fluid-build . --task lint",
153
155
  "lint:fix": "fluid-build . --task eslint:fix --task format",
@@ -20,8 +20,12 @@ export async function createDocument(
20
20
  ) {
21
21
  const pathName = new URL(resolvedUrl.url).pathname;
22
22
  const pathArr = pathName.split("/");
23
- const tenantId = pathArr[pathArr.length - 2];
24
- const id = pathArr[pathArr.length - 1];
23
+ // TODO Why are we non null asserting here
24
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
25
+ const tenantId = pathArr[pathArr.length - 2]!;
26
+ // TODO Why are we non null asserting here
27
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
28
+ const id = pathArr[pathArr.length - 1]!;
25
29
  const documentStorage = (localDeltaConnectionServer as LocalDeltaConnectionServer)
26
30
  .documentStorage;
27
31
  if (!isCombinedAppAndProtocolSummary(summary)) {
@@ -74,7 +74,9 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
74
74
  return null;
75
75
  }
76
76
 
77
- requestVersion = versions[0];
77
+ // Non null asserting here because of the length check above
78
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
79
+ requestVersion = versions[0]!;
78
80
  }
79
81
 
80
82
  const rawTree = await this.manager.getTree(requestVersion.treeId);
@@ -91,12 +93,16 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
91
93
  throw new Error("No versions for the document!");
92
94
  }
93
95
 
94
- versionId = versions[0].treeId;
96
+ // Non null asserting here because of the length check above
97
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
98
+ versionId = versions[0]!.treeId;
95
99
  }
96
100
  const rawTree = await this.manager.getTree(versionId);
97
101
  const snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);
98
102
  const groupIds = new Set<string>(snapshotFetchOptions?.loadingGroupIds ?? []);
99
- const attributesBlobId = snapshotTree.trees[".protocol"].blobs.attributes;
103
+ // TODO Why are we non null asserting here
104
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
105
+ const attributesBlobId = snapshotTree.trees[".protocol"]!.blobs.attributes!;
100
106
  // Only populate contents for the blobs which are supposed to be returned.
101
107
  const blobContents = new Map<string, ArrayBuffer>();
102
108
  const attributesBlobData = await this.readBlob(attributesBlobId);
@@ -296,7 +302,9 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
296
302
  }
297
303
  await createDocument(this.localDeltaConnectionServer, this.resolvedUrl, summary);
298
304
  const version = await this.getVersions(this.id, 1);
299
- return version[0].id;
305
+ // TODO Why are we non null asserting here
306
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
307
+ return version[0]!.id;
300
308
  }
301
309
  return this.summaryTreeUploadManager.writeSummaryTree(
302
310
  summary,
@@ -49,7 +49,9 @@ export class LocalResolver implements IUrlResolver {
49
49
  public async resolve(request: IRequest): Promise<IResolvedUrl> {
50
50
  const parsedUrl = new URL(request.url);
51
51
  const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
52
- const documentId = fullPath.split("/")[0];
52
+ // TODO Why are we non null asserting here
53
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
54
+ const documentId = fullPath.split("/")[0]!;
53
55
  const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];
54
56
  const resolved: IResolvedUrl = {
55
57
  endpoints: {
@@ -79,7 +79,9 @@ class LocalSessionStorageCollection<T> implements ICollection<T> {
79
79
  if (sort && Object.keys(sort).length === 1) {
80
80
  // eslint-disable-next-line no-inner-declarations
81
81
  function compare(a, b) {
82
- const sortKey = Object.keys(sort)[0];
82
+ // Non null asserting here because of the length check above
83
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
84
+ const sortKey = Object.keys(sort)[0]!;
83
85
  return sort[sortKey] === 1
84
86
  ? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)
85
87
  : getValueByKey(b, sortKey) - getValueByKey(a, sortKey);
package/tsconfig.json CHANGED
@@ -5,7 +5,6 @@
5
5
  "compilerOptions": {
6
6
  "rootDir": "./src",
7
7
  "outDir": "./lib",
8
- "noUncheckedIndexedAccess": false,
9
8
  "exactOptionalPropertyTypes": false,
10
9
  },
11
10
  }