@fluidframework/odsp-driver-definitions 2.0.0-internal.3.0.2 → 2.0.0-internal.3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +6 -9
- package/api-extractor.json +2 -2
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +19 -11
- package/dist/errors.js.map +1 -1
- package/dist/factory.d.ts +5 -0
- package/dist/factory.d.ts.map +1 -1
- package/dist/factory.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/odspCache.d.ts +7 -1
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js +10 -1
- package/dist/odspCache.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/resolvedUrl.d.ts +4 -4
- package/dist/resolvedUrl.d.ts.map +1 -1
- package/dist/resolvedUrl.js +2 -2
- package/dist/resolvedUrl.js.map +1 -1
- package/dist/tokenFetch.d.ts.map +1 -1
- package/dist/tokenFetch.js +3 -1
- package/dist/tokenFetch.js.map +1 -1
- package/lib/errors.d.ts +23 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +19 -11
- package/lib/errors.js.map +1 -1
- package/lib/factory.d.ts +5 -0
- package/lib/factory.d.ts.map +1 -1
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/odspCache.d.ts +7 -1
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js +8 -0
- package/lib/odspCache.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/resolvedUrl.d.ts +4 -4
- package/lib/resolvedUrl.d.ts.map +1 -1
- package/lib/resolvedUrl.js +2 -2
- package/lib/resolvedUrl.js.map +1 -1
- package/lib/tokenFetch.d.ts.map +1 -1
- package/lib/tokenFetch.js +3 -1
- package/lib/tokenFetch.js.map +1 -1
- package/package.json +31 -34
- package/prettier.config.cjs +1 -1
- package/src/errors.ts +57 -49
- package/src/factory.ts +134 -128
- package/src/index.ts +15 -2
- package/src/odspCache.ts +59 -50
- package/src/packageVersion.ts +1 -1
- package/src/resolvedUrl.ts +85 -87
- package/src/tokenFetch.ts +44 -37
- package/tsconfig.esnext.json +6 -6
- package/tsconfig.json +9 -13
- package/.editorconfig +0 -7
package/src/factory.ts
CHANGED
|
@@ -4,141 +4,147 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export interface ISnapshotOptions {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
7
|
+
blobs?: number;
|
|
8
|
+
deltas?: number;
|
|
9
|
+
channels?: number;
|
|
10
|
+
/*
|
|
11
|
+
* Maximum Data size (in bytes)
|
|
12
|
+
* If specified, SPO will fail snapshot request with 413 error (see OdspErrorType.snapshotTooBig)
|
|
13
|
+
* if snapshot is bigger in size than specified limit.
|
|
14
|
+
*/
|
|
15
|
+
mds?: number;
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* Maximum time limit to fetch snapshot (in seconds)
|
|
19
|
+
* If specified, client will timeout the fetch request if it exceeds the time limit and
|
|
20
|
+
* will try to fetch the snapshot without blobs.
|
|
21
|
+
*/
|
|
22
|
+
timeout?: number;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface IOpsCachingPolicy {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
26
|
+
/**
|
|
27
|
+
* Batch size. Controls how many ops are grouped together as single cache entry
|
|
28
|
+
* The bigger the number, the more efficient it is (less reads & writes)
|
|
29
|
+
* At the same time, big number means we wait for so many ops to accumulate, which
|
|
30
|
+
* increases chances and number of trailing ops that would not be flushed to cache
|
|
31
|
+
* when user closes tab
|
|
32
|
+
* Use any number below 1 to disable caching
|
|
33
|
+
* Default: 100
|
|
34
|
+
*/
|
|
35
|
+
batchSize?: number;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* To reduce the problem of losing trailing ops when using big batch sizes, host
|
|
39
|
+
* could specify how often driver should flush ops it has not flushed yet.
|
|
40
|
+
* -1 means do not use timer.
|
|
41
|
+
* Measured in ms.
|
|
42
|
+
* Default: 5000
|
|
43
|
+
*/
|
|
44
|
+
timerGranularity?: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Total number of ops to cache. When we reach that number, ops caching stops
|
|
48
|
+
* Default: 5000
|
|
49
|
+
*/
|
|
50
|
+
totalOpsToCache?: number;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export interface ICollabSessionOptions {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Value indicating the display name for session that admits unauthenticated user.
|
|
56
|
+
* This name will be used in attribution associated with edits made by such user.
|
|
57
|
+
*/
|
|
58
|
+
unauthenticatedUserDisplayName?: string;
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated Due to security reasons we will be passing the token via Authorization header only.
|
|
61
|
+
* Value indicating session preference to always pass access token via Authorization header.
|
|
62
|
+
* Default behavior is to pass access token via query parameter unless overall href string
|
|
63
|
+
* length exceeds 2048 characters. Using query param is performance optimization which results
|
|
64
|
+
* in ODSP XHR request being treated as 'simple' request which do not require OPTIONS call to
|
|
65
|
+
* validate CORS. However, not all ODSP implementations understand this optimization.
|
|
66
|
+
* For instance, auth layer on Converged stack will fail request with access token passed via
|
|
67
|
+
* query param.
|
|
68
|
+
*/
|
|
69
|
+
forceAccessTokenViaAuthorizationHeader?: boolean;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export interface HostStoragePolicy {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
73
|
+
snapshotOptions?: ISnapshotOptions;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* If set to true, tells driver to concurrently fetch snapshot from storage (SPO) and cache
|
|
77
|
+
* Container loads from whatever comes first in such case.
|
|
78
|
+
* Snapshot fetched from storage is pushed to cache in either case.
|
|
79
|
+
* If set to false, driver will first consult with cache. Only on cache miss (cache does not
|
|
80
|
+
* return snapshot), driver will fetch snapshot from storage (and push it to cache), otherwise
|
|
81
|
+
* it will load from cache and not reach out to storage.
|
|
82
|
+
* Passing true results in faster loads and keeping cache more current, but it increases bandwidth consumption.
|
|
83
|
+
*/
|
|
84
|
+
concurrentSnapshotFetch?: boolean;
|
|
85
|
+
|
|
86
|
+
// Options overwriting default ops fetching from storage.
|
|
87
|
+
opsBatchSize?: number;
|
|
88
|
+
concurrentOpsBatches?: number;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Policy controlling ops caching (leveraging IPersistedCache passed to driver factory)
|
|
92
|
+
*/
|
|
93
|
+
opsCaching?: IOpsCachingPolicy;
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Policy controlling how collaboration session is established
|
|
97
|
+
*/
|
|
98
|
+
sessionOptions?: ICollabSessionOptions;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* @deprecated This field will be always set to true after removal.
|
|
102
|
+
* True to have the sharing link redeem fallback in case the Trees Latest/Redeem 1RT call fails with redeem error.
|
|
103
|
+
* During fallback it will first redeem the sharing link and then make the Trees latest call.
|
|
104
|
+
*/
|
|
105
|
+
enableRedeemFallback?: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Policy controlling if we will cache initial summary when we create a document
|
|
109
|
+
*/
|
|
110
|
+
cacheCreateNewSummary?: boolean;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated This will be replaced with feature gate snapshotFormatFetchType.
|
|
114
|
+
* Policy controlling if we want to fetch binary format snapshot.
|
|
115
|
+
*/
|
|
116
|
+
fetchBinarySnapshotFormat?: boolean;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* If set to true, socket cache are per OdspDocumentService instead of shared across all instances
|
|
120
|
+
*/
|
|
121
|
+
isolateSocketCache?: boolean;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @deprecated Switch to using the new feature gated by enableSingleRequestForShareLinkWithCreate
|
|
125
|
+
* with 'createLinkScope' and 'createLinkRole' is requested to the odsp apis instead of 'createLinkType'.
|
|
126
|
+
* It enables the creation of sharing link along with the creation of file by setting this value to true.
|
|
127
|
+
* If the host provides a 'createLinkType' parameter in the request URL to the container.attach()
|
|
128
|
+
* method, we will send the request to ODSP with the same (if the flag is enabled) so
|
|
129
|
+
* that a share link can be created with the creation of file to save number for round trips made to ODSP.
|
|
130
|
+
* (This flag works independently of enableSingleRequestForShareLinkWithCreate which is used for sharing link
|
|
131
|
+
* requests where 'createLinkScope' is requested.)
|
|
132
|
+
*/
|
|
133
|
+
enableShareLinkWithCreate?: boolean;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Enable creation of sharing link along with the creation of file by setting this value to true.
|
|
137
|
+
* If the host provides a 'createLinkScope' parameter in the request URL to the container.attach()
|
|
138
|
+
* method, we will send the request to ODSP with the same (if the flag is enabled) so
|
|
139
|
+
* that a share link can be created with the creation of file to save number for round trips made to ODSP.
|
|
140
|
+
* (This flag works independently of enableShareLinkWithCreate which was used for old sharing link requests
|
|
141
|
+
* where 'createLinkType' was requested.)
|
|
142
|
+
*/
|
|
143
|
+
enableSingleRequestForShareLinkWithCreate?: boolean;
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* True if host does not want the storage service to use the prefetch cache to get the snapshot. Undefined will be treated
|
|
147
|
+
* as false. This is if the host wants to do some A/B testing.
|
|
148
|
+
*/
|
|
149
|
+
avoidPrefetchSnapshotCache?: boolean;
|
|
144
150
|
}
|
package/src/index.ts
CHANGED
|
@@ -4,8 +4,21 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export { IOdspError, IOdspErrorAugmentations, OdspError, OdspErrorType } from "./errors";
|
|
7
|
-
export {
|
|
8
|
-
|
|
7
|
+
export {
|
|
8
|
+
HostStoragePolicy,
|
|
9
|
+
ICollabSessionOptions,
|
|
10
|
+
IOpsCachingPolicy,
|
|
11
|
+
ISnapshotOptions,
|
|
12
|
+
} from "./factory";
|
|
13
|
+
export {
|
|
14
|
+
CacheContentType,
|
|
15
|
+
getKeyForCacheEntry,
|
|
16
|
+
ICacheEntry,
|
|
17
|
+
IEntry,
|
|
18
|
+
IFileEntry,
|
|
19
|
+
IPersistedCache,
|
|
20
|
+
snapshotKey,
|
|
21
|
+
} from "./odspCache";
|
|
9
22
|
export {
|
|
10
23
|
IOdspResolvedUrl,
|
|
11
24
|
IOdspUrlParts,
|
package/src/odspCache.ts
CHANGED
|
@@ -17,50 +17,50 @@ export type CacheContentType = "snapshot" | "ops";
|
|
|
17
17
|
* to implement storage / identify files.
|
|
18
18
|
*/
|
|
19
19
|
export interface IFileEntry {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Unique and stable ID of the document.
|
|
22
|
+
* Driver guarantees that docId is stable ID uniquely identifying document.
|
|
23
|
+
*/
|
|
24
|
+
docId: string;
|
|
25
|
+
/**
|
|
26
|
+
* Resolved URI is provided for additional versatility - host can use it to
|
|
27
|
+
* identify file in storage, and (as example) delete all cached entries for
|
|
28
|
+
* a file if user requests so.
|
|
29
|
+
* This is IOdspResolvedUrl in case of ODSP driver.
|
|
30
|
+
*/
|
|
31
|
+
resolvedUrl: IFluidResolvedUrl;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
35
|
* Cache entry. Identifies file that this entry belongs to, and type of content stored in it.
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
export interface IEntry {
|
|
38
|
+
/**
|
|
39
|
+
* Identifies type of entry for a given file.
|
|
40
|
+
* Each file can have multiple types of entries associated with it.
|
|
41
|
+
* For example, it can be snapshot, blob, ops, etc.
|
|
42
|
+
*/
|
|
43
|
+
type: CacheContentType;
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Identifies individual entry for a given file and type.
|
|
47
|
+
* Each file can have multiple cache entries associated with it.
|
|
48
|
+
* This property identifies a particular instance of entry.
|
|
49
|
+
* For example, for blobs it will be unique ID of the blob in a file.
|
|
50
|
+
* For batch of ops, it can be starting op sequence number.
|
|
51
|
+
* For types that have only one entry (like snapshots), it will be empty string.
|
|
52
|
+
*/
|
|
53
|
+
key: string;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Cache entry. Identifies file that this entry belongs to, and type of content stored in it.
|
|
58
58
|
*/
|
|
59
59
|
export interface ICacheEntry extends IEntry {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Identifies file in storage this cached entry is for
|
|
62
|
+
*/
|
|
63
|
+
file: IFileEntry;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
/**
|
|
@@ -71,24 +71,33 @@ export interface ICacheEntry extends IEntry {
|
|
|
71
71
|
* information.
|
|
72
72
|
*/
|
|
73
73
|
export interface IPersistedCache {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Get the cache value of the key
|
|
76
|
+
* @param entry - cache entry, identifies file and particular key for this file.
|
|
77
|
+
* @returns Cached value. undefined if nothing is cached.
|
|
78
|
+
*/
|
|
79
|
+
get(entry: ICacheEntry): Promise<any>;
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Put the value into cache.
|
|
83
|
+
* Important - only serializable content is allowed since this cache may be persisted between sessions
|
|
84
|
+
* @param entry - cache entry.
|
|
85
|
+
* @param value - JSON-serializable content.
|
|
86
|
+
*/
|
|
87
|
+
put(entry: ICacheEntry, value: any): Promise<void>;
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Removes the entries from the cache for given parametres.
|
|
91
|
+
* @param file - file entry to be deleted.
|
|
92
|
+
*/
|
|
93
|
+
removeEntries(file: IFileEntry): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Api to generate a cache key from cache entry.
|
|
98
|
+
* @param entry - cache entry from which a cache key is generated
|
|
99
|
+
* @returns - key for cache.
|
|
100
|
+
*/
|
|
101
|
+
export function getKeyForCacheEntry(entry: ICacheEntry): string {
|
|
102
|
+
return `${entry.file.docId}_${entry.type}_${entry.key}`;
|
|
94
103
|
}
|
package/src/packageVersion.ts
CHANGED