@fluidframework/datastore 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419

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 (145) hide show
  1. package/.eslintrc.js +5 -7
  2. package/.mocharc.js +12 -0
  3. package/CHANGELOG.md +273 -0
  4. package/README.md +41 -0
  5. package/api-extractor-lint.json +4 -0
  6. package/api-extractor.json +2 -2
  7. package/api-report/datastore.api.md +168 -0
  8. package/dist/channelContext.cjs +86 -0
  9. package/dist/channelContext.cjs.map +1 -0
  10. package/dist/channelContext.d.ts +15 -9
  11. package/dist/channelContext.d.ts.map +1 -1
  12. package/dist/{channelDeltaConnection.js → channelDeltaConnection.cjs} +14 -15
  13. package/dist/channelDeltaConnection.cjs.map +1 -0
  14. package/dist/channelDeltaConnection.d.ts +4 -5
  15. package/dist/channelDeltaConnection.d.ts.map +1 -1
  16. package/dist/{channelStorageService.js → channelStorageService.cjs} +13 -16
  17. package/dist/channelStorageService.cjs.map +1 -0
  18. package/dist/channelStorageService.d.ts +2 -2
  19. package/dist/channelStorageService.d.ts.map +1 -1
  20. package/dist/{dataStoreRuntime.js → dataStoreRuntime.cjs} +302 -225
  21. package/dist/dataStoreRuntime.cjs.map +1 -0
  22. package/dist/dataStoreRuntime.d.ts +81 -37
  23. package/dist/dataStoreRuntime.d.ts.map +1 -1
  24. package/dist/datastore-alpha.d.ts +317 -0
  25. package/dist/datastore-beta.d.ts +47 -0
  26. package/dist/datastore-public.d.ts +47 -0
  27. package/dist/datastore-untrimmed.d.ts +324 -0
  28. package/dist/{fluidHandle.js → fluidHandle.cjs} +44 -16
  29. package/dist/fluidHandle.cjs.map +1 -0
  30. package/dist/fluidHandle.d.ts +33 -6
  31. package/dist/fluidHandle.d.ts.map +1 -1
  32. package/dist/index.cjs +15 -0
  33. package/dist/index.cjs.map +1 -0
  34. package/dist/index.d.ts +2 -2
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/localChannelContext.cjs +190 -0
  37. package/dist/localChannelContext.cjs.map +1 -0
  38. package/dist/localChannelContext.d.ts +12 -21
  39. package/dist/localChannelContext.d.ts.map +1 -1
  40. package/dist/{localChannelStorageService.js → localChannelStorageService.cjs} +3 -3
  41. package/dist/localChannelStorageService.cjs.map +1 -0
  42. package/dist/localChannelStorageService.d.ts.map +1 -1
  43. package/dist/remoteChannelContext.cjs +124 -0
  44. package/dist/remoteChannelContext.cjs.map +1 -0
  45. package/dist/remoteChannelContext.d.ts +5 -10
  46. package/dist/remoteChannelContext.d.ts.map +1 -1
  47. package/dist/tsdoc-metadata.json +11 -0
  48. package/lib/{channelContext.d.ts → channelContext.d.mts} +16 -10
  49. package/lib/channelContext.d.mts.map +1 -0
  50. package/lib/channelContext.mjs +78 -0
  51. package/lib/channelContext.mjs.map +1 -0
  52. package/lib/{channelDeltaConnection.d.ts → channelDeltaConnection.d.mts} +4 -5
  53. package/lib/channelDeltaConnection.d.mts.map +1 -0
  54. package/lib/{channelDeltaConnection.js → channelDeltaConnection.mjs} +11 -12
  55. package/lib/channelDeltaConnection.mjs.map +1 -0
  56. package/lib/{channelStorageService.d.ts → channelStorageService.d.mts} +2 -2
  57. package/lib/channelStorageService.d.mts.map +1 -0
  58. package/lib/{channelStorageService.js → channelStorageService.mjs} +13 -16
  59. package/lib/channelStorageService.mjs.map +1 -0
  60. package/lib/{dataStoreRuntime.d.ts → dataStoreRuntime.d.mts} +81 -37
  61. package/lib/dataStoreRuntime.d.mts.map +1 -0
  62. package/lib/{dataStoreRuntime.js → dataStoreRuntime.mjs} +286 -209
  63. package/lib/dataStoreRuntime.mjs.map +1 -0
  64. package/lib/datastore-alpha.d.mts +317 -0
  65. package/lib/datastore-beta.d.mts +47 -0
  66. package/lib/datastore-public.d.mts +47 -0
  67. package/lib/datastore-untrimmed.d.mts +324 -0
  68. package/lib/fluidHandle.d.mts +57 -0
  69. package/lib/fluidHandle.d.mts.map +1 -0
  70. package/lib/{fluidHandle.js → fluidHandle.mjs} +44 -16
  71. package/lib/fluidHandle.mjs.map +1 -0
  72. package/lib/index.d.mts +7 -0
  73. package/lib/index.d.mts.map +1 -0
  74. package/lib/index.mjs +7 -0
  75. package/lib/index.mjs.map +1 -0
  76. package/lib/{localChannelContext.d.ts → localChannelContext.d.mts} +13 -22
  77. package/lib/localChannelContext.d.mts.map +1 -0
  78. package/lib/{localChannelContext.js → localChannelContext.mjs} +73 -85
  79. package/lib/localChannelContext.mjs.map +1 -0
  80. package/lib/localChannelStorageService.d.mts.map +1 -0
  81. package/lib/{localChannelStorageService.js → localChannelStorageService.mjs} +2 -2
  82. package/lib/localChannelStorageService.mjs.map +1 -0
  83. package/lib/{remoteChannelContext.d.ts → remoteChannelContext.d.mts} +7 -12
  84. package/lib/remoteChannelContext.d.mts.map +1 -0
  85. package/lib/remoteChannelContext.mjs +120 -0
  86. package/lib/remoteChannelContext.mjs.map +1 -0
  87. package/package.json +107 -72
  88. package/{lib/index.js → prettier.config.cjs} +4 -3
  89. package/src/channelContext.ts +168 -71
  90. package/src/channelDeltaConnection.ts +52 -47
  91. package/src/channelStorageService.ts +59 -55
  92. package/src/dataStoreRuntime.ts +1158 -983
  93. package/src/fluidHandle.ts +92 -64
  94. package/src/index.ts +8 -2
  95. package/src/localChannelContext.ts +278 -272
  96. package/src/localChannelStorageService.ts +48 -46
  97. package/src/remoteChannelContext.ts +237 -300
  98. package/tsc-multi.test.json +4 -0
  99. package/tsconfig.json +11 -13
  100. package/dist/channelContext.js +0 -35
  101. package/dist/channelContext.js.map +0 -1
  102. package/dist/channelDeltaConnection.js.map +0 -1
  103. package/dist/channelStorageService.js.map +0 -1
  104. package/dist/dataStoreRuntime.js.map +0 -1
  105. package/dist/fluidHandle.js.map +0 -1
  106. package/dist/index.js +0 -19
  107. package/dist/index.js.map +0 -1
  108. package/dist/localChannelContext.js +0 -202
  109. package/dist/localChannelContext.js.map +0 -1
  110. package/dist/localChannelStorageService.js.map +0 -1
  111. package/dist/packageVersion.d.ts +0 -9
  112. package/dist/packageVersion.d.ts.map +0 -1
  113. package/dist/packageVersion.js +0 -12
  114. package/dist/packageVersion.js.map +0 -1
  115. package/dist/remoteChannelContext.js +0 -207
  116. package/dist/remoteChannelContext.js.map +0 -1
  117. package/lib/channelContext.d.ts.map +0 -1
  118. package/lib/channelContext.js +0 -29
  119. package/lib/channelContext.js.map +0 -1
  120. package/lib/channelDeltaConnection.d.ts.map +0 -1
  121. package/lib/channelDeltaConnection.js.map +0 -1
  122. package/lib/channelStorageService.d.ts.map +0 -1
  123. package/lib/channelStorageService.js.map +0 -1
  124. package/lib/dataStoreRuntime.d.ts.map +0 -1
  125. package/lib/dataStoreRuntime.js.map +0 -1
  126. package/lib/fluidHandle.d.ts +0 -30
  127. package/lib/fluidHandle.d.ts.map +0 -1
  128. package/lib/fluidHandle.js.map +0 -1
  129. package/lib/index.d.ts +0 -7
  130. package/lib/index.d.ts.map +0 -1
  131. package/lib/index.js.map +0 -1
  132. package/lib/localChannelContext.d.ts.map +0 -1
  133. package/lib/localChannelContext.js.map +0 -1
  134. package/lib/localChannelStorageService.d.ts.map +0 -1
  135. package/lib/localChannelStorageService.js.map +0 -1
  136. package/lib/packageVersion.d.ts +0 -9
  137. package/lib/packageVersion.d.ts.map +0 -1
  138. package/lib/packageVersion.js +0 -9
  139. package/lib/packageVersion.js.map +0 -1
  140. package/lib/remoteChannelContext.d.ts.map +0 -1
  141. package/lib/remoteChannelContext.js +0 -203
  142. package/lib/remoteChannelContext.js.map +0 -1
  143. package/src/packageVersion.ts +0 -9
  144. package/tsconfig.esnext.json +0 -7
  145. /package/lib/{localChannelStorageService.d.ts → localChannelStorageService.d.mts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/datastore",
3
- "version": "1.4.0-121020",
3
+ "version": "2.0.0-dev-rc.1.0.0.224419",
4
4
  "description": "Fluid data store implementation",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": {
@@ -11,45 +11,32 @@
11
11
  "license": "MIT",
12
12
  "author": "Microsoft and contributors",
13
13
  "sideEffects": false,
14
- "main": "dist/index.js",
15
- "module": "lib/index.js",
16
- "types": "dist/index.d.ts",
17
- "scripts": {
18
- "build": "npm run build:genver && concurrently npm:build:compile npm:lint && npm run build:docs",
19
- "build:commonjs": "npm run tsc && npm run typetests:gen && npm run build:test",
20
- "build:compile": "concurrently npm:build:commonjs npm:build:esnext",
21
- "build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
22
- "build:esnext": "tsc --project ./tsconfig.esnext.json",
23
- "build:full": "npm run build",
24
- "build:full:compile": "npm run build:compile",
25
- "build:genver": "gen-version",
26
- "build:test": "tsc --project ./src/test/tsconfig.json",
27
- "ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
28
- "clean": "rimraf dist lib *.tsbuildinfo *.build.log",
29
- "eslint": "eslint --format stylish src",
30
- "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
31
- "lint": "npm run eslint",
32
- "lint:fix": "npm run eslint:fix",
33
- "test": "npm run test:mocha",
34
- "test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
35
- "test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
36
- "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
37
- "tsc": "tsc",
38
- "tsc:watch": "tsc --watch",
39
- "typetests:gen": "flub generate typetests --generate --dir . --no-generateInName",
40
- "typetests:prepare": "flub generate typetests --prepare --dir . --pin"
14
+ "exports": {
15
+ ".": {
16
+ "import": {
17
+ "types": "./lib/index.d.mts",
18
+ "default": "./lib/index.mjs"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.cjs"
23
+ }
24
+ }
41
25
  },
42
- "nyc": {
26
+ "main": "dist/index.cjs",
27
+ "module": "lib/index.mjs",
28
+ "types": "dist/index.d.ts",
29
+ "c8": {
43
30
  "all": true,
44
31
  "cache-dir": "nyc/.cache",
45
32
  "exclude": [
46
- "src/test/**/*.ts",
47
- "dist/test/**/*.js"
33
+ "src/test/**/*.*ts",
34
+ "dist/test/**/*.*js"
48
35
  ],
49
36
  "exclude-after-remap": false,
50
37
  "include": [
51
- "src/**/*.ts",
52
- "dist/**/*.js"
38
+ "src/**/*.*ts",
39
+ "dist/**/*.*js"
53
40
  ],
54
41
  "report-dir": "nyc/report",
55
42
  "reporter": [
@@ -60,49 +47,97 @@
60
47
  "temp-directory": "nyc/.nyc_output"
61
48
  },
62
49
  "dependencies": {
63
- "@fluidframework/common-definitions": "^0.20.1",
64
- "@fluidframework/common-utils": "^0.32.1",
65
- "@fluidframework/container-definitions": "1.4.0-121020",
66
- "@fluidframework/container-utils": "1.4.0-121020",
67
- "@fluidframework/core-interfaces": "1.4.0-121020",
68
- "@fluidframework/datastore-definitions": "1.4.0-121020",
69
- "@fluidframework/driver-definitions": "1.4.0-121020",
70
- "@fluidframework/driver-utils": "1.4.0-121020",
71
- "@fluidframework/garbage-collector": "1.4.0-121020",
72
- "@fluidframework/protocol-base": "^0.1036.5000",
73
- "@fluidframework/protocol-definitions": "^0.1028.2000",
74
- "@fluidframework/runtime-definitions": "1.4.0-121020",
75
- "@fluidframework/runtime-utils": "1.4.0-121020",
76
- "@fluidframework/telemetry-utils": "1.4.0-121020",
50
+ "@fluid-internal/client-utils": "2.0.0-dev-rc.1.0.0.224419",
51
+ "@fluidframework/container-definitions": "2.0.0-dev-rc.1.0.0.224419",
52
+ "@fluidframework/core-interfaces": "2.0.0-dev-rc.1.0.0.224419",
53
+ "@fluidframework/core-utils": "2.0.0-dev-rc.1.0.0.224419",
54
+ "@fluidframework/datastore-definitions": "2.0.0-dev-rc.1.0.0.224419",
55
+ "@fluidframework/driver-definitions": "2.0.0-dev-rc.1.0.0.224419",
56
+ "@fluidframework/driver-utils": "2.0.0-dev-rc.1.0.0.224419",
57
+ "@fluidframework/protocol-definitions": "^3.1.0-223007",
58
+ "@fluidframework/runtime-definitions": "2.0.0-dev-rc.1.0.0.224419",
59
+ "@fluidframework/runtime-utils": "2.0.0-dev-rc.1.0.0.224419",
60
+ "@fluidframework/telemetry-utils": "2.0.0-dev-rc.1.0.0.224419",
77
61
  "lodash": "^4.17.21",
78
- "uuid": "^8.3.1"
62
+ "uuid": "^9.0.0"
79
63
  },
80
64
  "devDependencies": {
81
- "@fluidframework/build-common": "^0.24.0",
82
- "@fluidframework/build-tools": "^0.6.0-110101",
83
- "@fluidframework/datastore-previous": "npm:@fluidframework/datastore@1.3.1",
84
- "@fluidframework/eslint-config-fluid": "^0.28.2000",
85
- "@fluidframework/mocha-test-setup": "1.4.0-121020",
86
- "@fluidframework/test-runtime-utils": "1.4.0-121020",
87
- "@microsoft/api-extractor": "^7.22.2",
88
- "@rushstack/eslint-config": "^2.5.1",
65
+ "@arethetypeswrong/cli": "^0.13.3",
66
+ "@fluid-tools/build-cli": "0.29.0-222379",
67
+ "@fluidframework/build-common": "^2.0.3",
68
+ "@fluidframework/build-tools": "0.29.0-222379",
69
+ "@fluidframework/datastore-previous": "npm:@fluidframework/datastore@2.0.0-internal.7.2.0",
70
+ "@fluidframework/eslint-config-fluid": "^3.1.0",
71
+ "@fluidframework/mocha-test-setup": "2.0.0-dev-rc.1.0.0.224419",
72
+ "@fluidframework/test-runtime-utils": "2.0.0-dev-rc.1.0.0.224419",
73
+ "@microsoft/api-extractor": "^7.38.3",
74
+ "@types/lodash": "^4.14.118",
89
75
  "@types/mocha": "^9.1.1",
90
- "@types/node": "^14.18.0",
91
- "@types/uuid": "^8.3.0",
92
- "concurrently": "^6.2.0",
93
- "copyfiles": "^2.1.0",
94
- "cross-env": "^7.0.2",
95
- "eslint": "~8.6.0",
96
- "mocha": "^10.0.0",
97
- "nyc": "^15.0.0",
98
- "rimraf": "^2.6.2",
99
- "typescript": "~4.5.5",
100
- "typescript-formatter": "7.1.0"
76
+ "@types/node": "^18.19.0",
77
+ "@types/uuid": "^9.0.2",
78
+ "c8": "^7.7.1",
79
+ "copyfiles": "^2.4.1",
80
+ "cross-env": "^7.0.3",
81
+ "eslint": "~8.50.0",
82
+ "mocha": "^10.2.0",
83
+ "mocha-json-output-reporter": "^2.0.1",
84
+ "mocha-multi-reporters": "^1.5.1",
85
+ "moment": "^2.21.0",
86
+ "prettier": "~3.0.3",
87
+ "renamer": "^4.0.0",
88
+ "rimraf": "^4.4.0",
89
+ "tsc-multi": "^1.1.0",
90
+ "typescript": "~5.1.6"
91
+ },
92
+ "fluidBuild": {
93
+ "tasks": {
94
+ "build:docs": {
95
+ "dependsOn": [
96
+ "...",
97
+ "api-extractor:commonjs",
98
+ "api-extractor:esnext"
99
+ ],
100
+ "script": false
101
+ }
102
+ }
101
103
  },
102
104
  "typeValidation": {
103
- "version": "1.4.0",
104
- "baselineRange": "~1.3.0",
105
- "baselineVersion": "1.3.1",
106
- "broken": {}
105
+ "broken": {
106
+ "ClassDeclaration_FluidDataStoreRuntime": {
107
+ "forwardCompat": false,
108
+ "backCompat": false
109
+ }
110
+ }
111
+ },
112
+ "scripts": {
113
+ "api": "fluid-build . --task api",
114
+ "api-extractor:commonjs": "api-extractor run --local",
115
+ "api-extractor:esnext": "copyfiles -u 1 \"dist/**/*-@(alpha|beta|public|untrimmed).d.ts\" lib",
116
+ "build": "fluid-build . --task build",
117
+ "build:commonjs": "fluid-build . --task commonjs",
118
+ "build:compile": "fluid-build . --task compile",
119
+ "build:docs": "fluid-build . --task api",
120
+ "build:esnext": "tsc-multi --config ../../../common/build/build-common/tsc-multi.esm.json",
121
+ "build:rename-types": "renamer \"lib/**\" -f .d.ts -r .d.mts --force",
122
+ "build:test": "tsc-multi --config ./tsc-multi.test.json",
123
+ "check:are-the-types-wrong": "attw --pack",
124
+ "check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
125
+ "ci:build:docs": "api-extractor run",
126
+ "clean": "rimraf --glob dist lib \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
127
+ "eslint": "eslint --format stylish src",
128
+ "eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
129
+ "format": "npm run prettier:fix",
130
+ "lint": "npm run prettier && npm run check:release-tags && npm run eslint",
131
+ "lint:fix": "npm run prettier:fix && npm run eslint:fix",
132
+ "prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
133
+ "prettier:fix": "prettier --write . --cache --ignore-path ../../../.prettierignore",
134
+ "test": "npm run test:mocha",
135
+ "test:coverage": "c8 npm test",
136
+ "test:mocha": "mocha --ignore \"dist/test/types/*\" --recursive dist/test --exit -r node_modules/@fluidframework/mocha-test-setup",
137
+ "test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
138
+ "tsc": "tsc-multi --config ../../../common/build/build-common/tsc-multi.cjs.json",
139
+ "tsc:watch": "tsc --watch",
140
+ "typetests:gen": "fluid-type-test-generator",
141
+ "typetests:prepare": "flub typetests --dir . --reset --previous --normalize"
107
142
  }
108
- }
143
+ }
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- export * from "./dataStoreRuntime";
6
- export * from "./fluidHandle";
7
- //# sourceMappingURL=index.js.map
5
+
6
+ module.exports = {
7
+ ...require("@fluidframework/build-common/prettier.config.cjs"),
8
+ };
@@ -3,106 +3,203 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { ITelemetryLogger } from "@fluidframework/common-definitions";
6
+ import {
7
+ DataCorruptionError,
8
+ ITelemetryLoggerExt,
9
+ tagCodeArtifacts,
10
+ } from "@fluidframework/telemetry-utils";
7
11
  import { IFluidHandle } from "@fluidframework/core-interfaces";
8
- import { IChannel } from "@fluidframework/datastore-definitions";
12
+ import {
13
+ IChannel,
14
+ IChannelAttributes,
15
+ IChannelFactory,
16
+ IFluidDataStoreRuntime,
17
+ } from "@fluidframework/datastore-definitions";
9
18
  import { IDocumentStorageService } from "@fluidframework/driver-definitions";
10
19
  import { ISequencedDocumentMessage, ISnapshotTree } from "@fluidframework/protocol-definitions";
11
20
  import {
12
- IGarbageCollectionData,
13
- ISummarizeResult,
14
- ISummaryTreeWithStats,
15
- ITelemetryContext,
21
+ IGarbageCollectionData,
22
+ IExperimentalIncrementalSummaryContext,
23
+ ISummarizeResult,
24
+ ISummaryTreeWithStats,
25
+ ITelemetryContext,
26
+ IFluidDataStoreContext,
16
27
  } from "@fluidframework/runtime-definitions";
17
28
  import { addBlobToSummary } from "@fluidframework/runtime-utils";
18
- import { ChannelDeltaConnection } from "./channelDeltaConnection";
29
+ import { readAndParse } from "@fluidframework/driver-utils";
19
30
  import { ChannelStorageService } from "./channelStorageService";
31
+ import { ChannelDeltaConnection } from "./channelDeltaConnection";
32
+ import { ISharedObjectRegistry } from "./dataStoreRuntime";
20
33
 
21
34
  export const attributesBlobKey = ".attributes";
22
35
 
23
36
  export interface IChannelContext {
24
- getChannel(): Promise<IChannel>;
37
+ getChannel(): Promise<IChannel>;
25
38
 
26
- setConnectionState(connected: boolean, clientId?: string);
39
+ setConnectionState(connected: boolean, clientId?: string);
27
40
 
28
- processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;
41
+ processOp(message: ISequencedDocumentMessage, local: boolean, localOpMetadata?: unknown): void;
29
42
 
30
- summarize(
31
- fullTree?: boolean,
32
- trackState?: boolean,
33
- telemetryContext?: ITelemetryContext,
34
- ): Promise<ISummarizeResult>;
43
+ summarize(
44
+ fullTree?: boolean,
45
+ trackState?: boolean,
46
+ telemetryContext?: ITelemetryContext,
47
+ ): Promise<ISummarizeResult>;
35
48
 
36
- reSubmit(content: any, localOpMetadata: unknown): void;
49
+ reSubmit(content: any, localOpMetadata: unknown): void;
37
50
 
38
- applyStashedOp(content: any): unknown;
51
+ applyStashedOp(content: any): unknown;
39
52
 
40
- rollback(message: any, localOpMetadata: unknown): void;
53
+ rollback(message: any, localOpMetadata: unknown): void;
41
54
 
42
- /**
43
- * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context
44
- * including any of its children. Each node has a set of outbound routes to other GC nodes in the document.
45
- * @param fullGC - true to bypass optimizations and force full generation of GC data.
46
- */
47
- getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
55
+ /**
56
+ * Returns the data used for garbage collection. This includes a list of GC nodes that represent this context
57
+ * including any of its children. Each node has a set of outbound routes to other GC nodes in the document.
58
+ * @param fullGC - true to bypass optimizations and force full generation of GC data.
59
+ */
60
+ getGCData(fullGC?: boolean): Promise<IGarbageCollectionData>;
48
61
 
49
- /**
50
- * After GC has run, called to notify this context of routes that are used in it. These are used for the following:
51
- * 1. To identify if this context is being referenced in the document or not.
52
- * 2. To identify if this context or any of its children's used routes changed since last summary.
53
- * 3. They are added to the summary generated by this context.
54
- * 4. To update the timestamp when this context is marked as unreferenced.
55
- */
56
- updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number): void;
62
+ /**
63
+ * After GC has run, called to notify this context of routes that are used in it. These are used for the following:
64
+ * 1. To identify if this context is being referenced in the document or not.
65
+ * 2. To identify if this context or any of its children's used routes changed since last summary.
66
+ * 3. They are added to the summary generated by this context.
67
+ */
68
+ updateUsedRoutes(usedRoutes: string[]): void;
57
69
  }
58
70
 
59
- export function createServiceEndpoints(
60
- id: string,
61
- connected: boolean,
62
- submitFn: (content: any, localOpMetadata: unknown) => void,
63
- dirtyFn: () => void,
64
- addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,
65
- storageService: IDocumentStorageService,
66
- logger: ITelemetryLogger,
67
- tree?: ISnapshotTree,
68
- extraBlobs?: Map<string, ArrayBufferLike>,
69
- ) {
70
- const deltaConnection = new ChannelDeltaConnection(
71
- id,
72
- connected,
73
- (message, localOpMetadata) => submitFn(message, localOpMetadata),
74
- dirtyFn,
75
- addedGCOutboundReferenceFn);
76
- const objectStorage = new ChannelStorageService(tree, storageService, logger, extraBlobs);
77
-
78
- return {
79
- deltaConnection,
80
- objectStorage,
81
- };
71
+ export interface ChannelServiceEndpoints {
72
+ deltaConnection: ChannelDeltaConnection;
73
+ objectStorage: ChannelStorageService;
74
+ }
75
+
76
+ export function createChannelServiceEndpoints(
77
+ connected: boolean,
78
+ submitFn: (content: any, localOpMetadata: unknown) => void,
79
+ dirtyFn: () => void,
80
+ addedGCOutboundReferenceFn: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void,
81
+ storageService: IDocumentStorageService,
82
+ logger: ITelemetryLoggerExt,
83
+ tree?: ISnapshotTree,
84
+ extraBlobs?: Map<string, ArrayBufferLike>,
85
+ ): ChannelServiceEndpoints {
86
+ const deltaConnection = new ChannelDeltaConnection(
87
+ connected,
88
+ (message, localOpMetadata) => submitFn(message, localOpMetadata),
89
+ dirtyFn,
90
+ addedGCOutboundReferenceFn,
91
+ );
92
+ const objectStorage = new ChannelStorageService(tree, storageService, logger, extraBlobs);
93
+
94
+ return {
95
+ deltaConnection,
96
+ objectStorage,
97
+ };
82
98
  }
83
99
 
84
100
  export function summarizeChannel(
85
- channel: IChannel,
86
- fullTree: boolean = false,
87
- trackState: boolean = false,
88
- telemetryContext?: ITelemetryContext,
101
+ channel: IChannel,
102
+ fullTree: boolean = false,
103
+ trackState: boolean = false,
104
+ telemetryContext?: ITelemetryContext,
89
105
  ): ISummaryTreeWithStats {
90
- const summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);
106
+ const summarizeResult = channel.getAttachSummary(fullTree, trackState, telemetryContext);
91
107
 
92
- // Add the channel attributes to the returned result.
93
- addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
94
- return summarizeResult;
108
+ // Add the channel attributes to the returned result.
109
+ addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
110
+ return summarizeResult;
95
111
  }
96
112
 
97
113
  export async function summarizeChannelAsync(
98
- channel: IChannel,
99
- fullTree: boolean = false,
100
- trackState: boolean = false,
101
- telemetryContext?: ITelemetryContext,
114
+ channel: IChannel,
115
+ fullTree: boolean = false,
116
+ trackState: boolean = false,
117
+ telemetryContext?: ITelemetryContext,
118
+ incrementalSummaryContext?: IExperimentalIncrementalSummaryContext,
102
119
  ): Promise<ISummaryTreeWithStats> {
103
- const summarizeResult = await channel.summarize(fullTree, trackState, telemetryContext);
120
+ const summarizeResult = await channel.summarize(
121
+ fullTree,
122
+ trackState,
123
+ telemetryContext,
124
+ incrementalSummaryContext,
125
+ );
126
+
127
+ // Add the channel attributes to the returned result.
128
+ addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
129
+ return summarizeResult;
130
+ }
131
+
132
+ export async function loadChannelFactoryAndAttributes(
133
+ dataStoreContext: IFluidDataStoreContext,
134
+ services: ChannelServiceEndpoints,
135
+ channelId: string,
136
+ registry: ISharedObjectRegistry,
137
+ attachMessageType?: string,
138
+ ): Promise<{ factory: IChannelFactory; attributes: IChannelAttributes }> {
139
+ let attributes: IChannelAttributes | undefined;
140
+ if (await services.objectStorage.contains(attributesBlobKey)) {
141
+ attributes = await readAndParse<IChannelAttributes | undefined>(
142
+ services.objectStorage,
143
+ attributesBlobKey,
144
+ );
145
+ }
146
+
147
+ // This is a backward compatibility case where the attach message doesn't include attributes. They must
148
+ // include attach message type.
149
+ // Since old attach messages will not have attributes, we need to keep this as long as we support old attach
150
+ // messages.
151
+ const channelFactoryType = attributes ? attributes.type : attachMessageType;
152
+ if (channelFactoryType === undefined) {
153
+ throw new DataCorruptionError(
154
+ "channelTypeNotAvailable",
155
+ tagCodeArtifacts({
156
+ channelId,
157
+ dataStoreId: dataStoreContext.id,
158
+ dataStorePackagePath: dataStoreContext.packagePath.join("/"),
159
+ channelFactoryType,
160
+ }),
161
+ );
162
+ }
163
+ const factory = registry.get(channelFactoryType);
164
+ if (factory === undefined) {
165
+ throw new DataCorruptionError(
166
+ "channelFactoryNotRegisteredForGivenType",
167
+ tagCodeArtifacts({
168
+ channelId,
169
+ dataStoreId: dataStoreContext.id,
170
+ dataStorePackagePath: dataStoreContext.packagePath.join("/"),
171
+ channelFactoryType,
172
+ }),
173
+ );
174
+ }
175
+ // This is a backward compatibility case where the attach message doesn't include attributes. Get the attributes
176
+ // from the factory.
177
+ attributes = attributes ?? factory.attributes;
178
+ return { factory, attributes };
179
+ }
104
180
 
105
- // Add the channel attributes to the returned result.
106
- addBlobToSummary(summarizeResult, attributesBlobKey, JSON.stringify(channel.attributes));
107
- return summarizeResult;
181
+ export async function loadChannel(
182
+ dataStoreRuntime: IFluidDataStoreRuntime,
183
+ attributes: IChannelAttributes,
184
+ factory: IChannelFactory,
185
+ services: ChannelServiceEndpoints,
186
+ logger: ITelemetryLoggerExt,
187
+ channelId: string,
188
+ ): Promise<IChannel> {
189
+ // Compare snapshot version to collaborative object version
190
+ if (
191
+ attributes.snapshotFormatVersion !== undefined &&
192
+ attributes.snapshotFormatVersion !== factory.attributes.snapshotFormatVersion
193
+ ) {
194
+ logger.sendTelemetryEvent({
195
+ eventName: "ChannelAttributesVersionMismatch",
196
+ ...tagCodeArtifacts({
197
+ channelType: attributes.type,
198
+ channelSnapshotVersion: `${attributes.snapshotFormatVersion}@${attributes.packageVersion}`,
199
+ channelCodeVersion: `${factory.attributes.snapshotFormatVersion}@${factory.attributes.packageVersion}`,
200
+ }),
201
+ });
202
+ }
203
+
204
+ return factory.load(dataStoreRuntime, channelId, services, attributes);
108
205
  }
@@ -3,63 +3,68 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import { assert } from "@fluidframework/common-utils";
7
- import { IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
6
+ import { assert } from "@fluidframework/core-utils";
7
+ import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
8
8
  import { IDeltaConnection, IDeltaHandler } from "@fluidframework/datastore-definitions";
9
- import { DataProcessingError } from "@fluidframework/container-utils";
9
+ import { DataProcessingError } from "@fluidframework/telemetry-utils";
10
10
  import { IFluidHandle } from "@fluidframework/core-interfaces";
11
11
 
12
12
  export class ChannelDeltaConnection implements IDeltaConnection {
13
- private _handler: IDeltaHandler | undefined;
13
+ private _handler: IDeltaHandler | undefined;
14
14
 
15
- private get handler(): IDeltaHandler {
16
- assert(!!this._handler, 0x177 /* "Missing delta handler" */);
17
- return this._handler;
18
- }
19
- public get connected(): boolean {
20
- return this._connected;
21
- }
15
+ private get handler(): IDeltaHandler {
16
+ assert(!!this._handler, 0x177 /* "Missing delta handler" */);
17
+ return this._handler;
18
+ }
19
+ public get connected(): boolean {
20
+ return this._connected;
21
+ }
22
22
 
23
- constructor(
24
- public objectId: string,
25
- private _connected: boolean,
26
- public readonly submit: (message: IDocumentMessage, localOpMetadata: unknown) => void,
27
- public readonly dirty: () => void,
28
- public readonly addedGCOutboundReference: (srcHandle: IFluidHandle, outboundHandle: IFluidHandle) => void) {
29
- }
23
+ constructor(
24
+ private _connected: boolean,
25
+ public readonly submit: (content: any, localOpMetadata: unknown) => void,
26
+ public readonly dirty: () => void,
27
+ public readonly addedGCOutboundReference: (
28
+ srcHandle: IFluidHandle,
29
+ outboundHandle: IFluidHandle,
30
+ ) => void,
31
+ ) {}
30
32
 
31
- public attach(handler: IDeltaHandler) {
32
- assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
33
- this._handler = handler;
34
- }
33
+ public attach(handler: IDeltaHandler) {
34
+ assert(this._handler === undefined, 0x178 /* "Missing delta handler on attach" */);
35
+ this._handler = handler;
36
+ }
35
37
 
36
- public setConnectionState(connected: boolean) {
37
- this._connected = connected;
38
- this.handler.setConnectionState(connected);
39
- }
38
+ public setConnectionState(connected: boolean) {
39
+ this._connected = connected;
40
+ this.handler.setConnectionState(connected);
41
+ }
40
42
 
41
- public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {
42
- try {
43
- // catches as data processing error whether or not they come from async pending queues
44
- this.handler.process(message, local, localOpMetadata);
45
- } catch (error) {
46
- throw DataProcessingError.wrapIfUnrecognized(
47
- error, "channelDeltaConnectionFailedToProcessMessage", message);
48
- }
49
- }
43
+ public process(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown) {
44
+ try {
45
+ // catches as data processing error whether or not they come from async pending queues
46
+ this.handler.process(message, local, localOpMetadata);
47
+ } catch (error) {
48
+ throw DataProcessingError.wrapIfUnrecognized(
49
+ error,
50
+ "channelDeltaConnectionFailedToProcessMessage",
51
+ message,
52
+ );
53
+ }
54
+ }
50
55
 
51
- public reSubmit(content: any, localOpMetadata: unknown) {
52
- this.handler.reSubmit(content, localOpMetadata);
53
- }
56
+ public reSubmit(content: any, localOpMetadata: unknown) {
57
+ this.handler.reSubmit(content, localOpMetadata);
58
+ }
54
59
 
55
- public rollback(content: any, localOpMetadata: unknown) {
56
- if (this.handler.rollback === undefined) {
57
- throw new Error("Handler doesn't support rollback");
58
- }
59
- this.handler.rollback(content, localOpMetadata);
60
- }
60
+ public rollback(content: any, localOpMetadata: unknown) {
61
+ if (this.handler.rollback === undefined) {
62
+ throw new Error("Handler doesn't support rollback");
63
+ }
64
+ this.handler.rollback(content, localOpMetadata);
65
+ }
61
66
 
62
- public applyStashedOp(message: ISequencedDocumentMessage): unknown {
63
- return this.handler.applyStashedOp(message);
64
- }
67
+ public applyStashedOp(content: any): unknown {
68
+ return this.handler.applyStashedOp(content);
69
+ }
65
70
  }