@fluid-tools/fetch-tool 1.4.0-115997 → 2.0.0-dev-rc.1.0.0.224419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -8
- package/CHANGELOG.md +117 -0
- package/README.md +38 -7
- package/bin/fluid-fetch +0 -0
- package/dist/fluidAnalyzeMessages.d.ts.map +1 -1
- package/dist/fluidAnalyzeMessages.js +106 -116
- package/dist/fluidAnalyzeMessages.js.map +1 -1
- package/dist/fluidFetch.js +5 -3
- package/dist/fluidFetch.js.map +1 -1
- package/dist/fluidFetchArgs.d.ts +0 -3
- package/dist/fluidFetchArgs.d.ts.map +1 -1
- package/dist/fluidFetchArgs.js +10 -14
- package/dist/fluidFetchArgs.js.map +1 -1
- package/dist/fluidFetchInit.d.ts +0 -1
- package/dist/fluidFetchInit.d.ts.map +1 -1
- package/dist/fluidFetchInit.js +41 -34
- package/dist/fluidFetchInit.js.map +1 -1
- package/dist/fluidFetchMessages.d.ts.map +1 -1
- package/dist/fluidFetchMessages.js +168 -200
- package/dist/fluidFetchMessages.js.map +1 -1
- package/dist/fluidFetchSharePoint.d.ts +0 -1
- package/dist/fluidFetchSharePoint.d.ts.map +1 -1
- package/dist/fluidFetchSharePoint.js +20 -6
- package/dist/fluidFetchSharePoint.js.map +1 -1
- package/dist/fluidFetchSnapshot.d.ts.map +1 -1
- package/dist/fluidFetchSnapshot.js +18 -20
- package/dist/fluidFetchSnapshot.js.map +1 -1
- package/package.json +47 -42
- package/prettier.config.cjs +8 -0
- package/src/fluidAnalyzeMessages.ts +701 -630
- package/src/fluidFetch.ts +93 -88
- package/src/fluidFetchArgs.ts +167 -168
- package/src/fluidFetchInit.ts +133 -104
- package/src/fluidFetchMessages.ts +253 -232
- package/src/fluidFetchSharePoint.ts +130 -112
- package/src/fluidFetchSnapshot.ts +313 -295
- package/tsconfig.json +8 -15
package/src/fluidFetchInit.ts
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { URL } from "url";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { configurableUrlResolver } from "@fluidframework/driver-utils";
|
|
7
|
+
import { IRequest } from "@fluidframework/core-interfaces";
|
|
8
|
+
import { IResolvedUrl } from "@fluidframework/driver-definitions";
|
|
10
9
|
import { FluidAppOdspUrlResolver } from "@fluid-tools/fluidapp-odsp-urlresolver";
|
|
11
10
|
import { IClientConfig, IOdspAuthRequestInfo } from "@fluidframework/odsp-doclib-utils";
|
|
12
11
|
import * as odsp from "@fluidframework/odsp-driver";
|
|
13
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
IOdspResolvedUrl,
|
|
14
|
+
OdspResourceTokenFetchOptions,
|
|
15
|
+
} from "@fluidframework/odsp-driver-definitions";
|
|
14
16
|
import { OdspUrlResolver } from "@fluidframework/odsp-urlresolver";
|
|
15
17
|
import * as r11s from "@fluidframework/routerlicious-driver";
|
|
16
18
|
import { RouterliciousUrlResolver } from "@fluidframework/routerlicious-urlresolver";
|
|
@@ -21,122 +23,149 @@ import { resolveWrapper } from "./fluidFetchSharePoint";
|
|
|
21
23
|
export let latestVersionsId: string = "";
|
|
22
24
|
export let connectionInfo: any;
|
|
23
25
|
|
|
24
|
-
export const fluidFetchWebNavigator = (url: string) => {
|
|
25
|
-
let message = "Please open browser and navigate to this URL:";
|
|
26
|
-
if (process.platform === "win32") {
|
|
27
|
-
child_process.exec(`start "fluid-fetch" /B "${url}"`);
|
|
28
|
-
message = "Opening browser to get authorization code. If that doesn't open, please go to this URL manually";
|
|
29
|
-
}
|
|
30
|
-
console.log(`${message}\n ${url}`);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
26
|
async function initializeODSPCore(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
odspResolvedUrl: IOdspResolvedUrl,
|
|
28
|
+
server: string,
|
|
29
|
+
clientConfig: IClientConfig,
|
|
37
30
|
) {
|
|
38
|
-
|
|
31
|
+
const { driveId, itemId } = odspResolvedUrl;
|
|
39
32
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
connectionInfo = {
|
|
34
|
+
server,
|
|
35
|
+
drive: driveId,
|
|
36
|
+
item: itemId,
|
|
37
|
+
};
|
|
45
38
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
if (localDataOnly) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
49
42
|
|
|
50
|
-
|
|
43
|
+
const docId = await odsp.getHashedDocumentId(driveId, itemId);
|
|
51
44
|
|
|
52
|
-
|
|
45
|
+
console.log(`Connecting to ODSP:
|
|
53
46
|
server: ${server}
|
|
54
47
|
drive: ${driveId}
|
|
55
48
|
item: ${itemId}
|
|
56
49
|
docId: ${docId}`);
|
|
57
50
|
|
|
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
|
-
|
|
51
|
+
const getStorageTokenStub = async (options: OdspResourceTokenFetchOptions) => {
|
|
52
|
+
return resolveWrapper(
|
|
53
|
+
async (authRequestInfo: IOdspAuthRequestInfo) => {
|
|
54
|
+
if (
|
|
55
|
+
(options.refresh || !authRequestInfo.accessToken) &&
|
|
56
|
+
authRequestInfo.refreshTokenFn
|
|
57
|
+
) {
|
|
58
|
+
return authRequestInfo.refreshTokenFn();
|
|
59
|
+
}
|
|
60
|
+
return authRequestInfo.accessToken;
|
|
61
|
+
},
|
|
62
|
+
server,
|
|
63
|
+
clientConfig,
|
|
64
|
+
undefined,
|
|
65
|
+
true,
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
69
|
+
const getWebsocketTokenStub = (_options: OdspResourceTokenFetchOptions) => Promise.resolve("");
|
|
70
|
+
const odspDocumentServiceFactory = new odsp.OdspDocumentServiceFactory(
|
|
71
|
+
getStorageTokenStub,
|
|
72
|
+
getWebsocketTokenStub,
|
|
73
|
+
undefined,
|
|
74
|
+
{
|
|
75
|
+
opsBatchSize: 20000,
|
|
76
|
+
concurrentOpsBatches: 4,
|
|
77
|
+
},
|
|
78
|
+
);
|
|
79
|
+
return odspDocumentServiceFactory.createDocumentService(odspResolvedUrl);
|
|
83
80
|
}
|
|
84
81
|
|
|
85
|
-
async function initializeR11s(server: string, pathname: string, r11sResolvedUrl:
|
|
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
|
-
|
|
82
|
+
async function initializeR11s(server: string, pathname: string, r11sResolvedUrl: IResolvedUrl) {
|
|
83
|
+
const path = pathname.split("/");
|
|
84
|
+
let tenantId: string;
|
|
85
|
+
let documentId: string;
|
|
86
|
+
if (server === "localhost" && path.length < 4) {
|
|
87
|
+
tenantId = "fluid";
|
|
88
|
+
documentId = path[2];
|
|
89
|
+
} else {
|
|
90
|
+
tenantId = path[2];
|
|
91
|
+
documentId = path[3];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Latest version id is the documentId for r11s
|
|
95
|
+
latestVersionsId = documentId;
|
|
96
|
+
|
|
97
|
+
connectionInfo = {
|
|
98
|
+
server,
|
|
99
|
+
tenantId,
|
|
100
|
+
id: documentId,
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (localDataOnly) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
console.log(`Connecting to r11s: tenantId=${tenantId} id:${documentId}`);
|
|
108
|
+
const tokenProvider = new r11s.DefaultTokenProvider(paramJWT);
|
|
109
|
+
const r11sDocumentServiceFactory = new r11s.RouterliciousDocumentServiceFactory(tokenProvider);
|
|
110
|
+
return r11sDocumentServiceFactory.createDocumentService(r11sResolvedUrl);
|
|
114
111
|
}
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
113
|
+
interface IResolvedInfo {
|
|
114
|
+
resolvedUrl: IResolvedUrl;
|
|
115
|
+
serviceType: "odsp" | "r11s";
|
|
116
|
+
}
|
|
117
|
+
async function resolveUrl(url: string): Promise<IResolvedInfo | undefined> {
|
|
118
|
+
const request: IRequest = { url };
|
|
119
|
+
let maybeResolvedUrl: IResolvedUrl | undefined;
|
|
120
|
+
|
|
121
|
+
// Try each url resolver in turn to figure out which one the request is compatible with.
|
|
122
|
+
maybeResolvedUrl = await new OdspUrlResolver().resolve(request);
|
|
123
|
+
if (maybeResolvedUrl !== undefined) {
|
|
124
|
+
return {
|
|
125
|
+
resolvedUrl: maybeResolvedUrl,
|
|
126
|
+
serviceType: "odsp",
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
maybeResolvedUrl = await new FluidAppOdspUrlResolver().resolve(request);
|
|
131
|
+
if (maybeResolvedUrl !== undefined) {
|
|
132
|
+
return {
|
|
133
|
+
resolvedUrl: maybeResolvedUrl,
|
|
134
|
+
serviceType: "odsp",
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
maybeResolvedUrl = await new RouterliciousUrlResolver(
|
|
139
|
+
undefined,
|
|
140
|
+
async () => Promise.resolve(paramJWT),
|
|
141
|
+
"",
|
|
142
|
+
).resolve(request);
|
|
143
|
+
if (maybeResolvedUrl !== undefined) {
|
|
144
|
+
return {
|
|
145
|
+
resolvedUrl: maybeResolvedUrl,
|
|
146
|
+
serviceType: "r11s",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return undefined;
|
|
125
151
|
}
|
|
126
152
|
|
|
127
153
|
export async function fluidFetchInit(urlStr: string) {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
154
|
+
const resolvedInfo = await resolveUrl(urlStr);
|
|
155
|
+
if (resolvedInfo === undefined) {
|
|
156
|
+
throw new Error(`Unknown URL ${urlStr}`);
|
|
157
|
+
}
|
|
158
|
+
const fluidResolvedUrl = resolvedInfo.resolvedUrl;
|
|
159
|
+
if (resolvedInfo.serviceType === "odsp") {
|
|
160
|
+
const odspResolvedUrl = fluidResolvedUrl as IOdspResolvedUrl;
|
|
161
|
+
return initializeODSPCore(
|
|
162
|
+
odspResolvedUrl,
|
|
163
|
+
new URL(odspResolvedUrl.siteUrl).host,
|
|
164
|
+
getMicrosoftConfiguration(),
|
|
165
|
+
);
|
|
166
|
+
} else if (resolvedInfo.serviceType === "r11s") {
|
|
167
|
+
const url = new URL(urlStr);
|
|
168
|
+
const server = url.hostname.toLowerCase();
|
|
169
|
+
return initializeR11s(server, url.pathname, fluidResolvedUrl);
|
|
170
|
+
}
|
|
142
171
|
}
|