@fluidframework/driver-utils 2.0.0-internal.3.0.1 → 2.0.0-internal.3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/.eslintrc.js +17 -19
  2. package/.mocharc.js +2 -2
  3. package/api-extractor.json +2 -2
  4. package/dist/blobAggregationStorage.d.ts +2 -2
  5. package/dist/blobAggregationStorage.d.ts.map +1 -1
  6. package/dist/blobAggregationStorage.js +11 -6
  7. package/dist/blobAggregationStorage.js.map +1 -1
  8. package/dist/blobCacheStorageService.d.ts.map +1 -1
  9. package/dist/blobCacheStorageService.js.map +1 -1
  10. package/dist/buildSnapshotTree.d.ts.map +1 -1
  11. package/dist/buildSnapshotTree.js.map +1 -1
  12. package/dist/documentStorageServiceProxy.d.ts.map +1 -1
  13. package/dist/documentStorageServiceProxy.js.map +1 -1
  14. package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  15. package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
  16. package/dist/error.d.ts.map +1 -1
  17. package/dist/error.js.map +1 -1
  18. package/dist/fluidResolvedUrl.d.ts.map +1 -1
  19. package/dist/fluidResolvedUrl.js.map +1 -1
  20. package/dist/index.d.ts +1 -1
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/insecureUrlResolver.d.ts.map +1 -1
  24. package/dist/insecureUrlResolver.js +2 -1
  25. package/dist/insecureUrlResolver.js.map +1 -1
  26. package/dist/mapWithExpiration.d.ts.map +1 -1
  27. package/dist/mapWithExpiration.js +5 -3
  28. package/dist/mapWithExpiration.js.map +1 -1
  29. package/dist/messageRecognition.d.ts.map +1 -1
  30. package/dist/messageRecognition.js.map +1 -1
  31. package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
  32. package/dist/multiDocumentServiceFactory.js.map +1 -1
  33. package/dist/multiUrlResolver.d.ts.map +1 -1
  34. package/dist/multiUrlResolver.js.map +1 -1
  35. package/dist/network.d.ts +1 -1
  36. package/dist/network.d.ts.map +1 -1
  37. package/dist/network.js +4 -3
  38. package/dist/network.js.map +1 -1
  39. package/dist/networkUtils.d.ts.map +1 -1
  40. package/dist/networkUtils.js +2 -3
  41. package/dist/networkUtils.js.map +1 -1
  42. package/dist/packageVersion.d.ts +1 -1
  43. package/dist/packageVersion.js +1 -1
  44. package/dist/packageVersion.js.map +1 -1
  45. package/dist/parallelRequests.d.ts.map +1 -1
  46. package/dist/parallelRequests.js +19 -9
  47. package/dist/parallelRequests.js.map +1 -1
  48. package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
  49. package/dist/prefetchDocumentStorageService.js.map +1 -1
  50. package/dist/rateLimiter.d.ts.map +1 -1
  51. package/dist/rateLimiter.js.map +1 -1
  52. package/dist/readAndParse.d.ts.map +1 -1
  53. package/dist/readAndParse.js.map +1 -1
  54. package/dist/runWithRetry.d.ts.map +1 -1
  55. package/dist/runWithRetry.js.map +1 -1
  56. package/dist/summaryForCreateNew.d.ts.map +1 -1
  57. package/dist/summaryForCreateNew.js.map +1 -1
  58. package/dist/treeConversions.d.ts.map +1 -1
  59. package/dist/treeConversions.js +1 -4
  60. package/dist/treeConversions.js.map +1 -1
  61. package/dist/treeUtils.d.ts +10 -10
  62. package/dist/treeUtils.d.ts.map +1 -1
  63. package/dist/treeUtils.js +10 -10
  64. package/dist/treeUtils.js.map +1 -1
  65. package/lib/blobAggregationStorage.d.ts +2 -2
  66. package/lib/blobAggregationStorage.d.ts.map +1 -1
  67. package/lib/blobAggregationStorage.js +11 -6
  68. package/lib/blobAggregationStorage.js.map +1 -1
  69. package/lib/blobCacheStorageService.d.ts.map +1 -1
  70. package/lib/blobCacheStorageService.js.map +1 -1
  71. package/lib/buildSnapshotTree.d.ts.map +1 -1
  72. package/lib/buildSnapshotTree.js.map +1 -1
  73. package/lib/documentStorageServiceProxy.d.ts.map +1 -1
  74. package/lib/documentStorageServiceProxy.js.map +1 -1
  75. package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
  76. package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
  77. package/lib/error.d.ts.map +1 -1
  78. package/lib/error.js.map +1 -1
  79. package/lib/fluidResolvedUrl.d.ts.map +1 -1
  80. package/lib/fluidResolvedUrl.js.map +1 -1
  81. package/lib/index.d.ts +1 -1
  82. package/lib/index.d.ts.map +1 -1
  83. package/lib/index.js +1 -1
  84. package/lib/index.js.map +1 -1
  85. package/lib/insecureUrlResolver.d.ts.map +1 -1
  86. package/lib/insecureUrlResolver.js +2 -1
  87. package/lib/insecureUrlResolver.js.map +1 -1
  88. package/lib/mapWithExpiration.d.ts.map +1 -1
  89. package/lib/mapWithExpiration.js +5 -3
  90. package/lib/mapWithExpiration.js.map +1 -1
  91. package/lib/messageRecognition.d.ts.map +1 -1
  92. package/lib/messageRecognition.js +1 -1
  93. package/lib/messageRecognition.js.map +1 -1
  94. package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
  95. package/lib/multiDocumentServiceFactory.js.map +1 -1
  96. package/lib/multiUrlResolver.d.ts.map +1 -1
  97. package/lib/multiUrlResolver.js.map +1 -1
  98. package/lib/network.d.ts +1 -1
  99. package/lib/network.d.ts.map +1 -1
  100. package/lib/network.js +4 -3
  101. package/lib/network.js.map +1 -1
  102. package/lib/networkUtils.d.ts.map +1 -1
  103. package/lib/networkUtils.js +2 -3
  104. package/lib/networkUtils.js.map +1 -1
  105. package/lib/packageVersion.d.ts +1 -1
  106. package/lib/packageVersion.js +1 -1
  107. package/lib/packageVersion.js.map +1 -1
  108. package/lib/parallelRequests.d.ts.map +1 -1
  109. package/lib/parallelRequests.js +19 -9
  110. package/lib/parallelRequests.js.map +1 -1
  111. package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
  112. package/lib/prefetchDocumentStorageService.js.map +1 -1
  113. package/lib/rateLimiter.d.ts.map +1 -1
  114. package/lib/rateLimiter.js.map +1 -1
  115. package/lib/readAndParse.d.ts.map +1 -1
  116. package/lib/readAndParse.js.map +1 -1
  117. package/lib/runWithRetry.d.ts.map +1 -1
  118. package/lib/runWithRetry.js.map +1 -1
  119. package/lib/summaryForCreateNew.d.ts.map +1 -1
  120. package/lib/summaryForCreateNew.js.map +1 -1
  121. package/lib/treeConversions.d.ts.map +1 -1
  122. package/lib/treeConversions.js +4 -7
  123. package/lib/treeConversions.js.map +1 -1
  124. package/lib/treeUtils.d.ts +10 -10
  125. package/lib/treeUtils.d.ts.map +1 -1
  126. package/lib/treeUtils.js +11 -11
  127. package/lib/treeUtils.js.map +1 -1
  128. package/package.json +128 -105
  129. package/prettier.config.cjs +1 -1
  130. package/src/blobAggregationStorage.ts +374 -322
  131. package/src/blobCacheStorageService.ts +20 -17
  132. package/src/buildSnapshotTree.ts +54 -51
  133. package/src/documentStorageServiceProxy.ts +49 -43
  134. package/src/emptyDocumentDeltaStorageService.ts +11 -10
  135. package/src/error.ts +5 -7
  136. package/src/fluidResolvedUrl.ts +9 -6
  137. package/src/index.ts +5 -1
  138. package/src/insecureUrlResolver.ts +127 -116
  139. package/src/mapWithExpiration.ts +111 -104
  140. package/src/messageRecognition.ts +25 -19
  141. package/src/multiDocumentServiceFactory.ts +73 -62
  142. package/src/multiUrlResolver.ts +26 -29
  143. package/src/network.ts +114 -112
  144. package/src/networkUtils.ts +37 -34
  145. package/src/packageVersion.ts +1 -1
  146. package/src/parallelRequests.ts +571 -509
  147. package/src/prefetchDocumentStorageService.ts +76 -74
  148. package/src/rateLimiter.ts +29 -29
  149. package/src/readAndParse.ts +7 -4
  150. package/src/runWithRetry.ts +105 -94
  151. package/src/summaryForCreateNew.ts +27 -24
  152. package/src/treeConversions.ts +48 -70
  153. package/src/treeUtils.ts +70 -74
  154. package/tsconfig.esnext.json +6 -6
  155. package/tsconfig.json +8 -12
@@ -10,108 +10,115 @@ import { assert } from "@fluidframework/common-utils";
10
10
  * The policy is based on the last time a key was written to.
11
11
  */
12
12
  export class MapWithExpiration<TKey = any, TValue = any> extends Map<TKey, TValue> {
13
- /** Timestamps (as epoch ms numbers) of when each key was last refreshed */
14
- private readonly lastRefreshedTimes = new Map<TKey, number>();
15
-
16
- constructor(
17
- private readonly expiryMs: number,
18
- ) {
19
- super();
20
- }
21
-
22
- private refresh(key: TKey): void {
23
- this.lastRefreshedTimes.set(key, (new Date()).valueOf());
24
- }
25
-
26
- /**
27
- * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found
28
- * If cleanUp is passed as true, then delete any expired entry before returning.
29
- */
30
- private checkExpiry(key: TKey, cleanUp: boolean = false): boolean | undefined {
31
- const refreshTime = this.lastRefreshedTimes.get(key);
32
- assert((refreshTime !== undefined) === super.has(key), 0x50c /* freshness map out of sync */);
33
-
34
- if (refreshTime === undefined) {
35
- return undefined;
36
- }
37
- const expired = (new Date()).valueOf() - refreshTime >= this.expiryMs;
38
- if (expired && cleanUp) {
39
- this.delete(key);
40
- }
41
- return expired;
42
- }
43
-
44
- private clearExpiredEntries() {
45
- // forEach clears out any expired entries
46
- this.forEach(() => {});
47
- }
48
-
49
- get size(): number {
50
- this.clearExpiredEntries();
51
- return super.size;
52
- }
53
-
54
- has(key: TKey): boolean {
55
- this.checkExpiry(key, true /* cleanUp */);
56
- return super.has(key);
57
- }
58
-
59
- get(key: TKey): TValue | undefined {
60
- this.checkExpiry(key, true /* cleanUp */);
61
- return super.get(key);
62
- }
63
-
64
- set(key: TKey, value: TValue): this {
65
- // Sliding window expiration policy (on write)
66
- this.refresh(key);
67
- return super.set(key, value);
68
- }
69
-
70
- delete(key: TKey): boolean {
71
- this.lastRefreshedTimes.delete(key);
72
- return super.delete(key);
73
- }
74
-
75
- clear(): void {
76
- this.lastRefreshedTimes.clear();
77
- super.clear();
78
- }
79
-
80
- forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void, thisArg?: any): void {
81
- const expiredKeys: TKey[] = [];
82
- super.forEach((v, k, m) => {
83
- if (this.checkExpiry(k) === true) {
84
- expiredKeys.push(k);
85
- } else {
86
- callbackfn.bind(thisArg)(v, k, m);
87
- }
88
- },
89
- // Note we don't pass thisArg here, since we bind it directly to callbackFn and don't need it otherwise
90
- );
91
-
92
- // Clean up keys we know are expired now that we're done iterating
93
- expiredKeys.forEach((key: TKey) => { this.delete(key); });
94
- }
95
-
96
- entries(): IterableIterator<[TKey, TValue]> {
97
- this.clearExpiredEntries();
98
- return super.entries();
99
- }
100
- keys(): IterableIterator<TKey> {
101
- this.clearExpiredEntries();
102
- return super.keys();
103
- }
104
- values(): IterableIterator<TValue> {
105
- this.clearExpiredEntries();
106
- return super.values();
107
- }
108
- [Symbol.iterator](): IterableIterator<[TKey, TValue]> {
109
- this.clearExpiredEntries();
110
- return super[Symbol.iterator]();
111
- }
112
-
113
- valueOf() {
114
- this.clearExpiredEntries();
115
- return super.valueOf();
116
- }
13
+ /** Timestamps (as epoch ms numbers) of when each key was last refreshed */
14
+ private readonly lastRefreshedTimes = new Map<TKey, number>();
15
+
16
+ constructor(private readonly expiryMs: number) {
17
+ super();
18
+ }
19
+
20
+ private refresh(key: TKey): void {
21
+ this.lastRefreshedTimes.set(key, new Date().valueOf());
22
+ }
23
+
24
+ /**
25
+ * Returns true if the key is present and expired, false if it's not expired, and undefined if it's not found
26
+ * If cleanUp is passed as true, then delete any expired entry before returning.
27
+ */
28
+ private checkExpiry(key: TKey, cleanUp: boolean = false): boolean | undefined {
29
+ const refreshTime = this.lastRefreshedTimes.get(key);
30
+ assert(
31
+ (refreshTime !== undefined) === super.has(key),
32
+ 0x50c /* freshness map out of sync */,
33
+ );
34
+
35
+ if (refreshTime === undefined) {
36
+ return undefined;
37
+ }
38
+ const expired = new Date().valueOf() - refreshTime >= this.expiryMs;
39
+ if (expired && cleanUp) {
40
+ this.delete(key);
41
+ }
42
+ return expired;
43
+ }
44
+
45
+ private clearExpiredEntries() {
46
+ // forEach clears out any expired entries
47
+ this.forEach(() => {});
48
+ }
49
+
50
+ get size(): number {
51
+ this.clearExpiredEntries();
52
+ return super.size;
53
+ }
54
+
55
+ has(key: TKey): boolean {
56
+ this.checkExpiry(key, true /* cleanUp */);
57
+ return super.has(key);
58
+ }
59
+
60
+ get(key: TKey): TValue | undefined {
61
+ this.checkExpiry(key, true /* cleanUp */);
62
+ return super.get(key);
63
+ }
64
+
65
+ set(key: TKey, value: TValue): this {
66
+ // Sliding window expiration policy (on write)
67
+ this.refresh(key);
68
+ return super.set(key, value);
69
+ }
70
+
71
+ delete(key: TKey): boolean {
72
+ this.lastRefreshedTimes.delete(key);
73
+ return super.delete(key);
74
+ }
75
+
76
+ clear(): void {
77
+ this.lastRefreshedTimes.clear();
78
+ super.clear();
79
+ }
80
+
81
+ forEach(
82
+ callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void,
83
+ thisArg?: any,
84
+ ): void {
85
+ const expiredKeys: TKey[] = [];
86
+ super.forEach(
87
+ (v, k, m) => {
88
+ if (this.checkExpiry(k) === true) {
89
+ expiredKeys.push(k);
90
+ } else {
91
+ callbackfn.bind(thisArg)(v, k, m);
92
+ }
93
+ },
94
+ // Note we don't pass thisArg here, since we bind it directly to callbackFn and don't need it otherwise
95
+ );
96
+
97
+ // Clean up keys we know are expired now that we're done iterating
98
+ expiredKeys.forEach((key: TKey) => {
99
+ this.delete(key);
100
+ });
101
+ }
102
+
103
+ entries(): IterableIterator<[TKey, TValue]> {
104
+ this.clearExpiredEntries();
105
+ return super.entries();
106
+ }
107
+ keys(): IterableIterator<TKey> {
108
+ this.clearExpiredEntries();
109
+ return super.keys();
110
+ }
111
+ values(): IterableIterator<TValue> {
112
+ this.clearExpiredEntries();
113
+ return super.values();
114
+ }
115
+ [Symbol.iterator](): IterableIterator<[TKey, TValue]> {
116
+ this.clearExpiredEntries();
117
+ return super[Symbol.iterator]();
118
+ }
119
+
120
+ valueOf() {
121
+ this.clearExpiredEntries();
122
+ return super.valueOf();
123
+ }
117
124
  }
@@ -2,25 +2,29 @@
2
2
  * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
3
  * Licensed under the MIT License.
4
4
  */
5
- import { IDocumentMessage, ISequencedDocumentMessage, MessageType } from "@fluidframework/protocol-definitions";
5
+ import {
6
+ IDocumentMessage,
7
+ ISequencedDocumentMessage,
8
+ MessageType,
9
+ } from "@fluidframework/protocol-definitions";
6
10
 
7
11
  /**
8
12
  * Tells if message was sent by container runtime
9
13
  * @privateRemarks ADO #1385: To be moved to container-definitions
10
14
  * @returns whether the message is a runtime message
11
15
  */
12
- export function isRuntimeMessage(message: { type: string; }): boolean {
13
- return message.type === MessageType.Operation;
16
+ export function isRuntimeMessage(message: { type: string }): boolean {
17
+ return message.type === MessageType.Operation;
14
18
  }
15
19
 
16
20
  enum RuntimeMessage {
17
- FluidDataStoreOp = "component",
18
- Attach = "attach",
19
- ChunkedOp = "chunkedOp",
20
- BlobAttach = "blobAttach",
21
- Rejoin = "rejoin",
22
- Alias = "alias",
23
- Operation = "op",
21
+ FluidDataStoreOp = "component",
22
+ Attach = "attach",
23
+ ChunkedOp = "chunkedOp",
24
+ BlobAttach = "blobAttach",
25
+ Rejoin = "rejoin",
26
+ Alias = "alias",
27
+ Operation = "op",
24
28
  }
25
29
 
26
30
  /**
@@ -43,21 +47,23 @@ enum RuntimeMessage {
43
47
  * @deprecated This API should not be used.
44
48
  */
45
49
  export function isUnpackedRuntimeMessage(message: ISequencedDocumentMessage): boolean {
46
- if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {
47
- return true;
48
- }
49
- return false;
50
+ if ((Object.values(RuntimeMessage) as string[]).includes(message.type)) {
51
+ return true;
52
+ }
53
+ return false;
50
54
  }
51
55
 
52
56
  // ADO #1385: staging code changes across layers.
53
57
  // Eventually to be replaced by MessageType.accept
54
58
  export enum MessageType2 {
55
- Accept = "accept",
59
+ Accept = "accept",
56
60
  }
57
61
 
58
62
  // ADO #1385: To be moved to packages/protocol-base/src/protocol.ts
59
- export function canBeCoalescedByService(message: ISequencedDocumentMessage | IDocumentMessage): boolean {
60
- // This assumes that in the future relay service may implement coalescing of accept messages,
61
- // same way it was doing coalescing of immediate noops in the past.
62
- return message.type === MessageType.NoOp || message.type === MessageType2.Accept;
63
+ export function canBeCoalescedByService(
64
+ message: ISequencedDocumentMessage | IDocumentMessage,
65
+ ): boolean {
66
+ // This assumes that in the future relay service may implement coalescing of accept messages,
67
+ // same way it was doing coalescing of immediate noops in the past.
68
+ return message.type === MessageType.NoOp || message.type === MessageType2.Accept;
63
69
  }
@@ -5,76 +5,87 @@
5
5
 
6
6
  import { parse } from "url";
7
7
  import {
8
- IDocumentServiceFactory,
9
- IResolvedUrl,
10
- IDocumentService,
8
+ IDocumentServiceFactory,
9
+ IResolvedUrl,
10
+ IDocumentService,
11
11
  } from "@fluidframework/driver-definitions";
12
12
  import { ISummaryTree } from "@fluidframework/protocol-definitions";
13
13
  import { ITelemetryBaseLogger } from "@fluidframework/common-definitions";
14
14
  import { ensureFluidResolvedUrl } from "./fluidResolvedUrl";
15
15
 
16
16
  export class MultiDocumentServiceFactory implements IDocumentServiceFactory {
17
- public static create(documentServiceFactory: IDocumentServiceFactory | IDocumentServiceFactory[]) {
18
- if (Array.isArray(documentServiceFactory)) {
19
- const factories: IDocumentServiceFactory[] = [];
20
- documentServiceFactory.forEach((factory) => {
21
- const maybeMulti = factory as MultiDocumentServiceFactory;
22
- if (maybeMulti.protocolToDocumentFactoryMap !== undefined) {
23
- factories.push(...maybeMulti.protocolToDocumentFactoryMap.values());
24
- } else {
25
- factories.push(factory);
26
- }
27
- });
28
- if (factories.length === 1) {
29
- return factories[0];
30
- }
31
- return new MultiDocumentServiceFactory(factories);
32
- }
33
- return documentServiceFactory;
34
- }
17
+ public static create(
18
+ documentServiceFactory: IDocumentServiceFactory | IDocumentServiceFactory[],
19
+ ) {
20
+ if (Array.isArray(documentServiceFactory)) {
21
+ const factories: IDocumentServiceFactory[] = [];
22
+ documentServiceFactory.forEach((factory) => {
23
+ const maybeMulti = factory as MultiDocumentServiceFactory;
24
+ if (maybeMulti.protocolToDocumentFactoryMap !== undefined) {
25
+ factories.push(...maybeMulti.protocolToDocumentFactoryMap.values());
26
+ } else {
27
+ factories.push(factory);
28
+ }
29
+ });
30
+ if (factories.length === 1) {
31
+ return factories[0];
32
+ }
33
+ return new MultiDocumentServiceFactory(factories);
34
+ }
35
+ return documentServiceFactory;
36
+ }
35
37
 
36
- private readonly protocolToDocumentFactoryMap: Map<string, IDocumentServiceFactory>;
38
+ private readonly protocolToDocumentFactoryMap: Map<string, IDocumentServiceFactory>;
37
39
 
38
- constructor(documentServiceFactories: IDocumentServiceFactory[]) {
39
- this.protocolToDocumentFactoryMap = new Map();
40
- documentServiceFactories.forEach((factory: IDocumentServiceFactory) => {
41
- this.protocolToDocumentFactoryMap.set(factory.protocolName, factory);
42
- });
43
- }
44
- public readonly protocolName = "none:";
45
- async createDocumentService(
46
- resolvedUrl: IResolvedUrl,
47
- logger?: ITelemetryBaseLogger,
48
- clientIsSummarizer?: boolean,
49
- ): Promise<IDocumentService> {
50
- ensureFluidResolvedUrl(resolvedUrl);
51
- const urlObj = parse(resolvedUrl.url);
52
- if (urlObj.protocol === undefined || urlObj.protocol === null) {
53
- throw new Error("No protocol provided");
54
- }
55
- const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);
56
- if (factory === undefined) {
57
- throw new Error("Unknown Fluid protocol");
58
- }
40
+ constructor(documentServiceFactories: IDocumentServiceFactory[]) {
41
+ this.protocolToDocumentFactoryMap = new Map();
42
+ documentServiceFactories.forEach((factory: IDocumentServiceFactory) => {
43
+ this.protocolToDocumentFactoryMap.set(factory.protocolName, factory);
44
+ });
45
+ }
46
+ public readonly protocolName = "none:";
47
+ async createDocumentService(
48
+ resolvedUrl: IResolvedUrl,
49
+ logger?: ITelemetryBaseLogger,
50
+ clientIsSummarizer?: boolean,
51
+ ): Promise<IDocumentService> {
52
+ ensureFluidResolvedUrl(resolvedUrl);
53
+ const urlObj = parse(resolvedUrl.url);
54
+ if (urlObj.protocol === undefined || urlObj.protocol === null) {
55
+ throw new Error("No protocol provided");
56
+ }
57
+ const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(
58
+ urlObj.protocol,
59
+ );
60
+ if (factory === undefined) {
61
+ throw new Error("Unknown Fluid protocol");
62
+ }
59
63
 
60
- return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
61
- }
64
+ return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
65
+ }
62
66
 
63
- public async createContainer(
64
- createNewSummary: ISummaryTree,
65
- createNewResolvedUrl: IResolvedUrl,
66
- logger?: ITelemetryBaseLogger,
67
- clientIsSummarizer?: boolean,
68
- ): Promise<IDocumentService> {
69
- ensureFluidResolvedUrl(createNewResolvedUrl);
70
- const urlObj = parse(createNewResolvedUrl.url);
71
- if (urlObj.protocol === undefined || urlObj.protocol === null) {
72
- throw new Error("No protocol provided");
73
- }
74
- const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);
75
- if (factory === undefined) {
76
- throw new Error("Unknown Fluid protocol");
77
- }
78
- return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);
79
- }
67
+ public async createContainer(
68
+ createNewSummary: ISummaryTree,
69
+ createNewResolvedUrl: IResolvedUrl,
70
+ logger?: ITelemetryBaseLogger,
71
+ clientIsSummarizer?: boolean,
72
+ ): Promise<IDocumentService> {
73
+ ensureFluidResolvedUrl(createNewResolvedUrl);
74
+ const urlObj = parse(createNewResolvedUrl.url);
75
+ if (urlObj.protocol === undefined || urlObj.protocol === null) {
76
+ throw new Error("No protocol provided");
77
+ }
78
+ const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(
79
+ urlObj.protocol,
80
+ );
81
+ if (factory === undefined) {
82
+ throw new Error("Unknown Fluid protocol");
83
+ }
84
+ return factory.createContainer(
85
+ createNewSummary,
86
+ createNewResolvedUrl,
87
+ logger,
88
+ clientIsSummarizer,
89
+ );
90
+ }
80
91
  }
@@ -12,40 +12,37 @@ import { IResolvedUrl, IUrlResolver } from "@fluidframework/driver-definitions";
12
12
  * @param request - Request to be resolved.
13
13
  */
14
14
  export async function configurableUrlResolver(
15
- resolversList: IUrlResolver[],
16
- request: IRequest,
15
+ resolversList: IUrlResolver[],
16
+ request: IRequest,
17
17
  ): Promise<IResolvedUrl | undefined> {
18
- let resolved: IResolvedUrl | undefined;
19
- for (const resolver of resolversList) {
20
- resolved = await resolver.resolve({ ...request });
21
- if (resolved !== undefined) {
22
- return resolved;
23
- }
24
- }
25
- return undefined;
18
+ let resolved: IResolvedUrl | undefined;
19
+ for (const resolver of resolversList) {
20
+ resolved = await resolver.resolve({ ...request });
21
+ if (resolved !== undefined) {
22
+ return resolved;
23
+ }
24
+ }
25
+ return undefined;
26
26
  }
27
27
 
28
28
  export class MultiUrlResolver implements IUrlResolver {
29
- public static create(urlResolver: IUrlResolver | IUrlResolver[]) {
30
- if (Array.isArray(urlResolver)) {
31
- if (urlResolver.length === 1) {
32
- return urlResolver[0];
33
- }
34
- return new MultiUrlResolver(urlResolver);
35
- }
36
- return urlResolver;
37
- }
29
+ public static create(urlResolver: IUrlResolver | IUrlResolver[]) {
30
+ if (Array.isArray(urlResolver)) {
31
+ if (urlResolver.length === 1) {
32
+ return urlResolver[0];
33
+ }
34
+ return new MultiUrlResolver(urlResolver);
35
+ }
36
+ return urlResolver;
37
+ }
38
38
 
39
- private constructor(private readonly urlResolvers: IUrlResolver[]) { }
39
+ private constructor(private readonly urlResolvers: IUrlResolver[]) {}
40
40
 
41
- async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {
42
- return configurableUrlResolver(this.urlResolvers, request);
43
- }
41
+ async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {
42
+ return configurableUrlResolver(this.urlResolvers, request);
43
+ }
44
44
 
45
- public async getAbsoluteUrl(
46
- resolvedUrl: IResolvedUrl,
47
- relativeUrl: string,
48
- ): Promise<string> {
49
- throw new Error("Not implmented");
50
- }
45
+ public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
46
+ throw new Error("Not implmented");
47
+ }
51
48
  }