@fluidframework/odsp-driver 2.116.1 → 2.118.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/CHANGELOG.md +60 -0
- package/api-extractor/api-extractor-lint-pointInTime.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-pointInTime.esm.json +5 -0
- package/api-extractor/api-extractor-report.pointInTime.json +9 -0
- package/api-report/odsp-driver.legacy.alpha.api.md +28 -1
- package/api-report/odsp-driver.legacy.beta.api.md +28 -1
- package/api-report/odsp-driver.point-in-time.legacy.beta.api.md +117 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -5
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +4 -0
- package/dist/legacyAlpha.d.ts +4 -0
- package/dist/odspDocumentServiceFactory.d.ts +46 -1
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +60 -1
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +74 -3
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +0 -3
- package/dist/odspDocumentServiceFactoryCore.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/pointInTime.d.ts +15 -0
- package/dist/pointInTime.d.ts.map +1 -0
- package/dist/pointInTime.js +16 -0
- package/dist/pointInTime.js.map +1 -0
- package/dist/pointInTimeDriver/createPointInTimeDocumentService.d.ts +34 -0
- package/dist/pointInTimeDriver/createPointInTimeDocumentService.d.ts.map +1 -0
- package/dist/pointInTimeDriver/createPointInTimeDocumentService.js +90 -0
- package/dist/pointInTimeDriver/createPointInTimeDocumentService.js.map +1 -0
- package/legacy/point-in-time.d.ts +6 -0
- package/lib/index.d.ts +2 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -5
- package/lib/index.js.map +1 -1
- package/lib/legacy.d.ts +4 -0
- package/lib/legacyAlpha.d.ts +4 -0
- package/lib/odspDocumentServiceFactory.d.ts +46 -1
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +58 -1
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +74 -3
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +0 -3
- package/lib/odspDocumentServiceFactoryCore.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/pointInTime.d.ts +15 -0
- package/lib/pointInTime.d.ts.map +1 -0
- package/lib/pointInTime.js +12 -0
- package/lib/pointInTime.js.map +1 -0
- package/lib/pointInTimeDriver/createPointInTimeDocumentService.d.ts +34 -0
- package/lib/pointInTimeDriver/createPointInTimeDocumentService.d.ts.map +1 -0
- package/lib/pointInTimeDriver/createPointInTimeDocumentService.js +87 -0
- package/lib/pointInTimeDriver/createPointInTimeDocumentService.js.map +1 -0
- package/package.json +25 -11
- package/src/index.ts +7 -5
- package/src/odspDocumentServiceFactory.ts +103 -1
- package/src/odspDocumentServiceFactoryCore.ts +90 -3
- package/src/odspVersionManager/DEV.md +9 -8
- package/src/packageVersion.ts +1 -1
- package/src/pointInTime.ts +30 -0
- package/src/pointInTimeDriver/createPointInTimeDocumentService.ts +180 -0
- package/dist/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.d.ts +0 -41
- package/dist/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.d.ts.map +0 -1
- package/dist/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.js +0 -132
- package/dist/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.js.map +0 -1
- package/lib/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.d.ts +0 -41
- package/lib/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.d.ts.map +0 -1
- package/lib/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.js +0 -128
- package/lib/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.js.map +0 -1
- package/src/pointInTimeDriver/odspPointInTimeDocumentServiceFactory.ts +0 -260
|
@@ -4,7 +4,27 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { IDocumentServiceFactory, IPersistedCache } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import type { HostStoragePolicy, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions/internal";
|
|
7
|
-
import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore.js";
|
|
7
|
+
import { type IPointInTimeDocumentServiceFactory, type OdspPointInTimeDocumentServiceImplementation, OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore.js";
|
|
8
|
+
/**
|
|
9
|
+
* Options for creating an ODSP document service factory.
|
|
10
|
+
*
|
|
11
|
+
* @legacy @beta
|
|
12
|
+
*/
|
|
13
|
+
export interface IOdspDocumentServiceFactoryOptions {
|
|
14
|
+
/** Fetches storage access tokens. */
|
|
15
|
+
readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>;
|
|
16
|
+
/** Fetches websocket access tokens, or `undefined` when unavailable. */
|
|
17
|
+
readonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined;
|
|
18
|
+
/** Persisted ODSP cache. When omitted, a local in-memory cache is used. */
|
|
19
|
+
readonly persistedCache?: IPersistedCache | undefined;
|
|
20
|
+
/** Host storage policy. When omitted, the default driver policies are used. */
|
|
21
|
+
readonly hostPolicy?: HostStoragePolicy | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Enables point-in-time loading. Consumers that omit this implementation do not include the
|
|
24
|
+
* feature code in their dependency graph.
|
|
25
|
+
*/
|
|
26
|
+
readonly pointInTimeDocumentServiceImplementation?: OdspPointInTimeDocumentServiceImplementation | undefined;
|
|
27
|
+
}
|
|
8
28
|
/**
|
|
9
29
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
10
30
|
* use the sharepoint implementation.
|
|
@@ -14,6 +34,31 @@ import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore
|
|
|
14
34
|
export declare class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
|
|
15
35
|
constructor(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy);
|
|
16
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Creates an ODSP document service factory with optional consumer-provided features.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Tokens, cache, host policy, and optional feature implementations.
|
|
41
|
+
* @returns The configured ODSP document service factory.
|
|
42
|
+
*
|
|
43
|
+
* @legacy @beta
|
|
44
|
+
*/
|
|
45
|
+
export declare function createOdspDocumentServiceFactory(options: IOdspDocumentServiceFactoryOptions): OdspDocumentServiceFactory;
|
|
46
|
+
/**
|
|
47
|
+
* Creates an ODSP document service factory that supports point-in-time loading.
|
|
48
|
+
*
|
|
49
|
+
* @param getStorageToken - Fetches storage access tokens.
|
|
50
|
+
* @param getWebsocketToken - Fetches websocket access tokens, or `undefined` when unavailable.
|
|
51
|
+
* @param persistedCache - Optional persisted ODSP cache.
|
|
52
|
+
* @param hostPolicy - Optional host storage policy.
|
|
53
|
+
* @returns An ODSP document service factory with point-in-time loading capability.
|
|
54
|
+
*
|
|
55
|
+
* @deprecated Use
|
|
56
|
+
* {@link createOdspDocumentServiceFactory} with a point-in-time implementation instead.
|
|
57
|
+
* See {@link https://github.com/microsoft/FluidFramework/issues/26500} for context.
|
|
58
|
+
*
|
|
59
|
+
* @legacy @beta
|
|
60
|
+
*/
|
|
61
|
+
export declare function getOdspPointInTimeDocumentServiceFactory(getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>, getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined, persistedCache?: IPersistedCache, hostPolicy?: HostStoragePolicy): IPointInTimeDocumentServiceFactory;
|
|
17
62
|
/**
|
|
18
63
|
* Creates a factory instance for creating a sharepoint document service from a provided snapshot.
|
|
19
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,uBAAuB,EACvB,eAAe,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,EACZ,MAAM,kDAAkD,CAAC;AAI1D,OAAO,
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,uBAAuB,EACvB,eAAe,EACf,MAAM,6CAA6C,CAAC;AACrD,OAAO,KAAK,EACX,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,EACZ,MAAM,kDAAkD,CAAC;AAI1D,OAAO,EACN,KAAK,kCAAkC,EACvC,KAAK,4CAA4C,EACjD,8BAA8B,EAC9B,MAAM,qCAAqC,CAAC;AAG7C;;;;GAIG;AACH,MAAM,WAAW,kCAAkC;IAClD,qCAAqC;IACrC,QAAQ,CAAC,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IACtE,wEAAwE;IACxE,QAAQ,CAAC,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,CAAC;IACpF,2EAA2E;IAC3E,QAAQ,CAAC,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;IACtD,+EAA+E;IAC/E,QAAQ,CAAC,UAAU,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IACpD;;;OAGG;IACH,QAAQ,CAAC,wCAAwC,CAAC,EAC/C,4CAA4C,GAC5C,SAAS,CAAC;CACb;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,8BAA8B;gBAE5E,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,EAC1E,cAAc,CAAC,EAAE,eAAe,EAChC,UAAU,CAAC,EAAE,iBAAiB;CAI/B;AAED;;;;;;;GAOG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,kCAAkC,GACzC,0BAA0B,CA6B5B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wCAAwC,CACvD,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,iBAAiB,EAAE,YAAY,CAAC,6BAA6B,CAAC,GAAG,SAAS,EAC1E,cAAc,CAAC,EAAE,eAAe,EAChC,UAAU,CAAC,EAAE,iBAAiB,GAC5B,kCAAkC,CAWpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qCAAqC,CACpD,aAAa,EAAE,UAAU,GAAG,MAAM,GAChC,uBAAuB,CAEzB"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
// eslint-disable-next-line import-x/no-internal-modules
|
|
6
6
|
import { LocalOdspDocumentServiceFactory } from "./localOdspDriver/localOdspDocumentServiceFactory.js";
|
|
7
|
-
import { OdspDocumentServiceFactoryCore } from "./odspDocumentServiceFactoryCore.js";
|
|
7
|
+
import { OdspDocumentServiceFactoryCore, } from "./odspDocumentServiceFactoryCore.js";
|
|
8
|
+
import { LocalPersistentCache } from "./odspCache.js";
|
|
8
9
|
/**
|
|
9
10
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
10
11
|
* use the sharepoint implementation.
|
|
@@ -16,6 +17,62 @@ export class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {
|
|
|
16
17
|
super(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);
|
|
17
18
|
}
|
|
18
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates an ODSP document service factory with optional consumer-provided features.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Tokens, cache, host policy, and optional feature implementations.
|
|
24
|
+
* @returns The configured ODSP document service factory.
|
|
25
|
+
*
|
|
26
|
+
* @legacy @beta
|
|
27
|
+
*/
|
|
28
|
+
export function createOdspDocumentServiceFactory(options) {
|
|
29
|
+
const persistedCache = options.persistedCache ?? new LocalPersistentCache();
|
|
30
|
+
const pointInTimeImplementation = options.pointInTimeDocumentServiceImplementation;
|
|
31
|
+
class ConfiguredOdspDocumentServiceFactory extends OdspDocumentServiceFactory {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
this.createPointInTimeDocumentService = pointInTimeImplementation === undefined
|
|
35
|
+
? undefined
|
|
36
|
+
: async (resolvedUrl, targetSequenceNumber, logger, clientIsSummarizer) => pointInTimeImplementation({
|
|
37
|
+
resolvedUrl,
|
|
38
|
+
targetSequenceNumber,
|
|
39
|
+
logger,
|
|
40
|
+
clientIsSummarizer,
|
|
41
|
+
persistedCache,
|
|
42
|
+
getStorageToken: options.getStorageToken,
|
|
43
|
+
createDocumentService: async (url, odspLogger, cacheAndTracker, isSummarizer) => this.createDocumentServiceCore(url, odspLogger, cacheAndTracker, isSummarizer),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return new ConfiguredOdspDocumentServiceFactory(options.getStorageToken, options.getWebsocketToken, persistedCache, options.hostPolicy);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Creates an ODSP document service factory that supports point-in-time loading.
|
|
51
|
+
*
|
|
52
|
+
* @param getStorageToken - Fetches storage access tokens.
|
|
53
|
+
* @param getWebsocketToken - Fetches websocket access tokens, or `undefined` when unavailable.
|
|
54
|
+
* @param persistedCache - Optional persisted ODSP cache.
|
|
55
|
+
* @param hostPolicy - Optional host storage policy.
|
|
56
|
+
* @returns An ODSP document service factory with point-in-time loading capability.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated Use
|
|
59
|
+
* {@link createOdspDocumentServiceFactory} with a point-in-time implementation instead.
|
|
60
|
+
* See {@link https://github.com/microsoft/FluidFramework/issues/26500} for context.
|
|
61
|
+
*
|
|
62
|
+
* @legacy @beta
|
|
63
|
+
*/
|
|
64
|
+
export function getOdspPointInTimeDocumentServiceFactory(getStorageToken, getWebsocketToken, persistedCache, hostPolicy) {
|
|
65
|
+
return createOdspDocumentServiceFactory({
|
|
66
|
+
getStorageToken,
|
|
67
|
+
getWebsocketToken,
|
|
68
|
+
persistedCache,
|
|
69
|
+
hostPolicy,
|
|
70
|
+
pointInTimeDocumentServiceImplementation: async (props) => {
|
|
71
|
+
const { createPointInTimeDocumentService } = await import("./pointInTime.js");
|
|
72
|
+
return createPointInTimeDocumentService(props);
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
}
|
|
19
76
|
/**
|
|
20
77
|
* Creates a factory instance for creating a sharepoint document service from a provided snapshot.
|
|
21
78
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,wDAAwD;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactory.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,wDAAwD;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sDAAsD,CAAC;AACvG,OAAO,EAGN,8BAA8B,GAC9B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAyBtD;;;;;GAKG;AACH,MAAM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,wCAAwC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;YACzD,MAAM,EAAE,gCAAgC,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;YAC9E,OAAO,gCAAgC,CAAC,KAAK,CAAC,CAAC;QAChD,CAAC;KACD,CAAuC,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,qCAAqC,CACpD,aAAkC;IAElC,OAAO,IAAI,+BAA+B,CAAC,aAAa,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentServiceFactory,\n\tIPersistedCache,\n} from \"@fluidframework/driver-definitions/internal\";\nimport type {\n\tHostStoragePolicy,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\n\n// eslint-disable-next-line import-x/no-internal-modules\nimport { LocalOdspDocumentServiceFactory } from \"./localOdspDriver/localOdspDocumentServiceFactory.js\";\nimport {\n\ttype IPointInTimeDocumentServiceFactory,\n\ttype OdspPointInTimeDocumentServiceImplementation,\n\tOdspDocumentServiceFactoryCore,\n} from \"./odspDocumentServiceFactoryCore.js\";\nimport { LocalPersistentCache } from \"./odspCache.js\";\n\n/**\n * Options for creating an ODSP document service factory.\n *\n * @legacy @beta\n */\nexport interface IOdspDocumentServiceFactoryOptions {\n\t/** Fetches storage access tokens. */\n\treadonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/** Fetches websocket access tokens, or `undefined` when unavailable. */\n\treadonly getWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined;\n\t/** Persisted ODSP cache. When omitted, a local in-memory cache is used. */\n\treadonly persistedCache?: IPersistedCache | undefined;\n\t/** Host storage policy. When omitted, the default driver policies are used. */\n\treadonly hostPolicy?: HostStoragePolicy | undefined;\n\t/**\n\t * Enables point-in-time loading. Consumers that omit this implementation do not include the\n\t * feature code in their dependency graph.\n\t */\n\treadonly pointInTimeDocumentServiceImplementation?:\n\t\t| OdspPointInTimeDocumentServiceImplementation\n\t\t| undefined;\n}\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactory extends OdspDocumentServiceFactoryCore {\n\tconstructor(\n\t\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\t\tpersistedCache?: IPersistedCache,\n\t\thostPolicy?: HostStoragePolicy,\n\t) {\n\t\tsuper(getStorageToken, getWebsocketToken, persistedCache, hostPolicy);\n\t}\n}\n\n/**\n * Creates an ODSP document service factory with optional consumer-provided features.\n *\n * @param options - Tokens, cache, host policy, and optional feature implementations.\n * @returns The configured ODSP document service factory.\n *\n * @legacy @beta\n */\nexport function createOdspDocumentServiceFactory(\n\toptions: IOdspDocumentServiceFactoryOptions,\n): OdspDocumentServiceFactory {\n\tconst persistedCache = options.persistedCache ?? new LocalPersistentCache();\n\tconst pointInTimeImplementation = options.pointInTimeDocumentServiceImplementation;\n\n\tclass ConfiguredOdspDocumentServiceFactory extends OdspDocumentServiceFactory {\n\t\tpublic override readonly createPointInTimeDocumentService:\n\t\t\t| IPointInTimeDocumentServiceFactory[\"createPointInTimeDocumentService\"]\n\t\t\t| undefined =\n\t\t\tpointInTimeImplementation === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (resolvedUrl, targetSequenceNumber, logger, clientIsSummarizer) =>\n\t\t\t\t\t\tpointInTimeImplementation({\n\t\t\t\t\t\t\tresolvedUrl,\n\t\t\t\t\t\t\ttargetSequenceNumber,\n\t\t\t\t\t\t\tlogger,\n\t\t\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t\t\t\tpersistedCache,\n\t\t\t\t\t\t\tgetStorageToken: options.getStorageToken,\n\t\t\t\t\t\t\tcreateDocumentService: async (url, odspLogger, cacheAndTracker, isSummarizer) =>\n\t\t\t\t\t\t\t\tthis.createDocumentServiceCore(url, odspLogger, cacheAndTracker, isSummarizer),\n\t\t\t\t\t\t});\n\t}\n\n\treturn new ConfiguredOdspDocumentServiceFactory(\n\t\toptions.getStorageToken,\n\t\toptions.getWebsocketToken,\n\t\tpersistedCache,\n\t\toptions.hostPolicy,\n\t);\n}\n\n/**\n * Creates an ODSP document service factory that supports point-in-time loading.\n *\n * @param getStorageToken - Fetches storage access tokens.\n * @param getWebsocketToken - Fetches websocket access tokens, or `undefined` when unavailable.\n * @param persistedCache - Optional persisted ODSP cache.\n * @param hostPolicy - Optional host storage policy.\n * @returns An ODSP document service factory with point-in-time loading capability.\n *\n * @deprecated Use\n * {@link createOdspDocumentServiceFactory} with a point-in-time implementation instead.\n * See {@link https://github.com/microsoft/FluidFramework/issues/26500} for context.\n *\n * @legacy @beta\n */\nexport function getOdspPointInTimeDocumentServiceFactory(\n\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tgetWebsocketToken: TokenFetcher<OdspResourceTokenFetchOptions> | undefined,\n\tpersistedCache?: IPersistedCache,\n\thostPolicy?: HostStoragePolicy,\n): IPointInTimeDocumentServiceFactory {\n\treturn createOdspDocumentServiceFactory({\n\t\tgetStorageToken,\n\t\tgetWebsocketToken,\n\t\tpersistedCache,\n\t\thostPolicy,\n\t\tpointInTimeDocumentServiceImplementation: async (props) => {\n\t\t\tconst { createPointInTimeDocumentService } = await import(\"./pointInTime.js\");\n\t\t\treturn createPointInTimeDocumentService(props);\n\t\t},\n\t}) as IPointInTimeDocumentServiceFactory;\n}\n\n/**\n * Creates a factory instance for creating a sharepoint document service from a provided snapshot.\n *\n * @remarks Use if you don't want to connect to any kind of external/internal storages and want to provide\n * content directly.\n *\n * @legacy\n * @beta\n */\nexport function createLocalOdspDocumentServiceFactory(\n\tlocalSnapshot: Uint8Array | string,\n): IDocumentServiceFactory {\n\treturn new LocalOdspDocumentServiceFactory(localSnapshot);\n}\n"]}
|
|
@@ -9,12 +9,68 @@ import type { IDocumentService, IDocumentServiceFactory, IPersistedCache, IResol
|
|
|
9
9
|
import { type HostStoragePolicy, type IRelaySessionAwareDriverFactory, type ISocketStorageDiscovery, type OdspResourceTokenFetchOptions, type TokenFetcher } from "@fluidframework/odsp-driver-definitions/internal";
|
|
10
10
|
import { type ICacheAndTracker } from "./epochTracker.js";
|
|
11
11
|
import { type IPrefetchSnapshotContents } from "./odspCache.js";
|
|
12
|
+
/**
|
|
13
|
+
* An ODSP document service factory that supports point-in-time (sequence-number-based) loading.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* The loader detects this capability structurally, so hosts can pass this factory directly to
|
|
17
|
+
* {@link @fluidframework/container-loader#loadContainerToSequenceNumber}.
|
|
18
|
+
*
|
|
19
|
+
* @legacy @beta
|
|
20
|
+
*/
|
|
21
|
+
export interface IPointInTimeDocumentServiceFactory extends IDocumentServiceFactory {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a document service that materializes the document at the requested sequence number.
|
|
24
|
+
*
|
|
25
|
+
* @param resolvedUrl - The resolved ODSP {@link @fluidframework/driver-definitions#IResolvedUrl}.
|
|
26
|
+
* @param targetSequenceNumber - The sequence number at which to materialize the document. See
|
|
27
|
+
* {@link @fluidframework/container-loader#ILoadContainerToSequenceNumberProps.loadToSequenceNumber}.
|
|
28
|
+
* @param logger - Optional {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}.
|
|
29
|
+
* @param clientIsSummarizer - Whether to apply summarizer policies and telemetry to the
|
|
30
|
+
* underlying document services. Defaults to `false`.
|
|
31
|
+
* @returns A read-only {@link @fluidframework/driver-definitions#IDocumentService} materialized
|
|
32
|
+
* at the requested sequence number.
|
|
33
|
+
*/
|
|
34
|
+
createPointInTimeDocumentService(resolvedUrl: IResolvedUrl, targetSequenceNumber: number, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Inputs supplied by the ODSP document service factory to an injected point-in-time implementation.
|
|
38
|
+
*
|
|
39
|
+
* @legacy @beta
|
|
40
|
+
*/
|
|
41
|
+
export interface IOdspPointInTimeDocumentServiceImplementationProps {
|
|
42
|
+
/** The resolved ODSP URL for the document to materialize. */
|
|
43
|
+
readonly resolvedUrl: IResolvedUrl;
|
|
44
|
+
/** The sequence number at which to materialize the document. */
|
|
45
|
+
readonly targetSequenceNumber: number;
|
|
46
|
+
/** Optional telemetry logger for the point-in-time load. */
|
|
47
|
+
readonly logger?: ITelemetryBaseLogger;
|
|
48
|
+
/** Whether to apply summarizer policies and telemetry. Defaults to `false`. */
|
|
49
|
+
readonly clientIsSummarizer?: boolean;
|
|
50
|
+
/** The persisted ODSP cache supplied to the document service factory. */
|
|
51
|
+
readonly persistedCache: IPersistedCache;
|
|
52
|
+
/** Fetches storage access tokens for ODSP requests. */
|
|
53
|
+
readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>;
|
|
54
|
+
/**
|
|
55
|
+
* Creates an ODSP document service for a resolved URL.
|
|
56
|
+
*
|
|
57
|
+
* @param resolvedUrl - The resolved URL for the document or file version to load.
|
|
58
|
+
* @param logger - The telemetry logger for the document service.
|
|
59
|
+
* @param cacheAndTracker - The cache and epoch tracker shared by the point-in-time load.
|
|
60
|
+
* @param clientIsSummarizer - Whether to apply summarizer policies and telemetry.
|
|
61
|
+
* @returns The document service for the resolved URL.
|
|
62
|
+
*/
|
|
63
|
+
readonly createDocumentService: (resolvedUrl: IResolvedUrl, logger: ITelemetryBaseLogger, cacheAndTracker: ICacheAndTracker, clientIsSummarizer?: boolean) => Promise<IDocumentService>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Consumer-provided implementation of ODSP point-in-time loading.
|
|
67
|
+
*
|
|
68
|
+
* @legacy @beta
|
|
69
|
+
*/
|
|
70
|
+
export type OdspPointInTimeDocumentServiceImplementation = (props: IOdspPointInTimeDocumentServiceImplementationProps) => Promise<IDocumentService>;
|
|
12
71
|
/**
|
|
13
72
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
14
73
|
* use the sharepoint implementation.
|
|
15
|
-
*
|
|
16
|
-
* This constructor should be used by environments that support dynamic imports and that wish
|
|
17
|
-
* to leverage code splitting as a means to keep bundles as small as possible.
|
|
18
74
|
* @legacy
|
|
19
75
|
* @beta
|
|
20
76
|
*/
|
|
@@ -54,6 +110,21 @@ export declare class OdspDocumentServiceFactoryCore implements IDocumentServiceF
|
|
|
54
110
|
*/
|
|
55
111
|
readonly ILayerCompatDetails?: unknown;
|
|
56
112
|
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a document service that reads its snapshot from the closest file version at or before
|
|
115
|
+
* the target and its deltas from the live document, materializing a requested sequence number
|
|
116
|
+
* through replay.
|
|
117
|
+
*
|
|
118
|
+
* @param resolvedUrl - The resolved ODSP {@link @fluidframework/driver-definitions#IResolvedUrl}.
|
|
119
|
+
* @param targetSequenceNumber - The sequence number at which to materialize the document. See
|
|
120
|
+
* {@link @fluidframework/container-loader#ILoadContainerToSequenceNumberProps.loadToSequenceNumber}.
|
|
121
|
+
* @param logger - Optional {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}.
|
|
122
|
+
* @param clientIsSummarizer - Whether to apply summarizer policies and telemetry to the
|
|
123
|
+
* underlying document services. Defaults to `false`.
|
|
124
|
+
* @returns A read-only {@link @fluidframework/driver-definitions#IDocumentService} materialized
|
|
125
|
+
* at the requested sequence number.
|
|
126
|
+
*/
|
|
127
|
+
readonly createPointInTimeDocumentService?: IPointInTimeDocumentServiceFactory["createPointInTimeDocumentService"];
|
|
57
128
|
protected createDocumentServiceCore(resolvedUrl: IResolvedUrl, odspLogger: ITelemetryBaseLogger, cacheAndTrackerArg?: ICacheAndTracker, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
58
129
|
}
|
|
59
130
|
//# sourceMappingURL=odspDocumentServiceFactoryCore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.d.ts","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EACX,gBAAgB,EAChB,uBAAuB,EAEvB,eAAe,EACf,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EACN,KAAK,iBAAiB,EAEtB,KAAK,+BAA+B,EAEpC,KAAK,uBAAuB,EAC5B,KAAK,6BAA6B,EAIlC,KAAK,YAAY,EACjB,MAAM,kDAAkD,CAAC;AAK1D,OAAO,EAAE,KAAK,gBAAgB,EAA6B,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAEN,KAAK,yBAAyB,EAG9B,MAAM,gBAAgB,CAAC;AAcxB;;;;;;;;GAQG;AACH,qBAAa,8BACZ,YAAW,uBAAuB,EAAE,+BAA+B;IAqKlE,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAGlC,SAAS,CAAC,cAAc,EAAE,eAAe;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAxK5B,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAiD;IACpF,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC,CAAS;IAEnD,IAAW,2BAA2B,IAAI,YAAY,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAExF;IAGD,IAAW,+BAA+B,IAAI,IAAI,CAEjD;IAED;;;;;OAKG;IACU,0BAA0B,CACtC,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 import { createOdspLogger, getJoinSessionCacheKey, getOdspResolvedUrl, isNewFile
|
|
|
15
15
|
/**
|
|
16
16
|
* Factory for creating the sharepoint document service. Use this if you want to
|
|
17
17
|
* use the sharepoint implementation.
|
|
18
|
-
*
|
|
19
|
-
* This constructor should be used by environments that support dynamic imports and that wish
|
|
20
|
-
* to leverage code splitting as a means to keep bundles as small as possible.
|
|
21
18
|
* @legacy
|
|
22
19
|
* @beta
|
|
23
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAON,eAAe,EACf,gBAAgB,GAGhB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAyB,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAGN,oBAAoB,EACpB,kBAAkB,GAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAGN,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACb,qCAAqC,EACrC,8BAA8B,GAC9B,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,OAAO,8BAA8B;IAM1C,IAAW,2BAA2B;QACrC,OAAO,IAAI,CAAC,kBAAkB,CAAC,2BAA2B,CAAC;IAC5D,CAAC;IAED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AC,CAAC;QAC1D,IAAI,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1D,oBAAoB,GAAG;gBACtB,mEAAmE;gBACnE,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,eAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,mEAAmE;wBACpE,EAAE,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIFileEntry,\n\tIPersistedCache,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IOdspUrlParts,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n *\n * This constructor should be used by environments that support dynamic imports and that wish\n * to leverage code splitting as a means to keep bundles as small as possible.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\tfileVersion: undefined,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\t\t},\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentServiceFactoryCore.js","sourceRoot":"","sources":["../src/odspDocumentServiceFactoryCore.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAYH,OAAO,EACN,mCAAmC,EACnC,+BAA+B,GAC/B,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAON,eAAe,EACf,gBAAgB,GAGhB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC/F,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAyB,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAGN,oBAAoB,EACpB,kBAAkB,GAClB,M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IAAI,CAAC,UAAU,EACf,eAAe,CAAC,YAAY,EAC5B,IAAI,CAAC,wBAAwB,EAC7B,kBAAkB,CAClB,CAAC;IACH,CAAC;CACD;AAED;;GAEG;AACH,SAAS,oBAAoB,CAC5B,UAA6B,EAC7B,YAA6B;IAE7B,kGAAkG;IAClG,IAAI,oBAAkD,CAAC;IACvD,IAAI,UAAU,CAAC,yCAAyC,EAAE,CAAC;QAC1D,MAAM,eAAe,GAAG,YAAY,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC5D,MAAM,cAAc,GAAG,YAAY,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC1D,IAAI,eAAe,IAAI,gBAAgB,CAAC,eAAe,CAAC,EAAE,CAAC;YAC1D,oBAAoB,GAAG;gBACtB,mEAAmE;gBACnE,KAAK,EAAE,gBAAgB,CAAC,eAAe,CAAC;gBACxC,GAAG,CAAC,cAAc,IAAI,eAAe,CAAC,cAAc,CAAC;oBACpD,CAAC,CAAC,mEAAmE;wBACpE,EAAE,IAAI,EAAE,eAAe,CAAC,cAAc,CAAC,EAAE;oBAC1C,CAAC,CAAC,EAAE,CAAC;aACN,CAAC;QACH,CAAC;IACF,CAAC;IACD,OAAO,oBAAoB,CAAC;AAC7B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport type { PromiseCache } from \"@fluidframework/core-utils/internal\";\nimport type { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport type {\n\tIDocumentService,\n\tIDocumentServiceFactory,\n\tIFileEntry,\n\tIPersistedCache,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tgetDocAttributesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\ttype HostStoragePolicy,\n\ttype IOdspUrlParts,\n\ttype IRelaySessionAwareDriverFactory,\n\ttype ISharingLinkKind,\n\ttype ISocketStorageDiscovery,\n\ttype OdspResourceTokenFetchOptions,\n\tSharingLinkRole,\n\tSharingLinkScope,\n\ttype TokenFetchOptions,\n\ttype TokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport { PerformanceEvent, createChildLogger } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { useCreateNewModule } from \"./createFile/index.js\";\nimport { type ICacheAndTracker, createOdspCacheAndTracker } from \"./epochTracker.js\";\nimport {\n\ttype INonPersistentCache,\n\ttype IPrefetchSnapshotContents,\n\tLocalPersistentCache,\n\tNonPersistentCache,\n} from \"./odspCache.js\";\nimport { OdspDocumentService } from \"./odspDocumentService.js\";\nimport { odspDriverCompatDetailsForLoader } from \"./odspLayerCompatState.js\";\nimport {\n\ttype IExistingFileInfo,\n\ttype INewFileInfo,\n\tcreateOdspLogger,\n\tgetJoinSessionCacheKey,\n\tgetOdspResolvedUrl,\n\tisNewFileInfo,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttoInstrumentedOdspTokenFetcher,\n} from \"./odspUtils.js\";\n\n/**\n * An ODSP document service factory that supports point-in-time (sequence-number-based) loading.\n *\n * @remarks\n * The loader detects this capability structurally, so hosts can pass this factory directly to\n * {@link @fluidframework/container-loader#loadContainerToSequenceNumber}.\n *\n * @legacy @beta\n */\nexport interface IPointInTimeDocumentServiceFactory extends IDocumentServiceFactory {\n\t/**\n\t * Creates a document service that materializes the document at the requested sequence number.\n\t *\n\t * @param resolvedUrl - The resolved ODSP {@link @fluidframework/driver-definitions#IResolvedUrl}.\n\t * @param targetSequenceNumber - The sequence number at which to materialize the document. See\n\t * {@link @fluidframework/container-loader#ILoadContainerToSequenceNumberProps.loadToSequenceNumber}.\n\t * @param logger - Optional {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}.\n\t * @param clientIsSummarizer - Whether to apply summarizer policies and telemetry to the\n\t * underlying document services. Defaults to `false`.\n\t * @returns A read-only {@link @fluidframework/driver-definitions#IDocumentService} materialized\n\t * at the requested sequence number.\n\t */\n\tcreatePointInTimeDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\ttargetSequenceNumber: number,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService>;\n}\n\n/**\n * Inputs supplied by the ODSP document service factory to an injected point-in-time implementation.\n *\n * @legacy @beta\n */\nexport interface IOdspPointInTimeDocumentServiceImplementationProps {\n\t/** The resolved ODSP URL for the document to materialize. */\n\treadonly resolvedUrl: IResolvedUrl;\n\t/** The sequence number at which to materialize the document. */\n\treadonly targetSequenceNumber: number;\n\t/** Optional telemetry logger for the point-in-time load. */\n\treadonly logger?: ITelemetryBaseLogger;\n\t/** Whether to apply summarizer policies and telemetry. Defaults to `false`. */\n\treadonly clientIsSummarizer?: boolean;\n\t/** The persisted ODSP cache supplied to the document service factory. */\n\treadonly persistedCache: IPersistedCache;\n\t/** Fetches storage access tokens for ODSP requests. */\n\treadonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>;\n\t/**\n\t * Creates an ODSP document service for a resolved URL.\n\t *\n\t * @param resolvedUrl - The resolved URL for the document or file version to load.\n\t * @param logger - The telemetry logger for the document service.\n\t * @param cacheAndTracker - The cache and epoch tracker shared by the point-in-time load.\n\t * @param clientIsSummarizer - Whether to apply summarizer policies and telemetry.\n\t * @returns The document service for the resolved URL.\n\t */\n\treadonly createDocumentService: (\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger: ITelemetryBaseLogger,\n\t\tcacheAndTracker: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t) => Promise<IDocumentService>;\n}\n\n/**\n * Consumer-provided implementation of ODSP point-in-time loading.\n *\n * @legacy @beta\n */\nexport type OdspPointInTimeDocumentServiceImplementation = (\n\tprops: IOdspPointInTimeDocumentServiceImplementationProps,\n) => Promise<IDocumentService>;\n\n/**\n * Factory for creating the sharepoint document service. Use this if you want to\n * use the sharepoint implementation.\n * @legacy\n * @beta\n */\nexport class OdspDocumentServiceFactoryCore\n\timplements IDocumentServiceFactory, IRelaySessionAwareDriverFactory\n{\n\tprivate readonly nonPersistentCache: INonPersistentCache = new NonPersistentCache();\n\tprivate readonly socketReferenceKeyPrefix?: string;\n\n\tpublic get snapshotPrefetchResultCache(): PromiseCache<string, IPrefetchSnapshotContents> {\n\t\treturn this.nonPersistentCache.snapshotPrefetchResultCache;\n\t}\n\n\t// TODO: return `IRelaySessionAwareDriverFactory` instead of `this` (breaking change)\n\tpublic get IRelaySessionAwareDriverFactory(): this {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This function would return info about relay service session only if this factory established (or attempted to\n\t * establish) connection very recently. Otherwise, it will return undefined.\n\t * @param resolvedUrl - resolved url for container\n\t * @returns The current join session response stored in cache. `undefined` if not present.\n\t */\n\tpublic async getRelayServiceSessionInfo(\n\t\tresolvedUrl: IResolvedUrl,\n\t): Promise<ISocketStorageDiscovery | undefined> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst joinSessionResponse = await this.nonPersistentCache.sessionJoinCache.get(\n\t\t\tgetJoinSessionCacheKey(odspResolvedUrl),\n\t\t);\n\t\treturn joinSessionResponse?.joinSessionResponse;\n\t}\n\n\tpublic async createContainer(\n\t\tcreateNewSummary: ISummaryTree | undefined,\n\t\tcreateNewResolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(createNewResolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tlet fileInfo: INewFileInfo | IExistingFileInfo;\n\t\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\t\tif (odspResolvedUrl.itemId) {\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"Existing\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\titemId: odspResolvedUrl.itemId,\n\t\t\t};\n\t\t} else if (odspResolvedUrl.fileName) {\n\t\t\tconst [, queryString] = odspResolvedUrl.url.split(\"?\");\n\t\t\tconst searchParams = new URLSearchParams(queryString);\n\t\t\tconst filePath = searchParams.get(\"path\");\n\t\t\tif (filePath === undefined || filePath === null) {\n\t\t\t\tthrow new Error(\"File path should be provided!!\");\n\t\t\t}\n\t\t\tcreateShareLinkParam = getSharingLinkParams(this.hostPolicy, searchParams);\n\t\t\tfileInfo = {\n\t\t\t\ttype: \"New\",\n\t\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\t\tfilePath,\n\t\t\t\tfilename: odspResolvedUrl.fileName,\n\t\t\t\tcreateLinkType: createShareLinkParam,\n\t\t\t};\n\t\t} else {\n\t\t\tthrow new Error(\"A new or existing file must be specified to create container!\");\n\t\t}\n\n\t\tif (isCombinedAppAndProtocolSummary(createNewSummary)) {\n\t\t\tconst documentAttributes = getDocAttributesFromProtocolSummary(\n\t\t\t\tcreateNewSummary.tree[\".protocol\"],\n\t\t\t);\n\t\t\tif (documentAttributes?.sequenceNumber !== 0) {\n\t\t\t\tthrow new Error(\"Seq number in detached ODSP container should be 0\");\n\t\t\t}\n\t\t}\n\n\t\tconst odspLogger = createOdspLogger(logger);\n\n\t\tconst fileEntry: IFileEntry = {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\tfileVersion: undefined,\n\t\t};\n\t\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\t\tthis.persistedCache,\n\t\t\tthis.nonPersistentCache,\n\t\t\tfileEntry,\n\t\t\todspLogger,\n\t\t\tclientIsSummarizer,\n\t\t);\n\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\todspLogger,\n\t\t\t{\n\t\t\t\teventName: \"CreateNew\",\n\t\t\t\tisWithSummaryUpload: true,\n\t\t\t\tcreateShareLinkParam: createShareLinkParam\n\t\t\t\t\t? JSON.stringify(createShareLinkParam)\n\t\t\t\t\t: undefined,\n\t\t\t\tenableSingleRequestForShareLinkWithCreate:\n\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t},\n\t\t\tasync (event) => {\n\t\t\t\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\t\t\t\todspLogger,\n\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\tthis.getStorageToken,\n\t\t\t\t);\n\t\t\t\tconst _odspResolvedUrl = await useCreateNewModule(odspLogger, async (module) => {\n\t\t\t\t\treturn isNewFileInfo(fileInfo)\n\t\t\t\t\t\t? module.createNewFluidFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\tthis.hostPolicy.enableSingleRequestForShareLinkWithCreate,\n\t\t\t\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: module.createNewContainerOnExistingFile(\n\t\t\t\t\t\t\t\tgetAuthHeader,\n\t\t\t\t\t\t\t\tfileInfo,\n\t\t\t\t\t\t\t\todspLogger,\n\t\t\t\t\t\t\t\tcreateNewSummary,\n\t\t\t\t\t\t\t\tcacheAndTracker.epochTracker,\n\t\t\t\t\t\t\t\tfileEntry,\n\t\t\t\t\t\t\t\tthis.hostPolicy.cacheCreateNewSummary ?? true,\n\t\t\t\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\t\t\t\todspResolvedUrl.isClpCompliantApp,\n\t\t\t\t\t\t\t\todspResolvedUrl.fileMetadata?.eTag,\n\t\t\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t\tconst docService = this.createDocumentServiceCore(\n\t\t\t\t\t_odspResolvedUrl,\n\t\t\t\t\todspLogger,\n\t\t\t\t\tcacheAndTracker,\n\t\t\t\t\tclientIsSummarizer,\n\t\t\t\t);\n\t\t\t\tevent.end({\n\t\t\t\t\tdocId: _odspResolvedUrl.hashedDocumentId,\n\t\t\t\t});\n\t\t\t\treturn docService;\n\t\t\t},\n\t\t);\n\t}\n\n\t/**\n\t * @param getStorageToken - function that can provide the storage token for a given site. This is\n\t * is also referred to as the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param persistedCache - PersistedCache provided by host for use in this session.\n\t * @param hostPolicy - Policy for storage provided by host.\n\t */\n\tconstructor(\n\t\tprivate readonly getStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| TokenFetcher<OdspResourceTokenFetchOptions>\n\t\t\t| undefined,\n\t\tprotected persistedCache: IPersistedCache = new LocalPersistentCache(),\n\t\tprivate readonly hostPolicy: HostStoragePolicy = {},\n\t) {\n\t\tif (this.hostPolicy.isolateSocketCache === true) {\n\t\t\t// create the key to separate the socket reuse cache\n\t\t\tthis.socketReferenceKeyPrefix = uuid();\n\t\t}\n\t\t// Set enableRedeemFallback by default as true.\n\t\tthis.hostPolicy.enableRedeemFallback = this.hostPolicy.enableRedeemFallback ?? true;\n\t\tthis.hostPolicy.sessionOptions = {\n\t\t\tforceAccessTokenViaAuthorizationHeader: true,\n\t\t\t...this.hostPolicy.sessionOptions,\n\t\t};\n\t}\n\n\t/**\n\t * The compatibility details of the ODSP Driver layer that is exposed to the Loader layer\n\t * for validating Loader-Driver compatibility.\n\t * @remarks This is for internal use only.\n\t * The type of this should be ILayerCompatDetails. However, ILayerCompatDetails is internal and this class\n\t * is currently marked as legacy alpha. So, using unknown here.\n\t */\n\tpublic readonly ILayerCompatDetails?: unknown = odspDriverCompatDetailsForLoader;\n\n\tpublic async createDocumentService(\n\t\tresolvedUrl: IResolvedUrl,\n\t\tlogger?: ITelemetryBaseLogger,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\treturn this.createDocumentServiceCore(\n\t\t\tresolvedUrl,\n\t\t\tcreateOdspLogger(logger),\n\t\t\tundefined,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n\n\t/**\n\t * Creates a document service that reads its snapshot from the closest file version at or before\n\t * the target and its deltas from the live document, materializing a requested sequence number\n\t * through replay.\n\t *\n\t * @param resolvedUrl - The resolved ODSP {@link @fluidframework/driver-definitions#IResolvedUrl}.\n\t * @param targetSequenceNumber - The sequence number at which to materialize the document. See\n\t * {@link @fluidframework/container-loader#ILoadContainerToSequenceNumberProps.loadToSequenceNumber}.\n\t * @param logger - Optional {@link @fluidframework/core-interfaces#ITelemetryBaseLogger}.\n\t * @param clientIsSummarizer - Whether to apply summarizer policies and telemetry to the\n\t * underlying document services. Defaults to `false`.\n\t * @returns A read-only {@link @fluidframework/driver-definitions#IDocumentService} materialized\n\t * at the requested sequence number.\n\t */\n\tpublic readonly createPointInTimeDocumentService?: IPointInTimeDocumentServiceFactory[\"createPointInTimeDocumentService\"];\n\n\tprotected async createDocumentServiceCore(\n\t\tresolvedUrl: IResolvedUrl,\n\t\todspLogger: ITelemetryBaseLogger,\n\t\tcacheAndTrackerArg?: ICacheAndTracker,\n\t\tclientIsSummarizer?: boolean,\n\t): Promise<IDocumentService> {\n\t\tconst extLogger = createChildLogger({ logger: odspLogger });\n\t\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\t\tconst resolvedUrlData: IOdspUrlParts = {\n\t\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\t\tdriveId: odspResolvedUrl.driveId,\n\t\t\titemId: odspResolvedUrl.itemId,\n\t\t};\n\n\t\tconst cacheAndTracker =\n\t\t\tcacheAndTrackerArg ??\n\t\t\tcreateOdspCacheAndTracker(\n\t\t\t\tthis.persistedCache,\n\t\t\t\tthis.nonPersistentCache,\n\t\t\t\t{\n\t\t\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t\t\t},\n\t\t\t\textLogger,\n\t\t\t\tclientIsSummarizer,\n\t\t\t);\n\n\t\tconst storageTokenFetcher = toInstrumentedOdspStorageTokenFetcher(\n\t\t\textLogger,\n\t\t\tresolvedUrlData,\n\t\t\tthis.getStorageToken,\n\t\t);\n\n\t\tconst webSocketTokenFetcher =\n\t\t\tthis.getWebsocketToken === undefined\n\t\t\t\t? undefined\n\t\t\t\t: async (options: TokenFetchOptions): Promise<string | null> =>\n\t\t\t\t\t\t// websocket expects a plain token\n\t\t\t\t\t\ttoInstrumentedOdspTokenFetcher(\n\t\t\t\t\t\t\textLogger,\n\t\t\t\t\t\t\tresolvedUrlData,\n\t\t\t\t\t\t\tthis.getWebsocketToken!,\n\t\t\t\t\t\t\tfalse /* throwOnNullToken */,\n\t\t\t\t\t\t\ttrue /* returnPlainToken */,\n\t\t\t\t\t\t)(options, \"GetWebsocketToken\");\n\n\t\treturn OdspDocumentService.create(\n\t\t\tresolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\twebSocketTokenFetcher,\n\t\t\textLogger,\n\t\t\tcacheAndTracker.cache,\n\t\t\tthis.hostPolicy,\n\t\t\tcacheAndTracker.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tclientIsSummarizer,\n\t\t);\n\t}\n}\n\n/**\n * Extract the sharing link kind from the resolved URL's query paramerters\n */\nfunction getSharingLinkParams(\n\thostPolicy: HostStoragePolicy,\n\tsearchParams: URLSearchParams,\n): ISharingLinkKind | undefined {\n\t// extract request parameters for creation of sharing link (if provided) if the feature is enabled\n\tlet createShareLinkParam: ISharingLinkKind | undefined;\n\tif (hostPolicy.enableSingleRequestForShareLinkWithCreate) {\n\t\tconst createLinkScope = searchParams.get(\"createLinkScope\");\n\t\tconst createLinkRole = searchParams.get(\"createLinkRole\");\n\t\tif (createLinkScope && SharingLinkScope[createLinkScope]) {\n\t\t\tcreateShareLinkParam = {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\tscope: SharingLinkScope[createLinkScope],\n\t\t\t\t...(createLinkRole && SharingLinkRole[createLinkRole]\n\t\t\t\t\t? // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\t\t{ role: SharingLinkRole[createLinkRole] }\n\t\t\t\t\t: {}),\n\t\t\t};\n\t\t}\n\t}\n\treturn createShareLinkParam;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export declare const pkgName = "@fluidframework/odsp-driver";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.118.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.118.0\";\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Optional ODSP point-in-time loading implementation for consumer injection.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
export { createPointInTimeDocumentService } from "./pointInTimeDriver/createPointInTimeDocumentService.js";
|
|
11
|
+
export type { IOdspPointInTimeDocumentServiceImplementationProps, OdspPointInTimeDocumentServiceImplementation, } from "./odspDocumentServiceFactoryCore.js";
|
|
12
|
+
export type { EpochTracker, FetchType, FetchTypeInternal, ICacheAndTracker, } from "./epochTracker.js";
|
|
13
|
+
export type { INonPersistentCache, IOdspCache, IPersistedFileCache, IPrefetchSnapshotContents, } from "./odspCache.js";
|
|
14
|
+
export type { IOdspResponse } from "./odspUtils.js";
|
|
15
|
+
//# sourceMappingURL=pointInTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointInTime.d.ts","sourceRoot":"","sources":["../src/pointInTime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAGH,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAC3G,YAAY,EACX,kDAAkD,EAClD,4CAA4C,GAC5C,MAAM,qCAAqC,CAAC;AAC7C,YAAY,EACX,YAAY,EACZ,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACX,mBAAmB,EACnB,UAAU,EACV,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Optional ODSP point-in-time loading implementation for consumer injection.
|
|
7
|
+
*
|
|
8
|
+
* @packageDocumentation
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line import-x/no-internal-modules -- Dedicated entrypoint for the optional point-in-time implementation.
|
|
11
|
+
export { createPointInTimeDocumentService } from "./pointInTimeDriver/createPointInTimeDocumentService.js";
|
|
12
|
+
//# sourceMappingURL=pointInTime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointInTime.js","sourceRoot":"","sources":["../src/pointInTime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,+HAA+H;AAC/H,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Optional ODSP point-in-time loading implementation for consumer injection.\n *\n * @packageDocumentation\n */\n\n// eslint-disable-next-line import-x/no-internal-modules -- Dedicated entrypoint for the optional point-in-time implementation.\nexport { createPointInTimeDocumentService } from \"./pointInTimeDriver/createPointInTimeDocumentService.js\";\nexport type {\n\tIOdspPointInTimeDocumentServiceImplementationProps,\n\tOdspPointInTimeDocumentServiceImplementation,\n} from \"./odspDocumentServiceFactoryCore.js\";\nexport type {\n\tEpochTracker,\n\tFetchType,\n\tFetchTypeInternal,\n\tICacheAndTracker,\n} from \"./epochTracker.js\";\nexport type {\n\tINonPersistentCache,\n\tIOdspCache,\n\tIPersistedFileCache,\n\tIPrefetchSnapshotContents,\n} from \"./odspCache.js\";\nexport type { IOdspResponse } from \"./odspUtils.js\";\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import type { IDocumentService, IResolvedUrl } from "@fluidframework/driver-definitions/internal";
|
|
6
|
+
import type { IOdspResolvedUrl } from "@fluidframework/odsp-driver-definitions/internal";
|
|
7
|
+
import { type TelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { type EpochTracker } from "../epochTracker.js";
|
|
9
|
+
import type { IOdspPointInTimeDocumentServiceImplementationProps } from "../odspDocumentServiceFactoryCore.js";
|
|
10
|
+
import { type IOdspVersionManager } from "../odspVersionManager/odspVersionManager.js";
|
|
11
|
+
import { OdspPointInTimeDocumentService } from "./odspPointInTimeDocumentService.js";
|
|
12
|
+
interface IPointInTimeDocumentServiceDependencies {
|
|
13
|
+
readonly createVersionManager?: (odspResolvedUrl: IOdspResolvedUrl, logger: TelemetryLoggerExt, epochTracker: EpochTracker) => IOdspVersionManager | Promise<IOdspVersionManager>;
|
|
14
|
+
readonly resolveFileVersion?: (resolvedUrl: IResolvedUrl, fileVersion: string) => IResolvedUrl | Promise<IResolvedUrl>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ODSP's point-in-time document service implementation.
|
|
18
|
+
*
|
|
19
|
+
* @remarks Import this function from the dedicated point-in-time entrypoint and inject it through
|
|
20
|
+
* {@link IOdspDocumentServiceFactoryOptions.pointInTimeDocumentServiceImplementation}.
|
|
21
|
+
*
|
|
22
|
+
* @param props - ODSP service dependencies and point-in-time load parameters supplied by the factory.
|
|
23
|
+
* @returns A read-only ODSP document service materialized at the requested sequence number.
|
|
24
|
+
*
|
|
25
|
+
* @legacy @beta
|
|
26
|
+
*/
|
|
27
|
+
export declare function createPointInTimeDocumentService(props: IOdspPointInTimeDocumentServiceImplementationProps): Promise<IDocumentService>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates the point-in-time service with replaceable dependencies for testing.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare function createPointInTimeDocumentServiceCore({ resolvedUrl, targetSequenceNumber, logger, clientIsSummarizer, persistedCache, getStorageToken, createDocumentService, }: IOdspPointInTimeDocumentServiceImplementationProps, dependencies?: IPointInTimeDocumentServiceDependencies): Promise<OdspPointInTimeDocumentService>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=createPointInTimeDocumentService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPointInTimeDocumentService.d.ts","sourceRoot":"","sources":["../../src/pointInTimeDriver/createPointInTimeDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EACX,gBAAgB,EAChB,YAAY,EACZ,MAAM,6CAA6C,CAAC;AAErD,OAAO,KAAK,EACX,gBAAgB,EAEhB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAA6B,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlF,OAAO,KAAK,EAAE,kDAAkD,EAAE,MAAM,sCAAsC,CAAC;AAM/G,OAAO,EAEN,KAAK,mBAAmB,EAExB,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,UAAU,uCAAuC;IAChD,QAAQ,CAAC,oBAAoB,CAAC,EAAE,CAC/B,eAAe,EAAE,gBAAgB,EACjC,MAAM,EAAE,kBAAkB,EAC1B,YAAY,EAAE,YAAY,KACtB,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACxD,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAC7B,WAAW,EAAE,YAAY,EACzB,WAAW,EAAE,MAAM,KACf,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CAC1C;AA+CD;;;;;;;;;;GAUG;AACH,wBAAsB,gCAAgC,CACrD,KAAK,EAAE,kDAAkD,GACvD,OAAO,CAAC,gBAAgB,CAAC,CAE3B;AAED;;;GAGG;AACH,wBAAsB,oCAAoC,CACzD,EACC,WAAW,EACX,oBAAoB,EACpB,MAAM,EACN,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,qBAAqB,GACrB,EAAE,kDAAkD,EACrD,YAAY,GAAE,uCAA4C,GACxD,OAAO,CAAC,8BAA8B,CAAC,CAsDzC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { UsageError } from "@fluidframework/driver-utils/internal";
|
|
6
|
+
import { createChildLogger, } from "@fluidframework/telemetry-utils/internal";
|
|
7
|
+
import { createOdspCacheAndTracker } from "../epochTracker.js";
|
|
8
|
+
import { NonPersistentCache } from "../odspCache.js";
|
|
9
|
+
import { OdspDriverUrlResolver } from "../odspDriverUrlResolver.js";
|
|
10
|
+
import { createOdspLogger, getOdspResolvedUrl, toInstrumentedOdspStorageTokenFetcher, } from "../odspUtils.js";
|
|
11
|
+
import { createOdspVersionManager,
|
|
12
|
+
// eslint-disable-next-line import-x/no-internal-modules -- the feature implementation owns version selection
|
|
13
|
+
} from "../odspVersionManager/odspVersionManager.js";
|
|
14
|
+
import { OdspPointInTimeDocumentService } from "./odspPointInTimeDocumentService.js";
|
|
15
|
+
async function createVersionManager(odspResolvedUrl, logger, epochTracker, getStorageToken) {
|
|
16
|
+
const urlParts = {
|
|
17
|
+
siteUrl: odspResolvedUrl.siteUrl,
|
|
18
|
+
driveId: odspResolvedUrl.driveId,
|
|
19
|
+
itemId: odspResolvedUrl.itemId,
|
|
20
|
+
};
|
|
21
|
+
const getAuthHeader = toInstrumentedOdspStorageTokenFetcher(logger, urlParts, getStorageToken);
|
|
22
|
+
return createOdspVersionManager({
|
|
23
|
+
urlParts,
|
|
24
|
+
getAuthHeader,
|
|
25
|
+
epochTracker,
|
|
26
|
+
logger,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function resolveFileVersion(resolvedUrl, fileVersion) {
|
|
30
|
+
const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);
|
|
31
|
+
const query = new URLSearchParams({
|
|
32
|
+
driveId: odspResolvedUrl.driveId,
|
|
33
|
+
itemId: odspResolvedUrl.itemId,
|
|
34
|
+
fileVersion,
|
|
35
|
+
});
|
|
36
|
+
if (odspResolvedUrl.dataStorePath !== undefined) {
|
|
37
|
+
query.set("path", odspResolvedUrl.dataStorePath);
|
|
38
|
+
}
|
|
39
|
+
if (odspResolvedUrl.codeHint?.containerPackageName !== undefined) {
|
|
40
|
+
query.set("containerPackageName", odspResolvedUrl.codeHint.containerPackageName);
|
|
41
|
+
}
|
|
42
|
+
return new OdspDriverUrlResolver().resolve({
|
|
43
|
+
url: `${odspResolvedUrl.siteUrl}?${query.toString()}`,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* ODSP's point-in-time document service implementation.
|
|
48
|
+
*
|
|
49
|
+
* @remarks Import this function from the dedicated point-in-time entrypoint and inject it through
|
|
50
|
+
* {@link IOdspDocumentServiceFactoryOptions.pointInTimeDocumentServiceImplementation}.
|
|
51
|
+
*
|
|
52
|
+
* @param props - ODSP service dependencies and point-in-time load parameters supplied by the factory.
|
|
53
|
+
* @returns A read-only ODSP document service materialized at the requested sequence number.
|
|
54
|
+
*
|
|
55
|
+
* @legacy @beta
|
|
56
|
+
*/
|
|
57
|
+
export async function createPointInTimeDocumentService(props) {
|
|
58
|
+
return createPointInTimeDocumentServiceCore(props);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates the point-in-time service with replaceable dependencies for testing.
|
|
62
|
+
* @internal
|
|
63
|
+
*/
|
|
64
|
+
export async function createPointInTimeDocumentServiceCore({ resolvedUrl, targetSequenceNumber, logger, clientIsSummarizer, persistedCache, getStorageToken, createDocumentService, }, dependencies = {}) {
|
|
65
|
+
const odspLogger = createOdspLogger(logger);
|
|
66
|
+
const extLogger = createChildLogger({ logger: odspLogger });
|
|
67
|
+
const odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);
|
|
68
|
+
const cacheAndTracker = createOdspCacheAndTracker(persistedCache, new NonPersistentCache(), {
|
|
69
|
+
resolvedUrl: odspResolvedUrl,
|
|
70
|
+
docId: odspResolvedUrl.hashedDocumentId,
|
|
71
|
+
fileVersion: odspResolvedUrl.fileVersion,
|
|
72
|
+
}, extLogger, clientIsSummarizer);
|
|
73
|
+
const versionManager = await (dependencies.createVersionManager ??
|
|
74
|
+
(async (url, versionLogger, epochTracker) => createVersionManager(url, versionLogger, epochTracker, getStorageToken)))(odspResolvedUrl, extLogger, cacheAndTracker.epochTracker);
|
|
75
|
+
const baseResult = await versionManager.findBaseForSeq(targetSequenceNumber);
|
|
76
|
+
if (baseResult.kind === "noBaseVersion") {
|
|
77
|
+
const oldestResolvedSequenceDetail = baseResult.oldestResolvedSeq === undefined
|
|
78
|
+
? ""
|
|
79
|
+
: ` The oldest resolved file version is at sequence number ${baseResult.oldestResolvedSeq}.`;
|
|
80
|
+
throw new UsageError(`No ODSP file version is available at or before sequence number ${targetSequenceNumber}.${oldestResolvedSequenceDetail}`);
|
|
81
|
+
}
|
|
82
|
+
const recoverableResolvedUrl = await (dependencies.resolveFileVersion ?? resolveFileVersion)(resolvedUrl, baseResult.base.versionId);
|
|
83
|
+
const recoverableDocumentService = await createDocumentService(recoverableResolvedUrl, odspLogger, cacheAndTracker, clientIsSummarizer);
|
|
84
|
+
const liveDocumentService = await createDocumentService(resolvedUrl, odspLogger, cacheAndTracker, clientIsSummarizer);
|
|
85
|
+
return new OdspPointInTimeDocumentService(recoverableResolvedUrl, recoverableDocumentService, liveDocumentService, targetSequenceNumber);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=createPointInTimeDocumentService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createPointInTimeDocumentService.js","sourceRoot":"","sources":["../../src/pointInTimeDriver/createPointInTimeDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAKnE,OAAO,EACN,iBAAiB,GAEjB,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,yBAAyB,EAAqB,MAAM,oBAAoB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EACN,gBAAgB,EAChB,kBAAkB,EAClB,qCAAqC,GACrC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,wBAAwB;AAExB,6GAA6G;EAC7G,MAAM,6CAA6C,CAAC;AAErD,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAcrF,KAAK,UAAU,oBAAoB,CAClC,eAAiC,EACjC,MAA0B,EAC1B,YAA0B,EAC1B,eA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kBAAkB,CAAC,CAC3F,WAAW,EACX,UAAU,CAAC,IAAI,CAAC,SAAS,CACzB,CAAC;IACF,MAAM,0BAA0B,GAAG,MAAM,qBAAqB,CAC7D,sBAAsB,EACtB,UAAU,EACV,eAAe,EACf,kBAAkB,CAClB,CAAC;IACF,MAAM,mBAAmB,GAAG,MAAM,qBAAqB,CACtD,WAAW,EACX,UAAU,EACV,eAAe,EACf,kBAAkB,CAClB,CAAC;IACF,OAAO,IAAI,8BAA8B,CACxC,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,CACpB,CAAC;AACH,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport type {\n\tIDocumentService,\n\tIResolvedUrl,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { UsageError } from \"@fluidframework/driver-utils/internal\";\nimport type {\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tcreateChildLogger,\n\ttype TelemetryLoggerExt,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { createOdspCacheAndTracker, type EpochTracker } from \"../epochTracker.js\";\nimport { NonPersistentCache } from \"../odspCache.js\";\nimport { OdspDriverUrlResolver } from \"../odspDriverUrlResolver.js\";\nimport type { IOdspPointInTimeDocumentServiceImplementationProps } from \"../odspDocumentServiceFactoryCore.js\";\nimport {\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\ttoInstrumentedOdspStorageTokenFetcher,\n} from \"../odspUtils.js\";\nimport {\n\tcreateOdspVersionManager,\n\ttype IOdspVersionManager,\n\t// eslint-disable-next-line import-x/no-internal-modules -- the feature implementation owns version selection\n} from \"../odspVersionManager/odspVersionManager.js\";\n\nimport { OdspPointInTimeDocumentService } from \"./odspPointInTimeDocumentService.js\";\n\ninterface IPointInTimeDocumentServiceDependencies {\n\treadonly createVersionManager?: (\n\t\todspResolvedUrl: IOdspResolvedUrl,\n\t\tlogger: TelemetryLoggerExt,\n\t\tepochTracker: EpochTracker,\n\t) => IOdspVersionManager | Promise<IOdspVersionManager>;\n\treadonly resolveFileVersion?: (\n\t\tresolvedUrl: IResolvedUrl,\n\t\tfileVersion: string,\n\t) => IResolvedUrl | Promise<IResolvedUrl>;\n}\n\nasync function createVersionManager(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tlogger: TelemetryLoggerExt,\n\tepochTracker: EpochTracker,\n\tgetStorageToken: IOdspPointInTimeDocumentServiceImplementationProps[\"getStorageToken\"],\n): Promise<IOdspVersionManager> {\n\tconst urlParts: IOdspUrlParts = {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t};\n\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\tlogger,\n\t\turlParts,\n\t\tgetStorageToken,\n\t);\n\treturn createOdspVersionManager({\n\t\turlParts,\n\t\tgetAuthHeader,\n\t\tepochTracker,\n\t\tlogger,\n\t});\n}\n\nasync function resolveFileVersion(\n\tresolvedUrl: IResolvedUrl,\n\tfileVersion: string,\n): Promise<IResolvedUrl> {\n\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\tconst query = new URLSearchParams({\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t\tfileVersion,\n\t});\n\tif (odspResolvedUrl.dataStorePath !== undefined) {\n\t\tquery.set(\"path\", odspResolvedUrl.dataStorePath);\n\t}\n\tif (odspResolvedUrl.codeHint?.containerPackageName !== undefined) {\n\t\tquery.set(\"containerPackageName\", odspResolvedUrl.codeHint.containerPackageName);\n\t}\n\treturn new OdspDriverUrlResolver().resolve({\n\t\turl: `${odspResolvedUrl.siteUrl}?${query.toString()}`,\n\t});\n}\n\n/**\n * ODSP's point-in-time document service implementation.\n *\n * @remarks Import this function from the dedicated point-in-time entrypoint and inject it through\n * {@link IOdspDocumentServiceFactoryOptions.pointInTimeDocumentServiceImplementation}.\n *\n * @param props - ODSP service dependencies and point-in-time load parameters supplied by the factory.\n * @returns A read-only ODSP document service materialized at the requested sequence number.\n *\n * @legacy @beta\n */\nexport async function createPointInTimeDocumentService(\n\tprops: IOdspPointInTimeDocumentServiceImplementationProps,\n): Promise<IDocumentService> {\n\treturn createPointInTimeDocumentServiceCore(props);\n}\n\n/**\n * Creates the point-in-time service with replaceable dependencies for testing.\n * @internal\n */\nexport async function createPointInTimeDocumentServiceCore(\n\t{\n\t\tresolvedUrl,\n\t\ttargetSequenceNumber,\n\t\tlogger,\n\t\tclientIsSummarizer,\n\t\tpersistedCache,\n\t\tgetStorageToken,\n\t\tcreateDocumentService,\n\t}: IOdspPointInTimeDocumentServiceImplementationProps,\n\tdependencies: IPointInTimeDocumentServiceDependencies = {},\n): Promise<OdspPointInTimeDocumentService> {\n\tconst odspLogger = createOdspLogger(logger);\n\tconst extLogger = createChildLogger({ logger: odspLogger });\n\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\tconst cacheAndTracker = createOdspCacheAndTracker(\n\t\tpersistedCache,\n\t\tnew NonPersistentCache(),\n\t\t{\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t\tfileVersion: odspResolvedUrl.fileVersion,\n\t\t},\n\t\textLogger,\n\t\tclientIsSummarizer,\n\t);\n\n\tconst versionManager = await (\n\t\tdependencies.createVersionManager ??\n\t\t(async (url, versionLogger, epochTracker) =>\n\t\t\tcreateVersionManager(url, versionLogger, epochTracker, getStorageToken))\n\t)(odspResolvedUrl, extLogger, cacheAndTracker.epochTracker);\n\tconst baseResult = await versionManager.findBaseForSeq(targetSequenceNumber);\n\tif (baseResult.kind === \"noBaseVersion\") {\n\t\tconst oldestResolvedSequenceDetail =\n\t\t\tbaseResult.oldestResolvedSeq === undefined\n\t\t\t\t? \"\"\n\t\t\t\t: ` The oldest resolved file version is at sequence number ${baseResult.oldestResolvedSeq}.`;\n\t\tthrow new UsageError(\n\t\t\t`No ODSP file version is available at or before sequence number ${targetSequenceNumber}.${oldestResolvedSequenceDetail}`,\n\t\t);\n\t}\n\n\tconst recoverableResolvedUrl = await (dependencies.resolveFileVersion ?? resolveFileVersion)(\n\t\tresolvedUrl,\n\t\tbaseResult.base.versionId,\n\t);\n\tconst recoverableDocumentService = await createDocumentService(\n\t\trecoverableResolvedUrl,\n\t\todspLogger,\n\t\tcacheAndTracker,\n\t\tclientIsSummarizer,\n\t);\n\tconst liveDocumentService = await createDocumentService(\n\t\tresolvedUrl,\n\t\todspLogger,\n\t\tcacheAndTracker,\n\t\tclientIsSummarizer,\n\t);\n\treturn new OdspPointInTimeDocumentService(\n\t\trecoverableResolvedUrl,\n\t\trecoverableDocumentService,\n\t\tliveDocumentService,\n\t\ttargetSequenceNumber,\n\t);\n}\n"]}
|