@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.
Files changed (64) hide show
  1. package/.eslintrc.js +6 -9
  2. package/api-extractor.json +2 -2
  3. package/dist/errors.d.ts +23 -0
  4. package/dist/errors.d.ts.map +1 -1
  5. package/dist/errors.js +19 -11
  6. package/dist/errors.js.map +1 -1
  7. package/dist/factory.d.ts +5 -0
  8. package/dist/factory.d.ts.map +1 -1
  9. package/dist/factory.js.map +1 -1
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +2 -1
  13. package/dist/index.js.map +1 -1
  14. package/dist/odspCache.d.ts +7 -1
  15. package/dist/odspCache.d.ts.map +1 -1
  16. package/dist/odspCache.js +10 -1
  17. package/dist/odspCache.js.map +1 -1
  18. package/dist/packageVersion.d.ts +1 -1
  19. package/dist/packageVersion.js +1 -1
  20. package/dist/packageVersion.js.map +1 -1
  21. package/dist/resolvedUrl.d.ts +4 -4
  22. package/dist/resolvedUrl.d.ts.map +1 -1
  23. package/dist/resolvedUrl.js +2 -2
  24. package/dist/resolvedUrl.js.map +1 -1
  25. package/dist/tokenFetch.d.ts.map +1 -1
  26. package/dist/tokenFetch.js +3 -1
  27. package/dist/tokenFetch.js.map +1 -1
  28. package/lib/errors.d.ts +23 -0
  29. package/lib/errors.d.ts.map +1 -1
  30. package/lib/errors.js +19 -11
  31. package/lib/errors.js.map +1 -1
  32. package/lib/factory.d.ts +5 -0
  33. package/lib/factory.d.ts.map +1 -1
  34. package/lib/factory.js.map +1 -1
  35. package/lib/index.d.ts +2 -2
  36. package/lib/index.d.ts.map +1 -1
  37. package/lib/index.js +1 -1
  38. package/lib/index.js.map +1 -1
  39. package/lib/odspCache.d.ts +7 -1
  40. package/lib/odspCache.d.ts.map +1 -1
  41. package/lib/odspCache.js +8 -0
  42. package/lib/odspCache.js.map +1 -1
  43. package/lib/packageVersion.d.ts +1 -1
  44. package/lib/packageVersion.js +1 -1
  45. package/lib/packageVersion.js.map +1 -1
  46. package/lib/resolvedUrl.d.ts +4 -4
  47. package/lib/resolvedUrl.d.ts.map +1 -1
  48. package/lib/resolvedUrl.js +2 -2
  49. package/lib/resolvedUrl.js.map +1 -1
  50. package/lib/tokenFetch.d.ts.map +1 -1
  51. package/lib/tokenFetch.js +3 -1
  52. package/lib/tokenFetch.js.map +1 -1
  53. package/package.json +31 -34
  54. package/prettier.config.cjs +1 -1
  55. package/src/errors.ts +57 -49
  56. package/src/factory.ts +134 -128
  57. package/src/index.ts +15 -2
  58. package/src/odspCache.ts +59 -50
  59. package/src/packageVersion.ts +1 -1
  60. package/src/resolvedUrl.ts +85 -87
  61. package/src/tokenFetch.ts +44 -37
  62. package/tsconfig.esnext.json +6 -6
  63. package/tsconfig.json +9 -13
  64. package/.editorconfig +0 -7
@@ -6,55 +6,55 @@
6
6
  import { IFluidResolvedUrl } from "@fluidframework/driver-definitions";
7
7
 
8
8
  export interface IOdspUrlParts {
9
- siteUrl: string;
10
- driveId: string;
11
- itemId: string;
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
- csl = "csl",
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
- organization = "organization",
27
- users = "users",
28
- anonymous = "anonymous",
29
- default = "default",
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
- view = "view",
37
- edit = "edit",
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
- 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;
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
- webUrl: string;
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
- * We create a new file in ODSP with the /snapshot api call. Applications then need to make a separate apis call to
69
- * create a sharing link for that file. To reduce the number of network calls, ODSP now provides a feature
70
- * where we can create a share link along with creating a file by passing a query parameter called
71
- * createShareLink (deprecated) or createLinkScope and createLinkRole. createLink object below saves the information
72
- * from the /snapshot api response.
73
- */
74
- createLink?: {
75
- /**
76
- * @deprecated
77
- * Type of shareLink requested/created when creating the file for the first time. The 'type' property here
78
- * represents the type of sharing link requested.
79
- * Will be deprecated soon. Type of sharing link will be present in the link:ISharingLink property below.
80
- */
81
- type?: ShareLinkTypes | ISharingLinkKind;
82
-
83
- /**
84
- * Share link created when the file is created for the first time with /snapshot api call.
85
- */
86
- link?: string | ISharingLink;
87
-
88
- /**
89
- * Error message if creation of sharing link fails with /snapshot api call
90
- */
91
- error?: any;
92
-
93
- shareId?: string;
94
-
95
- };
96
-
97
- /**
98
- * This is used to save the network calls while doing trees/latest call as if the client does not have
99
- * permission then this link can be redeemed for the permissions in the same network call.
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
- type: "fluid";
105
- odspResolvedUrl: true;
102
+ type: "fluid";
103
+ odspResolvedUrl: true;
106
104
 
107
- // URL to send to fluid, contains the documentId and the path
108
- url: string;
105
+ // URL to send to fluid, contains the documentId and the path
106
+ url: string;
109
107
 
110
- // A hashed identifier that is unique to this document
111
- hashedDocumentId: string;
108
+ // A hashed identifier that is unique to this document
109
+ hashedDocumentId: string;
112
110
 
113
- endpoints: {
114
- snapshotStorageUrl: string;
115
- attachmentPOSTStorageUrl: string;
116
- attachmentGETStorageUrl: string;
117
- deltaStorageUrl: string;
118
- };
111
+ endpoints: {
112
+ snapshotStorageUrl: string;
113
+ attachmentPOSTStorageUrl: string;
114
+ attachmentGETStorageUrl: string;
115
+ deltaStorageUrl: string;
116
+ };
119
117
 
120
- // Tokens are not obtained by the ODSP driver using the resolve flow, the app must provide them.
121
- // eslint-disable-next-line @typescript-eslint/ban-types
122
- tokens: {};
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
- fileName: string;
122
+ fileName: string;
125
123
 
126
- summarizer: boolean;
124
+ summarizer: boolean;
127
125
 
128
- codeHint?: {
129
- // containerPackageName is used for adding the package name to the request headers.
130
- // This may be used for preloading the container package when loading Fluid content.
131
- containerPackageName?: string;
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
- fileVersion: string | undefined;
132
+ fileVersion: string | undefined;
135
133
 
136
- dataStorePath?: string;
134
+ dataStorePath?: string;
137
135
 
138
- /**
139
- * Sharing link data created for the ODSP item.
140
- * Contains information about either sharing link created while creating a new file or
141
- * a redeemable share link created when loading an existing file
142
- */
143
- shareLinkInfo?: ShareLinkInfoType;
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
- isClpCompliantApp?: boolean;
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
- /** Token value */
11
- token: string;
10
+ /** Token value */
11
+ token: string;
12
12
 
13
- /** Flag indicating whether token was obtained from local cache */
14
- fromCache?: boolean;
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
- * 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;
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
- * 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;
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
- * 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;
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
- /** Site url representing ODSP resource location */
46
- siteUrl: string;
45
+ /** Site url representing ODSP resource location */
46
+ siteUrl: string;
47
47
 
48
- /** ODSP drive id where resource resides. Optional, used only when fetching token to access ODSP file */
49
- driveId?: string;
48
+ /** ODSP drive id where resource resides. Optional, used only when fetching token to access ODSP file */
49
+ driveId?: string;
50
50
 
51
- /** ODSP item id representing resource. Optional, used only when fetching token to access ODSP file */
52
- itemId?: string;
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 = (tokenResponse: string | TokenResponse | null | undefined): string | null =>
70
- tokenResponse === null || typeof tokenResponse === "string"
71
- ? tokenResponse
72
- : tokenResponse === undefined ? null : tokenResponse.token;
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 = (tokenResponse: string | TokenResponse | null): boolean | undefined =>
81
- tokenResponse === null || typeof tokenResponse === "string"
82
- ? undefined
83
- : tokenResponse.fromCache;
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
- options: TokenFetchOptions,
94
- name: string,
95
- alwaysRecordTokenFetchTelemetry?: boolean) => Promise<string | null>;
99
+ options: TokenFetchOptions,
100
+ name: string,
101
+ alwaysRecordTokenFetchTelemetry?: boolean,
102
+ ) => Promise<string | null>;
@@ -1,7 +1,7 @@
1
1
  {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./lib",
5
- "module": "esnext"
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
- "extends": "@fluidframework/build-common/ts-common-config.json",
3
- "exclude": [
4
- "src/test/**/*"
5
- ],
6
- "compilerOptions": {
7
- "rootDir": "./src",
8
- "outDir": "./dist",
9
- "composite": true
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
+ }
package/.editorconfig DELETED
@@ -1,7 +0,0 @@
1
- [*]
2
- indent_size = 4
3
- trim_trailing_whitespace = true
4
- insert_final_newline = true
5
-
6
- [package.json]
7
- indent_size = 2