@fluidframework/odsp-driver-definitions 2.0.0-internal.7.3.0 → 2.0.0-internal.7.4.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-extractor-lint.json +13 -0
  3. package/api-extractor.json +3 -3
  4. package/api-report/odsp-driver-definitions.api.md +36 -36
  5. package/dist/errors.cjs +2 -0
  6. package/dist/errors.cjs.map +1 -1
  7. package/dist/errors.d.ts +12 -0
  8. package/dist/errors.d.ts.map +1 -1
  9. package/dist/factory.cjs.map +1 -1
  10. package/dist/factory.d.ts +12 -0
  11. package/dist/factory.d.ts.map +1 -1
  12. package/dist/odsp-driver-definitions-alpha.d.ts +475 -0
  13. package/dist/odsp-driver-definitions-beta.d.ts +81 -0
  14. package/dist/odsp-driver-definitions-public.d.ts +81 -0
  15. package/dist/odsp-driver-definitions-untrimmed.d.ts +652 -0
  16. package/dist/odspCache.cjs +2 -0
  17. package/dist/odspCache.cjs.map +1 -1
  18. package/dist/odspCache.d.ts +11 -0
  19. package/dist/odspCache.d.ts.map +1 -1
  20. package/dist/resolvedUrl.cjs +3 -0
  21. package/dist/resolvedUrl.cjs.map +1 -1
  22. package/dist/resolvedUrl.d.ts +12 -0
  23. package/dist/resolvedUrl.d.ts.map +1 -1
  24. package/dist/sessionProvider.cjs.map +1 -1
  25. package/dist/sessionProvider.d.ts +3 -0
  26. package/dist/sessionProvider.d.ts.map +1 -1
  27. package/dist/tokenFetch.cjs +2 -0
  28. package/dist/tokenFetch.cjs.map +1 -1
  29. package/dist/tokenFetch.d.ts +10 -0
  30. package/dist/tokenFetch.d.ts.map +1 -1
  31. package/lib/errors.d.ts +12 -4
  32. package/lib/errors.d.ts.map +1 -1
  33. package/lib/errors.mjs +2 -0
  34. package/lib/errors.mjs.map +1 -1
  35. package/lib/factory.d.ts +12 -0
  36. package/lib/factory.d.ts.map +1 -1
  37. package/lib/factory.mjs.map +1 -1
  38. package/lib/index.d.ts +6 -6
  39. package/lib/index.d.ts.map +1 -1
  40. package/lib/odsp-driver-definitions-alpha.d.ts +475 -0
  41. package/lib/odsp-driver-definitions-beta.d.ts +81 -0
  42. package/lib/odsp-driver-definitions-public.d.ts +81 -0
  43. package/lib/odsp-driver-definitions-untrimmed.d.ts +652 -0
  44. package/lib/odspCache.d.ts +11 -0
  45. package/lib/odspCache.d.ts.map +1 -1
  46. package/lib/odspCache.mjs +2 -0
  47. package/lib/odspCache.mjs.map +1 -1
  48. package/lib/resolvedUrl.d.ts +12 -0
  49. package/lib/resolvedUrl.d.ts.map +1 -1
  50. package/lib/resolvedUrl.mjs +3 -0
  51. package/lib/resolvedUrl.mjs.map +1 -1
  52. package/lib/sessionProvider.d.ts +3 -0
  53. package/lib/sessionProvider.d.ts.map +1 -1
  54. package/lib/sessionProvider.mjs.map +1 -1
  55. package/lib/tokenFetch.d.ts +10 -0
  56. package/lib/tokenFetch.d.ts.map +1 -1
  57. package/lib/tokenFetch.mjs +2 -0
  58. package/lib/tokenFetch.mjs.map +1 -1
  59. package/package.json +25 -6
  60. package/src/errors.ts +12 -0
  61. package/src/factory.ts +12 -0
  62. package/src/odspCache.ts +11 -0
  63. package/src/resolvedUrl.ts +12 -0
  64. package/src/sessionProvider.ts +3 -0
  65. package/src/tokenFetch.ts +10 -0
@@ -0,0 +1,652 @@
1
+ import { DriverError } from '@fluidframework/driver-definitions';
2
+ import { IDriverErrorBase } from '@fluidframework/driver-definitions';
3
+ import { IResolvedUrl } from '@fluidframework/driver-definitions';
4
+
5
+ /**
6
+ * @alpha
7
+ */
8
+ export declare type CacheContentType = "snapshot" | "ops";
9
+
10
+ /**
11
+ * Api to generate a cache key from cache entry.
12
+ * @param entry - cache entry from which a cache key is generated
13
+ * @returns The key for cache.
14
+ * @internal
15
+ */
16
+ export declare function getKeyForCacheEntry(entry: ICacheEntry): string;
17
+
18
+ /**
19
+ * @alpha
20
+ */
21
+ export declare interface HostStoragePolicy {
22
+ snapshotOptions?: ISnapshotOptions;
23
+ /**
24
+ * If set to true, tells driver to concurrently fetch snapshot from storage (SPO) and cache
25
+ * Container loads from whatever comes first in such case.
26
+ * Snapshot fetched from storage is pushed to cache in either case.
27
+ * If set to false, driver will first consult with cache. Only on cache miss (cache does not
28
+ * return snapshot), driver will fetch snapshot from storage (and push it to cache), otherwise
29
+ * it will load from cache and not reach out to storage.
30
+ * Passing true results in faster loads and keeping cache more current, but it increases bandwidth consumption.
31
+ */
32
+ concurrentSnapshotFetch?: boolean;
33
+ opsBatchSize?: number;
34
+ concurrentOpsBatches?: number;
35
+ /**
36
+ * Policy controlling ops caching (leveraging IPersistedCache passed to driver factory)
37
+ */
38
+ opsCaching?: IOpsCachingPolicy;
39
+ /**
40
+ * Policy controlling how collaboration session is established
41
+ */
42
+ sessionOptions?: ICollabSessionOptions;
43
+ /**
44
+ * @deprecated This field will be always set to true after removal.
45
+ * True to have the sharing link redeem fallback in case the Trees Latest/Redeem 1RT call fails with redeem error.
46
+ * During fallback it will first redeem the sharing link and then make the Trees latest call.
47
+ */
48
+ enableRedeemFallback?: boolean;
49
+ /**
50
+ * Policy controlling if we will cache initial summary when we create a document
51
+ */
52
+ cacheCreateNewSummary?: boolean;
53
+ /**
54
+ * @deprecated This will be replaced with feature gate snapshotFormatFetchType.
55
+ * Policy controlling if we want to fetch binary format snapshot.
56
+ */
57
+ fetchBinarySnapshotFormat?: boolean;
58
+ /**
59
+ * If set to true, socket cache are per OdspDocumentService instead of shared across all instances
60
+ */
61
+ isolateSocketCache?: boolean;
62
+ /**
63
+ * @deprecated Switch to using the new feature gated by enableSingleRequestForShareLinkWithCreate
64
+ * with 'createLinkScope' and 'createLinkRole' is requested to the odsp apis instead of 'createLinkType'.
65
+ * It enables the creation of sharing link along with the creation of file by setting this value to true.
66
+ * If the host provides a 'createLinkType' parameter in the request URL to the container.attach()
67
+ * method, we will send the request to ODSP with the same (if the flag is enabled) so
68
+ * that a share link can be created with the creation of file to save number for round trips made to ODSP.
69
+ * (This flag works independently of enableSingleRequestForShareLinkWithCreate which is used for sharing link
70
+ * requests where 'createLinkScope' is requested.)
71
+ */
72
+ enableShareLinkWithCreate?: boolean;
73
+ /**
74
+ * Enable creation of sharing link along with the creation of file by setting this value to true.
75
+ * If the host provides a 'createLinkScope' parameter in the request URL to the container.attach()
76
+ * method, we will send the request to ODSP with the same (if the flag is enabled) so
77
+ * that a share link can be created with the creation of file to save number for round trips made to ODSP.
78
+ * (This flag works independently of enableShareLinkWithCreate which was used for old sharing link requests
79
+ * where 'createLinkType' was requested.)
80
+ */
81
+ enableSingleRequestForShareLinkWithCreate?: boolean;
82
+ /**
83
+ * True if host does not want the storage service to use the prefetch cache to get the snapshot. Undefined will be treated
84
+ * as false. This is if the host wants to do some A/B testing.
85
+ */
86
+ avoidPrefetchSnapshotCache?: boolean;
87
+ }
88
+
89
+ /**
90
+ * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.
91
+ * @alpha
92
+ */
93
+ export declare interface ICacheEntry extends IEntry {
94
+ /**
95
+ * Identifies file in storage this cached entry is for
96
+ */
97
+ file: IFileEntry;
98
+ }
99
+
100
+ /**
101
+ * @alpha
102
+ */
103
+ export declare interface ICollabSessionOptions {
104
+ /**
105
+ * Value indicating the display name for session that admits unauthenticated user.
106
+ * This name will be used in attribution associated with edits made by such user.
107
+ */
108
+ unauthenticatedUserDisplayName?: string;
109
+ /**
110
+ * @deprecated Due to security reasons we will be passing the token via Authorization header only.
111
+ * Value indicating session preference to always pass access token via Authorization header.
112
+ * Default behavior is to pass access token via query parameter unless overall href string
113
+ * length exceeds 2048 characters. Using query param is performance optimization which results
114
+ * in ODSP XHR request being treated as 'simple' request which do not require OPTIONS call to
115
+ * validate CORS. However, not all ODSP implementations understand this optimization.
116
+ * For instance, auth layer on Converged stack will fail request with access token passed via
117
+ * query param.
118
+ */
119
+ forceAccessTokenViaAuthorizationHeader?: boolean;
120
+ }
121
+
122
+ /**
123
+ * Identity types supported by ODSP driver.
124
+ * `Consumer` represents user authenticated with Microsoft Account (MSA).
125
+ * `Enterprise` represents user authenticated with M365 tenant account.
126
+ * @internal
127
+ */
128
+ export declare type IdentityType = "Consumer" | "Enterprise";
129
+
130
+ /**
131
+ * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.
132
+ * @alpha
133
+ */
134
+ export declare interface IEntry {
135
+ /**
136
+ * Identifies type of entry for a given file.
137
+ * Each file can have multiple types of entries associated with it.
138
+ * For example, it can be snapshot, blob, ops, etc.
139
+ */
140
+ type: CacheContentType;
141
+ /**
142
+ * Identifies individual entry for a given file and type.
143
+ * Each file can have multiple cache entries associated with it.
144
+ * This property identifies a particular instance of entry.
145
+ * For example, for blobs it will be unique ID of the blob in a file.
146
+ * For batch of ops, it can be starting op sequence number.
147
+ * For types that have only one entry (like snapshots), it will be empty string.
148
+ */
149
+ key: string;
150
+ }
151
+
152
+ /**
153
+ * @alpha
154
+ */
155
+ export declare interface IFileEntry {
156
+ /**
157
+ * Unique and stable ID of the document.
158
+ * Driver guarantees that docId is stable ID uniquely identifying document.
159
+ */
160
+ docId: string;
161
+ /**
162
+ * Resolved URI is provided for additional versatility - host can use it to
163
+ * identify file in storage, and (as example) delete all cached entries for
164
+ * a file if user requests so.
165
+ * This is IOdspResolvedUrl in case of ODSP driver.
166
+ */
167
+ resolvedUrl: IResolvedUrl;
168
+ }
169
+
170
+ /**
171
+ * @internal
172
+ */
173
+ export declare type InstrumentedStorageTokenFetcher = (options: TokenFetchOptions, name: string, alwaysRecordTokenFetchTelemetry?: boolean) => Promise<string | null>;
174
+
175
+ /**
176
+ * Base interface for all errors and warnings
177
+ * Superset of IDriverErrorBase, but with Odsp-specific errorType and properties
178
+ * @internal
179
+ */
180
+ export declare interface IOdspError extends Omit<IDriverErrorBase, "errorType">, IOdspErrorAugmentations {
181
+ readonly errorType: OdspErrorType;
182
+ }
183
+
184
+ /**
185
+ * @internal
186
+ */
187
+ export declare interface IOdspErrorAugmentations {
188
+ /**
189
+ * Server epoch indicates when the file was last modified.
190
+ * Used to detect modifications outside Fluid's services
191
+ */
192
+ serverEpoch?: string;
193
+ /**
194
+ * It is the redirection url at which the network call should have been made. It is due to change
195
+ * in site domain of the file on server.
196
+ */
197
+ redirectLocation?: string;
198
+ /**
199
+ * It is array of error codes included in error response from server.
200
+ */
201
+ facetCodes?: string[];
202
+ }
203
+
204
+ /**
205
+ * @alpha
206
+ */
207
+ export declare interface IOdspResolvedUrl extends IResolvedUrl, IOdspUrlParts {
208
+ type: "fluid";
209
+ odspResolvedUrl: true;
210
+ url: string;
211
+ hashedDocumentId: string;
212
+ endpoints: {
213
+ snapshotStorageUrl: string;
214
+ attachmentPOSTStorageUrl: string;
215
+ attachmentGETStorageUrl: string;
216
+ deltaStorageUrl: string;
217
+ };
218
+ tokens: {};
219
+ fileName: string;
220
+ summarizer: boolean;
221
+ codeHint?: {
222
+ containerPackageName?: string;
223
+ };
224
+ fileVersion: string | undefined;
225
+ dataStorePath?: string;
226
+ /**
227
+ * Sharing link data created for the ODSP item.
228
+ * Contains information about either sharing link created while creating a new file or
229
+ * a redeemable share link created when loading an existing file
230
+ */
231
+ shareLinkInfo?: ShareLinkInfoType;
232
+ isClpCompliantApp?: boolean;
233
+ }
234
+
235
+ /**
236
+ * @alpha
237
+ */
238
+ export declare interface IOdspUrlParts {
239
+ siteUrl: string;
240
+ driveId: string;
241
+ itemId: string;
242
+ }
243
+
244
+ /**
245
+ * @alpha
246
+ */
247
+ export declare interface IOpsCachingPolicy {
248
+ /**
249
+ * Batch size. Controls how many ops are grouped together as single cache entry
250
+ * The bigger the number, the more efficient it is (less reads & writes)
251
+ * At the same time, big number means we wait for so many ops to accumulate, which
252
+ * increases chances and number of trailing ops that would not be flushed to cache
253
+ * when user closes tab
254
+ * Use any number below 1 to disable caching
255
+ * Default: 100
256
+ */
257
+ batchSize?: number;
258
+ /**
259
+ * To reduce the problem of losing trailing ops when using big batch sizes, host
260
+ * could specify how often driver should flush ops it has not flushed yet.
261
+ * -1 means do not use timer.
262
+ * Measured in ms.
263
+ * Default: 5000
264
+ */
265
+ timerGranularity?: number;
266
+ /**
267
+ * Total number of ops to cache. When we reach that number, ops caching stops
268
+ * Default: 5000
269
+ */
270
+ totalOpsToCache?: number;
271
+ }
272
+
273
+ /**
274
+ * Persistent cache. This interface can be implemented by the host to provide durable caching
275
+ * across sessions. If not provided at driver factory construction, factory will use in-memory
276
+ * cache implementation that does not survive across sessions. Snapshot entires stored in the
277
+ * IPersistedCache will be considered stale and removed after 2 days. Read the README for more
278
+ * information.
279
+ * @alpha
280
+ */
281
+ export declare interface IPersistedCache {
282
+ /**
283
+ * Get the cache value of the key
284
+ * @param entry - cache entry, identifies file and particular key for this file.
285
+ * @returns Cached value. undefined if nothing is cached.
286
+ */
287
+ get(entry: ICacheEntry): Promise<any>;
288
+ /**
289
+ * Put the value into cache.
290
+ * Important - only serializable content is allowed since this cache may be persisted between sessions
291
+ * @param entry - cache entry.
292
+ * @param value - JSON-serializable content.
293
+ */
294
+ put(entry: ICacheEntry, value: any): Promise<void>;
295
+ /**
296
+ * Removes the entries from the cache for given parametres.
297
+ * @param file - file entry to be deleted.
298
+ */
299
+ removeEntries(file: IFileEntry): Promise<void>;
300
+ }
301
+
302
+ /**
303
+ * An interface that allows a concrete instance of a driver factory to interrogate itself
304
+ * to find out if it is session aware.
305
+ * @alpha
306
+ */
307
+ export declare interface IProvideSessionAwareDriverFactory {
308
+ readonly IRelaySessionAwareDriverFactory: IRelaySessionAwareDriverFactory;
309
+ }
310
+
311
+ /**
312
+ * An interface that allows a concrete instance of a driver factory to call the `getRelayServiceSessionInfo`
313
+ * function if it session aware.
314
+ * @alpha
315
+ */
316
+ export declare interface IRelaySessionAwareDriverFactory extends IProvideSessionAwareDriverFactory {
317
+ getRelayServiceSessionInfo(resolvedUrl: IResolvedUrl): Promise<ISocketStorageDiscovery | undefined>;
318
+ }
319
+
320
+ /**
321
+ * Sharing link data received from the /snapshot api response.
322
+ * @alpha
323
+ */
324
+ export declare interface ISharingLink extends ISharingLinkKind {
325
+ webUrl: string;
326
+ }
327
+
328
+ /**
329
+ * Defines the permissions scope for a share link requested to be created during the creation the file in ODSP.
330
+ * Providing these properties to the /snapshot api will also create and return the requested kind of sharing link.
331
+ * @alpha
332
+ */
333
+ export declare interface ISharingLinkKind {
334
+ scope: SharingLinkScope;
335
+ role?: SharingLinkRole;
336
+ }
337
+
338
+ /**
339
+ * @alpha
340
+ */
341
+ export declare interface ISnapshotOptions {
342
+ blobs?: number;
343
+ deltas?: number;
344
+ channels?: number;
345
+ mds?: number;
346
+ timeout?: number;
347
+ }
348
+
349
+ /**
350
+ * Socket storage discovery api response
351
+ * @alpha
352
+ */
353
+ export declare interface ISocketStorageDiscovery {
354
+ id: string;
355
+ runtimeTenantId?: string;
356
+ tenantId: string;
357
+ snapshotStorageUrl: string;
358
+ deltaStorageUrl: string;
359
+ /**
360
+ * PUSH URL
361
+ */
362
+ deltaStreamSocketUrl: string;
363
+ /**
364
+ * The access token for PushChannel. Optionally returned, depending on implementation.
365
+ * OneDrive for Consumer implementation returns it and OneDrive for Business implementation
366
+ * does not return it and instead expects token to be returned via `getWebsocketToken` callback
367
+ * passed as a parameter to `OdspDocumentService.create()` factory.
368
+ */
369
+ socketToken?: string;
370
+ /**
371
+ * This is the time within which client has to refresh the session on (ODSP) relay service.
372
+ */
373
+ refreshSessionDurationSeconds?: number;
374
+ }
375
+
376
+ /**
377
+ * Helper method which returns flag indicating whether token response comes from local cache
378
+ * @param tokenResponse - return value for TokenFetcher method
379
+ * @returns Value indicating whether response came from cache.
380
+ * Undefined is returned when we could not determine the source of token.
381
+ * @internal
382
+ */
383
+ export declare const isTokenFromCache: (tokenResponse: string | TokenResponse | null) => boolean | undefined;
384
+
385
+ /**
386
+ * @internal
387
+ */
388
+ export declare type OdspError = IOdspError | (DriverError & IOdspErrorAugmentations);
389
+
390
+ /**
391
+ * ODSP Error types.
392
+ * Different error types that may be thrown by the ODSP driver.
393
+ *
394
+ * @deprecated Use {@link (OdspErrorTypes:variable)} instead.
395
+ * @internal
396
+ */
397
+ export declare enum OdspErrorType {
398
+ /**
399
+ * Storage is out of space
400
+ */
401
+ outOfStorageError = "outOfStorageError",
402
+ /**
403
+ * Invalid file name (at creation of the file)
404
+ */
405
+ invalidFileNameError = "invalidFileNameError",
406
+ /**
407
+ * Snapshot is too big. Host application specified limit for snapshot size, and snapshot was bigger
408
+ * that that limit, thus request failed. Hosting application is expected to have fall-back behavior for
409
+ * such case.
410
+ */
411
+ snapshotTooBig = "snapshotTooBig",
412
+ /**
413
+ * Maximum time limit to fetch reached. Host application specified limit for fetching of snapshot, when
414
+ * that limit is reached, request fails. Hosting application is expected to have fall-back behavior for
415
+ * such case.
416
+ */
417
+ fetchTimeout = "fetchTimeout",
418
+ /**
419
+ * SPO admin toggle: fluid service is not enabled.
420
+ */
421
+ fluidNotEnabled = "fluidNotEnabled",
422
+ /**
423
+ * {@inheritDoc @fluidframework/driver-definitions#FluidErrorType.fetchTokenError}
424
+ */
425
+ fetchTokenError = "fetchTokenError",
426
+ /**
427
+ * This error will be raised when client is too behind with no way to catch up.
428
+ * This condition will happen when user was offline for too long, resulting in old ops / blobs being deleted
429
+ * by storage, and thus removing an ability for client to catch up.
430
+ * This condition will result in any local changes being lost (i.e. only way to save state is by user
431
+ * copying it over manually)
432
+ */
433
+ cannotCatchUp = "cannotCatchUp",
434
+ /**
435
+ * SPO can occasionally return 403 for r/w operations on document when there is a fail over to another data center.
436
+ * So to preserve integrity of the data, the data becomes readonly.
437
+ */
438
+ serviceReadOnly = "serviceReadOnly",
439
+ /**
440
+ * Due to organizational policies, you can't access server resources from the current network location.
441
+ */
442
+ blockedIPAddress = "blockedIPAddress"
443
+ }
444
+
445
+ /**
446
+ * ODSP Error types.
447
+ * Different error types that may be thrown by the ODSP driver.
448
+ * @internal
449
+ */
450
+ export declare const OdspErrorTypes: {
451
+ /**
452
+ * Invalid file name (at creation of the file)
453
+ */
454
+ readonly invalidFileNameError: "invalidFileNameError";
455
+ /**
456
+ * Snapshot is too big. Host application specified limit for snapshot size, and snapshot was bigger
457
+ * that that limit, thus request failed. Hosting application is expected to have fall-back behavior for
458
+ * such case.
459
+ */
460
+ readonly snapshotTooBig: "snapshotTooBig";
461
+ /**
462
+ * Maximum time limit to fetch reached. Host application specified limit for fetching of snapshot, when
463
+ * that limit is reached, request fails. Hosting application is expected to have fall-back behavior for
464
+ * such case.
465
+ */
466
+ readonly fetchTimeout: "fetchTimeout";
467
+ /**
468
+ * SPO admin toggle: fluid service is not enabled.
469
+ */
470
+ readonly fluidNotEnabled: "fluidNotEnabled";
471
+ /**
472
+ * This error will be raised when client is too behind with no way to catch up.
473
+ * This condition will happen when user was offline for too long, resulting in old ops / blobs being deleted
474
+ * by storage, and thus removing an ability for client to catch up.
475
+ * This condition will result in any local changes being lost (i.e. only way to save state is by user
476
+ * copying it over manually)
477
+ */
478
+ readonly cannotCatchUp: "cannotCatchUp";
479
+ /**
480
+ * SPO can occasionally return 403 for r/w operations on document when there is a fail over to another data center.
481
+ * So to preserve integrity of the data, the data becomes readonly.
482
+ */
483
+ readonly serviceReadOnly: "serviceReadOnly";
484
+ /**
485
+ * Due to organizational policies, you can't access server resources from the current network location.
486
+ */
487
+ readonly blockedIPAddress: "blockedIPAddress";
488
+ readonly genericNetworkError: "genericNetworkError";
489
+ readonly authorizationError: "authorizationError";
490
+ readonly fileNotFoundOrAccessDeniedError: "fileNotFoundOrAccessDeniedError";
491
+ readonly offlineError: "offlineError";
492
+ readonly unsupportedClientProtocolVersion: "unsupportedClientProtocolVersion";
493
+ readonly writeError: "writeError";
494
+ readonly fetchFailure: "fetchFailure";
495
+ readonly fetchTokenError: "fetchTokenError";
496
+ readonly incorrectServerResponse: "incorrectServerResponse";
497
+ readonly fileOverwrittenInStorage: "fileOverwrittenInStorage";
498
+ readonly deltaStreamConnectionForbidden: "deltaStreamConnectionForbidden";
499
+ readonly locationRedirection: "locationRedirection";
500
+ readonly fluidInvalidSchema: "fluidInvalidSchema";
501
+ readonly fileIsLocked: "fileIsLocked";
502
+ readonly outOfStorageError: "outOfStorageError";
503
+ readonly genericError: "genericError";
504
+ readonly throttlingError: "throttlingError";
505
+ readonly usageError: "usageError";
506
+ };
507
+
508
+ /**
509
+ * @internal
510
+ */
511
+ export declare type OdspErrorTypes = (typeof OdspErrorTypes)[keyof typeof OdspErrorTypes];
512
+
513
+ /**
514
+ * Represents access token fetch options for ODSP resource
515
+ * @alpha
516
+ */
517
+ export declare interface OdspResourceTokenFetchOptions extends TokenFetchOptions {
518
+ /** Site url representing ODSP resource location */
519
+ siteUrl: string;
520
+ /** ODSP drive id where resource resides. Optional, used only when fetching token to access ODSP file */
521
+ driveId?: string;
522
+ /** ODSP item id representing resource. Optional, used only when fetching token to access ODSP file */
523
+ itemId?: string;
524
+ }
525
+
526
+ /**
527
+ * Sharing link data created for the ODSP item.
528
+ * Contains information about either sharing link created while creating a new file or
529
+ * a redeemable share link created when loading an existing file
530
+ * @alpha
531
+ */
532
+ export declare interface ShareLinkInfoType {
533
+ /**
534
+ * We create a new file in ODSP with the /snapshot api call. Applications then need to make a separate apis call to
535
+ * create a sharing link for that file. To reduce the number of network calls, ODSP now provides a feature
536
+ * where we can create a share link along with creating a file by passing a query parameter called
537
+ * createShareLink (deprecated) or createLinkScope and createLinkRole. createLink object below saves the information
538
+ * from the /snapshot api response.
539
+ */
540
+ createLink?: {
541
+ /**
542
+ * @deprecated
543
+ * Type of shareLink requested/created when creating the file for the first time. The 'type' property here
544
+ * represents the type of sharing link requested.
545
+ * Will be deprecated soon. Type of sharing link will be present in the link:ISharingLink property below.
546
+ */
547
+ type?: ShareLinkTypes | ISharingLinkKind;
548
+ /**
549
+ * Share link created when the file is created for the first time with /snapshot api call.
550
+ */
551
+ link?: string | ISharingLink;
552
+ /**
553
+ * Error message if creation of sharing link fails with /snapshot api call
554
+ */
555
+ error?: any;
556
+ shareId?: string;
557
+ };
558
+ /**
559
+ * This is used to save the network calls while doing trees/latest call as if the client does not have
560
+ * permission then this link can be redeemed for the permissions in the same network call.
561
+ */
562
+ sharingLinkToRedeem?: string;
563
+ }
564
+
565
+ /**
566
+ * @deprecated Use ISharingLinkKind type instead.
567
+ * Type of shareLink requested/created when creating the file for the first time.
568
+ * @alpha
569
+ */
570
+ export declare enum ShareLinkTypes {
571
+ csl = "csl"
572
+ }
573
+
574
+ /**
575
+ * View/edit permission role for a sharing link.
576
+ * @alpha
577
+ */
578
+ export declare enum SharingLinkRole {
579
+ view = "view",
580
+ edit = "edit"
581
+ }
582
+
583
+ /**
584
+ * Sharing scope of the share links created for a file.
585
+ * @alpha
586
+ */
587
+ export declare enum SharingLinkScope {
588
+ organization = "organization",
589
+ users = "users",
590
+ anonymous = "anonymous",
591
+ default = "default"
592
+ }
593
+
594
+ /**
595
+ * Describes what kind of content is stored in cache entry.
596
+ * @internal
597
+ */
598
+ export declare const snapshotKey = "snapshot";
599
+
600
+ /**
601
+ * Method signature for callback method used to fetch access token
602
+ * @param options - token fetch options
603
+ * @returns If successful, TokenResponse object representing token value along with flag indicating
604
+ * whether token came from cache. Legacy implementation may return a string for token value;
605
+ * in this case it should be assumes that fromCache signal is undefined. Null is returned in case of failure.
606
+ * @alpha
607
+ */
608
+ export declare type TokenFetcher<T> = (options: T) => Promise<string | TokenResponse | null>;
609
+
610
+ /**
611
+ * Represents access token fetch options
612
+ * @alpha
613
+ */
614
+ export declare interface TokenFetchOptions {
615
+ /**
616
+ * Value indicating whether fresh token has to be returned.
617
+ * If false then it is okay to return cached unexpired token if available.
618
+ */
619
+ refresh: boolean;
620
+ /**
621
+ * Claims that have to be passed with token fetch request.
622
+ * These can be used to specify additional information that must be passed to token authority.
623
+ */
624
+ claims?: string;
625
+ /**
626
+ * Tenant id of authority that must be handling token fetch.
627
+ * If it is not specified then it is up to token fetching logic to determine which tenant authority
628
+ * to use to issue access token.
629
+ */
630
+ tenantId?: string;
631
+ }
632
+
633
+ /**
634
+ * Helper method which transforms return value for TokenFetcher method to token string
635
+ * @param tokenResponse - return value for TokenFetcher method
636
+ * @returns Token value
637
+ * @internal
638
+ */
639
+ export declare const tokenFromResponse: (tokenResponse: string | TokenResponse | null | undefined) => string | null;
640
+
641
+ /**
642
+ * Represents token response
643
+ * @alpha
644
+ */
645
+ export declare interface TokenResponse {
646
+ /** Token value */
647
+ token: string;
648
+ /** Flag indicating whether token was obtained from local cache */
649
+ fromCache?: boolean;
650
+ }
651
+
652
+ export { }
@@ -7,12 +7,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.getKeyForCacheEntry = exports.snapshotKey = void 0;
8
8
  /**
9
9
  * Describes what kind of content is stored in cache entry.
10
+ * @internal
10
11
  */
11
12
  exports.snapshotKey = "snapshot";
12
13
  /**
13
14
  * Api to generate a cache key from cache entry.
14
15
  * @param entry - cache entry from which a cache key is generated
15
16
  * @returns The key for cache.
17
+ * @internal
16
18
  */
17
19
  function getKeyForCacheEntry(entry) {
18
20
  return `${entry.file.docId}_${entry.type}_${entry.key}`;
@@ -1 +1 @@
1
- {"version":3,"file":"odspCache.cjs","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;GAEG;AACU,QAAA,WAAW,GAAG,UAAU,CAAC;AAqFtC;;;;GAIG;AACH,SAAgB,mBAAmB,CAAC,KAAkB;IACrD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;AACzD,CAAC;AAFD,kDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\n\n/**\n * Describes what kind of content is stored in cache entry.\n */\nexport const snapshotKey = \"snapshot\";\nexport type CacheContentType = \"snapshot\" | \"ops\";\n\n/*\n * File / container identifier.\n * There is overlapping information here - host can use all of it or parts\n * to implement storage / identify files.\n */\nexport interface IFileEntry {\n\t/**\n\t * Unique and stable ID of the document.\n\t * Driver guarantees that docId is stable ID uniquely identifying document.\n\t */\n\tdocId: string;\n\t/**\n\t * Resolved URI is provided for additional versatility - host can use it to\n\t * identify file in storage, and (as example) delete all cached entries for\n\t * a file if user requests so.\n\t * This is IOdspResolvedUrl in case of ODSP driver.\n\t */\n\tresolvedUrl: IResolvedUrl;\n}\n\n/**\n * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.\n */\nexport interface IEntry {\n\t/**\n\t * Identifies type of entry for a given file.\n\t * Each file can have multiple types of entries associated with it.\n\t * For example, it can be snapshot, blob, ops, etc.\n\t */\n\ttype: CacheContentType;\n\n\t/**\n\t * Identifies individual entry for a given file and type.\n\t * Each file can have multiple cache entries associated with it.\n\t * This property identifies a particular instance of entry.\n\t * For example, for blobs it will be unique ID of the blob in a file.\n\t * For batch of ops, it can be starting op sequence number.\n\t * For types that have only one entry (like snapshots), it will be empty string.\n\t */\n\tkey: string;\n}\n\n/**\n * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.\n */\nexport interface ICacheEntry extends IEntry {\n\t/**\n\t * Identifies file in storage this cached entry is for\n\t */\n\tfile: IFileEntry;\n}\n\n/**\n * Persistent cache. This interface can be implemented by the host to provide durable caching\n * across sessions. If not provided at driver factory construction, factory will use in-memory\n * cache implementation that does not survive across sessions. Snapshot entires stored in the\n * IPersistedCache will be considered stale and removed after 2 days. Read the README for more\n * information.\n */\nexport interface IPersistedCache {\n\t/**\n\t * Get the cache value of the key\n\t * @param entry - cache entry, identifies file and particular key for this file.\n\t * @returns Cached value. undefined if nothing is cached.\n\t */\n\tget(entry: ICacheEntry): Promise<any>;\n\n\t/**\n\t * Put the value into cache.\n\t * Important - only serializable content is allowed since this cache may be persisted between sessions\n\t * @param entry - cache entry.\n\t * @param value - JSON-serializable content.\n\t */\n\tput(entry: ICacheEntry, value: any): Promise<void>;\n\n\t/**\n\t * Removes the entries from the cache for given parametres.\n\t * @param file - file entry to be deleted.\n\t */\n\tremoveEntries(file: IFileEntry): Promise<void>;\n}\n\n/**\n * Api to generate a cache key from cache entry.\n * @param entry - cache entry from which a cache key is generated\n * @returns The key for cache.\n */\nexport function getKeyForCacheEntry(entry: ICacheEntry): string {\n\treturn `${entry.file.docId}_${entry.type}_${entry.key}`;\n}\n"]}
1
+ {"version":3,"file":"odspCache.cjs","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAIH;;;GAGG;AACU,QAAA,WAAW,GAAG,UAAU,CAAC;AA8FtC;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,KAAkB;IACrD,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,GAAG,EAAE,CAAC;AACzD,CAAC;AAFD,kDAEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions\";\n\n/**\n * Describes what kind of content is stored in cache entry.\n * @internal\n */\nexport const snapshotKey = \"snapshot\";\n/**\n * @alpha\n */\nexport type CacheContentType = \"snapshot\" | \"ops\";\n\n/*\n * File / container identifier.\n * There is overlapping information here - host can use all of it or parts\n * to implement storage / identify files.\n */\n/**\n * @alpha\n */\nexport interface IFileEntry {\n\t/**\n\t * Unique and stable ID of the document.\n\t * Driver guarantees that docId is stable ID uniquely identifying document.\n\t */\n\tdocId: string;\n\t/**\n\t * Resolved URI is provided for additional versatility - host can use it to\n\t * identify file in storage, and (as example) delete all cached entries for\n\t * a file if user requests so.\n\t * This is IOdspResolvedUrl in case of ODSP driver.\n\t */\n\tresolvedUrl: IResolvedUrl;\n}\n\n/**\n * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.\n * @alpha\n */\nexport interface IEntry {\n\t/**\n\t * Identifies type of entry for a given file.\n\t * Each file can have multiple types of entries associated with it.\n\t * For example, it can be snapshot, blob, ops, etc.\n\t */\n\ttype: CacheContentType;\n\n\t/**\n\t * Identifies individual entry for a given file and type.\n\t * Each file can have multiple cache entries associated with it.\n\t * This property identifies a particular instance of entry.\n\t * For example, for blobs it will be unique ID of the blob in a file.\n\t * For batch of ops, it can be starting op sequence number.\n\t * For types that have only one entry (like snapshots), it will be empty string.\n\t */\n\tkey: string;\n}\n\n/**\n * Cache entry. Identifies file that this entry belongs to, and type of content stored in it.\n * @alpha\n */\nexport interface ICacheEntry extends IEntry {\n\t/**\n\t * Identifies file in storage this cached entry is for\n\t */\n\tfile: IFileEntry;\n}\n\n/**\n * Persistent cache. This interface can be implemented by the host to provide durable caching\n * across sessions. If not provided at driver factory construction, factory will use in-memory\n * cache implementation that does not survive across sessions. Snapshot entires stored in the\n * IPersistedCache will be considered stale and removed after 2 days. Read the README for more\n * information.\n * @alpha\n */\nexport interface IPersistedCache {\n\t/**\n\t * Get the cache value of the key\n\t * @param entry - cache entry, identifies file and particular key for this file.\n\t * @returns Cached value. undefined if nothing is cached.\n\t */\n\tget(entry: ICacheEntry): Promise<any>;\n\n\t/**\n\t * Put the value into cache.\n\t * Important - only serializable content is allowed since this cache may be persisted between sessions\n\t * @param entry - cache entry.\n\t * @param value - JSON-serializable content.\n\t */\n\tput(entry: ICacheEntry, value: any): Promise<void>;\n\n\t/**\n\t * Removes the entries from the cache for given parametres.\n\t * @param file - file entry to be deleted.\n\t */\n\tremoveEntries(file: IFileEntry): Promise<void>;\n}\n\n/**\n * Api to generate a cache key from cache entry.\n * @param entry - cache entry from which a cache key is generated\n * @returns The key for cache.\n * @internal\n */\nexport function getKeyForCacheEntry(entry: ICacheEntry): string {\n\treturn `${entry.file.docId}_${entry.type}_${entry.key}`;\n}\n"]}