@fluidframework/routerlicious-driver 2.0.0-rc.1.0.6 → 2.0.0-rc.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/{.eslintrc.js → .eslintrc.cjs} +4 -1
  2. package/{.mocharc.js → .mocharc.cjs} +1 -1
  3. package/CHANGELOG.md +32 -0
  4. package/api-report/routerlicious-driver.api.md +6 -9
  5. package/dist/contracts.d.ts +1 -0
  6. package/dist/contracts.d.ts.map +1 -1
  7. package/dist/contracts.js.map +1 -1
  8. package/dist/deltaStorageService.js.map +1 -1
  9. package/dist/documentService.d.ts +2 -1
  10. package/dist/documentService.d.ts.map +1 -1
  11. package/dist/documentService.js +5 -3
  12. package/dist/documentService.js.map +1 -1
  13. package/dist/documentServiceFactory.d.ts.map +1 -1
  14. package/dist/documentServiceFactory.js +11 -9
  15. package/dist/documentServiceFactory.js.map +1 -1
  16. package/dist/errorUtils.d.ts +1 -18
  17. package/dist/errorUtils.d.ts.map +1 -1
  18. package/dist/errorUtils.js +2 -20
  19. package/dist/errorUtils.js.map +1 -1
  20. package/dist/index.d.ts +2 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +1 -2
  23. package/dist/index.js.map +1 -1
  24. package/dist/nullBlobStorageService.d.ts +0 -1
  25. package/dist/nullBlobStorageService.d.ts.map +1 -1
  26. package/dist/nullBlobStorageService.js +0 -3
  27. package/dist/nullBlobStorageService.js.map +1 -1
  28. package/dist/packageVersion.d.ts +1 -1
  29. package/dist/packageVersion.js +1 -1
  30. package/dist/packageVersion.js.map +1 -1
  31. package/dist/policies.d.ts +0 -6
  32. package/dist/policies.d.ts.map +1 -1
  33. package/dist/policies.js.map +1 -1
  34. package/dist/r11sSnapshotParser.d.ts.map +1 -1
  35. package/dist/r11sSnapshotParser.js +1 -0
  36. package/dist/r11sSnapshotParser.js.map +1 -1
  37. package/dist/restWrapper.d.ts +3 -3
  38. package/dist/restWrapper.d.ts.map +1 -1
  39. package/dist/restWrapper.js.map +1 -1
  40. package/dist/routerlicious-driver-alpha.d.ts +25 -4
  41. package/dist/routerlicious-driver-beta.d.ts +3 -4
  42. package/dist/routerlicious-driver-public.d.ts +3 -4
  43. package/dist/routerlicious-driver-untrimmed.d.ts +23 -24
  44. package/dist/routerliciousResolvedUrl.d.ts +34 -0
  45. package/dist/routerliciousResolvedUrl.d.ts.map +1 -0
  46. package/dist/routerliciousResolvedUrl.js +14 -0
  47. package/dist/routerliciousResolvedUrl.js.map +1 -0
  48. package/dist/shreddedSummaryDocumentStorageService.d.ts +0 -1
  49. package/dist/shreddedSummaryDocumentStorageService.d.ts.map +1 -1
  50. package/dist/shreddedSummaryDocumentStorageService.js +0 -1
  51. package/dist/shreddedSummaryDocumentStorageService.js.map +1 -1
  52. package/dist/tokens.d.ts +1 -2
  53. package/dist/tokens.d.ts.map +1 -1
  54. package/dist/tokens.js.map +1 -1
  55. package/dist/treeUtils.d.ts +1 -0
  56. package/dist/treeUtils.d.ts.map +1 -1
  57. package/dist/treeUtils.js +2 -0
  58. package/dist/treeUtils.js.map +1 -1
  59. package/dist/tsdoc-metadata.json +1 -1
  60. package/dist/urlUtils.d.ts +0 -2
  61. package/dist/urlUtils.d.ts.map +1 -1
  62. package/dist/urlUtils.js +9 -17
  63. package/dist/urlUtils.js.map +1 -1
  64. package/dist/wholeSummaryDocumentStorageService.d.ts +0 -1
  65. package/dist/wholeSummaryDocumentStorageService.d.ts.map +1 -1
  66. package/dist/wholeSummaryDocumentStorageService.js +0 -1
  67. package/dist/wholeSummaryDocumentStorageService.js.map +1 -1
  68. package/lib/contracts.d.mts +1 -0
  69. package/lib/contracts.d.mts.map +1 -1
  70. package/lib/contracts.mjs.map +1 -1
  71. package/lib/deltaStorageService.mjs.map +1 -1
  72. package/lib/documentService.d.mts +2 -1
  73. package/lib/documentService.d.mts.map +1 -1
  74. package/lib/documentService.mjs +5 -3
  75. package/lib/documentService.mjs.map +1 -1
  76. package/lib/documentServiceFactory.d.mts.map +1 -1
  77. package/lib/documentServiceFactory.mjs +12 -10
  78. package/lib/documentServiceFactory.mjs.map +1 -1
  79. package/lib/errorUtils.d.mts +1 -18
  80. package/lib/errorUtils.d.mts.map +1 -1
  81. package/lib/errorUtils.mjs +1 -19
  82. package/lib/errorUtils.mjs.map +1 -1
  83. package/lib/index.d.mts +2 -1
  84. package/lib/index.d.mts.map +1 -1
  85. package/lib/index.mjs +1 -1
  86. package/lib/index.mjs.map +1 -1
  87. package/lib/nullBlobStorageService.d.mts +0 -1
  88. package/lib/nullBlobStorageService.d.mts.map +1 -1
  89. package/lib/nullBlobStorageService.mjs +0 -3
  90. package/lib/nullBlobStorageService.mjs.map +1 -1
  91. package/lib/packageVersion.d.mts +1 -1
  92. package/lib/packageVersion.mjs +1 -1
  93. package/lib/packageVersion.mjs.map +1 -1
  94. package/lib/policies.d.mts +0 -6
  95. package/lib/policies.d.mts.map +1 -1
  96. package/lib/policies.mjs.map +1 -1
  97. package/lib/r11sSnapshotParser.d.mts.map +1 -1
  98. package/lib/r11sSnapshotParser.mjs +1 -0
  99. package/lib/r11sSnapshotParser.mjs.map +1 -1
  100. package/lib/restWrapper.d.mts +3 -3
  101. package/lib/restWrapper.d.mts.map +1 -1
  102. package/lib/restWrapper.mjs.map +1 -1
  103. package/lib/routerlicious-driver-alpha.d.mts +25 -4
  104. package/lib/routerlicious-driver-beta.d.mts +3 -4
  105. package/lib/routerlicious-driver-public.d.mts +3 -4
  106. package/lib/routerlicious-driver-untrimmed.d.mts +23 -24
  107. package/lib/routerliciousResolvedUrl.d.mts +34 -0
  108. package/lib/routerliciousResolvedUrl.d.mts.map +1 -0
  109. package/lib/routerliciousResolvedUrl.mjs +10 -0
  110. package/lib/routerliciousResolvedUrl.mjs.map +1 -0
  111. package/lib/shreddedSummaryDocumentStorageService.d.mts +0 -1
  112. package/lib/shreddedSummaryDocumentStorageService.d.mts.map +1 -1
  113. package/lib/shreddedSummaryDocumentStorageService.mjs +0 -1
  114. package/lib/shreddedSummaryDocumentStorageService.mjs.map +1 -1
  115. package/lib/tokens.d.mts +1 -2
  116. package/lib/tokens.d.mts.map +1 -1
  117. package/lib/tokens.mjs.map +1 -1
  118. package/lib/treeUtils.d.mts +1 -0
  119. package/lib/treeUtils.d.mts.map +1 -1
  120. package/lib/treeUtils.mjs +2 -0
  121. package/lib/treeUtils.mjs.map +1 -1
  122. package/lib/urlUtils.d.mts +0 -2
  123. package/lib/urlUtils.d.mts.map +1 -1
  124. package/lib/urlUtils.mjs +8 -12
  125. package/lib/urlUtils.mjs.map +1 -1
  126. package/lib/wholeSummaryDocumentStorageService.d.mts +0 -1
  127. package/lib/wholeSummaryDocumentStorageService.d.mts.map +1 -1
  128. package/lib/wholeSummaryDocumentStorageService.mjs +0 -1
  129. package/lib/wholeSummaryDocumentStorageService.mjs.map +1 -1
  130. package/package.json +31 -25
  131. package/src/contracts.ts +1 -0
  132. package/src/deltaStorageService.ts +3 -3
  133. package/src/documentService.ts +10 -4
  134. package/src/documentServiceFactory.ts +16 -13
  135. package/src/errorUtils.ts +2 -21
  136. package/src/index.ts +4 -1
  137. package/src/nullBlobStorageService.ts +0 -4
  138. package/src/packageVersion.ts +1 -1
  139. package/src/policies.ts +0 -6
  140. package/src/r11sSnapshotParser.ts +1 -0
  141. package/src/restWrapper.ts +3 -3
  142. package/src/routerliciousResolvedUrl.ts +39 -0
  143. package/src/shreddedSummaryDocumentStorageService.ts +0 -2
  144. package/src/tokens.ts +1 -2
  145. package/src/treeUtils.ts +3 -0
  146. package/src/urlUtils.ts +8 -13
  147. package/src/wholeSummaryDocumentStorageService.ts +0 -2
@@ -4,7 +4,10 @@
4
4
  */
5
5
 
6
6
  module.exports = {
7
- extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
7
+ extends: [
8
+ require.resolve("@fluidframework/eslint-config-fluid/minimal-deprecated"),
9
+ "prettier",
10
+ ],
8
11
  parserOptions: {
9
12
  project: ["./tsconfig.json", "./src/test/tsconfig.json"],
10
13
  },
@@ -5,7 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
8
+ const getFluidTestMochaConfig = require("@fluid-internal/mocha-test-setup/mocharc-common");
9
9
 
10
10
  const packageDir = __dirname;
11
11
  const config = getFluidTestMochaConfig(packageDir);
package/CHANGELOG.md CHANGED
@@ -1,5 +1,37 @@
1
1
  # @fluidframework/routerlicious-driver
2
2
 
3
+ ## 2.0.0-rc.2.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Resolved URLs no longer use non-standard protocols ([#19840](https://github.com/microsoft/FluidFramework/issues/19840)) [9d3d185183](https://github.com/microsoft/FluidFramework/commits/9d3d1851830d953792a6dfad60dde6f1c59480de)
8
+
9
+ Previously, `IResolvedUrl.url` could use a non-standard protocol like `fluid://`, `fluid-odsp://`, or `fluid-test://`. These have been replaced with `https://` to permit standards-compliant URL parsing.
10
+
11
+ - driver-definitions: repositoryUrl removed from IDocumentStorageService ([#19522](https://github.com/microsoft/FluidFramework/issues/19522)) [90eb3c9d33](https://github.com/microsoft/FluidFramework/commits/90eb3c9d33d80e24caa1393a50f414c5602f6aa3)
12
+
13
+ The `repositoryUrl` member of `IDocumentStorageService` was unused and always equal to the empty string. It has been removed.
14
+
15
+ - Deprecated error-related enums have been removed ([#19067](https://github.com/microsoft/FluidFramework/issues/19067)) [59793302e5](https://github.com/microsoft/FluidFramework/commits/59793302e56784cfb6ace0e6469345f3565b3312)
16
+
17
+ Error-related enums `ContainerErrorType`, `DriverErrorType`, `OdspErrorType` and `RouterliciousErrorType` were previously
18
+ deprecated and are now removed. There are replacement object-based enumerations of `ContainerErrorTypes`,
19
+ `DriverErrorTypes`, `OdspErrorTypes` and `RouterliciousErrorTypes`. Refer to the release notes of [Fluid Framework version
20
+ 2.0.0-internal.7.0.0](https://github.com/microsoft/FluidFramework/releases/tag/client_v2.0.0-internal.7.0.0) for details
21
+ on the replacements.
22
+
23
+ - routerlicious-driver: Ephemeral containers now controlled in attach() call rather than as driver policy ([#19646](https://github.com/microsoft/FluidFramework/issues/19646)) [22bd1fc045](https://github.com/microsoft/FluidFramework/commits/22bd1fc045fd6bb74eed812ddcf86ae85bd81125)
24
+
25
+ Previously, ephemeral containers were created by adding an `isEphemeralContainer` flag in `IRouterliciousDriverPolicies`. Now, it is controlled by a `createAsEphemeral` flag on the resolved URL. See <https://github.com/microsoft/FluidFramework/pull/19544> for an example of how to set this flag via your URL resolver.
26
+
27
+ - container-definitions: Added containerMetadata prop on IContainer interface ([#19142](https://github.com/microsoft/FluidFramework/issues/19142)) [d0d77f3516](https://github.com/microsoft/FluidFramework/commits/d0d77f3516d67f3c9faedb47b20dbd4e309c3bc2)
28
+
29
+ Added `containerMetadata` prop on IContainer interface.
30
+
31
+ - runtime-definitions: Moved ISignalEnvelope interface to core-interfaces ([#19142](https://github.com/microsoft/FluidFramework/issues/19142)) [d0d77f3516](https://github.com/microsoft/FluidFramework/commits/d0d77f3516d67f3c9faedb47b20dbd4e309c3bc2)
32
+
33
+ The `ISignalEnvelope` interface has been moved to the @fluidframework/core-interfaces package.
34
+
3
35
  ## 2.0.0-rc.1.0.0
4
36
 
5
37
  ### Minor Changes
@@ -39,11 +39,16 @@ export interface IRouterliciousDriverPolicies {
39
39
  enablePrefetch: boolean;
40
40
  enableRestLess: boolean;
41
41
  enableWholeSummaryUpload: boolean;
42
- isEphemeralContainer: boolean;
43
42
  maxConcurrentOrdererRequests: number;
44
43
  maxConcurrentStorageRequests: number;
45
44
  }
46
45
 
46
+ // @alpha
47
+ export interface IRouterliciousResolvedUrl extends IResolvedUrl {
48
+ createAsEphemeral?: boolean;
49
+ routerliciousResolvedUrl: true;
50
+ }
51
+
47
52
  // @public
48
53
  export interface ITokenProvider {
49
54
  documentPostCreateCallback?(documentId: string, creationToken: string): Promise<void>;
@@ -65,18 +70,10 @@ export interface ITokenService {
65
70
  // @internal
66
71
  export class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {
67
72
  constructor(tokenProvider: ITokenProvider, driverPolicies?: Partial<IRouterliciousDriverPolicies>);
68
- // (undocumented)
69
73
  createContainer(createNewSummary: ISummaryTree | undefined, resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
70
- // (undocumented)
71
74
  createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean, session?: ISession): Promise<IDocumentService>;
72
75
  }
73
76
 
74
- // @internal @deprecated
75
- export enum RouterliciousErrorType {
76
- fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
77
- sslCertError = "sslCertError"
78
- }
79
-
80
77
  // @internal
81
78
  export const RouterliciousErrorTypes: {
82
79
  readonly sslCertError: "sslCertError";
@@ -7,6 +7,7 @@ export interface IWholeFlatSnapshotTreeEntryTree {
7
7
  path: string;
8
8
  type: "tree";
9
9
  unreferenced?: true;
10
+ groupId?: string;
10
11
  }
11
12
  export interface IWholeFlatSnapshotTreeEntryBlob {
12
13
  id: string;
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAQrE,MAAM,WAAW,+BAA+B;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY,CAAC,EAAE,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,MAAM,2BAA2B,GACpC,+BAA+B,GAC/B,+BAA+B,CAAC;AAEnC,MAAM,WAAW,sBAAsB;IACtC,OAAO,EAAE,2BAA2B,EAAE,CAAC;IACvC,EAAE,EAA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C;IAChB,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,kBAAkB;IAElC,EAAE,EAAE,MAAM,CAAC;IAEX,KAAK,EAAE,sBAAsB,EAAE,CAAC;IAChC,KAAK,CAAC,EAAE,sBAAsB,EAAE,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAChC,YAAY,EAAE,aAAa,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,EAAE,EAAE,MAAM,CAAC;CACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/*\n *\n * Whole Snapshot Download Data Structures\n *\n */\n\nexport interface IWholeFlatSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n}\n\nexport interface IWholeFlatSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IWholeFlatSnapshotTreeEntry =\n\t| IWholeFlatSnapshotTreeEntryTree\n\t| IWholeFlatSnapshotTreeEntryBlob;\n\nexport interface IWholeFlatSnapshotTree {\n\tentries: IWholeFlatSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\nexport interface IWholeFlatSnapshotBlob {\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n\tid: string;\n\tsize: number;\n}\n\nexport interface IWholeFlatSnapshot {\n\t// The same as the id of the first snapshot tree in the trees array.\n\tid: string;\n\t// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.\n\ttrees: IWholeFlatSnapshotTree[];\n\tblobs?: IWholeFlatSnapshotBlob[];\n}\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSnapshot {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n"]}
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../src/contracts.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\n\n/*\n *\n * Whole Snapshot Download Data Structures\n *\n */\n\nexport interface IWholeFlatSnapshotTreeEntryTree {\n\tpath: string;\n\ttype: \"tree\";\n\t// Indicates that this tree entry is unreferenced. If this is not present, the tree entry is considered referenced.\n\tunreferenced?: true;\n\tgroupId?: string;\n}\n\nexport interface IWholeFlatSnapshotTreeEntryBlob {\n\tid: string;\n\tpath: string;\n\ttype: \"blob\";\n}\n\nexport type IWholeFlatSnapshotTreeEntry =\n\t| IWholeFlatSnapshotTreeEntryTree\n\t| IWholeFlatSnapshotTreeEntryBlob;\n\nexport interface IWholeFlatSnapshotTree {\n\tentries: IWholeFlatSnapshotTreeEntry[];\n\tid: string;\n\tsequenceNumber: number;\n}\n\nexport interface IWholeFlatSnapshotBlob {\n\tcontent: string;\n\tencoding: \"base64\" | \"utf-8\";\n\tid: string;\n\tsize: number;\n}\n\nexport interface IWholeFlatSnapshot {\n\t// The same as the id of the first snapshot tree in the trees array.\n\tid: string;\n\t// Receive an array of snapshot trees for future-proofing, however, always length 1 for now.\n\ttrees: IWholeFlatSnapshotTree[];\n\tblobs?: IWholeFlatSnapshotBlob[];\n}\n\n/**\n * Normalized Whole Summary with decoded blobs and unflattened snapshot tree.\n */\nexport interface INormalizedWholeSnapshot {\n\tblobs: Map<string, ArrayBuffer>;\n\tsnapshotTree: ISnapshotTree;\n\tsequenceNumber: number | undefined;\n\tid: string;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"deltaStorageService.js","sourceRoot":"","sources":["../src/deltaStorageService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,6DAA2E;AAQ3E,+DAKsC;AACtC,qEAAwF;AAIxF;;;;;;GAMG;AACH,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;GAEG;AACH,MAAa,2BAA2B;IACvC,YACkB,QAAgB,EAChB,EAAU,EACV,mBAAyC,EACzC,sBAA8C,EAC9C,MAA2B;QAJ3B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,OAAE,GAAF,EAAE,CAAQ;QACV,wBAAmB,GAAnB,mBAAmB,CAAsB;QACzC,2BAAsB,GAAtB,sBAAsB,CAAwB;QAC9C,WAAM,GAAN,MAAM,CAAqB;QAGrC,eAAU,GAAuB,IAAI,CAAC,sBAAsB,CAAC,UAAU,CAAC;IAF7E,CAAC;IAKJ,aAAa,CACZ,SAAiB,EACjB,OAA2B,EAC3B,WAAyB,EACzB,UAAoB,EACpB,WAAoB;QAEpB,IAAI,UAAU,EAAE;YACf,OAAO,iCAAkB,CAAC;SAC1B;QAED,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,IAAI,cAAc,GAAG,CAAC,CAAC;QACvB,MAAM,eAAe,GAAG,KAAK,EAC5B,IAAY,EACZ,EAAU,EACV,cAAoC,EACnC,EAAE;YACH,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,UAAU;gBACjC,CAAC,CAAC,MAAM,IAAA,2BAAY,EAClB,IAAI,CAAC,sBAAsB,EAC3B,IAAI,CAAC,UAAU,CACd;gBACH,CAAC,CAAC,EAAE,CAAC;YACN,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAE5B,IAAI,IAAI,CAAC,WAAW,KAAK,S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AAI,CAAC,MAAM,EACX;YACC,SAAS,EAAE,UAAU;YACrB,IAAI;YACJ,EAAE;SACF,EACD,KAAK,EAAE,KAAK,EAAE,EAAE;YACf,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAA8B,GAAG,EAAE;gBACxE,IAAI,EAAE,IAAI,GAAG,CAAC;gBACd,EAAE;aACF,CAAC,CAAC;YACH,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;gBAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc;oBACrD,eAAe,EACd,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,cAAc;iBAC9D,CAAC;gBACF,GAAG,QAAQ,CAAC,UAAU;gBACtB,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;aACpD,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD;AA/CD,kDA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryProperties } from \"@fluidframework/core-interfaces\";\nimport { getW3CData, validateMessages } from \"@fluidframework/driver-base\";\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\treadAndParse,\n\trequestOps,\n\temptyMessageStream,\n\tstreamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { RestWrapper } from \"./restWrapperBase\";\n\n/**\n * Maximum number of ops we can fetch at a time. This should be kept at 2k, as\n * server determines whether to try to fallback to long-term storage if the ops range requested is larger than\n * what they have locally available in short-term storage. So if we request 2k ops, they know it is not a\n * specific request and they don't fall to long term storage which takes time.\n * Please coordinate to AFR team if this value need to be changed.\n */\nconst MaxBatchDeltas = 2000;\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined;\n\n\tfetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromStorage = 0;\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryProperties,\n\t\t) => {\n\t\t\tthis.snapshotOps = this.logtailSha\n\t\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\t\tthis.logtailSha,\n\t\t\t\t )\n\t\t\t\t: [];\n\t\t\tthis.logtailSha = undefined;\n\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"snapshotOps\", messages, from, this.logger, false /* strict */);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\tconst ops = await this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger, false /* strict */);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tlength: response.content.length,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tfirstOpSeqNumber: response.content[0]?.sequenceNumber,\n\t\t\t\t\t\tlastOpSeqNumber:\n\t\t\t\t\t\t\tresponse.content[response.content.length - 1]?.sequenceNumber,\n\t\t\t\t\t}),\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
1
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,cAAc,EAAE,CAAC;YAChD,MAAM,GAAG,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC;YACtC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,GAAG,CAA8B,GAAG,EAAE;gBACxE,IAAI,EAAE,IAAI,GAAG,CAAC;gBACd,EAAE;aACF,CAAC,CAAC;YACH,KAAK,CAAC,GAAG,CAAC;gBACT,MAAM,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM;gBAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,gBAAgB,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,cAAc;oBACrD,eAAe,EACd,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,cAAc;iBAC9D,CAAC;gBACF,GAAG,QAAQ,CAAC,UAAU;gBACtB,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;aACpD,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,OAAO,CAAC;QACzB,CAAC,CACD,CAAC;QAEF,oGAAoG;QACpG,4GAA4G;QAC5G,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAChD,CAAC;CACD;AA/CD,kDA+CC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { getW3CData, validateMessages } from \"@fluidframework/driver-base\";\nimport {\n\tIDeltaStorageService,\n\tIDocumentDeltaStorageService,\n\tIDeltasFetchResult,\n\tIStream,\n} from \"@fluidframework/driver-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\nimport {\n\treadAndParse,\n\trequestOps,\n\temptyMessageStream,\n\tstreamObserver,\n} from \"@fluidframework/driver-utils\";\nimport { ITelemetryLoggerExt, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { RestWrapper } from \"./restWrapperBase\";\n\n/**\n * Maximum number of ops we can fetch at a time. This should be kept at 2k, as\n * server determines whether to try to fallback to long-term storage if the ops range requested is larger than\n * what they have locally available in short-term storage. So if we request 2k ops, they know it is not a\n * specific request and they don't fall to long term storage which takes time.\n * Please coordinate to AFR team if this value need to be changed.\n */\nconst MaxBatchDeltas = 2000;\n\n/**\n * Storage service limited to only being able to fetch documents for a specific document\n */\nexport class DocumentDeltaStorageService implements IDocumentDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly tenantId: string,\n\t\tprivate readonly id: string,\n\t\tprivate readonly deltaStorageService: IDeltaStorageService,\n\t\tprivate readonly documentStorageService: DocumentStorageService,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t) {}\n\n\tprivate logtailSha: string | undefined = this.documentStorageService.logTailSha;\n\tprivate snapshotOps: ISequencedDocumentMessage[] | undefined;\n\n\tfetchMessages(\n\t\tfromTotal: number,\n\t\ttoTotal: number | undefined,\n\t\tabortSignal?: AbortSignal,\n\t\tcachedOnly?: boolean,\n\t\tfetchReason?: string,\n\t): IStream<ISequencedDocumentMessage[]> {\n\t\tif (cachedOnly) {\n\t\t\treturn emptyMessageStream;\n\t\t}\n\n\t\tlet opsFromSnapshot = 0;\n\t\tlet opsFromStorage = 0;\n\t\tconst requestCallback = async (\n\t\t\tfrom: number,\n\t\t\tto: number,\n\t\t\ttelemetryProps: ITelemetryBaseProperties,\n\t\t) => {\n\t\t\tthis.snapshotOps = this.logtailSha\n\t\t\t\t? await readAndParse<ISequencedDocumentMessage[]>(\n\t\t\t\t\t\tthis.documentStorageService,\n\t\t\t\t\t\tthis.logtailSha,\n\t\t\t\t )\n\t\t\t\t: [];\n\t\t\tthis.logtailSha = undefined;\n\n\t\t\tif (this.snapshotOps !== undefined && this.snapshotOps.length !== 0) {\n\t\t\t\tconst messages = this.snapshotOps.filter(\n\t\t\t\t\t(op) => op.sequenceNumber >= from && op.sequenceNumber < to,\n\t\t\t\t);\n\t\t\t\tvalidateMessages(\"snapshotOps\", messages, from, this.logger, false /* strict */);\n\t\t\t\tif (messages.length > 0 && messages[0].sequenceNumber === from) {\n\t\t\t\t\tthis.snapshotOps = this.snapshotOps.filter((op) => op.sequenceNumber >= to);\n\t\t\t\t\topsFromSnapshot += messages.length;\n\t\t\t\t\treturn { messages, partialResult: true };\n\t\t\t\t}\n\t\t\t\tthis.snapshotOps = undefined;\n\t\t\t}\n\n\t\t\tconst ops = await this.deltaStorageService.get(this.tenantId, this.id, from, to);\n\t\t\tvalidateMessages(\"storage\", ops.messages, from, this.logger, false /* strict */);\n\t\t\topsFromStorage += ops.messages.length;\n\t\t\treturn ops;\n\t\t};\n\n\t\tconst stream = requestOps(\n\t\t\tasync (from: number, to: number, telemetryProps: ITelemetryBaseProperties) => {\n\t\t\t\tconst result = await requestCallback(from, to, telemetryProps);\n\t\t\t\t// Catch all case, just in case\n\t\t\t\tvalidateMessages(\"catch all\", result.messages, from, this.logger);\n\t\t\t\treturn result;\n\t\t\t},\n\t\t\t// Staging: starting with no concurrency, listening for feedback first.\n\t\t\t// In future releases we will switch to actual concurrency\n\t\t\t1, // concurrency\n\t\t\tfromTotal, // inclusive\n\t\t\ttoTotal, // exclusive\n\t\t\tMaxBatchDeltas,\n\t\t\tthis.logger,\n\t\t\tabortSignal,\n\t\t\tfetchReason,\n\t\t);\n\n\t\treturn streamObserver(stream, (result) => {\n\t\t\tif (result.done && opsFromSnapshot + opsFromStorage !== 0) {\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"CacheOpsRetrieved\",\n\t\t\t\t\topsFromSnapshot,\n\t\t\t\t\topsFromStorage,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n}\n\n/**\n * Provides access to the underlying delta storage on the server for routerlicious driver.\n */\nexport class DeltaStorageService implements IDeltaStorageService {\n\tconstructor(\n\t\tprivate readonly url: string,\n\t\tprivate readonly restWrapper: RestWrapper,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly getRestWrapper: () => Promise<RestWrapper> = async () => this.restWrapper,\n\t\tprivate readonly getDeltaStorageUrl: () => string = () => this.url,\n\t) {}\n\n\tpublic async get(\n\t\ttenantId: string,\n\t\tid: string,\n\t\tfrom: number, // inclusive\n\t\tto: number, // exclusive\n\t): Promise<IDeltasFetchResult> {\n\t\tconst ops = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: \"OpsFetch\",\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst restWrapper = await this.getRestWrapper();\n\t\t\t\tconst url = this.getDeltaStorageUrl();\n\t\t\t\tconst response = await restWrapper.get<ISequencedDocumentMessage[]>(url, {\n\t\t\t\t\tfrom: from - 1,\n\t\t\t\t\tto,\n\t\t\t\t});\n\t\t\t\tevent.end({\n\t\t\t\t\tlength: response.content.length,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tfirstOpSeqNumber: response.content[0]?.sequenceNumber,\n\t\t\t\t\t\tlastOpSeqNumber:\n\t\t\t\t\t\t\tresponse.content[response.content.length - 1]?.sequenceNumber,\n\t\t\t\t\t}),\n\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t});\n\t\t\t\treturn response.content;\n\t\t\t},\n\t\t);\n\n\t\t// It is assumed that server always returns all the ops that it has in the range that was requested.\n\t\t// This may change in the future, if so, we need to adjust and receive \"end\" value from server in such case.\n\t\treturn { messages: ops, partialResult: false };\n\t}\n}\n"]}
@@ -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
+ import { TypedEventEmitter } from "@fluid-internal/client-utils";
5
6
  import * as api from "@fluidframework/driver-definitions";
6
7
  import { IClient } from "@fluidframework/protocol-definitions";
7
8
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
@@ -15,7 +16,7 @@ import { INormalizedWholeSnapshot } from "./contracts";
15
16
  * The DocumentService manages the Socket.IO connection and manages routing requests to connected
16
17
  * clients.
17
18
  */
18
- export declare class DocumentService implements api.IDocumentService {
19
+ export declare class DocumentService extends TypedEventEmitter<api.IDocumentServiceEvents> implements api.IDocumentService {
19
20
  private _resolvedUrl;
20
21
  protected ordererUrl: string;
21
22
  private deltaStorageUrl;
@@ -1 +1 @@
1
- {"version":3,"file":"documentService.d.ts","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,GAAG,MAAM,oCAAoC,CAAC;AAG1D,OAAO,EAAE,OAAO,EAAE,MAAM,sCAAsC,CAAC;AAE/D,OAAO,EAA+B,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAKnG,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EACN,+BAA+B,EAC/B,+BAA+B,EAC/B,YAAY,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAKrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAUvD;;;GAGG;AAEH,qBAAa,eAAgB,YAAW,GAAG,CAAC,gBAAgB;IAY1D,OAAO,CAAC,YAAY;IACpB,SAAS,CAAC,UAAU,EAAE,MAAM;IAC5B,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,SAAS,CAAC,aAAa,EAAE,cAAc;IACvC,SAAS,CAAC,Q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AAY,CAAC,EAClE,kBAAkB,EAAE,+BAA+B,EAC1C,mBAAmB,EAAE,YAAY,EACjC,mBAAmB,EAAE,YAAY;IAKnD,OAAO,CAAC,sBAAsB,CAAqC;IAE5D,OAAO;IAEd;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;IA0DrE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC;IAsC/E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IA+EzF;;OAEG;YACW,gBAAgB;YAahB,oBAAoB;IASlC;;OAEG;IACH,OAAO,CAAC,iCAAiC;CAsBzC"}
@@ -8,11 +8,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
8
8
  };
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.DocumentService = void 0;
11
+ const client_utils_1 = require("@fluid-internal/client-utils");
11
12
  const core_utils_1 = require("@fluidframework/core-utils");
12
- const driver_definitions_1 = require("@fluidframework/driver-definitions");
13
13
  const driver_utils_1 = require("@fluidframework/driver-utils");
14
14
  const socket_io_client_1 = __importDefault(require("socket.io-client"));
15
15
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
16
+ const errorUtils_1 = require("./errorUtils");
16
17
  const deltaStorageService_1 = require("./deltaStorageService");
17
18
  const documentStorageService_1 = require("./documentStorageService");
18
19
  const documentDeltaConnection_1 = require("./documentDeltaConnection");
@@ -33,11 +34,12 @@ const RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute
33
34
  * clients.
34
35
  */
35
36
  // eslint-disable-next-line import/namespace
36
- class DocumentService {
37
+ class DocumentService extends client_utils_1.TypedEventEmitter {
37
38
  get resolvedUrl() {
38
39
  return this._resolvedUrl;
39
40
  }
40
41
  constructor(_resolvedUrl, ordererUrl, deltaStorageUrl, deltaStreamUrl, storageUrl, logger, tokenProvider, tenantId, documentId, ordererRestWrapper, documentStorageServicePolicies, driverPolicies, blobCache, wholeSnapshotTreeCache, shreddedSummaryTreeCache, discoverFluidResolvedUrl, storageRestWrapper, storageTokenFetcher, ordererTokenFetcher) {
42
+ super();
41
43
  this._resolvedUrl = _resolvedUrl;
42
44
  this.ordererUrl = ordererUrl;
43
45
  this.deltaStorageUrl = deltaStorageUrl;
@@ -142,7 +144,7 @@ class DocumentService {
142
144
  this.ordererRestWrapper.setToken(newOrdererToken);
143
145
  return newOrdererToken;
144
146
  }, (error) => {
145
- const tokenError = (0, telemetry_utils_1.wrapError)(error, (errorMessage) => new driver_utils_1.NetworkErrorBasic(`The Host-provided token fetcher threw an error`, driver_definitions_1.DriverErrorTypes.fetchTokenError, (0, driver_utils_1.canRetryOnError)(error), { errorMessage, driverVersion: packageVersion_1.pkgVersion }));
147
+ const tokenError = (0, telemetry_utils_1.wrapError)(error, (errorMessage) => new driver_utils_1.NetworkErrorBasic(`The Host-provided token fetcher threw an error`, errorUtils_1.RouterliciousErrorTypes.fetchTokenError, (0, driver_utils_1.canRetryOnError)(error), { errorMessage, driverVersion: packageVersion_1.pkgVersion }));
146
148
  throw tokenError;
147
149
  }));
148
150
  }
@@ -1 +1 @@
1
- {"version":3,"file":"documentService.js","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2DAAoD;AAEpD,2EAAsE;AACtE,+DAA+F;AAE/F,wEAAkC;AAClC,qEAAmG;AACnG,+DAAyF;AACzF,qEAAkE;AAClE,uEAAwE;AACxE,qEAAkE;AAElE,+CAIuB;AAIvB,qDAA+D;AAC/D,6CAA0C;AAC1C,2CAAwC;AAIxC;;;;;GAKG;AACH,MAAM,mCAAmC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,WAAW;AAElE;;;GAGG;AACH,4CAA4C;AAC5C,MAAa,eAAe;IAO3B,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,YAAY,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C;QAC/D,IAAI,CAAC,YAAY,GAAG,gBAAgB,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC;QACxD,IAAI,CAAC,eAAe,GAAG,gBAAgB,CAAC,SAAS,CAAC,eAAe,CAAC;QAClE,IAAI,CAAC,cAAc,GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;IACpF,CAAC;IAED;;OAEG;IACK,iCAAiC;QACxC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,oGAAoG;QACpG,6DAA6D;QAC7D,+FAA+F;QAC/F,8DAA8D;QAC9D,MAAM,8BAA8B,GACnC,GAAG,GAAG,IAAI,CAAC,gBAAgB,GAAG,mCAAmC,CAAC;QACnE,IAAI,8BAA8B,EAAE;YACnC,gDAAgD;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAClC,oEAAoE;gBACpE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACH;QACD,OAAO,8BAA8B,CAAC;IACvC,CAAC;CACD;AArRD,0CAqRC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { DriverErrorTypes } from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NetworkErrorBasic, canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport io from \"socket.io-client\";\nimport { PerformanceEvent, wrapError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\tTokenFetcher,\n} from \"./restWrapper\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { GitManager } from \"./gitManager\";\nimport { Historian } from \"./historian\";\nimport { RestWrapper } from \"./restWrapperBase\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Amount of time between discoveries within which we don't need to rediscover on re-connect.\n * Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,\n * we set the limit to 5 minutes here.\n * In the future, we likely want to retrieve this information from service's \"inactive session\" definition.\n */\nconst RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\n// eslint-disable-next-line import/namespace\nexport class DocumentService implements api.IDocumentService {\n\tprivate lastDiscoveredAt: number = Date.now();\n\tprivate discoverP: Promise<void> | undefined;\n\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: api.IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,\n\t\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly discoverFluidResolvedUrl: () => Promise<api.IResolvedUrl>,\n\t\tprivate storageRestWrapper: RouterliciousStorageRestWrapper,\n\t\tprivate readonly storageTokenFetcher: TokenFetcher,\n\t\tprivate readonly ordererTokenFetcher: TokenFetcher,\n\t) {}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<api.IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!this.storageManager ||\n\t\t\t\t!this.noCacheStorageManager ||\n\t\t\t\tshouldUpdateDiscoveredSessionInfo\n\t\t\t) {\n\t\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t\t);\n\t\t\t\t\tthis.storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.storageTokenFetcher,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\trateLimiter,\n\t\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\t\tthis.storageUrl,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst historian = new Historian(true, false, this.storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(true, true, this.storageRestWrapper);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\tthis.driverPolicies.maxConcurrentOrdererRequests,\n\t\t\t\t);\n\t\t\t\tthis.ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.ordererTokenFetcher,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = await this.ordererRestWrapper.getToken();\n\t\t\tif (this.shouldUpdateDiscoveredSessionInfo()) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tDriverErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tio,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\tundefined /* timeoutMs */,\n\t\t\t\t\t\tthis.driverPolicies.enableLongPollingDowngrade,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (error?.statusCode === 401) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Re-discover session URLs if necessary.\n\t */\n\tprivate async refreshDiscovery(): Promise<void> {\n\t\tif (!this.discoverP) {\n\t\t\tthis.discoverP = PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"RefreshDiscovery\",\n\t\t\t\t},\n\t\t\t\tasync () => this.refreshDiscoveryCore(),\n\t\t\t);\n\t\t}\n\t\treturn this.discoverP;\n\t}\n\n\tprivate async refreshDiscoveryCore(): Promise<void> {\n\t\tconst fluidResolvedUrl = await this.discoverFluidResolvedUrl();\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;\n\t}\n\n\t/**\n\t * Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.\n\t */\n\tprivate shouldUpdateDiscoveredSessionInfo(): boolean {\n\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\treturn false;\n\t\t}\n\t\tconst now = Date.now();\n\t\t// When connection is disconnected, we cannot know if session has moved or document has been deleted\n\t\t// without re-doing discovery on the next attempt to connect.\n\t\t// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,\n\t\t// re-discover if enough time has passed since last discovery.\n\t\tconst pastLastDiscoveryTimeThreshold =\n\t\t\tnow - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;\n\t\tif (pastLastDiscoveryTimeThreshold) {\n\t\t\t// Reset discover promise and refresh discovery.\n\t\t\tthis.lastDiscoveredAt = Date.now();\n\t\t\tthis.discoverP = undefined;\n\t\t\tthis.refreshDiscovery().catch(() => {\n\t\t\t\t// Undo discovery time set on failure, so that next check refreshes.\n\t\t\t\tthis.lastDiscoveredAt = 0;\n\t\t\t});\n\t\t}\n\t\treturn pastLastDiscoveryTimeThreshold;\n\t}\n}\n"]}
1
+ {"version":3,"file":"documentService.js","sourceRoot":"","sources":["../src/documentService.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,+DAAiE;AACjE,2DAAoD;AAEpD,+DAA+F;AAE/F,wEAAkC;AAClC,qEAAmG;AACnG,6CAAuD;AACvD,+DAAyF;AACzF,qEAAkE;AAClE,uEAAwE;AACxE,qEAAkE;AAElE,+CAIuB;AAIvB,qDAA+D;AAC/D,6CAA0C;AAC1C,2CAAwC;AAIxC;;;;;GAKG;AACH,MAAM,mCAAmC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,WAAW;AAElE;;;GAGG;AACH,4CAA4C;AAC5C,MAAa,eACZ,SAAQ,gCAA6C;IASrD,IAAW,WAAW;QACrB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC1B,CAAC;IAED,YACS,YAA8B,EAC5B,UAAkB,EACpB,eAAuB,EACvB,cAAsB,EACtB,UAAkB,EACT,MAA2B,EAClC,aAA6B,EAC7B,QAAgB,EAChB,UAAkB,EAClB,kBAAmD,EAC5C,8BAAmE,EACnE,cAA4C,EAC5C,SAAkC,EAClC,sBAAwD,EACxD,wBAAsD,EACtD,wBAAyD,EAClE,kBAAmD,EAC1C,mBAAiC,EACjC,mBAAiC;QAElD,KAAK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GAAG,gBAAgB,CAAC,SAAS,CAAC,cAAc,IAAI,IAAI,CAAC,UAAU,CAAC;IACpF,CAAC;IAED;;OAEG;IACK,iCAAiC;QACxC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE;YACzC,OAAO,KAAK,CAAC;SACb;QACD,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,oGAAoG;QACpG,6DAA6D;QAC7D,+FAA+F;QAC/F,8DAA8D;QAC9D,MAAM,8BAA8B,GACnC,GAAG,GAAG,IAAI,CAAC,gBAAgB,GAAG,mCAAmC,CAAC;QACnE,IAAI,8BAA8B,EAAE;YACnC,gDAAgD;YAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;YAC3B,IAAI,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;gBAClC,oEAAoE;gBACpE,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;SACH;QACD,OAAO,8BAA8B,CAAC;IACvC,CAAC;CACD;AA1RD,0CA0RC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { TypedEventEmitter } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport * as api from \"@fluidframework/driver-definitions\";\nimport { RateLimiter, NetworkErrorBasic, canRetryOnError } from \"@fluidframework/driver-utils\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\nimport io from \"socket.io-client\";\nimport { PerformanceEvent, wrapError, ITelemetryLoggerExt } from \"@fluidframework/telemetry-utils\";\nimport { RouterliciousErrorTypes } from \"./errorUtils\";\nimport { DeltaStorageService, DocumentDeltaStorageService } from \"./deltaStorageService\";\nimport { DocumentStorageService } from \"./documentStorageService\";\nimport { R11sDocumentDeltaConnection } from \"./documentDeltaConnection\";\nimport { NullBlobStorageService } from \"./nullBlobStorageService\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\tTokenFetcher,\n} from \"./restWrapper\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ICache } from \"./cache\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { GitManager } from \"./gitManager\";\nimport { Historian } from \"./historian\";\nimport { RestWrapper } from \"./restWrapperBase\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\n/**\n * Amount of time between discoveries within which we don't need to rediscover on re-connect.\n * Currently, R11s defines session length at 10 minutes. To avoid any weird unknown edge-cases though,\n * we set the limit to 5 minutes here.\n * In the future, we likely want to retrieve this information from service's \"inactive session\" definition.\n */\nconst RediscoverAfterTimeSinceDiscoveryMs = 5 * 60000; // 5 minute\n\n/**\n * The DocumentService manages the Socket.IO connection and manages routing requests to connected\n * clients.\n */\n// eslint-disable-next-line import/namespace\nexport class DocumentService\n\textends TypedEventEmitter<api.IDocumentServiceEvents>\n\timplements api.IDocumentService\n{\n\tprivate lastDiscoveredAt: number = Date.now();\n\tprivate discoverP: Promise<void> | undefined;\n\n\tprivate storageManager: GitManager | undefined;\n\tprivate noCacheStorageManager: GitManager | undefined;\n\n\tpublic get resolvedUrl() {\n\t\treturn this._resolvedUrl;\n\t}\n\n\tconstructor(\n\t\tprivate _resolvedUrl: api.IResolvedUrl,\n\t\tprotected ordererUrl: string,\n\t\tprivate deltaStorageUrl: string,\n\t\tprivate deltaStreamUrl: string,\n\t\tprivate storageUrl: string,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprotected tokenProvider: ITokenProvider,\n\t\tprotected tenantId: string,\n\t\tprotected documentId: string,\n\t\tprotected ordererRestWrapper: RouterliciousOrdererRestWrapper,\n\t\tprivate readonly documentStorageServicePolicies: api.IDocumentStorageServicePolicies,\n\t\tprivate readonly driverPolicies: IRouterliciousDriverPolicies,\n\t\tprivate readonly blobCache: ICache<ArrayBufferLike>,\n\t\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot>,\n\t\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion>,\n\t\tprivate readonly discoverFluidResolvedUrl: () => Promise<api.IResolvedUrl>,\n\t\tprivate storageRestWrapper: RouterliciousStorageRestWrapper,\n\t\tprivate readonly storageTokenFetcher: TokenFetcher,\n\t\tprivate readonly ordererTokenFetcher: TokenFetcher,\n\t) {\n\t\tsuper();\n\t}\n\n\tprivate documentStorageService: DocumentStorageService | undefined;\n\n\tpublic dispose() {}\n\n\t/**\n\t * Connects to a storage endpoint for snapshot service.\n\t *\n\t * @returns returns the document storage service for routerlicious driver.\n\t */\n\tpublic async connectToStorage(): Promise<api.IDocumentStorageService> {\n\t\tif (this.documentStorageService !== undefined) {\n\t\t\treturn this.documentStorageService;\n\t\t}\n\n\t\tif (this.storageUrl === undefined) {\n\t\t\treturn new NullBlobStorageService();\n\t\t}\n\n\t\tconst getStorageManager = async (disableCache?: boolean): Promise<GitManager> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\t\t\tif (\n\t\t\t\t!this.storageManager ||\n\t\t\t\t!this.noCacheStorageManager ||\n\t\t\t\tshouldUpdateDiscoveredSessionInfo\n\t\t\t) {\n\t\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\t\tthis.driverPolicies.maxConcurrentStorageRequests,\n\t\t\t\t\t);\n\t\t\t\t\tthis.storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.storageTokenFetcher,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\trateLimiter,\n\t\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t\t\tthis.storageUrl,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst historian = new Historian(true, false, this.storageRestWrapper);\n\t\t\t\tthis.storageManager = new GitManager(historian);\n\t\t\t\tconst noCacheHistorian = new Historian(true, true, this.storageRestWrapper);\n\t\t\t\tthis.noCacheStorageManager = new GitManager(noCacheHistorian);\n\t\t\t}\n\n\t\t\treturn disableCache ? this.noCacheStorageManager : this.storageManager;\n\t\t};\n\t\t// Initialize storageManager and noCacheStorageManager\n\t\tconst storageManager = await getStorageManager();\n\t\tconst noCacheStorageManager = await getStorageManager(true);\n\t\tthis.documentStorageService = new DocumentStorageService(\n\t\t\tthis.documentId,\n\t\t\tstorageManager,\n\t\t\tthis.logger,\n\t\t\tthis.documentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tnoCacheStorageManager,\n\t\t\tgetStorageManager,\n\t\t);\n\t\treturn this.documentStorageService;\n\t}\n\n\t/**\n\t * Connects to a delta storage endpoint for getting ops between a range.\n\t *\n\t * @returns returns the document delta storage service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStorage(): Promise<api.IDocumentDeltaStorageService> {\n\t\tawait this.connectToStorage();\n\t\tassert(!!this.documentStorageService, 0x0b1 /* \"Storage service not initialized\" */);\n\n\t\tconst getRestWrapper = async (): Promise<RestWrapper> => {\n\t\t\tconst shouldUpdateDiscoveredSessionInfo = this.shouldUpdateDiscoveredSessionInfo();\n\n\t\t\tif (shouldUpdateDiscoveredSessionInfo) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t\tconst rateLimiter = new RateLimiter(\n\t\t\t\t\tthis.driverPolicies.maxConcurrentOrdererRequests,\n\t\t\t\t);\n\t\t\t\tthis.ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\t\t\tthis.ordererTokenFetcher,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\trateLimiter,\n\t\t\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn this.ordererRestWrapper;\n\t\t};\n\t\tconst restWrapper = await getRestWrapper();\n\t\tconst deltaStorageService = new DeltaStorageService(\n\t\t\tthis.deltaStorageUrl,\n\t\t\trestWrapper,\n\t\t\tthis.logger,\n\t\t\tgetRestWrapper,\n\t\t\t() => this.deltaStorageUrl,\n\t\t);\n\t\treturn new DocumentDeltaStorageService(\n\t\t\tthis.tenantId,\n\t\t\tthis.documentId,\n\t\t\tdeltaStorageService,\n\t\t\tthis.documentStorageService,\n\t\t\tthis.logger,\n\t\t);\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for routerlicious driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<api.IDocumentDeltaConnection> {\n\t\tconst connect = async (refreshToken?: boolean) => {\n\t\t\tlet ordererToken = await this.ordererRestWrapper.getToken();\n\t\t\tif (this.shouldUpdateDiscoveredSessionInfo()) {\n\t\t\t\tawait this.refreshDiscovery();\n\t\t\t}\n\n\t\t\tif (refreshToken) {\n\t\t\t\tordererToken = await PerformanceEvent.timedExecAsync(\n\t\t\t\t\tthis.logger,\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"GetDeltaStreamToken\",\n\t\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\t\trefreshToken,\n\t\t\t\t\t\t}),\n\t\t\t\t\t},\n\t\t\t\t\tasync () =>\n\t\t\t\t\t\tthis.tokenProvider\n\t\t\t\t\t\t\t.fetchOrdererToken(this.tenantId, this.documentId, refreshToken)\n\t\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\t\t(newOrdererToken) => {\n\t\t\t\t\t\t\t\t\tthis.ordererRestWrapper.setToken(newOrdererToken);\n\t\t\t\t\t\t\t\t\treturn newOrdererToken;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t(error) => {\n\t\t\t\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\t\t\t\tRouterliciousErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\t\t\t\tcanRetryOnError(error),\n\t\t\t\t\t\t\t\t\t\t\t\t{ errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"ConnectToDeltaStream\",\n\t\t\t\t\tdocId: this.documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\treturn R11sDocumentDeltaConnection.create(\n\t\t\t\t\t\tthis.tenantId,\n\t\t\t\t\t\tthis.documentId,\n\t\t\t\t\t\tordererToken.jwt,\n\t\t\t\t\t\tio,\n\t\t\t\t\t\tclient,\n\t\t\t\t\t\tthis.deltaStreamUrl,\n\t\t\t\t\t\tthis.logger,\n\t\t\t\t\t\tundefined /* timeoutMs */,\n\t\t\t\t\t\tthis.driverPolicies.enableLongPollingDowngrade,\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t);\n\t\t};\n\n\t\t// Attempt to establish connection.\n\t\t// Retry with new token on authorization error; otherwise, allow container layer to handle.\n\t\ttry {\n\t\t\tconst connection = await connect();\n\t\t\treturn connection;\n\t\t} catch (error: any) {\n\t\t\tif (error?.statusCode === 401) {\n\t\t\t\t// Fetch new token and retry once,\n\t\t\t\t// otherwise 401 will be bubbled up as non-retriable AuthorizationError.\n\t\t\t\treturn connect(true /* refreshToken */);\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\t/**\n\t * Re-discover session URLs if necessary.\n\t */\n\tprivate async refreshDiscovery(): Promise<void> {\n\t\tif (!this.discoverP) {\n\t\t\tthis.discoverP = PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"RefreshDiscovery\",\n\t\t\t\t},\n\t\t\t\tasync () => this.refreshDiscoveryCore(),\n\t\t\t);\n\t\t}\n\t\treturn this.discoverP;\n\t}\n\n\tprivate async refreshDiscoveryCore(): Promise<void> {\n\t\tconst fluidResolvedUrl = await this.discoverFluidResolvedUrl();\n\t\tthis._resolvedUrl = fluidResolvedUrl;\n\t\tthis.storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tthis.ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tthis.deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tthis.deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || this.ordererUrl;\n\t}\n\n\t/**\n\t * Whether enough time has passed since last disconnect to warrant a new discovery call on reconnect.\n\t */\n\tprivate shouldUpdateDiscoveredSessionInfo(): boolean {\n\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\treturn false;\n\t\t}\n\t\tconst now = Date.now();\n\t\t// When connection is disconnected, we cannot know if session has moved or document has been deleted\n\t\t// without re-doing discovery on the next attempt to connect.\n\t\t// Disconnect event is not so reliable in local testing. To ensure re-discovery when necessary,\n\t\t// re-discover if enough time has passed since last discovery.\n\t\tconst pastLastDiscoveryTimeThreshold =\n\t\t\tnow - this.lastDiscoveredAt > RediscoverAfterTimeSinceDiscoveryMs;\n\t\tif (pastLastDiscoveryTimeThreshold) {\n\t\t\t// Reset discover promise and refresh discovery.\n\t\t\tthis.lastDiscoveredAt = Date.now();\n\t\t\tthis.discoverP = undefined;\n\t\t\tthis.refreshDiscovery().catch(() => {\n\t\t\t\t// Undo discovery time set on failure, so that next check refreshes.\n\t\t\t\tthis.lastDiscoveredAt = 0;\n\t\t\t});\n\t\t}\n\t\treturn pastLastDiscoveryTimeThreshold;\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"documentServiceFactory.d.ts","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAEN,gBAAgB,EAChB,uBAAuB,EAEvB,YAAY,EAEZ,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAQpE,OAAO,EACN,QAAQ,EAER,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AA2B1C;;;;GAIG;AACH,qBAAa,mCAAoC,YAAW,uBAAuB;IAOjF,OAAO,CAAC,QAAQ,CAAC,aAAa;IAN/B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA+B;IAC9D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IACpD,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAAqD;IAC5F,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAiD;gBAGxE,aAAa,EAAE,cAAc,EAC9C,cAAc,GAAE,OAAO,CAAC,4BAA4B,CAAM;IAuB3D;;;;;OAKG;IACU,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B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KG;IACU,eAAe,CAC3B,gBAAgB,EAAE,YAAY,GAAG,SAAS,EAC1C,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,gBAAgB,CAAC;IAwI5B;;;;OAIG;IACU,qBAAqB,CACjC,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,EAC5B,OAAO,CAAC,EAAE,QAAQ,GAChB,OAAO,CAAC,gBAAgB,CAAC;CAwH5B;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAEhD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU;;IAH3B;;OAEG;IACc,UAAU,EAAE,KAAK;IAKnC,SAAgB,IAAI,6BAA6B;IAEjD,IAAW,KAAK,uBAEf;CACD"}
@@ -11,11 +11,12 @@ const driver_definitions_1 = require("@fluidframework/driver-definitions");
11
11
  const driver_utils_1 = require("@fluidframework/driver-utils");
12
12
  const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
13
13
  const server_services_client_1 = require("@fluidframework/server-services-client");
14
+ const cache_1 = require("./cache");
14
15
  const documentService_1 = require("./documentService");
16
+ const packageVersion_1 = require("./packageVersion");
15
17
  const restWrapper_1 = require("./restWrapper");
18
+ const routerliciousResolvedUrl_1 = require("./routerliciousResolvedUrl");
16
19
  const urlUtils_1 = require("./urlUtils");
17
- const cache_1 = require("./cache");
18
- const packageVersion_1 = require("./packageVersion");
19
20
  const maximumSnapshotCacheDurationMs = 432000000; // 5 days in ms
20
21
  const defaultRouterliciousDriverPolicies = {
21
22
  enablePrefetch: true,
@@ -26,7 +27,6 @@ const defaultRouterliciousDriverPolicies = {
26
27
  enableRestLess: true,
27
28
  enableInternalSummaryCaching: true,
28
29
  enableLongPollingDowngrade: true,
29
- isEphemeralContainer: false,
30
30
  };
31
31
  /**
32
32
  * Factory for creating the routerlicious document service. Use this if you want to
@@ -65,7 +65,7 @@ class RouterliciousDocumentServiceFactory {
65
65
  throw new Error("Empty file summary creation isn't supported in this driver.");
66
66
  }
67
67
  (0, core_utils_1.assert)(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* "Missing orderer URL!" */);
68
- let parsedUrl = (0, urlUtils_1.parseFluidUrl)(resolvedUrl.url);
68
+ const parsedUrl = new URL(resolvedUrl.url);
69
69
  if (!parsedUrl.pathname) {
70
70
  throw new Error("Parsed url should contain tenant and doc Id!!");
71
71
  }
@@ -81,12 +81,15 @@ class RouterliciousDocumentServiceFactory {
81
81
  const ordererTokenFetcher = (0, restWrapper_1.toInstrumentedR11sOrdererTokenFetcher)(tenantId, undefined /* documentId */, this.tokenProvider, logger2);
82
82
  const rateLimiter = new driver_utils_1.RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);
83
83
  const ordererRestWrapper = await restWrapper_1.RouterliciousOrdererRestWrapper.load(ordererTokenFetcher, logger2, rateLimiter, this.driverPolicies.enableRestLess, resolvedUrl.endpoints.ordererUrl);
84
+ const createAsEphemeral = (0, routerliciousResolvedUrl_1.isRouterliciousResolvedUrl)(resolvedUrl)
85
+ ? resolvedUrl.createAsEphemeral === true
86
+ : false;
84
87
  const res = await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger2, {
85
88
  eventName: "CreateNew",
86
89
  details: JSON.stringify({
87
90
  enableDiscovery: this.driverPolicies.enableDiscovery,
88
91
  sequenceNumber: documentAttributes.sequenceNumber,
89
- isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
92
+ isEphemeralContainer: createAsEphemeral,
90
93
  }),
91
94
  }, async (event) => {
92
95
  // @TODO: Remove returned "string" type when removing back-compat code
@@ -96,7 +99,7 @@ class RouterliciousDocumentServiceFactory {
96
99
  values: quorumValues,
97
100
  enableDiscovery: this.driverPolicies.enableDiscovery,
98
101
  generateToken: this.tokenProvider.documentPostCreateCallback !== undefined,
99
- isEphemeralContainer: this.driverPolicies.isEphemeralContainer,
102
+ isEphemeralContainer: createAsEphemeral,
100
103
  enableAnyBinaryBlobOnFirstSummary: true,
101
104
  })).content;
102
105
  event.end({
@@ -118,7 +121,6 @@ class RouterliciousDocumentServiceFactory {
118
121
  token = res.token;
119
122
  session = this.driverPolicies.enableDiscovery ? res.session : undefined;
120
123
  }
121
- parsedUrl = (0, urlUtils_1.parseFluidUrl)(resolvedUrl.url);
122
124
  // @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined
123
125
  // is sufficient to determine if the token will be undefined or not.
124
126
  try {
@@ -134,7 +136,7 @@ class RouterliciousDocumentServiceFactory {
134
136
  catch (error) {
135
137
  throw new DocumentPostCreateError(error);
136
138
  }
137
- parsedUrl.set("pathname", (0, urlUtils_1.replaceDocumentIdInPath)(parsedUrl.pathname, documentId));
139
+ parsedUrl.pathname = (0, urlUtils_1.replaceDocumentIdInPath)(parsedUrl.pathname, documentId);
138
140
  const deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;
139
141
  if (!deltaStorageUrl) {
140
142
  throw new Error(`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`);
@@ -157,7 +159,7 @@ class RouterliciousDocumentServiceFactory {
157
159
  * @returns Routerlicious document service.
158
160
  */
159
161
  async createDocumentService(resolvedUrl, logger, clientIsSummarizer, session) {
160
- const parsedUrl = (0, urlUtils_1.parseFluidUrl)(resolvedUrl.url);
162
+ const parsedUrl = new URL(resolvedUrl.url);
161
163
  const [, tenantId, documentId] = parsedUrl.pathname.split("/");
162
164
  if (!documentId || !tenantId) {
163
165
  throw new Error(`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`);
@@ -1 +1 @@
1
- {"version":3,"file":"documentServiceFactory.js","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,6DAAyD;AACzD,2EAO4C;AAG5C,+DAKsC;AACtC,qEAAsF;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C;IAID,IAAW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;CACD;AAfD,0DAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tFiveDaysMs,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils\";\nimport { createChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tISession,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { DocumentService } from \"./documentService\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport { ITokenProvider } from \"./tokens\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n\ttoInstrumentedR11sStorageTokenFetcher,\n} from \"./restWrapper\";\nimport { parseFluidUrl, replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from \"./urlUtils\";\nimport { ICache, InMemoryCache, NullCache } from \"./cache\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\n\nconst maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms\n\nconst defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {\n\tenablePrefetch: true,\n\tmaxConcurrentStorageRequests: 100,\n\tmaxConcurrentOrdererRequests: 100,\n\tenableDiscovery: false,\n\tenableWholeSummaryUpload: false,\n\tenableRestLess: true,\n\tenableInternalSummaryCaching: true,\n\tenableLongPollingDowngrade: true,\n\tisEphemeralContainer: false,\n};\n\n/**\n * Factory for creating the routerlicious document service. Use this if you want to\n * use the routerlicious implementation.\n * @internal\n */\nexport class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {\n\tprivate readonly driverPolicies: IRouterliciousDriverPolicies;\n\tprivate readonly blobCache: ICache<ArrayBufferLike>;\n\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();\n\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();\n\n\tconstructor(\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tdriverPolicies: Partial<IRouterliciousDriverPolicies> = {},\n\t) {\n\t\t// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)\n\t\tconst snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;\n\n\t\tthis.driverPolicies = {\n\t\t\t...defaultRouterliciousDriverPolicies,\n\t\t\t...driverPolicies,\n\t\t};\n\t\tthis.blobCache = new InMemoryCache<ArrayBufferLike>();\n\t\tif (this.driverPolicies.enableInternalSummaryCaching) {\n\t\t\tif (this.driverPolicies.enableWholeSummaryUpload) {\n\t\t\t\tthis.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.shreddedSummaryTreeCache = new InMemoryCache<ISnapshotTreeVersion>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}\n\t *\n\t * @throws {@link DocumentPostCreateError}\n\t * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.\n\t */\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tassert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* \"Missing orderer URL!\" */);\n\t\tlet parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tif (!parsedUrl.pathname) {\n\t\t\tthrow new Error(\"Parsed url should contain tenant and doc Id!!\");\n\t\t}\n\t\tconst [, tenantId] = parsedUrl.pathname.split(\"/\");\n\n\t\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\t\tconst appSummary = createNewSummary.tree[\".app\"];\n\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\n\t\tconst logger2 = createChildLogger({ logger, namespace: \"RouterliciousDriver\" });\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tundefined /* documentId */,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tresolvedUrl.endpoints.ordererUrl,\n\t\t);\n\n\t\tconst res = await PerformanceEvent.timedExecAsync(\n\t\t\tlogger2,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// @TODO: Remove returned \"string\" type when removing back-compat code\n\t\t\t\tconst postRes = (\n\t\t\t\t\tawait ordererRestWrapper.post<\n\t\t\t\t\t\t{ id: string; token?: string; session?: ISession } | string\n\t\t\t\t\t>(`/documents/${tenantId}`, {\n\t\t\t\t\t\tsummary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),\n\t\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\t\tvalues: quorumValues,\n\t\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\t\tgenerateToken: this.tokenProvider.documentPostCreateCallback !== undefined,\n\t\t\t\t\t\tisEphemeralContainer: this.driverPolicies.isEphemeralContainer,\n\t\t\t\t\t\tenableAnyBinaryBlobOnFirstSummary: true,\n\t\t\t\t\t})\n\t\t\t\t).content;\n\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: typeof postRes === \"string\" ? postRes : postRes.id,\n\t\t\t\t});\n\t\t\t\treturn postRes;\n\t\t\t},\n\t\t);\n\n\t\t// For supporting backward compatibility, when the request has generateToken === true, it will return\n\t\t// an object instead of string\n\t\t// @TODO: Remove the logic when no need to support back-compat\n\n\t\tlet documentId: string;\n\t\tlet token: string | undefined;\n\t\tlet session: ISession | undefined;\n\t\tif (typeof res === \"string\") {\n\t\t\tdocumentId = res;\n\t\t} else {\n\t\t\tdocumentId = res.id;\n\t\t\ttoken = res.token;\n\t\t\tsession = this.driverPolicies.enableDiscovery ? res.session : undefined;\n\t\t}\n\t\tparsedUrl = parseFluidUrl(resolvedUrl.url);\n\n\t\t// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined\n\t\t// is sufficient to determine if the token will be undefined or not.\n\t\ttry {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DocPostCreateCallback\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (token && this.tokenProvider.documentPostCreateCallback !== undefined) {\n\t\t\t\t\t\treturn this.tokenProvider.documentPostCreateCallback(documentId, token);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\tthrow new DocumentPostCreateError(error);\n\t\t}\n\n\t\tparsedUrl.set(\"pathname\", replaceDocumentIdInPath(parsedUrl.pathname, documentId));\n\t\tconst deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;\n\t\tif (!deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\t\tconst parsedDeltaStorageUrl = new URL(deltaStorageUrl);\n\t\tparsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(\n\t\t\tparsedDeltaStorageUrl.pathname,\n\t\t\tdocumentId,\n\t\t);\n\n\t\treturn this.createDocumentService(\n\t\t\t{\n\t\t\t\t...resolvedUrl,\n\t\t\t\turl: parsedUrl.toString(),\n\t\t\t\tid: documentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\t...resolvedUrl.endpoints,\n\t\t\t\t\tdeltaStorageUrl: parsedDeltaStorageUrl.toString(),\n\t\t\t\t},\n\t\t\t},\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t\tsession,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}\n\t *\n\t * @returns Routerlicious document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t\tsession?: ISession,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = parseFluidUrl(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\t\tconst logger2 = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"RouterliciousDriver\",\n\t\t\tproperties: {\n\t\t\t\tall: { driverVersion },\n\t\t\t},\n\t\t});\n\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst storageTokenFetcher = toInstrumentedR11sStorageTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst ordererTokenP = ordererTokenFetcher();\n\t\tconst storageTokenP = storageTokenFetcher();\n\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tundefined /* baseUrl */,\n\t\t\tordererTokenP,\n\t\t);\n\n\t\tconst discoverFluidResolvedUrl = async (): Promise<IResolvedUrl> => {\n\t\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\t\treturn resolvedUrl;\n\t\t\t}\n\n\t\t\tconst discoveredSession = await PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DiscoverSession\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\t// The service responds with the current document session associated with the container.\n\t\t\t\t\tconst response = await ordererRestWrapper.get<ISession>(\n\t\t\t\t\t\t`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);\n\t\t};\n\t\tconst fluidResolvedUrl: IResolvedUrl =\n\t\t\tsession !== undefined\n\t\t\t\t? getDiscoveredFluidResolvedUrl(resolvedUrl, session)\n\t\t\t\t: await discoverFluidResolvedUrl();\n\n\t\tconst storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tconst ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tconst deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tconst deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility\n\t\tif (!ordererUrl || !deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\ttenantId,\n\t\t\tstorageTokenFetcher,\n\t\t\tlogger2,\n\t\t\tnew RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tstorageUrl,\n\t\t\tstorageTokenP,\n\t\t);\n\n\t\tconst documentStorageServicePolicies: IDocumentStorageServicePolicies = {\n\t\t\tcaching: this.driverPolicies.enablePrefetch\n\t\t\t\t? LoaderCachingPolicy.Prefetch\n\t\t\t\t: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumSnapshotCacheDurationMs,\n\t\t};\n\n\t\treturn new DocumentService(\n\t\t\tfluidResolvedUrl,\n\t\t\tordererUrl,\n\t\t\tdeltaStorageUrl,\n\t\t\tdeltaStreamUrl,\n\t\t\tstorageUrl,\n\t\t\tlogger2,\n\t\t\tthis.tokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tordererRestWrapper,\n\t\t\tdocumentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tdiscoverFluidResolvedUrl,\n\t\t\tstorageRestWrapper,\n\t\t\tstorageTokenFetcher,\n\t\t\tordererTokenFetcher,\n\t\t);\n\t}\n}\n\n/**\n * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown\n * in {@link ITokenProvider.documentPostCreateCallback}.\n * It is the consumer's responsibility to ensure that any state related to container creation is appropriately\n * cleaned up in the event of failure.\n * This includes the document itself, which will have been created by the time this error was thrown.\n *\n * @remarks TODO: examples of suggested actions for recovery.\n * - How would a user delete the created document?\n * - What would a retry pattern look like here?\n * @internal\n */\nexport class DocumentPostCreateError extends Error {\n\tpublic constructor(\n\t\t/**\n\t\t * Inner error being wrapped.\n\t\t */\n\t\tprivate readonly innerError: Error,\n\t) {\n\t\tsuper(innerError.message);\n\t}\n\n\tpublic readonly name = \"DocumentPostCreateError\";\n\n\tpublic get stack() {\n\t\treturn this.innerError.stack;\n\t}\n}\n"]}
1
+ {"version":3,"file":"documentServiceFactory.js","sourceRoot":"","sources":["../src/documentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,2DAAoD;AACpD,6DAAyD;AACzD,2EAO4C;AAG5C,+DAKsC;AACtC,qEAAs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AW,KAAK;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC;IAC9B,CAAC;CACD;AAfD,0DAeC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport {\n\tFiveDaysMs,\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIDocumentStorageServicePolicies,\n\tIResolvedUrl,\n\tLoaderCachingPolicy,\n} from \"@fluidframework/driver-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils\";\nimport { createChildLogger, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n\tISession,\n\tconvertSummaryTreeToWholeSummaryTree,\n} from \"@fluidframework/server-services-client\";\nimport { ICache, InMemoryCache, NullCache } from \"./cache\";\nimport { INormalizedWholeSnapshot } from \"./contracts\";\nimport { ISnapshotTreeVersion } from \"./definitions\";\nimport { DocumentService } from \"./documentService\";\nimport { pkgVersion as driverVersion } from \"./packageVersion\";\nimport { IRouterliciousDriverPolicies } from \"./policies\";\nimport {\n\tRouterliciousOrdererRestWrapper,\n\tRouterliciousStorageRestWrapper,\n\ttoInstrumentedR11sOrdererTokenFetcher,\n\ttoInstrumentedR11sStorageTokenFetcher,\n} from \"./restWrapper\";\nimport { isRouterliciousResolvedUrl } from \"./routerliciousResolvedUrl\";\nimport { ITokenProvider } from \"./tokens\";\nimport { replaceDocumentIdInPath, getDiscoveredFluidResolvedUrl } from \"./urlUtils\";\n\nconst maximumSnapshotCacheDurationMs: FiveDaysMs = 432_000_000; // 5 days in ms\n\nconst defaultRouterliciousDriverPolicies: IRouterliciousDriverPolicies = {\n\tenablePrefetch: true,\n\tmaxConcurrentStorageRequests: 100,\n\tmaxConcurrentOrdererRequests: 100,\n\tenableDiscovery: false,\n\tenableWholeSummaryUpload: false,\n\tenableRestLess: true,\n\tenableInternalSummaryCaching: true,\n\tenableLongPollingDowngrade: true,\n};\n\n/**\n * Factory for creating the routerlicious document service. Use this if you want to\n * use the routerlicious implementation.\n * @internal\n */\nexport class RouterliciousDocumentServiceFactory implements IDocumentServiceFactory {\n\tprivate readonly driverPolicies: IRouterliciousDriverPolicies;\n\tprivate readonly blobCache: ICache<ArrayBufferLike>;\n\tprivate readonly wholeSnapshotTreeCache: ICache<INormalizedWholeSnapshot> = new NullCache();\n\tprivate readonly shreddedSummaryTreeCache: ICache<ISnapshotTreeVersion> = new NullCache();\n\n\tconstructor(\n\t\tprivate readonly tokenProvider: ITokenProvider,\n\t\tdriverPolicies: Partial<IRouterliciousDriverPolicies> = {},\n\t) {\n\t\t// Use the maximum allowed by the policy (IDocumentStorageServicePolicies.maximumCacheDurationMs set below)\n\t\tconst snapshotCacheExpiryMs: FiveDaysMs = maximumSnapshotCacheDurationMs;\n\n\t\tthis.driverPolicies = {\n\t\t\t...defaultRouterliciousDriverPolicies,\n\t\t\t...driverPolicies,\n\t\t};\n\t\tthis.blobCache = new InMemoryCache<ArrayBufferLike>();\n\t\tif (this.driverPolicies.enableInternalSummaryCaching) {\n\t\t\tif (this.driverPolicies.enableWholeSummaryUpload) {\n\t\t\t\tthis.wholeSnapshotTreeCache = new InMemoryCache<INormalizedWholeSnapshot>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.shreddedSummaryTreeCache = new InMemoryCache<ISnapshotTreeVersion>(\n\t\t\t\t\tsnapshotCacheExpiryMs,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createContainer}\n\t *\n\t * @throws {@link DocumentPostCreateError}\n\t * If an exception is thrown while invoking the provided {@link ITokenProvider.documentPostCreateCallback}.\n\t */\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tif (createNewSummary === undefined) {\n\t\t\tthrow new Error(\"Empty file summary creation isn't supported in this driver.\");\n\t\t}\n\t\tassert(!!resolvedUrl.endpoints.ordererUrl, 0x0b2 /* \"Missing orderer URL!\" */);\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tif (!parsedUrl.pathname) {\n\t\t\tthrow new Error(\"Parsed url should contain tenant and doc Id!!\");\n\t\t}\n\t\tconst [, tenantId] = parsedUrl.pathname.split(\"/\");\n\n\t\tif (!isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tthrow new Error(\"Protocol and App Summary required in the full summary\");\n\t\t}\n\t\tconst protocolSummary = createNewSummary.tree[\".protocol\"];\n\t\tconst appSummary = createNewSummary.tree[\".app\"];\n\n\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(protocolSummary);\n\t\tconst quorumValues = getQuorumValuesFromProtocolSummary(protocolSummary);\n\n\t\tconst logger2 = createChildLogger({ logger, namespace: \"RouterliciousDriver\" });\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tundefined /* documentId */,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tresolvedUrl.endpoints.ordererUrl,\n\t\t);\n\n\t\tconst createAsEphemeral = isRouterliciousResolvedUrl(resolvedUrl)\n\t\t\t? resolvedUrl.createAsEphemeral === true\n\t\t\t: false;\n\n\t\tconst res = await PerformanceEvent.timedExecAsync(\n\t\t\tlogger2,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\tisEphemeralContainer: createAsEphemeral,\n\t\t\t\t}),\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\t// @TODO: Remove returned \"string\" type when removing back-compat code\n\t\t\t\tconst postRes = (\n\t\t\t\t\tawait ordererRestWrapper.post<\n\t\t\t\t\t\t{ id: string; token?: string; session?: ISession } | string\n\t\t\t\t\t>(`/documents/${tenantId}`, {\n\t\t\t\t\t\tsummary: convertSummaryTreeToWholeSummaryTree(undefined, appSummary),\n\t\t\t\t\t\tsequenceNumber: documentAttributes.sequenceNumber,\n\t\t\t\t\t\tvalues: quorumValues,\n\t\t\t\t\t\tenableDiscovery: this.driverPolicies.enableDiscovery,\n\t\t\t\t\t\tgenerateToken: this.tokenProvider.documentPostCreateCallback !== undefined,\n\t\t\t\t\t\tisEphemeralContainer: createAsEphemeral,\n\t\t\t\t\t\tenableAnyBinaryBlobOnFirstSummary: true,\n\t\t\t\t\t})\n\t\t\t\t).content;\n\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: typeof postRes === \"string\" ? postRes : postRes.id,\n\t\t\t\t});\n\t\t\t\treturn postRes;\n\t\t\t},\n\t\t);\n\n\t\t// For supporting backward compatibility, when the request has generateToken === true, it will return\n\t\t// an object instead of string\n\t\t// @TODO: Remove the logic when no need to support back-compat\n\n\t\tlet documentId: string;\n\t\tlet token: string | undefined;\n\t\tlet session: ISession | undefined;\n\t\tif (typeof res === \"string\") {\n\t\t\tdocumentId = res;\n\t\t} else {\n\t\t\tdocumentId = res.id;\n\t\t\ttoken = res.token;\n\t\t\tsession = this.driverPolicies.enableDiscovery ? res.session : undefined;\n\t\t}\n\n\t\t// @TODO: Remove token from the condition, checking the documentPostCreateCallback !== undefined\n\t\t// is sufficient to determine if the token will be undefined or not.\n\t\ttry {\n\t\t\tawait PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DocPostCreateCallback\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync () => {\n\t\t\t\t\tif (token && this.tokenProvider.documentPostCreateCallback !== undefined) {\n\t\t\t\t\t\treturn this.tokenProvider.documentPostCreateCallback(documentId, token);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t} catch (error: any) {\n\t\t\tthrow new DocumentPostCreateError(error);\n\t\t}\n\n\t\tparsedUrl.pathname = replaceDocumentIdInPath(parsedUrl.pathname, documentId);\n\t\tconst deltaStorageUrl = resolvedUrl.endpoints.deltaStorageUrl;\n\t\tif (!deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\t\tconst parsedDeltaStorageUrl = new URL(deltaStorageUrl);\n\t\tparsedDeltaStorageUrl.pathname = replaceDocumentIdInPath(\n\t\t\tparsedDeltaStorageUrl.pathname,\n\t\t\tdocumentId,\n\t\t);\n\n\t\treturn this.createDocumentService(\n\t\t\t{\n\t\t\t\t...resolvedUrl,\n\t\t\t\turl: parsedUrl.toString(),\n\t\t\t\tid: documentId,\n\t\t\t\tendpoints: {\n\t\t\t\t\t...resolvedUrl.endpoints,\n\t\t\t\t\tdeltaStorageUrl: parsedDeltaStorageUrl.toString(),\n\t\t\t\t},\n\t\t\t},\n\t\t\tlogger,\n\t\t\tclientIsSummarizer,\n\t\t\tsession,\n\t\t);\n\t}\n\n\t/**\n\t * {@inheritDoc @fluidframework/driver-definitions#IDocumentServiceFactory.createDocumentService}\n\t *\n\t * @returns Routerlicious document service.\n\t */\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t\tsession?: ISession,\n\t): Promise<IDocumentService> {\n\t\tconst parsedUrl = new URL(resolvedUrl.url);\n\t\tconst [, tenantId, documentId] = parsedUrl.pathname.split(\"/\");\n\t\tif (!documentId || !tenantId) {\n\t\t\tthrow new Error(\n\t\t\t\t`Couldn't parse documentId and/or tenantId. [documentId:${documentId}][tenantId:${tenantId}]`,\n\t\t\t);\n\t\t}\n\t\tconst logger2 = createChildLogger({\n\t\t\tlogger,\n\t\t\tnamespace: \"RouterliciousDriver\",\n\t\t\tproperties: {\n\t\t\t\tall: { driverVersion },\n\t\t\t},\n\t\t});\n\n\t\tconst ordererTokenFetcher = toInstrumentedR11sOrdererTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst storageTokenFetcher = toInstrumentedR11sStorageTokenFetcher(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tthis.tokenProvider,\n\t\t\tlogger2,\n\t\t);\n\t\tconst ordererTokenP = ordererTokenFetcher();\n\t\tconst storageTokenP = storageTokenFetcher();\n\n\t\tconst rateLimiter = new RateLimiter(this.driverPolicies.maxConcurrentOrdererRequests);\n\t\tconst ordererRestWrapper = await RouterliciousOrdererRestWrapper.load(\n\t\t\tordererTokenFetcher,\n\t\t\tlogger2,\n\t\t\trateLimiter,\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tundefined /* baseUrl */,\n\t\t\tordererTokenP,\n\t\t);\n\n\t\tconst discoverFluidResolvedUrl = async (): Promise<IResolvedUrl> => {\n\t\t\tif (!this.driverPolicies.enableDiscovery) {\n\t\t\t\treturn resolvedUrl;\n\t\t\t}\n\n\t\t\tconst discoveredSession = await PerformanceEvent.timedExecAsync(\n\t\t\t\tlogger2,\n\t\t\t\t{\n\t\t\t\t\teventName: \"DiscoverSession\",\n\t\t\t\t\tdocId: documentId,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\t// The service responds with the current document session associated with the container.\n\t\t\t\t\tconst response = await ordererRestWrapper.get<ISession>(\n\t\t\t\t\t\t`${resolvedUrl.endpoints.ordererUrl}/documents/${tenantId}/session/${documentId}`,\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\t...response.propsToLog,\n\t\t\t\t\t\t...getW3CData(response.requestUrl, \"xmlhttprequest\"),\n\t\t\t\t\t});\n\t\t\t\t\treturn response.content;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn getDiscoveredFluidResolvedUrl(resolvedUrl, discoveredSession);\n\t\t};\n\t\tconst fluidResolvedUrl: IResolvedUrl =\n\t\t\tsession !== undefined\n\t\t\t\t? getDiscoveredFluidResolvedUrl(resolvedUrl, session)\n\t\t\t\t: await discoverFluidResolvedUrl();\n\n\t\tconst storageUrl = fluidResolvedUrl.endpoints.storageUrl;\n\t\tconst ordererUrl = fluidResolvedUrl.endpoints.ordererUrl;\n\t\tconst deltaStorageUrl = fluidResolvedUrl.endpoints.deltaStorageUrl;\n\t\tconst deltaStreamUrl = fluidResolvedUrl.endpoints.deltaStreamUrl || ordererUrl; // backward compatibility\n\t\tif (!ordererUrl || !deltaStorageUrl) {\n\t\t\tthrow new Error(\n\t\t\t\t`All endpoints urls must be provided. [ordererUrl:${ordererUrl}][deltaStorageUrl:${deltaStorageUrl}]`,\n\t\t\t);\n\t\t}\n\n\t\tconst storageRestWrapper = await RouterliciousStorageRestWrapper.load(\n\t\t\ttenantId,\n\t\t\tstorageTokenFetcher,\n\t\t\tlogger2,\n\t\t\tnew RateLimiter(this.driverPolicies.maxConcurrentStorageRequests),\n\t\t\tthis.driverPolicies.enableRestLess,\n\t\t\tstorageUrl,\n\t\t\tstorageTokenP,\n\t\t);\n\n\t\tconst documentStorageServicePolicies: IDocumentStorageServicePolicies = {\n\t\t\tcaching: this.driverPolicies.enablePrefetch\n\t\t\t\t? LoaderCachingPolicy.Prefetch\n\t\t\t\t: LoaderCachingPolicy.NoCaching,\n\t\t\tmaximumCacheDurationMs: maximumSnapshotCacheDurationMs,\n\t\t};\n\n\t\treturn new DocumentService(\n\t\t\tfluidResolvedUrl,\n\t\t\tordererUrl,\n\t\t\tdeltaStorageUrl,\n\t\t\tdeltaStreamUrl,\n\t\t\tstorageUrl,\n\t\t\tlogger2,\n\t\t\tthis.tokenProvider,\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\tordererRestWrapper,\n\t\t\tdocumentStorageServicePolicies,\n\t\t\tthis.driverPolicies,\n\t\t\tthis.blobCache,\n\t\t\tthis.wholeSnapshotTreeCache,\n\t\t\tthis.shreddedSummaryTreeCache,\n\t\t\tdiscoverFluidResolvedUrl,\n\t\t\tstorageRestWrapper,\n\t\t\tstorageTokenFetcher,\n\t\t\tordererTokenFetcher,\n\t\t);\n\t}\n}\n\n/**\n * Error returned by {@link RouterliciousDocumentServiceFactory.createContainer} when an error is thrown\n * in {@link ITokenProvider.documentPostCreateCallback}.\n * It is the consumer's responsibility to ensure that any state related to container creation is appropriately\n * cleaned up in the event of failure.\n * This includes the document itself, which will have been created by the time this error was thrown.\n *\n * @remarks TODO: examples of suggested actions for recovery.\n * - How would a user delete the created document?\n * - What would a retry pattern look like here?\n * @internal\n */\nexport class DocumentPostCreateError extends Error {\n\tpublic constructor(\n\t\t/**\n\t\t * Inner error being wrapped.\n\t\t */\n\t\tprivate readonly innerError: Error,\n\t) {\n\t\tsuper(innerError.message);\n\t}\n\n\tpublic readonly name = \"DocumentPostCreateError\";\n\n\tpublic get stack() {\n\t\treturn this.innerError.stack;\n\t}\n}\n"]}
@@ -37,23 +37,6 @@ export declare const RouterliciousErrorTypes: {
37
37
  * @internal
38
38
  */
39
39
  export type RouterliciousErrorTypes = (typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];
40
- /**
41
- * Routerlicious Error types
42
- * Different error types that may be thrown by the routerlicious driver
43
- *
44
- * @deprecated Use {@link (RouterliciousErrorTypes:variable)} instead.
45
- * @internal
46
- */
47
- export declare enum RouterliciousErrorType {
48
- /**
49
- * File not found, or file deleted during session
50
- */
51
- fileNotFoundOrAccessDeniedError = "fileNotFoundOrAccessDeniedError",
52
- /**
53
- * SSL Certificate Error.
54
- */
55
- sslCertError = "sslCertError"
56
- }
57
40
  /**
58
41
  * Interface for error responses for the WebSocket connection
59
42
  * Intended to be compatible with output from {@link NetworkError.toJSON}
@@ -81,7 +64,7 @@ export interface IR11sSocketError {
81
64
  retryAfterMs?: number;
82
65
  }
83
66
  export interface IR11sError extends Omit<IDriverErrorBase, "errorType"> {
84
- readonly errorType: RouterliciousErrorType;
67
+ readonly errorType: RouterliciousErrorTypes;
85
68
  }
86
69
  export type R11sError = DriverError | IR11sError;
87
70
  export declare function createR11sNetworkError(errorMessage: string, statusCode: number, retryAfterMs?: number): IFluidErrorBase & R11sError;
@@ -1 +1 @@
1
- {"version":3,"file":"errorUtils.d.ts","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,WAAW,EACX,gBAAgB,EAEhB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAGlE;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;IAInC;;OAEG;;;;;;;;;;;;;;;;;;;;CAEM,CAAC;AACX;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAClC,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,oBAAY,sBAAsB;IACjC;;OAEG;IACH,+BAA+B,oCAAoC;IAEnE;;OAEG;IACH,YAAY,iBAAiB;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC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