@fluidframework/local-driver 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.225277
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 +19 -22
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +127 -0
- package/README.md +38 -0
- package/api-extractor-esm.json +4 -0
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +4 -0
- package/api-report/local-driver.api.md +129 -0
- package/dist/{auth.js → auth.cjs} +8 -6
- package/dist/auth.cjs.map +1 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/index.cjs +24 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +7 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/local-driver-alpha.d.ts +110 -0
- package/dist/local-driver-beta.d.ts +75 -0
- package/dist/local-driver-public.d.ts +75 -0
- package/dist/local-driver-untrimmed.d.ts +226 -0
- package/dist/localCreateDocument.cjs +28 -0
- package/dist/localCreateDocument.cjs.map +1 -0
- package/dist/localCreateDocument.d.ts +8 -0
- package/dist/localCreateDocument.d.ts.map +1 -0
- package/dist/{localDeltaStorageService.js → localDeltaStorageService.cjs} +3 -2
- package/dist/localDeltaStorageService.cjs.map +1 -0
- package/dist/localDeltaStorageService.d.ts +4 -3
- package/dist/localDeltaStorageService.d.ts.map +1 -1
- package/dist/{localDocumentDeltaConnection.js → localDocumentDeltaConnection.cjs} +9 -11
- package/dist/localDocumentDeltaConnection.cjs.map +1 -0
- package/dist/localDocumentDeltaConnection.d.ts +5 -4
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/{localDocumentService.js → localDocumentService.cjs} +15 -30
- package/dist/localDocumentService.cjs.map +1 -0
- package/dist/localDocumentService.d.ts +15 -11
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/{localDocumentServiceFactory.js → localDocumentServiceFactory.cjs} +14 -31
- package/dist/localDocumentServiceFactory.cjs.map +1 -0
- package/dist/localDocumentServiceFactory.d.ts +3 -2
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentStorageService.cjs +88 -0
- package/dist/localDocumentStorageService.cjs.map +1 -0
- package/dist/localDocumentStorageService.d.ts +30 -0
- package/dist/localDocumentStorageService.d.ts.map +1 -0
- package/dist/{localResolver.js → localResolver.cjs} +10 -6
- package/dist/localResolver.cjs.map +1 -0
- package/dist/localResolver.d.ts +5 -0
- package/dist/localResolver.d.ts.map +1 -1
- package/dist/{localSessionStorageDb.js → localSessionStorageDb.cjs} +26 -18
- package/dist/localSessionStorageDb.cjs.map +1 -0
- package/dist/localSessionStorageDb.d.ts +1 -1
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/auth.d.mts +12 -0
- package/lib/auth.d.mts.map +1 -0
- package/lib/auth.mjs +40 -0
- package/lib/auth.mjs.map +1 -0
- package/lib/index.d.mts +12 -0
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +12 -0
- package/lib/index.mjs.map +1 -0
- package/lib/local-driver-alpha.d.mts +110 -0
- package/lib/local-driver-beta.d.mts +75 -0
- package/lib/local-driver-public.d.mts +75 -0
- package/lib/local-driver-untrimmed.d.mts +226 -0
- package/lib/localCreateDocument.d.mts +8 -0
- package/lib/localCreateDocument.d.mts.map +1 -0
- package/lib/localCreateDocument.mjs +24 -0
- package/lib/localCreateDocument.mjs.map +1 -0
- package/lib/localDeltaStorageService.d.mts +20 -0
- package/lib/localDeltaStorageService.d.mts.map +1 -0
- package/lib/localDeltaStorageService.mjs +32 -0
- package/lib/localDeltaStorageService.mjs.map +1 -0
- package/lib/localDocumentDeltaConnection.d.mts +48 -0
- package/lib/localDocumentDeltaConnection.d.mts.map +1 -0
- package/lib/localDocumentDeltaConnection.mjs +86 -0
- package/lib/localDocumentDeltaConnection.mjs.map +1 -0
- package/lib/localDocumentService.d.mts +56 -0
- package/lib/localDocumentService.d.mts.map +1 -0
- package/lib/localDocumentService.mjs +84 -0
- package/lib/localDocumentService.mjs.map +1 -0
- package/lib/localDocumentServiceFactory.d.mts +45 -0
- package/lib/localDocumentServiceFactory.d.mts.map +1 -0
- package/lib/localDocumentServiceFactory.mjs +80 -0
- package/lib/localDocumentServiceFactory.mjs.map +1 -0
- package/lib/localDocumentStorageService.d.mts +30 -0
- package/lib/localDocumentStorageService.d.mts.map +1 -0
- package/lib/localDocumentStorageService.mjs +84 -0
- package/lib/localDocumentStorageService.mjs.map +1 -0
- package/lib/localResolver.d.mts +31 -0
- package/lib/localResolver.d.mts.map +1 -0
- package/lib/localResolver.mjs +74 -0
- package/lib/localResolver.mjs.map +1 -0
- package/lib/localSessionStorageDb.d.mts +11 -0
- package/lib/localSessionStorageDb.d.mts.map +1 -0
- package/lib/localSessionStorageDb.mjs +292 -0
- package/lib/localSessionStorageDb.mjs.map +1 -0
- package/package.json +140 -59
- package/prettier.config.cjs +8 -0
- package/src/auth.ts +42 -33
- package/src/index.ts +7 -6
- package/src/localCreateDocument.ts +48 -0
- package/src/localDeltaStorageService.ts +28 -27
- package/src/localDocumentDeltaConnection.ts +91 -88
- package/src/localDocumentService.ts +117 -97
- package/src/localDocumentServiceFactory.ts +95 -123
- package/src/localDocumentStorageService.ts +131 -0
- package/src/localResolver.ts +57 -59
- package/src/localSessionStorageDb.ts +272 -265
- package/tsc-multi.test.json +4 -0
- package/tsconfig.json +11 -13
- package/dist/auth.js.map +0 -1
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/localDeltaStorageService.js.map +0 -1
- package/dist/localDocumentDeltaConnection.js.map +0 -1
- package/dist/localDocumentService.js.map +0 -1
- package/dist/localDocumentServiceFactory.js.map +0 -1
- package/dist/localResolver.js.map +0 -1
- package/dist/localSessionStorageDb.js.map +0 -1
- package/dist/packageVersion.d.ts +0 -9
- package/dist/packageVersion.d.ts.map +0 -1
- package/dist/packageVersion.js +0 -12
- package/dist/packageVersion.js.map +0 -1
- package/src/packageVersion.ts +0 -9
package/src/localResolver.ts
CHANGED
|
@@ -4,81 +4,79 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { parse } from "url";
|
|
7
|
-
import { assert } from "@fluidframework/
|
|
7
|
+
import { assert } from "@fluidframework/core-utils";
|
|
8
8
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
9
|
-
import {
|
|
10
|
-
IFluidResolvedUrl,
|
|
11
|
-
IResolvedUrl,
|
|
12
|
-
IUrlResolver,
|
|
13
|
-
DriverHeader,
|
|
14
|
-
} from "@fluidframework/driver-definitions";
|
|
9
|
+
import { IResolvedUrl, IUrlResolver, DriverHeader } from "@fluidframework/driver-definitions";
|
|
15
10
|
import { ScopeType } from "@fluidframework/protocol-definitions";
|
|
16
11
|
import { generateToken } from "./auth";
|
|
17
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @alpha
|
|
15
|
+
*/
|
|
18
16
|
export function createLocalResolverCreateNewRequest(documentId: string): IRequest {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
const createNewRequest: IRequest = {
|
|
18
|
+
url: `http://localhost:3000/${documentId}`,
|
|
19
|
+
headers: {
|
|
20
|
+
[DriverHeader.createNew]: true,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return createNewRequest;
|
|
26
24
|
}
|
|
27
25
|
|
|
28
26
|
/**
|
|
29
27
|
* Resolves URLs by providing fake URLs which succeed with the other
|
|
30
28
|
* related local classes.
|
|
29
|
+
* @alpha
|
|
31
30
|
*/
|
|
32
31
|
export class LocalResolver implements IUrlResolver {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constructor() { }
|
|
32
|
+
private readonly tenantId = "tenantId";
|
|
33
|
+
private readonly tokenKey = "tokenKey";
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
* Resolves URL requests by providing fake URLs with an actually generated
|
|
40
|
-
* token from constant test strings. The root of the URL is fake, but the
|
|
41
|
-
* remaining relative URL can still be parsed.
|
|
42
|
-
* @param request - request to handle
|
|
43
|
-
*/
|
|
44
|
-
public async resolve(request: IRequest): Promise<IResolvedUrl> {
|
|
45
|
-
const parsedUrl = new URL(request.url);
|
|
46
|
-
const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
|
|
47
|
-
const documentId = fullPath.split("/")[0];
|
|
48
|
-
const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];
|
|
49
|
-
const resolved: IFluidResolvedUrl = {
|
|
50
|
-
endpoints: {
|
|
51
|
-
deltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,
|
|
52
|
-
ordererUrl: "http://localhost:3000",
|
|
53
|
-
storageUrl: `http://localhost:3000/repos/${this.tenantId}`,
|
|
54
|
-
},
|
|
55
|
-
id: documentId,
|
|
56
|
-
tokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },
|
|
57
|
-
type: "fluid",
|
|
58
|
-
url: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,
|
|
59
|
-
};
|
|
35
|
+
constructor() {}
|
|
60
36
|
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Resolves URL requests by providing fake URLs with an actually generated
|
|
39
|
+
* token from constant test strings. The root of the URL is fake, but the
|
|
40
|
+
* remaining relative URL can still be parsed.
|
|
41
|
+
* @param request - request to handle
|
|
42
|
+
* @alpha
|
|
43
|
+
*/
|
|
44
|
+
public async resolve(request: IRequest): Promise<IResolvedUrl> {
|
|
45
|
+
const parsedUrl = new URL(request.url);
|
|
46
|
+
const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
|
|
47
|
+
const documentId = fullPath.split("/")[0];
|
|
48
|
+
const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];
|
|
49
|
+
const resolved: IResolvedUrl = {
|
|
50
|
+
endpoints: {
|
|
51
|
+
deltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,
|
|
52
|
+
ordererUrl: "http://localhost:3000",
|
|
53
|
+
storageUrl: `http://localhost:3000/repos/${this.tenantId}`,
|
|
54
|
+
},
|
|
55
|
+
id: documentId,
|
|
56
|
+
tokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },
|
|
57
|
+
type: "fluid",
|
|
58
|
+
url: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,
|
|
59
|
+
};
|
|
63
60
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (url.startsWith("/")) {
|
|
67
|
-
url = url.substr(1);
|
|
68
|
-
}
|
|
69
|
-
const fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;
|
|
61
|
+
return resolved;
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
64
|
+
public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
|
|
65
|
+
let url = relativeUrl;
|
|
66
|
+
if (url.startsWith("/")) {
|
|
67
|
+
url = url.substr(1);
|
|
68
|
+
}
|
|
69
|
+
const parsedUrl = parse(resolvedUrl.url);
|
|
70
|
+
if (parsedUrl.pathname === null) {
|
|
71
|
+
throw new Error("Url should contain tenant and docId!!");
|
|
72
|
+
}
|
|
73
|
+
const [, , documentId] = parsedUrl.pathname.split("/");
|
|
74
|
+
assert(!!documentId, 0x09a /* "'documentId' must be a defined, non-zero length string." */);
|
|
77
75
|
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
return `http://localhost:3000/${documentId}/${url}`;
|
|
77
|
+
}
|
|
80
78
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
public createCreateNewRequest(documentId: string): IRequest {
|
|
80
|
+
return createLocalResolverCreateNewRequest(documentId);
|
|
81
|
+
}
|
|
84
82
|
}
|