@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.
- package/.eslintrc.js +17 -19
- package/.mocharc.js +2 -2
- package/api-extractor.json +2 -2
- package/dist/blobAggregationStorage.d.ts +2 -2
- package/dist/blobAggregationStorage.d.ts.map +1 -1
- package/dist/blobAggregationStorage.js +11 -6
- package/dist/blobAggregationStorage.js.map +1 -1
- package/dist/blobCacheStorageService.d.ts.map +1 -1
- package/dist/blobCacheStorageService.js.map +1 -1
- package/dist/buildSnapshotTree.d.ts.map +1 -1
- package/dist/buildSnapshotTree.js.map +1 -1
- package/dist/documentStorageServiceProxy.d.ts.map +1 -1
- package/dist/documentStorageServiceProxy.js.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/dist/emptyDocumentDeltaStorageService.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/fluidResolvedUrl.d.ts.map +1 -1
- package/dist/fluidResolvedUrl.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/insecureUrlResolver.d.ts.map +1 -1
- package/dist/insecureUrlResolver.js +2 -1
- package/dist/insecureUrlResolver.js.map +1 -1
- package/dist/mapWithExpiration.d.ts.map +1 -1
- package/dist/mapWithExpiration.js +5 -3
- package/dist/mapWithExpiration.js.map +1 -1
- package/dist/messageRecognition.d.ts.map +1 -1
- package/dist/messageRecognition.js.map +1 -1
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/multiUrlResolver.d.ts.map +1 -1
- package/dist/multiUrlResolver.js.map +1 -1
- package/dist/network.d.ts +1 -1
- package/dist/network.d.ts.map +1 -1
- package/dist/network.js +4 -3
- package/dist/network.js.map +1 -1
- package/dist/networkUtils.d.ts.map +1 -1
- package/dist/networkUtils.js +2 -3
- package/dist/networkUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/parallelRequests.d.ts.map +1 -1
- package/dist/parallelRequests.js +19 -9
- package/dist/parallelRequests.js.map +1 -1
- package/dist/prefetchDocumentStorageService.d.ts.map +1 -1
- package/dist/prefetchDocumentStorageService.js.map +1 -1
- package/dist/rateLimiter.d.ts.map +1 -1
- package/dist/rateLimiter.js.map +1 -1
- package/dist/readAndParse.d.ts.map +1 -1
- package/dist/readAndParse.js.map +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js.map +1 -1
- package/dist/summaryForCreateNew.d.ts.map +1 -1
- package/dist/summaryForCreateNew.js.map +1 -1
- package/dist/treeConversions.d.ts.map +1 -1
- package/dist/treeConversions.js +1 -4
- package/dist/treeConversions.js.map +1 -1
- package/dist/treeUtils.d.ts +10 -10
- package/dist/treeUtils.d.ts.map +1 -1
- package/dist/treeUtils.js +10 -10
- package/dist/treeUtils.js.map +1 -1
- package/lib/blobAggregationStorage.d.ts +2 -2
- package/lib/blobAggregationStorage.d.ts.map +1 -1
- package/lib/blobAggregationStorage.js +11 -6
- package/lib/blobAggregationStorage.js.map +1 -1
- package/lib/blobCacheStorageService.d.ts.map +1 -1
- package/lib/blobCacheStorageService.js.map +1 -1
- package/lib/buildSnapshotTree.d.ts.map +1 -1
- package/lib/buildSnapshotTree.js.map +1 -1
- package/lib/documentStorageServiceProxy.d.ts.map +1 -1
- package/lib/documentStorageServiceProxy.js.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.d.ts.map +1 -1
- package/lib/emptyDocumentDeltaStorageService.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/fluidResolvedUrl.d.ts.map +1 -1
- package/lib/fluidResolvedUrl.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/insecureUrlResolver.d.ts.map +1 -1
- package/lib/insecureUrlResolver.js +2 -1
- package/lib/insecureUrlResolver.js.map +1 -1
- package/lib/mapWithExpiration.d.ts.map +1 -1
- package/lib/mapWithExpiration.js +5 -3
- package/lib/mapWithExpiration.js.map +1 -1
- package/lib/messageRecognition.d.ts.map +1 -1
- package/lib/messageRecognition.js +1 -1
- package/lib/messageRecognition.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/multiUrlResolver.d.ts.map +1 -1
- package/lib/multiUrlResolver.js.map +1 -1
- package/lib/network.d.ts +1 -1
- package/lib/network.d.ts.map +1 -1
- package/lib/network.js +4 -3
- package/lib/network.js.map +1 -1
- package/lib/networkUtils.d.ts.map +1 -1
- package/lib/networkUtils.js +2 -3
- package/lib/networkUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/parallelRequests.d.ts.map +1 -1
- package/lib/parallelRequests.js +19 -9
- package/lib/parallelRequests.js.map +1 -1
- package/lib/prefetchDocumentStorageService.d.ts.map +1 -1
- package/lib/prefetchDocumentStorageService.js.map +1 -1
- package/lib/rateLimiter.d.ts.map +1 -1
- package/lib/rateLimiter.js.map +1 -1
- package/lib/readAndParse.d.ts.map +1 -1
- package/lib/readAndParse.js.map +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js.map +1 -1
- package/lib/summaryForCreateNew.d.ts.map +1 -1
- package/lib/summaryForCreateNew.js.map +1 -1
- package/lib/treeConversions.d.ts.map +1 -1
- package/lib/treeConversions.js +4 -7
- package/lib/treeConversions.js.map +1 -1
- package/lib/treeUtils.d.ts +10 -10
- package/lib/treeUtils.d.ts.map +1 -1
- package/lib/treeUtils.js +11 -11
- package/lib/treeUtils.js.map +1 -1
- package/package.json +128 -105
- package/prettier.config.cjs +1 -1
- package/src/blobAggregationStorage.ts +374 -322
- package/src/blobCacheStorageService.ts +20 -17
- package/src/buildSnapshotTree.ts +54 -51
- package/src/documentStorageServiceProxy.ts +49 -43
- package/src/emptyDocumentDeltaStorageService.ts +11 -10
- package/src/error.ts +5 -7
- package/src/fluidResolvedUrl.ts +9 -6
- package/src/index.ts +5 -1
- package/src/insecureUrlResolver.ts +127 -116
- package/src/mapWithExpiration.ts +111 -104
- package/src/messageRecognition.ts +25 -19
- package/src/multiDocumentServiceFactory.ts +73 -62
- package/src/multiUrlResolver.ts +26 -29
- package/src/network.ts +114 -112
- package/src/networkUtils.ts +37 -34
- package/src/packageVersion.ts +1 -1
- package/src/parallelRequests.ts +571 -509
- package/src/prefetchDocumentStorageService.ts +76 -74
- package/src/rateLimiter.ts +29 -29
- package/src/readAndParse.ts +7 -4
- package/src/runWithRetry.ts +105 -94
- package/src/summaryForCreateNew.ts +27 -24
- package/src/treeConversions.ts +48 -70
- package/src/treeUtils.ts +70 -74
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +8 -12
package/src/mapWithExpiration.ts
CHANGED
|
@@ -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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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 {
|
|
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
|
|
13
|
-
|
|
16
|
+
export function isRuntimeMessage(message: { type: string }): boolean {
|
|
17
|
+
return message.type === MessageType.Operation;
|
|
14
18
|
}
|
|
15
19
|
|
|
16
20
|
enum RuntimeMessage {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
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(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
38
|
+
private readonly protocolToDocumentFactoryMap: Map<string, IDocumentServiceFactory>;
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
61
|
-
|
|
64
|
+
return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
65
|
+
}
|
|
62
66
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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
|
}
|
package/src/multiUrlResolver.ts
CHANGED
|
@@ -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
|
-
|
|
16
|
-
|
|
15
|
+
resolversList: IUrlResolver[],
|
|
16
|
+
request: IRequest,
|
|
17
17
|
): Promise<IResolvedUrl | undefined> {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
+
private constructor(private readonly urlResolvers: IUrlResolver[]) {}
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
async resolve(request: IRequest): Promise<IResolvedUrl | undefined> {
|
|
42
|
+
return configurableUrlResolver(this.urlResolvers, request);
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
}
|