@fluidframework/local-driver 2.0.0-dev-rc.1.0.0.228517 → 2.0.0-dev-rc.2.0.0.245554

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 (113) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +5 -5
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +20 -0
  4. package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
  5. package/api-extractor-lint.json +1 -1
  6. package/api-extractor.json +1 -1
  7. package/api-report/local-driver.api.md +7 -3
  8. package/dist/index.d.ts +7 -7
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +16 -16
  11. package/dist/index.js.map +1 -1
  12. package/dist/local-driver-alpha.d.ts +4 -2
  13. package/dist/local-driver-beta.d.ts +10 -0
  14. package/dist/local-driver-public.d.ts +10 -0
  15. package/dist/local-driver-untrimmed.d.ts +31 -4
  16. package/dist/localDocumentService.d.ts +4 -3
  17. package/dist/localDocumentService.d.ts.map +1 -1
  18. package/dist/localDocumentService.js +10 -8
  19. package/dist/localDocumentService.js.map +1 -1
  20. package/dist/localDocumentServiceFactory.d.ts +0 -1
  21. package/dist/localDocumentServiceFactory.d.ts.map +1 -1
  22. package/dist/localDocumentServiceFactory.js +6 -8
  23. package/dist/localDocumentServiceFactory.js.map +1 -1
  24. package/dist/localDocumentStorageService.d.ts +27 -2
  25. package/dist/localDocumentStorageService.d.ts.map +1 -1
  26. package/dist/localDocumentStorageService.js +130 -3
  27. package/dist/localDocumentStorageService.js.map +1 -1
  28. package/dist/localResolver.d.ts +0 -1
  29. package/dist/localResolver.d.ts.map +1 -1
  30. package/dist/localResolver.js +4 -6
  31. package/dist/localResolver.js.map +1 -1
  32. package/dist/localSessionStorageDb.js +2 -2
  33. package/dist/localSessionStorageDb.js.map +1 -1
  34. package/dist/package.json +3 -0
  35. package/dist/tsdoc-metadata.json +1 -1
  36. package/lib/{auth.d.mts → auth.d.ts} +1 -1
  37. package/lib/auth.d.ts.map +1 -0
  38. package/lib/{auth.mjs → auth.js} +1 -1
  39. package/lib/auth.js.map +1 -0
  40. package/lib/{index.mjs → index.d.ts} +8 -8
  41. package/lib/index.d.ts.map +1 -0
  42. package/lib/{index.d.mts → index.js} +8 -8
  43. package/lib/index.js.map +1 -0
  44. package/lib/{local-driver-alpha.d.mts → local-driver-alpha.d.ts} +4 -2
  45. package/lib/{local-driver-beta.d.mts → local-driver-beta.d.ts} +10 -0
  46. package/lib/{local-driver-public.d.mts → local-driver-public.d.ts} +10 -0
  47. package/lib/{local-driver-untrimmed.d.mts → local-driver-untrimmed.d.ts} +31 -4
  48. package/lib/{localCreateDocument.d.mts → localCreateDocument.d.ts} +1 -1
  49. package/lib/localCreateDocument.d.ts.map +1 -0
  50. package/lib/{localCreateDocument.mjs → localCreateDocument.js} +1 -1
  51. package/lib/localCreateDocument.js.map +1 -0
  52. package/lib/{localDeltaStorageService.d.mts → localDeltaStorageService.d.ts} +1 -1
  53. package/lib/localDeltaStorageService.d.ts.map +1 -0
  54. package/lib/{localDeltaStorageService.mjs → localDeltaStorageService.js} +1 -1
  55. package/lib/localDeltaStorageService.js.map +1 -0
  56. package/lib/{localDocumentDeltaConnection.d.mts → localDocumentDeltaConnection.d.ts} +1 -1
  57. package/lib/localDocumentDeltaConnection.d.ts.map +1 -0
  58. package/lib/{localDocumentDeltaConnection.mjs → localDocumentDeltaConnection.js} +1 -1
  59. package/lib/localDocumentDeltaConnection.js.map +1 -0
  60. package/lib/{localDocumentService.d.mts → localDocumentService.d.ts} +5 -4
  61. package/lib/localDocumentService.d.ts.map +1 -0
  62. package/lib/{localDocumentService.mjs → localDocumentService.js} +8 -6
  63. package/lib/localDocumentService.js.map +1 -0
  64. package/lib/{localDocumentServiceFactory.d.mts → localDocumentServiceFactory.d.ts} +1 -2
  65. package/lib/localDocumentServiceFactory.d.ts.map +1 -0
  66. package/lib/{localDocumentServiceFactory.mjs → localDocumentServiceFactory.js} +5 -7
  67. package/lib/localDocumentServiceFactory.js.map +1 -0
  68. package/lib/{localDocumentStorageService.d.mts → localDocumentStorageService.d.ts} +28 -3
  69. package/lib/localDocumentStorageService.d.ts.map +1 -0
  70. package/lib/localDocumentStorageService.js +211 -0
  71. package/lib/localDocumentStorageService.js.map +1 -0
  72. package/lib/{localResolver.d.mts → localResolver.d.ts} +1 -2
  73. package/lib/localResolver.d.ts.map +1 -0
  74. package/lib/{localResolver.mjs → localResolver.js} +4 -6
  75. package/lib/localResolver.js.map +1 -0
  76. package/lib/{localSessionStorageDb.d.mts → localSessionStorageDb.d.ts} +1 -1
  77. package/lib/localSessionStorageDb.d.ts.map +1 -0
  78. package/lib/{localSessionStorageDb.mjs → localSessionStorageDb.js} +6 -2
  79. package/lib/localSessionStorageDb.js.map +1 -0
  80. package/lib/test/localResolverTest.spec.js +47 -0
  81. package/lib/test/localResolverTest.spec.js.map +1 -0
  82. package/lib/test/types/validateLocalDriverPrevious.generated.js +26 -0
  83. package/lib/test/types/validateLocalDriverPrevious.generated.js.map +1 -0
  84. package/package.json +56 -57
  85. package/src/index.ts +7 -7
  86. package/src/localDocumentService.ts +13 -6
  87. package/src/localDocumentServiceFactory.ts +5 -7
  88. package/src/localDocumentStorageService.ts +180 -4
  89. package/src/localResolver.ts +3 -5
  90. package/src/localSessionStorageDb.ts +1 -1
  91. package/tsconfig.cjs.json +7 -0
  92. package/tsconfig.json +2 -5
  93. package/lib/auth.d.mts.map +0 -1
  94. package/lib/auth.mjs.map +0 -1
  95. package/lib/index.d.mts.map +0 -1
  96. package/lib/index.mjs.map +0 -1
  97. package/lib/localCreateDocument.d.mts.map +0 -1
  98. package/lib/localCreateDocument.mjs.map +0 -1
  99. package/lib/localDeltaStorageService.d.mts.map +0 -1
  100. package/lib/localDeltaStorageService.mjs.map +0 -1
  101. package/lib/localDocumentDeltaConnection.d.mts.map +0 -1
  102. package/lib/localDocumentDeltaConnection.mjs.map +0 -1
  103. package/lib/localDocumentService.d.mts.map +0 -1
  104. package/lib/localDocumentService.mjs.map +0 -1
  105. package/lib/localDocumentServiceFactory.d.mts.map +0 -1
  106. package/lib/localDocumentServiceFactory.mjs.map +0 -1
  107. package/lib/localDocumentStorageService.d.mts.map +0 -1
  108. package/lib/localDocumentStorageService.mjs +0 -84
  109. package/lib/localDocumentStorageService.mjs.map +0 -1
  110. package/lib/localResolver.d.mts.map +0 -1
  111. package/lib/localResolver.mjs.map +0 -1
  112. package/lib/localSessionStorageDb.d.mts.map +0 -1
  113. package/lib/localSessionStorageDb.mjs.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/local-driver",
3
- "version": "2.0.0-dev-rc.1.0.0.228517",
3
+ "version": "2.0.0-dev-rc.2.0.0.245554",
4
4
  "description": "Fluid local driver",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -10,60 +10,50 @@
10
10
  },
11
11
  "license": "MIT",
12
12
  "author": "Microsoft and contributors",
13
+ "type": "module",
13
14
  "exports": {
14
15
  ".": {
15
16
  "import": {
16
- "types": "./lib/index.d.mts",
17
- "default": "./lib/index.mjs"
17
+ "types": "./lib/index.d.ts",
18
+ "default": "./lib/index.js"
18
19
  },
19
20
  "require": {
20
21
  "types": "./dist/index.d.ts",
21
22
  "default": "./dist/index.js"
22
23
  }
23
24
  },
24
- "./alpha": {
25
+ "./public": {
25
26
  "import": {
26
- "types": "./lib/local-driver-alpha.d.mts",
27
- "default": "./lib/index.mjs"
27
+ "types": "./lib/local-driver-public.d.ts",
28
+ "default": "./lib/index.js"
28
29
  },
29
30
  "require": {
30
- "types": "./dist/local-driver-alpha.d.ts",
31
+ "types": "./dist/local-driver-public.d.ts",
31
32
  "default": "./dist/index.js"
32
33
  }
33
34
  },
34
- "./beta": {
35
+ "./alpha": {
35
36
  "import": {
36
- "types": "./lib/local-driver-beta.d.mts",
37
- "default": "./lib/index.mjs"
37
+ "types": "./lib/local-driver-alpha.d.ts",
38
+ "default": "./lib/index.js"
38
39
  },
39
40
  "require": {
40
- "types": "./dist/local-driver-beta.d.ts",
41
+ "types": "./dist/local-driver-alpha.d.ts",
41
42
  "default": "./dist/index.js"
42
43
  }
43
44
  },
44
45
  "./internal": {
45
46
  "import": {
46
- "types": "./lib/index.d.mts",
47
- "default": "./lib/index.mjs"
47
+ "types": "./lib/index.d.ts",
48
+ "default": "./lib/index.js"
48
49
  },
49
50
  "require": {
50
51
  "types": "./dist/index.d.ts",
51
52
  "default": "./dist/index.js"
52
53
  }
53
- },
54
- "./public": {
55
- "import": {
56
- "types": "./lib/local-driver-public.d.mts",
57
- "default": "./lib/index.mjs"
58
- },
59
- "require": {
60
- "types": "./dist/local-driver-public.d.ts",
61
- "default": "./dist/index.js"
62
- }
63
54
  }
64
55
  },
65
56
  "main": "dist/index.js",
66
- "module": "lib/index.mjs",
67
57
  "browser": {
68
58
  "moniker": "@fluidframework/server-services-client/dist/generateNames.js"
69
59
  },
@@ -89,50 +79,47 @@
89
79
  "temp-directory": "nyc/.nyc_output"
90
80
  },
91
81
  "dependencies": {
92
- "@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.228517",
93
- "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.228517",
94
- "@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.228517",
95
- "@fluidframework/driver-base": "2.0.0-dev-rc.1.0.0.228517",
96
- "@fluidframework/driver-definitions": "2.0.0-dev-rc.1.0.0.228517",
97
- "@fluidframework/driver-utils": "2.0.0-dev-rc.1.0.0.228517",
98
- "@fluidframework/protocol-base": "^3.0.0",
99
- "@fluidframework/protocol-definitions": "^3.1.0",
100
- "@fluidframework/routerlicious-driver": "2.0.0-dev-rc.1.0.0.228517",
101
- "@fluidframework/server-local-server": "^3.0.0",
102
- "@fluidframework/server-services-client": "^3.0.0",
103
- "@fluidframework/server-services-core": "^3.0.0",
104
- "@fluidframework/server-test-utils": "^3.0.0",
105
- "@fluidframework/telemetry-utils": "2.0.0-dev-rc.1.0.0.228517",
106
- "events": "^3.1.0",
107
- "jsrsasign": "^10.5.25",
108
- "url": "^0.11.0",
82
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.2.0.0.245554",
83
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.2.0.0.245554",
84
+ "@fluidframework/core-utils": "2.0.0-dev-rc.2.0.0.245554",
85
+ "@fluidframework/driver-base": "2.0.0-dev-rc.2.0.0.245554",
86
+ "@fluidframework/driver-definitions": "2.0.0-dev-rc.2.0.0.245554",
87
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.2.0.0.245554",
88
+ "@fluidframework/protocol-base": "^4.0.0",
89
+ "@fluidframework/protocol-definitions": "^3.2.0",
90
+ "@fluidframework/routerlicious-driver": "2.0.0-dev-rc.2.0.0.245554",
91
+ "@fluidframework/server-local-server": "^4.0.0",
92
+ "@fluidframework/server-services-client": "^4.0.0",
93
+ "@fluidframework/server-services-core": "^4.0.0",
94
+ "@fluidframework/server-test-utils": "^4.0.0",
95
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.2.0.0.245554",
96
+ "jsrsasign": "^11.0.0",
109
97
  "uuid": "^9.0.0"
110
98
  },
111
99
  "devDependencies": {
112
100
  "@arethetypeswrong/cli": "^0.13.3",
113
- "@fluid-tools/build-cli": "^0.29.0",
101
+ "@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.2.0.0.245554",
102
+ "@fluid-tools/build-cli": "^0.34.0",
114
103
  "@fluidframework/build-common": "^2.0.3",
115
- "@fluidframework/build-tools": "^0.29.0",
116
- "@fluidframework/eslint-config-fluid": "^3.2.0",
104
+ "@fluidframework/build-tools": "^0.34.0",
105
+ "@fluidframework/eslint-config-fluid": "^5.1.0",
117
106
  "@fluidframework/local-driver-previous": "npm:@fluidframework/local-driver@2.0.0-internal.8.0.0",
118
- "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.228517",
119
- "@microsoft/api-extractor": "^7.38.3",
120
- "@types/jsrsasign": "^8.0.8",
107
+ "@microsoft/api-extractor": "^7.42.3",
108
+ "@types/jsrsasign": "^10.5.12",
121
109
  "@types/mocha": "^9.1.1",
122
110
  "@types/node": "^18.19.0",
123
111
  "@types/uuid": "^9.0.2",
124
112
  "c8": "^8.0.1",
125
113
  "copyfiles": "^2.4.1",
126
114
  "cross-env": "^7.0.3",
127
- "eslint": "~8.50.0",
115
+ "eslint": "~8.55.0",
128
116
  "mocha": "^10.2.0",
129
117
  "mocha-json-output-reporter": "^2.0.1",
130
118
  "mocha-multi-reporters": "^1.5.1",
131
119
  "moment": "^2.21.0",
132
120
  "prettier": "~3.0.3",
133
121
  "rimraf": "^4.4.0",
134
- "socket.io-client": "^4.6.1",
135
- "tsc-multi": "^1.1.0",
122
+ "socket.io-client": "^4.7.3",
136
123
  "typescript": "~5.1.6"
137
124
  },
138
125
  "fluidBuild": {
@@ -148,18 +135,28 @@
148
135
  }
149
136
  },
150
137
  "typeValidation": {
151
- "broken": {}
138
+ "broken": {
139
+ "ClassDeclaration_LocalDocumentService": {
140
+ "forwardCompat": false
141
+ },
142
+ "ClassDeclaration_LocalDocumentStorageService": {
143
+ "backCompat": false,
144
+ "forwardCompat": false
145
+ }
146
+ }
152
147
  },
153
148
  "scripts": {
154
149
  "api": "fluid-build . --task api",
155
- "api-extractor:commonjs": "api-extractor run --local",
156
- "api-extractor:esnext": "api-extractor run --config ./api-extractor-esm.json",
150
+ "api-extractor:commonjs": "api-extractor run --config ./api-extractor-cjs.json",
151
+ "api-extractor:esnext": "api-extractor run --local",
157
152
  "build": "fluid-build . --task build",
158
153
  "build:commonjs": "fluid-build . --task commonjs",
159
154
  "build:compile": "fluid-build . --task compile",
160
155
  "build:docs": "fluid-build . --task api",
161
- "build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
162
- "build:test": "tsc --project ./src/test/tsconfig.json",
156
+ "build:esnext": "tsc --project ./tsconfig.json",
157
+ "build:test": "npm run build:test:esm && npm run build:test:cjs",
158
+ "build:test:cjs": "fluid-tsc commonjs --project ./src/test/tsconfig.cjs.json",
159
+ "build:test:esm": "tsc --project ./src/test/tsconfig.json",
163
160
  "check:are-the-types-wrong": "attw --pack . --entrypoints .",
164
161
  "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
165
162
  "ci:build:docs": "api-extractor run",
@@ -173,9 +170,11 @@
173
170
  "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
174
171
  "test": "npm run test:mocha",
175
172
  "test:coverage": "c8 npm test",
176
- "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup",
173
+ "test:mocha": "npm run test:mocha:esm && echo skipping cjs to avoid overhead - npm run test:mocha:cjs",
174
+ "test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
175
+ "test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
177
176
  "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
178
- "tsc": "tsc",
177
+ "tsc": "fluid-tsc commonjs --project ./tsconfig.cjs.json && copyfiles -f ../../../common/build/build-common/src/cjs/package.json ./dist",
179
178
  "typetests:gen": "fluid-type-test-generator",
180
179
  "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
181
180
  }
package/src/index.ts CHANGED
@@ -3,10 +3,10 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- export { LocalDeltaStorageService } from "./localDeltaStorageService";
7
- export { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection";
8
- export { createLocalDocumentService, LocalDocumentService } from "./localDocumentService";
9
- export { LocalDocumentServiceFactory } from "./localDocumentServiceFactory";
10
- export { LocalDocumentStorageService } from "./localDocumentStorageService";
11
- export { createLocalResolverCreateNewRequest, LocalResolver } from "./localResolver";
12
- export { LocalSessionStorageDbFactory } from "./localSessionStorageDb";
6
+ export { LocalDeltaStorageService } from "./localDeltaStorageService.js";
7
+ export { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection.js";
8
+ export { createLocalDocumentService, LocalDocumentService } from "./localDocumentService.js";
9
+ export { LocalDocumentServiceFactory } from "./localDocumentServiceFactory.js";
10
+ export { LocalDocumentStorageService } from "./localDocumentStorageService.js";
11
+ export { createLocalResolverCreateNewRequest, LocalResolver } from "./localResolver.js";
12
+ export { LocalSessionStorageDbFactory } from "./localSessionStorageDb.js";
@@ -3,10 +3,12 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
6
7
  import {
7
8
  IDocumentDeltaConnection,
8
9
  IDocumentDeltaStorageService,
9
10
  IDocumentService,
11
+ IDocumentServiceEvents,
10
12
  IDocumentServicePolicies,
11
13
  IDocumentStorageService,
12
14
  IResolvedUrl,
@@ -17,15 +19,18 @@ import { GitManager } from "@fluidframework/server-services-client";
17
19
  import { TestHistorian } from "@fluidframework/server-test-utils";
18
20
  import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
19
21
  import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
20
- import { LocalDocumentStorageService } from "./localDocumentStorageService";
21
- import { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection";
22
- import { LocalDeltaStorageService } from "./localDeltaStorageService";
22
+ import { LocalDocumentStorageService } from "./localDocumentStorageService.js";
23
+ import { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection.js";
24
+ import { LocalDeltaStorageService } from "./localDeltaStorageService.js";
23
25
 
24
26
  /**
25
27
  * Basic implementation of a document service for local use.
26
28
  * @internal
27
29
  */
28
- export class LocalDocumentService implements IDocumentService {
30
+ export class LocalDocumentService
31
+ extends TypedEventEmitter<IDocumentServiceEvents>
32
+ implements IDocumentService
33
+ {
29
34
  /**
30
35
  * @param localDeltaConnectionServer - delta connection server for ops
31
36
  * @param tokenProvider - token provider
@@ -39,10 +44,12 @@ export class LocalDocumentService implements IDocumentService {
39
44
  private readonly tenantId: string,
40
45
  private readonly documentId: string,
41
46
  private readonly documentDeltaConnectionsMap: Map<string, LocalDocumentDeltaConnection>,
42
- public readonly policies: IDocumentServicePolicies = {},
47
+ public readonly policies: IDocumentServicePolicies = { supportGetSnapshotApi: true },
43
48
  private readonly innerDocumentService?: IDocumentService,
44
49
  private readonly logger?: ITelemetryBaseLogger,
45
- ) {}
50
+ ) {
51
+ super();
52
+ }
46
53
 
47
54
  public dispose() {}
48
55
 
@@ -3,7 +3,6 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { parse } from "url";
7
6
  import {
8
7
  IDocumentService,
9
8
  IDocumentServiceFactory,
@@ -14,9 +13,9 @@ import { ITelemetryBaseLogger } from "@fluidframework/core-interfaces";
14
13
  import { DefaultTokenProvider } from "@fluidframework/routerlicious-driver";
15
14
  import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
16
15
  import { ISummaryTree, NackErrorType } from "@fluidframework/protocol-definitions";
17
- import { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection";
18
- import { createLocalDocumentService } from "./localDocumentService";
19
- import { createDocument } from "./localCreateDocument";
16
+ import { LocalDocumentDeltaConnection } from "./localDocumentDeltaConnection.js";
17
+ import { createLocalDocumentService } from "./localDocumentService.js";
18
+ import { createDocument } from "./localCreateDocument.js";
20
19
 
21
20
  /**
22
21
  * Implementation of document service factory for local use.
@@ -29,7 +28,6 @@ export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
29
28
 
30
29
  /**
31
30
  * @param localDeltaConnectionServer - delta connection server for ops
32
- * @alpha
33
31
  */
34
32
  constructor(
35
33
  private readonly localDeltaConnectionServer: ILocalDeltaConnectionServer,
@@ -62,8 +60,8 @@ export class LocalDocumentServiceFactory implements IDocumentServiceFactory {
62
60
  logger?: ITelemetryBaseLogger,
63
61
  clientIsSummarizer?: boolean,
64
62
  ): Promise<IDocumentService> {
65
- const parsedUrl = parse(resolvedUrl.url);
66
- const [, tenantId, documentId] = parsedUrl.path ? parsedUrl.path.split("/") : [];
63
+ const parsedUrl = new URL(resolvedUrl.url);
64
+ const [, tenantId, documentId] = parsedUrl.pathname ? parsedUrl.pathname.split("/") : [];
67
65
  if (!documentId || !tenantId) {
68
66
  throw new Error(
69
67
  `Couldn't parse resolved url. [documentId:${documentId}][tenantId:${tenantId}]`,
@@ -3,12 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { stringToBuffer, Uint8ArrayToString } from "@fluid-internal/client-utils";
6
+ import {
7
+ bufferToString,
8
+ IsoBuffer,
9
+ stringToBuffer,
10
+ Uint8ArrayToString,
11
+ } from "@fluid-internal/client-utils";
7
12
  import {
8
13
  IDocumentStorageService,
9
14
  IDocumentStorageServicePolicies,
10
15
  IResolvedUrl,
11
16
  ISummaryContext,
17
+ type ISnapshotFetchOptions,
18
+ type ISnapshot,
12
19
  } from "@fluidframework/driver-definitions";
13
20
  import {
14
21
  ICreateBlobResponse,
@@ -24,7 +31,8 @@ import {
24
31
  SummaryTreeUploadManager,
25
32
  } from "@fluidframework/server-services-client";
26
33
  import { ILocalDeltaConnectionServer } from "@fluidframework/server-local-server";
27
- import { createDocument } from "./localCreateDocument";
34
+ import { assert } from "@fluidframework/core-utils";
35
+ import { createDocument } from "./localCreateDocument.js";
28
36
 
29
37
  const minTTLInSeconds = 24 * 60 * 60; // Same TTL as ODSP
30
38
  /**
@@ -36,8 +44,6 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
36
44
  protected readonly blobsShaCache = new Map<string, string>();
37
45
  private readonly summaryTreeUploadManager: ISummaryUploadManager;
38
46
 
39
- public readonly repositoryUrl: string = "";
40
-
41
47
  constructor(
42
48
  private readonly id: string,
43
49
  private readonly manager: GitManager,
@@ -75,9 +81,179 @@ export class LocalDocumentStorageService implements IDocumentStorageService {
75
81
 
76
82
  const rawTree = await this.manager.getTree(requestVersion.treeId);
77
83
  const tree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);
84
+ await this.populateGroupId(tree);
78
85
  return tree;
79
86
  }
80
87
 
88
+ public async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {
89
+ let versionId = snapshotFetchOptions?.versionId;
90
+ if (!versionId) {
91
+ const versions = await this.getVersions(this.id, 1);
92
+ if (versions.length === 0) {
93
+ throw new Error("No versions for the document!");
94
+ }
95
+
96
+ versionId = versions[0].treeId;
97
+ }
98
+ const rawTree = await this.manager.getTree(versionId);
99
+ const snapshotTree = buildGitTreeHierarchy(rawTree, this.blobsShaCache, true);
100
+ if (snapshotFetchOptions?.loadingGroupIds !== undefined) {
101
+ const groupIds = new Set<string>(snapshotFetchOptions.loadingGroupIds);
102
+ const hasFoundTree = await this.filterTreeByLoadingGroupIds(
103
+ snapshotTree,
104
+ groupIds,
105
+ false,
106
+ );
107
+ assert(hasFoundTree, 0x8dd /* No tree found for the given groupIds */);
108
+ } else {
109
+ await this.stripTreeOfLoadingGroupIds(snapshotTree);
110
+ }
111
+
112
+ const blobContents = new Map<string, ArrayBufferLike>();
113
+ await this.populateBlobContents(snapshotTree, blobContents);
114
+
115
+ const metadataString = IsoBuffer.from(blobContents.get(".metadata")).toString("utf-8");
116
+ const metadata = JSON.parse(metadataString);
117
+ const sequenceNumber: number = metadata.message?.sequenceNumber ?? 0;
118
+ return {
119
+ snapshotTree,
120
+ blobContents,
121
+ ops: [],
122
+ snapshotFormatV: 1,
123
+ sequenceNumber,
124
+ latestSequenceNumber: undefined,
125
+ };
126
+ }
127
+
128
+ /**
129
+ * Strips the tree or any subtree of data if it has a groupId.
130
+ *
131
+ * @param tree - The tree to strip of loading groupIds
132
+ * @returns a tree that has trees with groupIds that are empty
133
+ */
134
+ private async stripTreeOfLoadingGroupIds(tree: ISnapshotTreeEx) {
135
+ const groupId = await this.readGroupId(tree);
136
+ if (groupId !== undefined) {
137
+ // strip
138
+ this.stripTree(tree, groupId);
139
+ return;
140
+ }
141
+ await Promise.all(
142
+ Object.values(tree.trees).map(async (childTree) => {
143
+ await this.stripTreeOfLoadingGroupIds(childTree);
144
+ }),
145
+ );
146
+ }
147
+
148
+ /**
149
+ * Named differently as the algorithm is a little more involved.
150
+ *
151
+ * 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
152
+ * that has a groupId that is in the loadingGroupIds.
153
+ *
154
+ * We keep the tree in the opposite case.
155
+ *
156
+ * @param tree - the tree to strip of any data that is not in the loadingGroupIds
157
+ * @param loadingGroupIds - the set of groupIds that are being loaded
158
+ * @param ancestorGroupIdInLoadingGroup - whether the ancestor of the tree has a groupId that is in the loadingGroupIds
159
+ * @returns whether or not it or descendant has a groupId that is in the loadingGroupIds
160
+ */
161
+ private async filterTreeByLoadingGroupIds(
162
+ tree: ISnapshotTreeEx,
163
+ loadingGroupIds: Set<string>,
164
+ ancestorGroupIdInLoadingGroup: boolean,
165
+ ): Promise<boolean> {
166
+ assert(loadingGroupIds.size > 0, 0x8de /* loadingGroupIds should not be empty */);
167
+ const groupId = await this.readGroupId(tree);
168
+
169
+ // Strip the tree if it has a groupId and it is not in the loadingGroupIds
170
+ // This is an optimization here as we have other reasons to keep the tree.
171
+ const noGroupIdInLoadingGroupIds = groupId !== undefined && !loadingGroupIds.has(groupId);
172
+ if (noGroupIdInLoadingGroupIds) {
173
+ this.stripTree(tree, groupId);
174
+ return false;
175
+ }
176
+
177
+ // Keep tree if it has a groupId and it is in the loadingGroupIds
178
+ const groupIdInLoadingGroupIds = groupId !== undefined && loadingGroupIds.has(groupId);
179
+
180
+ // Keep tree if it has an ancestor that has a groupId that is in loadingGroupIds and it doesn't have groupId
181
+ const isChildOfAncestorWithGroupId = ancestorGroupIdInLoadingGroup && groupId === undefined;
182
+
183
+ // Keep tree if it has a child that has a groupId that is in loadingGroupIds
184
+ const descendants = await Promise.all<boolean>(
185
+ Object.values(tree.trees).map(async (childTree) => {
186
+ return this.filterTreeByLoadingGroupIds(
187
+ childTree,
188
+ loadingGroupIds,
189
+ ancestorGroupIdInLoadingGroup || groupIdInLoadingGroupIds,
190
+ );
191
+ }),
192
+ );
193
+ const isAncestorOfDescendantsWithGroupId = descendants.some((keep) => keep);
194
+
195
+ // We don't want to return prematurely as we still may have children that we want to keep.
196
+ if (
197
+ groupIdInLoadingGroupIds ||
198
+ isChildOfAncestorWithGroupId ||
199
+ isAncestorOfDescendantsWithGroupId
200
+ ) {
201
+ // Keep this tree node
202
+ return true;
203
+ }
204
+
205
+ // This means we have no groupId and none of our ancestors or descendants have a groupId in the loadingGroupIds
206
+ this.stripTree(tree, groupId);
207
+ return false;
208
+ }
209
+
210
+ // Takes all the blobs of a tree and puts it into the blobContents
211
+ private async populateBlobContents(
212
+ tree: ISnapshotTreeEx,
213
+ blobContents: Map<string, ArrayBufferLike>,
214
+ ): Promise<void> {
215
+ await Promise.all(
216
+ Object.entries(tree.blobs).map(async ([path, blobId]) => {
217
+ const content = await this.readBlob(blobId);
218
+ blobContents.set(path, content);
219
+ }),
220
+ );
221
+ await Promise.all(
222
+ Object.values(tree.trees).map(async (childTree) => {
223
+ await this.populateBlobContents(childTree, blobContents);
224
+ }),
225
+ );
226
+ }
227
+
228
+ private async populateGroupId(tree: ISnapshotTreeEx): Promise<void> {
229
+ await this.readGroupId(tree);
230
+ await Promise.all(
231
+ Object.values(tree.trees).map(async (childTree) => {
232
+ await this.populateGroupId(childTree);
233
+ }),
234
+ );
235
+ }
236
+
237
+ private stripTree(tree: ISnapshotTreeEx, groupId: string | undefined) {
238
+ tree.blobs = {};
239
+ tree.groupId = groupId;
240
+ tree.trees = {};
241
+ tree.omitted = true;
242
+ }
243
+
244
+ private async readGroupId(tree: ISnapshotTreeEx): Promise<string | undefined> {
245
+ const groupIdBlobId = tree.blobs[".groupId"];
246
+ if (groupIdBlobId !== undefined) {
247
+ const groupIdBuffer = await this.readBlob(groupIdBlobId);
248
+ const groupId = bufferToString(groupIdBuffer, "utf8");
249
+ tree.groupId = groupId;
250
+ delete tree.blobs[".groupId"];
251
+ return groupId;
252
+ }
253
+
254
+ return tree.groupId;
255
+ }
256
+
81
257
  public async readBlob(blobId: string): Promise<ArrayBufferLike> {
82
258
  const blob = await this.manager.getBlob(blobId);
83
259
  this.blobsShaCache.set(blob.sha, "");
@@ -3,12 +3,11 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { parse } from "url";
7
6
  import { assert } from "@fluidframework/core-utils";
8
7
  import { IRequest } from "@fluidframework/core-interfaces";
9
8
  import { IResolvedUrl, IUrlResolver, DriverHeader } from "@fluidframework/driver-definitions";
10
9
  import { ScopeType } from "@fluidframework/protocol-definitions";
11
- import { generateToken } from "./auth";
10
+ import { generateToken } from "./auth.js";
12
11
 
13
12
  /**
14
13
  * @alpha
@@ -39,7 +38,6 @@ export class LocalResolver implements IUrlResolver {
39
38
  * token from constant test strings. The root of the URL is fake, but the
40
39
  * remaining relative URL can still be parsed.
41
40
  * @param request - request to handle
42
- * @alpha
43
41
  */
44
42
  public async resolve(request: IRequest): Promise<IResolvedUrl> {
45
43
  const parsedUrl = new URL(request.url);
@@ -55,7 +53,7 @@ export class LocalResolver implements IUrlResolver {
55
53
  id: documentId,
56
54
  tokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },
57
55
  type: "fluid",
58
- url: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,
56
+ url: `https://localhost:3000/${this.tenantId}/${fullPath}`,
59
57
  };
60
58
 
61
59
  return resolved;
@@ -66,7 +64,7 @@ export class LocalResolver implements IUrlResolver {
66
64
  if (url.startsWith("/")) {
67
65
  url = url.substr(1);
68
66
  }
69
- const parsedUrl = parse(resolvedUrl.url);
67
+ const parsedUrl = new URL(resolvedUrl.url);
70
68
  if (parsedUrl.pathname === null) {
71
69
  throw new Error("Url should contain tenant and docId!!");
72
70
  }
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { EventEmitter } from "events";
5
+ import { EventEmitter } from "@fluid-internal/client-utils";
6
6
  import { ICollection, IDb } from "@fluidframework/server-services-core";
7
7
  import { ITestDbFactory } from "@fluidframework/server-test-utils";
8
8
  import { v4 as uuid } from "uuid";
@@ -0,0 +1,7 @@
1
+ {
2
+ // This config must be used in a "type": "commonjs" environment. (Use fluid-tsc commonjs.)
3
+ "extends": "./tsconfig.json",
4
+ "compilerOptions": {
5
+ "outDir": "./dist",
6
+ },
7
+ }
package/tsconfig.json CHANGED
@@ -1,12 +1,9 @@
1
1
  {
2
- "extends": [
3
- "../../../common/build/build-common/tsconfig.base.json",
4
- "../../../common/build/build-common/tsconfig.cjs.json",
5
- ],
2
+ "extends": "../../../common/build/build-common/tsconfig.node16.json",
6
3
  "include": ["src/**/*"],
7
4
  "exclude": ["src/test/**/*"],
8
5
  "compilerOptions": {
9
6
  "rootDir": "./src",
10
- "outDir": "./dist",
7
+ "outDir": "./lib",
11
8
  },
12
9
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAgB,KAAK,EAAE,SAAS,EAAE,MAAM,sCAAsC;AAIrF;;;GAGG;AACH,wBAAgB,aAAa,CAC5B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,EAAE,EACnB,IAAI,CAAC,EAAE,KAAK,EACZ,QAAQ,GAAE,MAAgB,EAC1B,GAAG,GAAE,MAAc,GACjB,MAAM,CA0BR;AAED,wBAAgB,YAAY,IAAI,KAAK,CAWpC"}
package/lib/auth.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.mjs","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,WAAW;OACtC,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM;AAEjC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC5B,QAAgB,EAChB,UAAkB,EAClB,GAAW,EACX,MAAmB,EACnB,IAAY,EACZ,WAAmB,EAAE,GAAG,EAAE,EAC1B,MAAc,KAAK;IAEnB,IAAI,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC;IAC7C,IAAI,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,SAAS,CAAC,EAAE,KAAK,SAAS,EAAE;QACtD,SAAS,GAAG,YAAY,EAAE,CAAC;KAC3B;IAED,0BAA0B;IAC1B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAEpD,MAAM,MAAM,GAAiB;QAC5B,UAAU;QACV,MAAM;QACN,QAAQ;QACR,IAAI,EAAE,SAAS;QACf,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,QAAQ;QACnB,GAAG;KACH,CAAC;IAEF,MAAM,OAAO,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC9B,OAAO,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAC5B,IAAI,EACJ,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,EAC5C,MAAM,EACN,OAAO,CACP,CAAC;AACH,CAAC;AAED,MAAM,UAAU,YAAY;IAC3B,MAAM,MAAM,GAAG,IAAI,EAAE,CAAC;IACtB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACzD,MAAM,QAAQ,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,uEAAuE;IAE5H,MAAM,UAAU,GAAG;QAClB,EAAE,EAAE,MAAM;QACV,IAAI,EAAE,QAAQ;KACd,CAAC;IAEF,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITokenClaims, IUser, ScopeType } from \"@fluidframework/protocol-definitions\";\nimport { KJUR as jsrsasign } from \"jsrsasign\";\nimport { v4 as uuid } from \"uuid\";\n\n/**\n * Generates a JWT token to authorize against. We do not use the implementation in\n * services-client since it cannot run in the browser without polyfills.\n */\nexport function generateToken(\n\ttenantId: string,\n\tdocumentId: string,\n\tkey: string,\n\tscopes: ScopeType[],\n\tuser?: IUser,\n\tlifetime: number = 60 * 60,\n\tver: string = \"1.0\",\n): string {\n\tlet userClaim = user ? user : generateUser();\n\tif (userClaim.id === \"\" || userClaim.id === undefined) {\n\t\tuserClaim = generateUser();\n\t}\n\n\t// Current time in seconds\n\tconst now = Math.round(new Date().getTime() / 1000);\n\n\tconst claims: ITokenClaims = {\n\t\tdocumentId,\n\t\tscopes,\n\t\ttenantId,\n\t\tuser: userClaim,\n\t\tiat: now,\n\t\texp: now + lifetime,\n\t\tver,\n\t};\n\n\tconst utf8Key = { utf8: key };\n\treturn jsrsasign.jws.JWS.sign(\n\t\tnull,\n\t\tJSON.stringify({ alg: \"HS256\", typ: \"JWT\" }),\n\t\tclaims,\n\t\tutf8Key,\n\t);\n}\n\nexport function generateUser(): IUser {\n\tconst userId = uuid();\n\tconst match = userId.match(/^([\\da-f]{8})-([\\da-f]{4})/);\n\tconst userName = match !== null ? match[0] : userId; // Just use the first two segments of the (fake) userId as a fake name.\n\n\tconst randomUser = {\n\t\tid: userId,\n\t\tname: userName,\n\t};\n\n\treturn randomUser;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,wBAAwB,EAAE;OAC5B,EAAE,4BAA4B,EAAE;OAChC,EAAE,0BAA0B,EAAE,oBAAoB,EAAE;OACpD,EAAE,2BAA2B,EAAE;OAC/B,EAAE,2BAA2B,EAAE;OAC/B,EAAE,mCAAmC,EAAE,aAAa,EAAE;OACtD,EAAE,4BAA4B,EAAE"}
package/lib/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,wBAAwB,EAAE;OAC5B,EAAE,4BAA4B,EAAE;OAChC,EAAE,0BAA0B,EAAE,oBAAoB,EAAE;OACpD,EAAE,2BAA2B,EAAE;OAC/B,EAAE,2BAA2B,EAAE;OAC/B,EAAE,mCAAmC,EAAE,aAAa,EAAE;OACtD,EAAE,4BAA4B,EAAE","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { LocalDeltaStorageService } from \"./localDeltaStorageService\";\nexport { LocalDocumentDeltaConnection } from \"./localDocumentDeltaConnection\";\nexport { createLocalDocumentService, LocalDocumentService } from \"./localDocumentService\";\nexport { LocalDocumentServiceFactory } from \"./localDocumentServiceFactory\";\nexport { LocalDocumentStorageService } from \"./localDocumentStorageService\";\nexport { createLocalResolverCreateNewRequest, LocalResolver } from \"./localResolver\";\nexport { LocalSessionStorageDbFactory } from \"./localSessionStorageDb\";\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"localCreateDocument.d.mts","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,YAAY,EAAE,MAAM,oCAAoC;OAM1D,EAAE,YAAY,EAAE,MAAM,sCAAsC;AAInE,wBAAsB,cAAc,CACnC,0BAA0B,KAAA,EAC1B,WAAW,EAAE,YAAY,EACzB,OAAO,EAAE,YAAY,iBA6BrB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"localCreateDocument.mjs","sourceRoot":"","sources":["../src/localCreateDocument.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAGI,EACN,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,8BAA8B;OAG9B,EAAE,WAAW,EAAE,MAAM,wCAAwC;AAEpE,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;QAC9C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;KACzE;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 { IResolvedUrl } from \"@fluidframework/driver-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\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 +0,0 @@
1
- {"version":3,"file":"localDeltaStorageService.d.mts","sourceRoot":"","sources":["../src/localDeltaStorageService.ts"],"names":[],"mappings":"AAAA;;;GAGG;OAEI,EAAE,4BAA4B,EAAE,OAAO,EAAE,MAAM,oCAAoC;OACnF,EAAE,yBAAyB,EAAE,MAAM,sCAAsC;OACzE,EAAE,gBAAgB,EAAE,MAAM,sCAAsC;AAGvE;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,4BAA4B;IAE3E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,eAAe;gBAFf,QAAQ,EAAE,MAAM,EAChB,EAAE,EAAE,MAAM,EACV,eAAe,EAAE,gBAAgB;IAG5C,aAAa,CACnB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GAAG,SAAS,EACtB,WAAW,CAAC,EAAE,WAAW,EACzB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,yBAAyB,EAAE,CAAC;YAIzB,OAAO;CAcrB"}