@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/resolvedUrl.ts
CHANGED
|
@@ -6,55 +6,55 @@
|
|
|
6
6
|
import { IFluidResolvedUrl } from "@fluidframework/driver-definitions";
|
|
7
7
|
|
|
8
8
|
export interface IOdspUrlParts {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
siteUrl: string;
|
|
10
|
+
driveId: string;
|
|
11
|
+
itemId: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @deprecated Use ISharingLinkKind type instead.
|
|
16
16
|
* Type of shareLink requested/created when creating the file for the first time.
|
|
17
|
-
*/
|
|
17
|
+
*/
|
|
18
18
|
export enum ShareLinkTypes {
|
|
19
|
-
|
|
19
|
+
csl = "csl",
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* Sharing scope of the share links created for a file.
|
|
24
|
-
*/
|
|
24
|
+
*/
|
|
25
25
|
export enum SharingLinkScope {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
organization = "organization",
|
|
27
|
+
users = "users",
|
|
28
|
+
anonymous = "anonymous",
|
|
29
|
+
default = "default",
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* View/edit permission role for a sharing link.
|
|
34
34
|
*/
|
|
35
35
|
export enum SharingLinkRole {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
view = "view",
|
|
37
|
+
edit = "edit",
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Defines the permissions scope for a share link requested to be created during the creation the file in ODSP.
|
|
42
42
|
* Providing these properties to the /snapshot api will also create and return the requested kind of sharing link.
|
|
43
|
-
*/
|
|
43
|
+
*/
|
|
44
44
|
export interface ISharingLinkKind {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
scope: SharingLinkScope;
|
|
46
|
+
/*
|
|
47
|
+
* If this parameter is not provided, the API will default to "edit" links (provided
|
|
48
|
+
* a valid createLinkScope setting is given).
|
|
49
|
+
*/
|
|
50
|
+
role?: SharingLinkRole;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Sharing link data received from the /snapshot api response.
|
|
55
55
|
*/
|
|
56
56
|
export interface ISharingLink extends ISharingLinkKind {
|
|
57
|
-
|
|
57
|
+
webUrl: string;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
/**
|
|
@@ -63,84 +63,82 @@ export interface ISharingLink extends ISharingLinkKind {
|
|
|
63
63
|
* a redeemable share link created when loading an existing file
|
|
64
64
|
*/
|
|
65
65
|
export interface ShareLinkInfoType {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
sharingLinkToRedeem?: string;
|
|
66
|
+
/**
|
|
67
|
+
* We create a new file in ODSP with the /snapshot api call. Applications then need to make a separate apis call to
|
|
68
|
+
* create a sharing link for that file. To reduce the number of network calls, ODSP now provides a feature
|
|
69
|
+
* where we can create a share link along with creating a file by passing a query parameter called
|
|
70
|
+
* createShareLink (deprecated) or createLinkScope and createLinkRole. createLink object below saves the information
|
|
71
|
+
* from the /snapshot api response.
|
|
72
|
+
*/
|
|
73
|
+
createLink?: {
|
|
74
|
+
/**
|
|
75
|
+
* @deprecated
|
|
76
|
+
* Type of shareLink requested/created when creating the file for the first time. The 'type' property here
|
|
77
|
+
* represents the type of sharing link requested.
|
|
78
|
+
* Will be deprecated soon. Type of sharing link will be present in the link:ISharingLink property below.
|
|
79
|
+
*/
|
|
80
|
+
type?: ShareLinkTypes | ISharingLinkKind;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Share link created when the file is created for the first time with /snapshot api call.
|
|
84
|
+
*/
|
|
85
|
+
link?: string | ISharingLink;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Error message if creation of sharing link fails with /snapshot api call
|
|
89
|
+
*/
|
|
90
|
+
error?: any;
|
|
91
|
+
|
|
92
|
+
shareId?: string;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* This is used to save the network calls while doing trees/latest call as if the client does not have
|
|
97
|
+
* permission then this link can be redeemed for the permissions in the same network call.
|
|
98
|
+
*/
|
|
99
|
+
sharingLinkToRedeem?: string;
|
|
102
100
|
}
|
|
103
101
|
export interface IOdspResolvedUrl extends IFluidResolvedUrl, IOdspUrlParts {
|
|
104
|
-
|
|
105
|
-
|
|
102
|
+
type: "fluid";
|
|
103
|
+
odspResolvedUrl: true;
|
|
106
104
|
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
// URL to send to fluid, contains the documentId and the path
|
|
106
|
+
url: string;
|
|
109
107
|
|
|
110
|
-
|
|
111
|
-
|
|
108
|
+
// A hashed identifier that is unique to this document
|
|
109
|
+
hashedDocumentId: string;
|
|
112
110
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
111
|
+
endpoints: {
|
|
112
|
+
snapshotStorageUrl: string;
|
|
113
|
+
attachmentPOSTStorageUrl: string;
|
|
114
|
+
attachmentGETStorageUrl: string;
|
|
115
|
+
deltaStorageUrl: string;
|
|
116
|
+
};
|
|
119
117
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
// Tokens are not obtained by the ODSP driver using the resolve flow, the app must provide them.
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
120
|
+
tokens: {};
|
|
123
121
|
|
|
124
|
-
|
|
122
|
+
fileName: string;
|
|
125
123
|
|
|
126
|
-
|
|
124
|
+
summarizer: boolean;
|
|
127
125
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
codeHint?: {
|
|
127
|
+
// containerPackageName is used for adding the package name to the request headers.
|
|
128
|
+
// This may be used for preloading the container package when loading Fluid content.
|
|
129
|
+
containerPackageName?: string;
|
|
130
|
+
};
|
|
133
131
|
|
|
134
|
-
|
|
132
|
+
fileVersion: string | undefined;
|
|
135
133
|
|
|
136
|
-
|
|
134
|
+
dataStorePath?: string;
|
|
137
135
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
/**
|
|
137
|
+
* Sharing link data created for the ODSP item.
|
|
138
|
+
* Contains information about either sharing link created while creating a new file or
|
|
139
|
+
* a redeemable share link created when loading an existing file
|
|
140
|
+
*/
|
|
141
|
+
shareLinkInfo?: ShareLinkInfoType;
|
|
144
142
|
|
|
145
|
-
|
|
143
|
+
isClpCompliantApp?: boolean;
|
|
146
144
|
}
|
package/src/tokenFetch.ts
CHANGED
|
@@ -7,49 +7,49 @@
|
|
|
7
7
|
* Represents token response
|
|
8
8
|
*/
|
|
9
9
|
export interface TokenResponse {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
/** Token value */
|
|
11
|
+
token: string;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
/** Flag indicating whether token was obtained from local cache */
|
|
14
|
+
fromCache?: boolean;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Represents access token fetch options
|
|
19
19
|
*/
|
|
20
20
|
export interface TokenFetchOptions {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Value indicating whether fresh token has to be returned.
|
|
23
|
+
* If false then it is okay to return cached unexpired token if available.
|
|
24
|
+
*/
|
|
25
|
+
refresh: boolean;
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Claims that have to be passed with token fetch request.
|
|
29
|
+
* These can be used to specify additional information that must be passed to token authority.
|
|
30
|
+
*/
|
|
31
|
+
claims?: string;
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Tenant id of authority that must be handling token fetch.
|
|
35
|
+
* If it is not specified then it is up to token fetching logic to determine which tenant authority
|
|
36
|
+
* to use to issue access token.
|
|
37
|
+
*/
|
|
38
|
+
tenantId?: string;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Represents access token fetch options for ODSP resource
|
|
43
43
|
*/
|
|
44
44
|
export interface OdspResourceTokenFetchOptions extends TokenFetchOptions {
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
/** Site url representing ODSP resource location */
|
|
46
|
+
siteUrl: string;
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/** ODSP drive id where resource resides. Optional, used only when fetching token to access ODSP file */
|
|
49
|
+
driveId?: string;
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
/** ODSP item id representing resource. Optional, used only when fetching token to access ODSP file */
|
|
52
|
+
itemId?: string;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
/**
|
|
@@ -66,10 +66,14 @@ export type TokenFetcher<T> = (options: T) => Promise<string | TokenResponse | n
|
|
|
66
66
|
* @param tokenResponse - return value for TokenFetcher method
|
|
67
67
|
* @returns Token value
|
|
68
68
|
*/
|
|
69
|
-
export const tokenFromResponse = (
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
export const tokenFromResponse = (
|
|
70
|
+
tokenResponse: string | TokenResponse | null | undefined,
|
|
71
|
+
): string | null =>
|
|
72
|
+
tokenResponse === null || typeof tokenResponse === "string"
|
|
73
|
+
? tokenResponse
|
|
74
|
+
: tokenResponse === undefined
|
|
75
|
+
? null
|
|
76
|
+
: tokenResponse.token;
|
|
73
77
|
|
|
74
78
|
/**
|
|
75
79
|
* Helper method which returns flag indicating whether token response comes from local cache
|
|
@@ -77,10 +81,12 @@ export const tokenFromResponse = (tokenResponse: string | TokenResponse | null |
|
|
|
77
81
|
* @returns Value indicating whether response came from cache.
|
|
78
82
|
* Undefined is returned when we could not determine the source of token.
|
|
79
83
|
*/
|
|
80
|
-
export const isTokenFromCache = (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
export const isTokenFromCache = (
|
|
85
|
+
tokenResponse: string | TokenResponse | null,
|
|
86
|
+
): boolean | undefined =>
|
|
87
|
+
tokenResponse === null || typeof tokenResponse === "string"
|
|
88
|
+
? undefined
|
|
89
|
+
: tokenResponse.fromCache;
|
|
84
90
|
|
|
85
91
|
/**
|
|
86
92
|
* Identity types supported by ODSP driver.
|
|
@@ -90,6 +96,7 @@ export const isTokenFromCache = (tokenResponse: string | TokenResponse | null):
|
|
|
90
96
|
export type IdentityType = "Consumer" | "Enterprise";
|
|
91
97
|
|
|
92
98
|
export type InstrumentedStorageTokenFetcher = (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
options: TokenFetchOptions,
|
|
100
|
+
name: string,
|
|
101
|
+
alwaysRecordTokenFetchTelemetry?: boolean,
|
|
102
|
+
) => Promise<string | null>;
|
package/tsconfig.esnext.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./lib",
|
|
5
|
+
"module": "esnext",
|
|
6
|
+
},
|
|
7
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
10
|
+
}
|